babylon.max.js 7.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. /**
  335. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  336. */
  337. this.isRecursive = false;
  338. }
  339. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  340. /**
  341. * Does exist one action manager with at least one trigger
  342. **/
  343. get: function () {
  344. for (var t in AbstractActionManager.Triggers) {
  345. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  346. return true;
  347. }
  348. }
  349. return false;
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  355. /**
  356. * Does exist one action manager with at least one pick trigger
  357. **/
  358. get: function () {
  359. for (var t in AbstractActionManager.Triggers) {
  360. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  361. var t_int = parseInt(t);
  362. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  363. return true;
  364. }
  365. }
  366. }
  367. return false;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * Does exist one action manager that handles actions of a given trigger
  374. * @param trigger defines the trigger to be tested
  375. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  376. **/
  377. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  378. for (var t in AbstractActionManager.Triggers) {
  379. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  380. var t_int = parseInt(t);
  381. if (t_int === trigger) {
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. };
  388. /** Gets the list of active triggers */
  389. AbstractActionManager.Triggers = {};
  390. return AbstractActionManager;
  391. }());
  392. /***/ }),
  393. /***/ "./Actions/action.ts":
  394. /*!***************************!*\
  395. !*** ./Actions/action.ts ***!
  396. \***************************/
  397. /*! exports provided: Action */
  398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  399. "use strict";
  400. __webpack_require__.r(__webpack_exports__);
  401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  402. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  404. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  405. /**
  406. * The action to be carried out following a trigger
  407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  408. */
  409. var Action = /** @class */ (function () {
  410. /**
  411. * Creates a new Action
  412. * @param triggerOptions the trigger, with or without parameters, for the action
  413. * @param condition an optional determinant of action
  414. */
  415. function Action(
  416. /** the trigger, with or without parameters, for the action */
  417. triggerOptions, condition) {
  418. this.triggerOptions = triggerOptions;
  419. /**
  420. * An event triggered prior to action being executed.
  421. */
  422. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  423. if (triggerOptions.parameter) {
  424. this.trigger = triggerOptions.trigger;
  425. this._triggerParameter = triggerOptions.parameter;
  426. }
  427. else if (triggerOptions.trigger) {
  428. this.trigger = triggerOptions.trigger;
  429. }
  430. else {
  431. this.trigger = triggerOptions;
  432. }
  433. this._nextActiveAction = this;
  434. this._condition = condition;
  435. }
  436. /**
  437. * Internal only
  438. * @hidden
  439. */
  440. Action.prototype._prepare = function () {
  441. };
  442. /**
  443. * Gets the trigger parameters
  444. * @returns the trigger parameters
  445. */
  446. Action.prototype.getTriggerParameter = function () {
  447. return this._triggerParameter;
  448. };
  449. /**
  450. * Internal only - executes current action event
  451. * @hidden
  452. */
  453. Action.prototype._executeCurrent = function (evt) {
  454. if (this._nextActiveAction._condition) {
  455. var condition = this._nextActiveAction._condition;
  456. var currentRenderId = this._actionManager.getScene().getRenderId();
  457. // We cache the current evaluation for the current frame
  458. if (condition._evaluationId === currentRenderId) {
  459. if (!condition._currentResult) {
  460. return;
  461. }
  462. }
  463. else {
  464. condition._evaluationId = currentRenderId;
  465. if (!condition.isValid()) {
  466. condition._currentResult = false;
  467. return;
  468. }
  469. condition._currentResult = true;
  470. }
  471. }
  472. this.onBeforeExecuteObservable.notifyObservers(this);
  473. this._nextActiveAction.execute(evt);
  474. this.skipToNextActiveAction();
  475. };
  476. /**
  477. * Execute placeholder for child classes
  478. * @param evt optional action event
  479. */
  480. Action.prototype.execute = function (evt) {
  481. };
  482. /**
  483. * Skips to next active action
  484. */
  485. Action.prototype.skipToNextActiveAction = function () {
  486. if (this._nextActiveAction._child) {
  487. if (!this._nextActiveAction._child._actionManager) {
  488. this._nextActiveAction._child._actionManager = this._actionManager;
  489. }
  490. this._nextActiveAction = this._nextActiveAction._child;
  491. }
  492. else {
  493. this._nextActiveAction = this;
  494. }
  495. };
  496. /**
  497. * Adds action to chain of actions, may be a DoNothingAction
  498. * @param action defines the next action to execute
  499. * @returns The action passed in
  500. * @see https://www.babylonjs-playground.com/#1T30HR#0
  501. */
  502. Action.prototype.then = function (action) {
  503. this._child = action;
  504. action._actionManager = this._actionManager;
  505. action._prepare();
  506. return action;
  507. };
  508. /**
  509. * Internal only
  510. * @hidden
  511. */
  512. Action.prototype._getProperty = function (propertyPath) {
  513. return this._actionManager._getProperty(propertyPath);
  514. };
  515. /**
  516. * Internal only
  517. * @hidden
  518. */
  519. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  520. return this._actionManager._getEffectiveTarget(target, propertyPath);
  521. };
  522. /**
  523. * Serialize placeholder for child classes
  524. * @param parent of child
  525. * @returns the serialized object
  526. */
  527. Action.prototype.serialize = function (parent) {
  528. };
  529. /**
  530. * Internal only called by serialize
  531. * @hidden
  532. */
  533. Action.prototype._serialize = function (serializedAction, parent) {
  534. var serializationObject = {
  535. type: 1,
  536. children: [],
  537. name: serializedAction.name,
  538. properties: serializedAction.properties || []
  539. };
  540. // Serialize child
  541. if (this._child) {
  542. this._child.serialize(serializationObject);
  543. }
  544. // Check if "this" has a condition
  545. if (this._condition) {
  546. var serializedCondition = this._condition.serialize();
  547. serializedCondition.children.push(serializationObject);
  548. if (parent) {
  549. parent.children.push(serializedCondition);
  550. }
  551. return serializedCondition;
  552. }
  553. if (parent) {
  554. parent.children.push(serializationObject);
  555. }
  556. return serializationObject;
  557. };
  558. /**
  559. * Internal only
  560. * @hidden
  561. */
  562. Action._SerializeValueAsString = function (value) {
  563. if (typeof value === "number") {
  564. return value.toString();
  565. }
  566. if (typeof value === "boolean") {
  567. return value ? "true" : "false";
  568. }
  569. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  570. return value.x + ", " + value.y;
  571. }
  572. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  573. return value.x + ", " + value.y + ", " + value.z;
  574. }
  575. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  576. return value.r + ", " + value.g + ", " + value.b;
  577. }
  578. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  579. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  580. }
  581. return value; // string
  582. };
  583. /**
  584. * Internal only
  585. * @hidden
  586. */
  587. Action._GetTargetProperty = function (target) {
  588. return {
  589. name: "target",
  590. targetType: target._isMesh ? "MeshProperties"
  591. : target._isLight ? "LightProperties"
  592. : target._isCamera ? "CameraProperties"
  593. : "SceneProperties",
  594. value: target._isScene ? "Scene" : target.name
  595. };
  596. };
  597. return Action;
  598. }());
  599. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  600. /***/ }),
  601. /***/ "./Actions/actionEvent.ts":
  602. /*!********************************!*\
  603. !*** ./Actions/actionEvent.ts ***!
  604. \********************************/
  605. /*! exports provided: ActionEvent */
  606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  607. "use strict";
  608. __webpack_require__.r(__webpack_exports__);
  609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  610. /**
  611. * ActionEvent is the event being sent when an action is triggered.
  612. */
  613. var ActionEvent = /** @class */ (function () {
  614. /**
  615. * Creates a new ActionEvent
  616. * @param source The mesh or sprite that triggered the action
  617. * @param pointerX The X mouse cursor position at the time of the event
  618. * @param pointerY The Y mouse cursor position at the time of the event
  619. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  620. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  621. * @param additionalData additional data for the event
  622. */
  623. function ActionEvent(
  624. /** The mesh or sprite that triggered the action */
  625. source,
  626. /** The X mouse cursor position at the time of the event */
  627. pointerX,
  628. /** The Y mouse cursor position at the time of the event */
  629. pointerY,
  630. /** The mesh that is currently pointed at (can be null) */
  631. meshUnderPointer,
  632. /** the original (browser) event that triggered the ActionEvent */
  633. sourceEvent,
  634. /** additional data for the event */
  635. additionalData) {
  636. this.source = source;
  637. this.pointerX = pointerX;
  638. this.pointerY = pointerY;
  639. this.meshUnderPointer = meshUnderPointer;
  640. this.sourceEvent = sourceEvent;
  641. this.additionalData = additionalData;
  642. }
  643. /**
  644. * Helper function to auto-create an ActionEvent from a source mesh.
  645. * @param source The source mesh that triggered the event
  646. * @param evt The original (browser) event
  647. * @param additionalData additional data for the event
  648. * @returns the new ActionEvent
  649. */
  650. ActionEvent.CreateNew = function (source, evt, additionalData) {
  651. var scene = source.getScene();
  652. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  653. };
  654. /**
  655. * Helper function to auto-create an ActionEvent from a source sprite
  656. * @param source The source sprite that triggered the event
  657. * @param scene Scene associated with the sprite
  658. * @param evt The original (browser) event
  659. * @param additionalData additional data for the event
  660. * @returns the new ActionEvent
  661. */
  662. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  663. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  664. };
  665. /**
  666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  667. * @param scene the scene where the event occurred
  668. * @param evt The original (browser) event
  669. * @returns the new ActionEvent
  670. */
  671. ActionEvent.CreateNewFromScene = function (scene, evt) {
  672. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  673. };
  674. /**
  675. * Helper function to auto-create an ActionEvent from a primitive
  676. * @param prim defines the target primitive
  677. * @param pointerPos defines the pointer position
  678. * @param evt The original (browser) event
  679. * @param additionalData additional data for the event
  680. * @returns the new ActionEvent
  681. */
  682. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  683. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  684. };
  685. return ActionEvent;
  686. }());
  687. /***/ }),
  688. /***/ "./Actions/actionManager.ts":
  689. /*!**********************************!*\
  690. !*** ./Actions/actionManager.ts ***!
  691. \**********************************/
  692. /*! exports provided: ActionManager */
  693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  694. "use strict";
  695. __webpack_require__.r(__webpack_exports__);
  696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  699. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  700. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  701. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  703. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  704. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  705. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  706. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  707. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  708. /**
  709. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  710. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  712. */
  713. var ActionManager = /** @class */ (function (_super) {
  714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  715. /**
  716. * Creates a new action manager
  717. * @param scene defines the hosting scene
  718. */
  719. function ActionManager(scene) {
  720. var _this = _super.call(this) || this;
  721. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  722. scene.actionManagers.push(_this);
  723. return _this;
  724. }
  725. // Methods
  726. /**
  727. * Releases all associated resources
  728. */
  729. ActionManager.prototype.dispose = function () {
  730. var index = this._scene.actionManagers.indexOf(this);
  731. for (var i = 0; i < this.actions.length; i++) {
  732. var action = this.actions[i];
  733. ActionManager.Triggers[action.trigger]--;
  734. if (ActionManager.Triggers[action.trigger] === 0) {
  735. delete ActionManager.Triggers[action.trigger];
  736. }
  737. }
  738. if (index > -1) {
  739. this._scene.actionManagers.splice(index, 1);
  740. }
  741. };
  742. /**
  743. * Gets hosting scene
  744. * @returns the hosting scene
  745. */
  746. ActionManager.prototype.getScene = function () {
  747. return this._scene;
  748. };
  749. /**
  750. * Does this action manager handles actions of any of the given triggers
  751. * @param triggers defines the triggers to be tested
  752. * @return a boolean indicating whether one (or more) of the triggers is handled
  753. */
  754. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  755. for (var index = 0; index < this.actions.length; index++) {
  756. var action = this.actions[index];
  757. if (triggers.indexOf(action.trigger) > -1) {
  758. return true;
  759. }
  760. }
  761. return false;
  762. };
  763. /**
  764. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  765. * speed.
  766. * @param triggerA defines the trigger to be tested
  767. * @param triggerB defines the trigger to be tested
  768. * @return a boolean indicating whether one (or more) of the triggers is handled
  769. */
  770. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  771. for (var index = 0; index < this.actions.length; index++) {
  772. var action = this.actions[index];
  773. if (triggerA == action.trigger || triggerB == action.trigger) {
  774. return true;
  775. }
  776. }
  777. return false;
  778. };
  779. /**
  780. * Does this action manager handles actions of a given trigger
  781. * @param trigger defines the trigger to be tested
  782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  783. * @return whether the trigger is handled
  784. */
  785. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  786. for (var index = 0; index < this.actions.length; index++) {
  787. var action = this.actions[index];
  788. if (action.trigger === trigger) {
  789. if (parameterPredicate) {
  790. if (parameterPredicate(action.getTriggerParameter())) {
  791. return true;
  792. }
  793. }
  794. else {
  795. return true;
  796. }
  797. }
  798. }
  799. return false;
  800. };
  801. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  802. /**
  803. * Does this action manager has pointer triggers
  804. */
  805. get: function () {
  806. for (var index = 0; index < this.actions.length; index++) {
  807. var action = this.actions[index];
  808. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  809. return true;
  810. }
  811. }
  812. return false;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  818. /**
  819. * Does this action manager has pick triggers
  820. */
  821. get: function () {
  822. for (var index = 0; index < this.actions.length; index++) {
  823. var action = this.actions[index];
  824. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  825. return true;
  826. }
  827. }
  828. return false;
  829. },
  830. enumerable: true,
  831. configurable: true
  832. });
  833. /**
  834. * Registers an action to this action manager
  835. * @param action defines the action to be registered
  836. * @return the action amended (prepared) after registration
  837. */
  838. ActionManager.prototype.registerAction = function (action) {
  839. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  840. if (this.getScene().actionManager !== this) {
  841. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  842. return null;
  843. }
  844. }
  845. this.actions.push(action);
  846. if (ActionManager.Triggers[action.trigger]) {
  847. ActionManager.Triggers[action.trigger]++;
  848. }
  849. else {
  850. ActionManager.Triggers[action.trigger] = 1;
  851. }
  852. action._actionManager = this;
  853. action._prepare();
  854. return action;
  855. };
  856. /**
  857. * Unregisters an action to this action manager
  858. * @param action defines the action to be unregistered
  859. * @return a boolean indicating whether the action has been unregistered
  860. */
  861. ActionManager.prototype.unregisterAction = function (action) {
  862. var index = this.actions.indexOf(action);
  863. if (index !== -1) {
  864. this.actions.splice(index, 1);
  865. ActionManager.Triggers[action.trigger] -= 1;
  866. if (ActionManager.Triggers[action.trigger] === 0) {
  867. delete ActionManager.Triggers[action.trigger];
  868. }
  869. delete action._actionManager;
  870. return true;
  871. }
  872. return false;
  873. };
  874. /**
  875. * Process a specific trigger
  876. * @param trigger defines the trigger to process
  877. * @param evt defines the event details to be processed
  878. */
  879. ActionManager.prototype.processTrigger = function (trigger, evt) {
  880. for (var index = 0; index < this.actions.length; index++) {
  881. var action = this.actions[index];
  882. if (action.trigger === trigger) {
  883. if (evt) {
  884. if (trigger === ActionManager.OnKeyUpTrigger
  885. || trigger === ActionManager.OnKeyDownTrigger) {
  886. var parameter = action.getTriggerParameter();
  887. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  888. if (!parameter.toLowerCase) {
  889. continue;
  890. }
  891. var lowerCase = parameter.toLowerCase();
  892. if (lowerCase !== evt.sourceEvent.key) {
  893. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  894. var actualkey = String.fromCharCode(unicode).toLowerCase();
  895. if (actualkey !== lowerCase) {
  896. continue;
  897. }
  898. }
  899. }
  900. }
  901. }
  902. action._executeCurrent(evt);
  903. }
  904. }
  905. };
  906. /** @hidden */
  907. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  908. var properties = propertyPath.split(".");
  909. for (var index = 0; index < properties.length - 1; index++) {
  910. target = target[properties[index]];
  911. }
  912. return target;
  913. };
  914. /** @hidden */
  915. ActionManager.prototype._getProperty = function (propertyPath) {
  916. var properties = propertyPath.split(".");
  917. return properties[properties.length - 1];
  918. };
  919. /**
  920. * Serialize this manager to a JSON object
  921. * @param name defines the property name to store this manager
  922. * @returns a JSON representation of this manager
  923. */
  924. ActionManager.prototype.serialize = function (name) {
  925. var root = {
  926. children: new Array(),
  927. name: name,
  928. type: 3,
  929. properties: new Array() // Empty for root but required
  930. };
  931. for (var i = 0; i < this.actions.length; i++) {
  932. var triggerObject = {
  933. type: 0,
  934. children: new Array(),
  935. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  936. properties: new Array()
  937. };
  938. var triggerOptions = this.actions[i].triggerOptions;
  939. if (triggerOptions && typeof triggerOptions !== "number") {
  940. if (triggerOptions.parameter instanceof Node) {
  941. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  942. }
  943. else {
  944. var parameter = {};
  945. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  946. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  947. parameter._meshId = triggerOptions.parameter.mesh.id;
  948. }
  949. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  950. }
  951. }
  952. // Serialize child action, recursively
  953. this.actions[i].serialize(triggerObject);
  954. // Add serialized trigger
  955. root.children.push(triggerObject);
  956. }
  957. return root;
  958. };
  959. /**
  960. * Creates a new ActionManager from a JSON data
  961. * @param parsedActions defines the JSON data to read from
  962. * @param object defines the hosting mesh
  963. * @param scene defines the hosting scene
  964. */
  965. ActionManager.Parse = function (parsedActions, object, scene) {
  966. var actionManager = new ActionManager(scene);
  967. if (object === null) {
  968. scene.actionManager = actionManager;
  969. }
  970. else {
  971. object.actionManager = actionManager;
  972. }
  973. // instanciate a new object
  974. var instanciate = function (name, params) {
  975. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  976. if (internalClassType) {
  977. var newInstance = Object.create(internalClassType.prototype);
  978. newInstance.constructor.apply(newInstance, params);
  979. return newInstance;
  980. }
  981. };
  982. var parseParameter = function (name, value, target, propertyPath) {
  983. if (propertyPath === null) {
  984. // String, boolean or float
  985. var floatValue = parseFloat(value);
  986. if (value === "true" || value === "false") {
  987. return value === "true";
  988. }
  989. else {
  990. return isNaN(floatValue) ? value : floatValue;
  991. }
  992. }
  993. var effectiveTarget = propertyPath.split(".");
  994. var values = value.split(",");
  995. // Get effective Target
  996. for (var i = 0; i < effectiveTarget.length; i++) {
  997. target = target[effectiveTarget[i]];
  998. }
  999. // Return appropriate value with its type
  1000. if (typeof (target) === "boolean") {
  1001. return values[0] === "true";
  1002. }
  1003. if (typeof (target) === "string") {
  1004. return values[0];
  1005. }
  1006. // Parameters with multiple values such as Vector3 etc.
  1007. var split = new Array();
  1008. for (var i = 0; i < values.length; i++) {
  1009. split.push(parseFloat(values[i]));
  1010. }
  1011. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1012. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1013. }
  1014. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1015. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1016. }
  1017. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1018. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1019. }
  1020. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1021. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1022. }
  1023. return parseFloat(values[0]);
  1024. };
  1025. // traverse graph per trigger
  1026. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1027. if (combineArray === void 0) { combineArray = null; }
  1028. if (parsedAction.detached) {
  1029. return;
  1030. }
  1031. var parameters = new Array();
  1032. var target = null;
  1033. var propertyPath = null;
  1034. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1035. // Parameters
  1036. if (parsedAction.type === 2) {
  1037. parameters.push(actionManager);
  1038. }
  1039. else {
  1040. parameters.push(trigger);
  1041. }
  1042. if (combine) {
  1043. var actions = new Array();
  1044. for (var j = 0; j < parsedAction.combine.length; j++) {
  1045. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1046. }
  1047. parameters.push(actions);
  1048. }
  1049. else {
  1050. for (var i = 0; i < parsedAction.properties.length; i++) {
  1051. var value = parsedAction.properties[i].value;
  1052. var name = parsedAction.properties[i].name;
  1053. var targetType = parsedAction.properties[i].targetType;
  1054. if (name === "target") {
  1055. if (targetType !== null && targetType === "SceneProperties") {
  1056. value = target = scene;
  1057. }
  1058. else {
  1059. value = target = scene.getNodeByName(value);
  1060. }
  1061. }
  1062. else if (name === "parent") {
  1063. value = scene.getNodeByName(value);
  1064. }
  1065. else if (name === "sound") {
  1066. // Can not externalize to component, so only checks for the presence off the API.
  1067. if (scene.getSoundByName) {
  1068. value = scene.getSoundByName(value);
  1069. }
  1070. }
  1071. else if (name !== "propertyPath") {
  1072. if (parsedAction.type === 2 && name === "operator") {
  1073. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1074. }
  1075. else {
  1076. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1077. }
  1078. }
  1079. else {
  1080. propertyPath = value;
  1081. }
  1082. parameters.push(value);
  1083. }
  1084. }
  1085. if (combineArray === null) {
  1086. parameters.push(condition);
  1087. }
  1088. else {
  1089. parameters.push(null);
  1090. }
  1091. // If interpolate value action
  1092. if (parsedAction.name === "InterpolateValueAction") {
  1093. var param = parameters[parameters.length - 2];
  1094. parameters[parameters.length - 1] = param;
  1095. parameters[parameters.length - 2] = condition;
  1096. }
  1097. // Action or condition(s) and not CombineAction
  1098. var newAction = instanciate(parsedAction.name, parameters);
  1099. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1100. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1101. if (action) {
  1102. action.then(nothing);
  1103. }
  1104. else {
  1105. actionManager.registerAction(nothing);
  1106. }
  1107. action = nothing;
  1108. }
  1109. if (combineArray === null) {
  1110. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1111. condition = newAction;
  1112. newAction = action;
  1113. }
  1114. else {
  1115. condition = null;
  1116. if (action) {
  1117. action.then(newAction);
  1118. }
  1119. else {
  1120. actionManager.registerAction(newAction);
  1121. }
  1122. }
  1123. }
  1124. else {
  1125. combineArray.push(newAction);
  1126. }
  1127. for (var i = 0; i < parsedAction.children.length; i++) {
  1128. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1129. }
  1130. };
  1131. // triggers
  1132. for (var i = 0; i < parsedActions.children.length; i++) {
  1133. var triggerParams;
  1134. var trigger = parsedActions.children[i];
  1135. if (trigger.properties.length > 0) {
  1136. var param = trigger.properties[0].value;
  1137. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1138. if (value._meshId) {
  1139. value.mesh = scene.getMeshByID(value._meshId);
  1140. }
  1141. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1142. }
  1143. else {
  1144. triggerParams = ActionManager[trigger.name];
  1145. }
  1146. for (var j = 0; j < trigger.children.length; j++) {
  1147. if (!trigger.detached) {
  1148. traverse(trigger.children[j], triggerParams, null, null);
  1149. }
  1150. }
  1151. }
  1152. };
  1153. /**
  1154. * Get a trigger name by index
  1155. * @param trigger defines the trigger index
  1156. * @returns a trigger name
  1157. */
  1158. ActionManager.GetTriggerName = function (trigger) {
  1159. switch (trigger) {
  1160. case 0: return "NothingTrigger";
  1161. case 1: return "OnPickTrigger";
  1162. case 2: return "OnLeftPickTrigger";
  1163. case 3: return "OnRightPickTrigger";
  1164. case 4: return "OnCenterPickTrigger";
  1165. case 5: return "OnPickDownTrigger";
  1166. case 6: return "OnPickUpTrigger";
  1167. case 7: return "OnLongPressTrigger";
  1168. case 8: return "OnPointerOverTrigger";
  1169. case 9: return "OnPointerOutTrigger";
  1170. case 10: return "OnEveryFrameTrigger";
  1171. case 11: return "OnIntersectionEnterTrigger";
  1172. case 12: return "OnIntersectionExitTrigger";
  1173. case 13: return "OnKeyDownTrigger";
  1174. case 14: return "OnKeyUpTrigger";
  1175. case 15: return "OnPickOutTrigger";
  1176. default: return "";
  1177. }
  1178. };
  1179. /**
  1180. * Nothing
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1182. */
  1183. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1184. /**
  1185. * On pick
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1187. */
  1188. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1189. /**
  1190. * On left pick
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1194. /**
  1195. * On right pick
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1199. /**
  1200. * On center pick
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1204. /**
  1205. * On pick down
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1209. /**
  1210. * On double pick
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1214. /**
  1215. * On pick up
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1219. /**
  1220. * On pick out.
  1221. * This trigger will only be raised if you also declared a OnPickDown
  1222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1223. */
  1224. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1225. /**
  1226. * On long press
  1227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1228. */
  1229. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1230. /**
  1231. * On pointer over
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1233. */
  1234. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1235. /**
  1236. * On pointer out
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1238. */
  1239. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1240. /**
  1241. * On every frame
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1243. */
  1244. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1245. /**
  1246. * On intersection enter
  1247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1248. */
  1249. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1250. /**
  1251. * On intersection exit
  1252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1253. */
  1254. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1255. /**
  1256. * On key down
  1257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1258. */
  1259. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1260. /**
  1261. * On key up
  1262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1263. */
  1264. ActionManager.OnKeyUpTrigger = 15;
  1265. return ActionManager;
  1266. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1267. /***/ }),
  1268. /***/ "./Actions/condition.ts":
  1269. /*!******************************!*\
  1270. !*** ./Actions/condition.ts ***!
  1271. \******************************/
  1272. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1274. "use strict";
  1275. __webpack_require__.r(__webpack_exports__);
  1276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1281. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1283. /**
  1284. * A Condition applied to an Action
  1285. */
  1286. var Condition = /** @class */ (function () {
  1287. /**
  1288. * Creates a new Condition
  1289. * @param actionManager the manager of the action the condition is applied to
  1290. */
  1291. function Condition(actionManager) {
  1292. this._actionManager = actionManager;
  1293. }
  1294. /**
  1295. * Check if the current condition is valid
  1296. * @returns a boolean
  1297. */
  1298. Condition.prototype.isValid = function () {
  1299. return true;
  1300. };
  1301. /**
  1302. * Internal only
  1303. * @hidden
  1304. */
  1305. Condition.prototype._getProperty = function (propertyPath) {
  1306. return this._actionManager._getProperty(propertyPath);
  1307. };
  1308. /**
  1309. * Internal only
  1310. * @hidden
  1311. */
  1312. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1313. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1314. };
  1315. /**
  1316. * Serialize placeholder for child classes
  1317. * @returns the serialized object
  1318. */
  1319. Condition.prototype.serialize = function () {
  1320. };
  1321. /**
  1322. * Internal only
  1323. * @hidden
  1324. */
  1325. Condition.prototype._serialize = function (serializedCondition) {
  1326. return {
  1327. type: 2,
  1328. children: [],
  1329. name: serializedCondition.name,
  1330. properties: serializedCondition.properties
  1331. };
  1332. };
  1333. return Condition;
  1334. }());
  1335. /**
  1336. * Defines specific conditional operators as extensions of Condition
  1337. */
  1338. var ValueCondition = /** @class */ (function (_super) {
  1339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1340. /**
  1341. * Creates a new ValueCondition
  1342. * @param actionManager manager for the action the condition applies to
  1343. * @param target for the action
  1344. * @param propertyPath path to specify the property of the target the conditional operator uses
  1345. * @param value the value compared by the conditional operator against the current value of the property
  1346. * @param operator the conditional operator, default ValueCondition.IsEqual
  1347. */
  1348. function ValueCondition(actionManager, target,
  1349. /** path to specify the property of the target the conditional operator uses */
  1350. propertyPath,
  1351. /** the value compared by the conditional operator against the current value of the property */
  1352. value,
  1353. /** the conditional operator, default ValueCondition.IsEqual */
  1354. operator) {
  1355. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1356. var _this = _super.call(this, actionManager) || this;
  1357. _this.propertyPath = propertyPath;
  1358. _this.value = value;
  1359. _this.operator = operator;
  1360. _this._target = target;
  1361. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1362. _this._property = _this._getProperty(_this.propertyPath);
  1363. return _this;
  1364. }
  1365. Object.defineProperty(ValueCondition, "IsEqual", {
  1366. /**
  1367. * returns the number for IsEqual
  1368. */
  1369. get: function () {
  1370. return ValueCondition._IsEqual;
  1371. },
  1372. enumerable: true,
  1373. configurable: true
  1374. });
  1375. Object.defineProperty(ValueCondition, "IsDifferent", {
  1376. /**
  1377. * Returns the number for IsDifferent
  1378. */
  1379. get: function () {
  1380. return ValueCondition._IsDifferent;
  1381. },
  1382. enumerable: true,
  1383. configurable: true
  1384. });
  1385. Object.defineProperty(ValueCondition, "IsGreater", {
  1386. /**
  1387. * Returns the number for IsGreater
  1388. */
  1389. get: function () {
  1390. return ValueCondition._IsGreater;
  1391. },
  1392. enumerable: true,
  1393. configurable: true
  1394. });
  1395. Object.defineProperty(ValueCondition, "IsLesser", {
  1396. /**
  1397. * Returns the number for IsLesser
  1398. */
  1399. get: function () {
  1400. return ValueCondition._IsLesser;
  1401. },
  1402. enumerable: true,
  1403. configurable: true
  1404. });
  1405. /**
  1406. * Compares the given value with the property value for the specified conditional operator
  1407. * @returns the result of the comparison
  1408. */
  1409. ValueCondition.prototype.isValid = function () {
  1410. switch (this.operator) {
  1411. case ValueCondition.IsGreater:
  1412. return this._effectiveTarget[this._property] > this.value;
  1413. case ValueCondition.IsLesser:
  1414. return this._effectiveTarget[this._property] < this.value;
  1415. case ValueCondition.IsEqual:
  1416. case ValueCondition.IsDifferent:
  1417. var check;
  1418. if (this.value.equals) {
  1419. check = this.value.equals(this._effectiveTarget[this._property]);
  1420. }
  1421. else {
  1422. check = this.value === this._effectiveTarget[this._property];
  1423. }
  1424. return this.operator === ValueCondition.IsEqual ? check : !check;
  1425. }
  1426. return false;
  1427. };
  1428. /**
  1429. * Serialize the ValueCondition into a JSON compatible object
  1430. * @returns serialization object
  1431. */
  1432. ValueCondition.prototype.serialize = function () {
  1433. return this._serialize({
  1434. name: "ValueCondition",
  1435. properties: [
  1436. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1437. { name: "propertyPath", value: this.propertyPath },
  1438. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1439. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1440. ]
  1441. });
  1442. };
  1443. /**
  1444. * Gets the name of the conditional operator for the ValueCondition
  1445. * @param operator the conditional operator
  1446. * @returns the name
  1447. */
  1448. ValueCondition.GetOperatorName = function (operator) {
  1449. switch (operator) {
  1450. case ValueCondition._IsEqual: return "IsEqual";
  1451. case ValueCondition._IsDifferent: return "IsDifferent";
  1452. case ValueCondition._IsGreater: return "IsGreater";
  1453. case ValueCondition._IsLesser: return "IsLesser";
  1454. default: return "";
  1455. }
  1456. };
  1457. /**
  1458. * Internal only
  1459. * @hidden
  1460. */
  1461. ValueCondition._IsEqual = 0;
  1462. /**
  1463. * Internal only
  1464. * @hidden
  1465. */
  1466. ValueCondition._IsDifferent = 1;
  1467. /**
  1468. * Internal only
  1469. * @hidden
  1470. */
  1471. ValueCondition._IsGreater = 2;
  1472. /**
  1473. * Internal only
  1474. * @hidden
  1475. */
  1476. ValueCondition._IsLesser = 3;
  1477. return ValueCondition;
  1478. }(Condition));
  1479. /**
  1480. * Defines a predicate condition as an extension of Condition
  1481. */
  1482. var PredicateCondition = /** @class */ (function (_super) {
  1483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1484. /**
  1485. * Creates a new PredicateCondition
  1486. * @param actionManager manager for the action the condition applies to
  1487. * @param predicate defines the predicate function used to validate the condition
  1488. */
  1489. function PredicateCondition(actionManager,
  1490. /** defines the predicate function used to validate the condition */
  1491. predicate) {
  1492. var _this = _super.call(this, actionManager) || this;
  1493. _this.predicate = predicate;
  1494. return _this;
  1495. }
  1496. /**
  1497. * @returns the validity of the predicate condition
  1498. */
  1499. PredicateCondition.prototype.isValid = function () {
  1500. return this.predicate();
  1501. };
  1502. return PredicateCondition;
  1503. }(Condition));
  1504. /**
  1505. * Defines a state condition as an extension of Condition
  1506. */
  1507. var StateCondition = /** @class */ (function (_super) {
  1508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1509. /**
  1510. * Creates a new StateCondition
  1511. * @param actionManager manager for the action the condition applies to
  1512. * @param target of the condition
  1513. * @param value to compare with target state
  1514. */
  1515. function StateCondition(actionManager, target,
  1516. /** Value to compare with target state */
  1517. value) {
  1518. var _this = _super.call(this, actionManager) || this;
  1519. _this.value = value;
  1520. _this._target = target;
  1521. return _this;
  1522. }
  1523. /**
  1524. * Gets a boolean indicating if the current condition is met
  1525. * @returns the validity of the state
  1526. */
  1527. StateCondition.prototype.isValid = function () {
  1528. return this._target.state === this.value;
  1529. };
  1530. /**
  1531. * Serialize the StateCondition into a JSON compatible object
  1532. * @returns serialization object
  1533. */
  1534. StateCondition.prototype.serialize = function () {
  1535. return this._serialize({
  1536. name: "StateCondition",
  1537. properties: [
  1538. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1539. { name: "value", value: this.value }
  1540. ]
  1541. });
  1542. };
  1543. return StateCondition;
  1544. }(Condition));
  1545. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1546. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1547. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1548. /***/ }),
  1549. /***/ "./Actions/directActions.ts":
  1550. /*!**********************************!*\
  1551. !*** ./Actions/directActions.ts ***!
  1552. \**********************************/
  1553. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1555. "use strict";
  1556. __webpack_require__.r(__webpack_exports__);
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1567. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1568. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1569. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1570. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1572. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1573. /**
  1574. * This defines an action responsible to toggle a boolean once triggered.
  1575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1576. */
  1577. var SwitchBooleanAction = /** @class */ (function (_super) {
  1578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1579. /**
  1580. * Instantiate the action
  1581. * @param triggerOptions defines the trigger options
  1582. * @param target defines the object containing the boolean
  1583. * @param propertyPath defines the path to the boolean property in the target object
  1584. * @param condition defines the trigger related conditions
  1585. */
  1586. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1587. var _this = _super.call(this, triggerOptions, condition) || this;
  1588. _this.propertyPath = propertyPath;
  1589. _this._target = _this._effectiveTarget = target;
  1590. return _this;
  1591. }
  1592. /** @hidden */
  1593. SwitchBooleanAction.prototype._prepare = function () {
  1594. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1595. this._property = this._getProperty(this.propertyPath);
  1596. };
  1597. /**
  1598. * Execute the action toggle the boolean value.
  1599. */
  1600. SwitchBooleanAction.prototype.execute = function () {
  1601. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1602. };
  1603. /**
  1604. * Serializes the actions and its related information.
  1605. * @param parent defines the object to serialize in
  1606. * @returns the serialized object
  1607. */
  1608. SwitchBooleanAction.prototype.serialize = function (parent) {
  1609. return _super.prototype._serialize.call(this, {
  1610. name: "SwitchBooleanAction",
  1611. properties: [
  1612. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1613. { name: "propertyPath", value: this.propertyPath }
  1614. ]
  1615. }, parent);
  1616. };
  1617. return SwitchBooleanAction;
  1618. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1619. /**
  1620. * This defines an action responsible to set a the state field of the target
  1621. * to a desired value once triggered.
  1622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1623. */
  1624. var SetStateAction = /** @class */ (function (_super) {
  1625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1626. /**
  1627. * Instantiate the action
  1628. * @param triggerOptions defines the trigger options
  1629. * @param target defines the object containing the state property
  1630. * @param value defines the value to store in the state field
  1631. * @param condition defines the trigger related conditions
  1632. */
  1633. function SetStateAction(triggerOptions, target, value, condition) {
  1634. var _this = _super.call(this, triggerOptions, condition) || this;
  1635. _this.value = value;
  1636. _this._target = target;
  1637. return _this;
  1638. }
  1639. /**
  1640. * Execute the action and store the value on the target state property.
  1641. */
  1642. SetStateAction.prototype.execute = function () {
  1643. this._target.state = this.value;
  1644. };
  1645. /**
  1646. * Serializes the actions and its related information.
  1647. * @param parent defines the object to serialize in
  1648. * @returns the serialized object
  1649. */
  1650. SetStateAction.prototype.serialize = function (parent) {
  1651. return _super.prototype._serialize.call(this, {
  1652. name: "SetStateAction",
  1653. properties: [
  1654. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1655. { name: "value", value: this.value }
  1656. ]
  1657. }, parent);
  1658. };
  1659. return SetStateAction;
  1660. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1661. /**
  1662. * This defines an action responsible to set a property of the target
  1663. * to a desired value once triggered.
  1664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1665. */
  1666. var SetValueAction = /** @class */ (function (_super) {
  1667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1668. /**
  1669. * Instantiate the action
  1670. * @param triggerOptions defines the trigger options
  1671. * @param target defines the object containing the property
  1672. * @param propertyPath defines the path of the property to set in the target
  1673. * @param value defines the value to set in the property
  1674. * @param condition defines the trigger related conditions
  1675. */
  1676. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1677. var _this = _super.call(this, triggerOptions, condition) || this;
  1678. _this.propertyPath = propertyPath;
  1679. _this.value = value;
  1680. _this._target = _this._effectiveTarget = target;
  1681. return _this;
  1682. }
  1683. /** @hidden */
  1684. SetValueAction.prototype._prepare = function () {
  1685. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1686. this._property = this._getProperty(this.propertyPath);
  1687. };
  1688. /**
  1689. * Execute the action and set the targetted property to the desired value.
  1690. */
  1691. SetValueAction.prototype.execute = function () {
  1692. this._effectiveTarget[this._property] = this.value;
  1693. if (this._target.markAsDirty) {
  1694. this._target.markAsDirty(this._property);
  1695. }
  1696. };
  1697. /**
  1698. * Serializes the actions and its related information.
  1699. * @param parent defines the object to serialize in
  1700. * @returns the serialized object
  1701. */
  1702. SetValueAction.prototype.serialize = function (parent) {
  1703. return _super.prototype._serialize.call(this, {
  1704. name: "SetValueAction",
  1705. properties: [
  1706. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1707. { name: "propertyPath", value: this.propertyPath },
  1708. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1709. ]
  1710. }, parent);
  1711. };
  1712. return SetValueAction;
  1713. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1714. /**
  1715. * This defines an action responsible to increment the target value
  1716. * to a desired value once triggered.
  1717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1718. */
  1719. var IncrementValueAction = /** @class */ (function (_super) {
  1720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1721. /**
  1722. * Instantiate the action
  1723. * @param triggerOptions defines the trigger options
  1724. * @param target defines the object containing the property
  1725. * @param propertyPath defines the path of the property to increment in the target
  1726. * @param value defines the value value we should increment the property by
  1727. * @param condition defines the trigger related conditions
  1728. */
  1729. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1730. var _this = _super.call(this, triggerOptions, condition) || this;
  1731. _this.propertyPath = propertyPath;
  1732. _this.value = value;
  1733. _this._target = _this._effectiveTarget = target;
  1734. return _this;
  1735. }
  1736. /** @hidden */
  1737. IncrementValueAction.prototype._prepare = function () {
  1738. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1739. this._property = this._getProperty(this.propertyPath);
  1740. if (typeof this._effectiveTarget[this._property] !== "number") {
  1741. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1742. }
  1743. };
  1744. /**
  1745. * Execute the action and increment the target of the value amount.
  1746. */
  1747. IncrementValueAction.prototype.execute = function () {
  1748. this._effectiveTarget[this._property] += this.value;
  1749. if (this._target.markAsDirty) {
  1750. this._target.markAsDirty(this._property);
  1751. }
  1752. };
  1753. /**
  1754. * Serializes the actions and its related information.
  1755. * @param parent defines the object to serialize in
  1756. * @returns the serialized object
  1757. */
  1758. IncrementValueAction.prototype.serialize = function (parent) {
  1759. return _super.prototype._serialize.call(this, {
  1760. name: "IncrementValueAction",
  1761. properties: [
  1762. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1763. { name: "propertyPath", value: this.propertyPath },
  1764. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1765. ]
  1766. }, parent);
  1767. };
  1768. return IncrementValueAction;
  1769. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1770. /**
  1771. * This defines an action responsible to start an animation once triggered.
  1772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1773. */
  1774. var PlayAnimationAction = /** @class */ (function (_super) {
  1775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1776. /**
  1777. * Instantiate the action
  1778. * @param triggerOptions defines the trigger options
  1779. * @param target defines the target animation or animation name
  1780. * @param from defines from where the animation should start (animation frame)
  1781. * @param end defines where the animation should stop (animation frame)
  1782. * @param loop defines if the animation should loop or stop after the first play
  1783. * @param condition defines the trigger related conditions
  1784. */
  1785. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1786. var _this = _super.call(this, triggerOptions, condition) || this;
  1787. _this.from = from;
  1788. _this.to = to;
  1789. _this.loop = loop;
  1790. _this._target = target;
  1791. return _this;
  1792. }
  1793. /** @hidden */
  1794. PlayAnimationAction.prototype._prepare = function () {
  1795. };
  1796. /**
  1797. * Execute the action and play the animation.
  1798. */
  1799. PlayAnimationAction.prototype.execute = function () {
  1800. var scene = this._actionManager.getScene();
  1801. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1802. };
  1803. /**
  1804. * Serializes the actions and its related information.
  1805. * @param parent defines the object to serialize in
  1806. * @returns the serialized object
  1807. */
  1808. PlayAnimationAction.prototype.serialize = function (parent) {
  1809. return _super.prototype._serialize.call(this, {
  1810. name: "PlayAnimationAction",
  1811. properties: [
  1812. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1813. { name: "from", value: String(this.from) },
  1814. { name: "to", value: String(this.to) },
  1815. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1816. ]
  1817. }, parent);
  1818. };
  1819. return PlayAnimationAction;
  1820. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1821. /**
  1822. * This defines an action responsible to stop an animation once triggered.
  1823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1824. */
  1825. var StopAnimationAction = /** @class */ (function (_super) {
  1826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1827. /**
  1828. * Instantiate the action
  1829. * @param triggerOptions defines the trigger options
  1830. * @param target defines the target animation or animation name
  1831. * @param condition defines the trigger related conditions
  1832. */
  1833. function StopAnimationAction(triggerOptions, target, condition) {
  1834. var _this = _super.call(this, triggerOptions, condition) || this;
  1835. _this._target = target;
  1836. return _this;
  1837. }
  1838. /** @hidden */
  1839. StopAnimationAction.prototype._prepare = function () {
  1840. };
  1841. /**
  1842. * Execute the action and stop the animation.
  1843. */
  1844. StopAnimationAction.prototype.execute = function () {
  1845. var scene = this._actionManager.getScene();
  1846. scene.stopAnimation(this._target);
  1847. };
  1848. /**
  1849. * Serializes the actions and its related information.
  1850. * @param parent defines the object to serialize in
  1851. * @returns the serialized object
  1852. */
  1853. StopAnimationAction.prototype.serialize = function (parent) {
  1854. return _super.prototype._serialize.call(this, {
  1855. name: "StopAnimationAction",
  1856. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1857. }, parent);
  1858. };
  1859. return StopAnimationAction;
  1860. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1861. /**
  1862. * This defines an action responsible that does nothing once triggered.
  1863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1864. */
  1865. var DoNothingAction = /** @class */ (function (_super) {
  1866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1867. /**
  1868. * Instantiate the action
  1869. * @param triggerOptions defines the trigger options
  1870. * @param condition defines the trigger related conditions
  1871. */
  1872. function DoNothingAction(triggerOptions, condition) {
  1873. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1874. return _super.call(this, triggerOptions, condition) || this;
  1875. }
  1876. /**
  1877. * Execute the action and do nothing.
  1878. */
  1879. DoNothingAction.prototype.execute = function () {
  1880. };
  1881. /**
  1882. * Serializes the actions and its related information.
  1883. * @param parent defines the object to serialize in
  1884. * @returns the serialized object
  1885. */
  1886. DoNothingAction.prototype.serialize = function (parent) {
  1887. return _super.prototype._serialize.call(this, {
  1888. name: "DoNothingAction",
  1889. properties: []
  1890. }, parent);
  1891. };
  1892. return DoNothingAction;
  1893. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1894. /**
  1895. * This defines an action responsible to trigger several actions once triggered.
  1896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1897. */
  1898. var CombineAction = /** @class */ (function (_super) {
  1899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1900. /**
  1901. * Instantiate the action
  1902. * @param triggerOptions defines the trigger options
  1903. * @param children defines the list of aggregated animations to run
  1904. * @param condition defines the trigger related conditions
  1905. */
  1906. function CombineAction(triggerOptions, children, condition) {
  1907. var _this = _super.call(this, triggerOptions, condition) || this;
  1908. _this.children = children;
  1909. return _this;
  1910. }
  1911. /** @hidden */
  1912. CombineAction.prototype._prepare = function () {
  1913. for (var index = 0; index < this.children.length; index++) {
  1914. this.children[index]._actionManager = this._actionManager;
  1915. this.children[index]._prepare();
  1916. }
  1917. };
  1918. /**
  1919. * Execute the action and executes all the aggregated actions.
  1920. */
  1921. CombineAction.prototype.execute = function (evt) {
  1922. for (var index = 0; index < this.children.length; index++) {
  1923. this.children[index].execute(evt);
  1924. }
  1925. };
  1926. /**
  1927. * Serializes the actions and its related information.
  1928. * @param parent defines the object to serialize in
  1929. * @returns the serialized object
  1930. */
  1931. CombineAction.prototype.serialize = function (parent) {
  1932. var serializationObject = _super.prototype._serialize.call(this, {
  1933. name: "CombineAction",
  1934. properties: [],
  1935. combine: []
  1936. }, parent);
  1937. for (var i = 0; i < this.children.length; i++) {
  1938. serializationObject.combine.push(this.children[i].serialize(null));
  1939. }
  1940. return serializationObject;
  1941. };
  1942. return CombineAction;
  1943. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1944. /**
  1945. * This defines an action responsible to run code (external event) once triggered.
  1946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1947. */
  1948. var ExecuteCodeAction = /** @class */ (function (_super) {
  1949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1950. /**
  1951. * Instantiate the action
  1952. * @param triggerOptions defines the trigger options
  1953. * @param func defines the callback function to run
  1954. * @param condition defines the trigger related conditions
  1955. */
  1956. function ExecuteCodeAction(triggerOptions, func, condition) {
  1957. var _this = _super.call(this, triggerOptions, condition) || this;
  1958. _this.func = func;
  1959. return _this;
  1960. }
  1961. /**
  1962. * Execute the action and run the attached code.
  1963. */
  1964. ExecuteCodeAction.prototype.execute = function (evt) {
  1965. this.func(evt);
  1966. };
  1967. return ExecuteCodeAction;
  1968. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1969. /**
  1970. * This defines an action responsible to set the parent property of the target once triggered.
  1971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1972. */
  1973. var SetParentAction = /** @class */ (function (_super) {
  1974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1975. /**
  1976. * Instantiate the action
  1977. * @param triggerOptions defines the trigger options
  1978. * @param target defines the target containing the parent property
  1979. * @param parent defines from where the animation should start (animation frame)
  1980. * @param condition defines the trigger related conditions
  1981. */
  1982. function SetParentAction(triggerOptions, target, parent, condition) {
  1983. var _this = _super.call(this, triggerOptions, condition) || this;
  1984. _this._target = target;
  1985. _this._parent = parent;
  1986. return _this;
  1987. }
  1988. /** @hidden */
  1989. SetParentAction.prototype._prepare = function () {
  1990. };
  1991. /**
  1992. * Execute the action and set the parent property.
  1993. */
  1994. SetParentAction.prototype.execute = function () {
  1995. if (this._target.parent === this._parent) {
  1996. return;
  1997. }
  1998. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1999. invertParentWorldMatrix.invert();
  2000. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  2001. this._target.parent = this._parent;
  2002. };
  2003. /**
  2004. * Serializes the actions and its related information.
  2005. * @param parent defines the object to serialize in
  2006. * @returns the serialized object
  2007. */
  2008. SetParentAction.prototype.serialize = function (parent) {
  2009. return _super.prototype._serialize.call(this, {
  2010. name: "SetParentAction",
  2011. properties: [
  2012. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2013. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2014. ]
  2015. }, parent);
  2016. };
  2017. return SetParentAction;
  2018. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2024. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2025. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2026. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2027. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2028. /***/ }),
  2029. /***/ "./Actions/directAudioActions.ts":
  2030. /*!***************************************!*\
  2031. !*** ./Actions/directAudioActions.ts ***!
  2032. \***************************************/
  2033. /*! exports provided: PlaySoundAction, StopSoundAction */
  2034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2035. "use strict";
  2036. __webpack_require__.r(__webpack_exports__);
  2037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2040. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2041. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2042. /**
  2043. * This defines an action helpful to play a defined sound on a triggered action.
  2044. */
  2045. var PlaySoundAction = /** @class */ (function (_super) {
  2046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2047. /**
  2048. * Instantiate the action
  2049. * @param triggerOptions defines the trigger options
  2050. * @param sound defines the sound to play
  2051. * @param condition defines the trigger related conditions
  2052. */
  2053. function PlaySoundAction(triggerOptions, sound, condition) {
  2054. var _this = _super.call(this, triggerOptions, condition) || this;
  2055. _this._sound = sound;
  2056. return _this;
  2057. }
  2058. /** @hidden */
  2059. PlaySoundAction.prototype._prepare = function () {
  2060. };
  2061. /**
  2062. * Execute the action and play the sound.
  2063. */
  2064. PlaySoundAction.prototype.execute = function () {
  2065. if (this._sound !== undefined) {
  2066. this._sound.play();
  2067. }
  2068. };
  2069. /**
  2070. * Serializes the actions and its related information.
  2071. * @param parent defines the object to serialize in
  2072. * @returns the serialized object
  2073. */
  2074. PlaySoundAction.prototype.serialize = function (parent) {
  2075. return _super.prototype._serialize.call(this, {
  2076. name: "PlaySoundAction",
  2077. properties: [{ name: "sound", value: this._sound.name }]
  2078. }, parent);
  2079. };
  2080. return PlaySoundAction;
  2081. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2082. /**
  2083. * This defines an action helpful to stop a defined sound on a triggered action.
  2084. */
  2085. var StopSoundAction = /** @class */ (function (_super) {
  2086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2087. /**
  2088. * Instantiate the action
  2089. * @param triggerOptions defines the trigger options
  2090. * @param sound defines the sound to stop
  2091. * @param condition defines the trigger related conditions
  2092. */
  2093. function StopSoundAction(triggerOptions, sound, condition) {
  2094. var _this = _super.call(this, triggerOptions, condition) || this;
  2095. _this._sound = sound;
  2096. return _this;
  2097. }
  2098. /** @hidden */
  2099. StopSoundAction.prototype._prepare = function () {
  2100. };
  2101. /**
  2102. * Execute the action and stop the sound.
  2103. */
  2104. StopSoundAction.prototype.execute = function () {
  2105. if (this._sound !== undefined) {
  2106. this._sound.stop();
  2107. }
  2108. };
  2109. /**
  2110. * Serializes the actions and its related information.
  2111. * @param parent defines the object to serialize in
  2112. * @returns the serialized object
  2113. */
  2114. StopSoundAction.prototype.serialize = function (parent) {
  2115. return _super.prototype._serialize.call(this, {
  2116. name: "StopSoundAction",
  2117. properties: [{ name: "sound", value: this._sound.name }]
  2118. }, parent);
  2119. };
  2120. return StopSoundAction;
  2121. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2122. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2123. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2124. /***/ }),
  2125. /***/ "./Actions/index.ts":
  2126. /*!**************************!*\
  2127. !*** ./Actions/index.ts ***!
  2128. \**************************/
  2129. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2131. "use strict";
  2132. __webpack_require__.r(__webpack_exports__);
  2133. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2135. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2137. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2139. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2144. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2155. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2158. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2160. /***/ }),
  2161. /***/ "./Actions/interpolateValueAction.ts":
  2162. /*!*******************************************!*\
  2163. !*** ./Actions/interpolateValueAction.ts ***!
  2164. \*******************************************/
  2165. /*! exports provided: InterpolateValueAction */
  2166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2167. "use strict";
  2168. __webpack_require__.r(__webpack_exports__);
  2169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2171. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2172. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2173. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2174. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2175. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2176. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2177. /**
  2178. * This defines an action responsible to change the value of a property
  2179. * by interpolating between its current value and the newly set one once triggered.
  2180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2181. */
  2182. var InterpolateValueAction = /** @class */ (function (_super) {
  2183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2184. /**
  2185. * Instantiate the action
  2186. * @param triggerOptions defines the trigger options
  2187. * @param target defines the object containing the value to interpolate
  2188. * @param propertyPath defines the path to the property in the target object
  2189. * @param value defines the target value at the end of the interpolation
  2190. * @param duration deines the time it will take for the property to interpolate to the value.
  2191. * @param condition defines the trigger related conditions
  2192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2194. */
  2195. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2196. if (duration === void 0) { duration = 1000; }
  2197. var _this = _super.call(this, triggerOptions, condition) || this;
  2198. /**
  2199. * Defines the time it will take for the property to interpolate to the value.
  2200. */
  2201. _this.duration = 1000;
  2202. /**
  2203. * Observable triggered once the interpolation animation has been done.
  2204. */
  2205. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2206. _this.propertyPath = propertyPath;
  2207. _this.value = value;
  2208. _this.duration = duration;
  2209. _this.stopOtherAnimations = stopOtherAnimations;
  2210. _this.onInterpolationDone = onInterpolationDone;
  2211. _this._target = _this._effectiveTarget = target;
  2212. return _this;
  2213. }
  2214. /** @hidden */
  2215. InterpolateValueAction.prototype._prepare = function () {
  2216. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2217. this._property = this._getProperty(this.propertyPath);
  2218. };
  2219. /**
  2220. * Execute the action starts the value interpolation.
  2221. */
  2222. InterpolateValueAction.prototype.execute = function () {
  2223. var _this = this;
  2224. var scene = this._actionManager.getScene();
  2225. var keys = [
  2226. {
  2227. frame: 0,
  2228. value: this._effectiveTarget[this._property]
  2229. }, {
  2230. frame: 100,
  2231. value: this.value
  2232. }
  2233. ];
  2234. var dataType;
  2235. if (typeof this.value === "number") {
  2236. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2237. }
  2238. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2239. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2240. }
  2241. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2242. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2243. }
  2244. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2245. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2246. }
  2247. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2248. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2249. }
  2250. else {
  2251. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2252. return;
  2253. }
  2254. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2255. animation.setKeys(keys);
  2256. if (this.stopOtherAnimations) {
  2257. scene.stopAnimation(this._effectiveTarget);
  2258. }
  2259. var wrapper = function () {
  2260. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2261. if (_this.onInterpolationDone) {
  2262. _this.onInterpolationDone();
  2263. }
  2264. };
  2265. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2266. };
  2267. /**
  2268. * Serializes the actions and its related information.
  2269. * @param parent defines the object to serialize in
  2270. * @returns the serialized object
  2271. */
  2272. InterpolateValueAction.prototype.serialize = function (parent) {
  2273. return _super.prototype._serialize.call(this, {
  2274. name: "InterpolateValueAction",
  2275. properties: [
  2276. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2277. { name: "propertyPath", value: this.propertyPath },
  2278. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2279. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2280. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2281. ]
  2282. }, parent);
  2283. };
  2284. return InterpolateValueAction;
  2285. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2286. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = InterpolateValueAction;
  2287. /***/ }),
  2288. /***/ "./Animations/animatable.ts":
  2289. /*!**********************************!*\
  2290. !*** ./Animations/animatable.ts ***!
  2291. \**********************************/
  2292. /*! exports provided: Animatable */
  2293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2294. "use strict";
  2295. __webpack_require__.r(__webpack_exports__);
  2296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2297. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2298. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2300. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2302. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2303. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2304. /**
  2305. * Class used to store an actual running animation
  2306. */
  2307. var Animatable = /** @class */ (function () {
  2308. /**
  2309. * Creates a new Animatable
  2310. * @param scene defines the hosting scene
  2311. * @param target defines the target object
  2312. * @param fromFrame defines the starting frame number (default is 0)
  2313. * @param toFrame defines the ending frame number (default is 100)
  2314. * @param loopAnimation defines if the animation must loop (default is false)
  2315. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2316. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2317. * @param animations defines a group of animation to add to the new Animatable
  2318. * @param onAnimationLoop defines a callback to call when animation loops
  2319. */
  2320. function Animatable(scene,
  2321. /** defines the target object */
  2322. target,
  2323. /** defines the starting frame number (default is 0) */
  2324. fromFrame,
  2325. /** defines the ending frame number (default is 100) */
  2326. toFrame,
  2327. /** defines if the animation must loop (default is false) */
  2328. loopAnimation, speedRatio,
  2329. /** defines a callback to call when animation ends if it is not looping */
  2330. onAnimationEnd, animations,
  2331. /** defines a callback to call when animation loops */
  2332. onAnimationLoop) {
  2333. if (fromFrame === void 0) { fromFrame = 0; }
  2334. if (toFrame === void 0) { toFrame = 100; }
  2335. if (loopAnimation === void 0) { loopAnimation = false; }
  2336. if (speedRatio === void 0) { speedRatio = 1.0; }
  2337. this.target = target;
  2338. this.fromFrame = fromFrame;
  2339. this.toFrame = toFrame;
  2340. this.loopAnimation = loopAnimation;
  2341. this.onAnimationEnd = onAnimationEnd;
  2342. this.onAnimationLoop = onAnimationLoop;
  2343. this._localDelayOffset = null;
  2344. this._pausedDelay = null;
  2345. this._runtimeAnimations = new Array();
  2346. this._paused = false;
  2347. this._speedRatio = 1;
  2348. this._weight = -1.0;
  2349. /**
  2350. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2351. * This will only apply for non looping animation (default is true)
  2352. */
  2353. this.disposeOnEnd = true;
  2354. /**
  2355. * Gets a boolean indicating if the animation has started
  2356. */
  2357. this.animationStarted = false;
  2358. /**
  2359. * Observer raised when the animation ends
  2360. */
  2361. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. /**
  2363. * Observer raised when the animation loops
  2364. */
  2365. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2366. this._scene = scene;
  2367. if (animations) {
  2368. this.appendAnimations(target, animations);
  2369. }
  2370. this._speedRatio = speedRatio;
  2371. scene._activeAnimatables.push(this);
  2372. }
  2373. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2374. /**
  2375. * Gets the root Animatable used to synchronize and normalize animations
  2376. */
  2377. get: function () {
  2378. return this._syncRoot;
  2379. },
  2380. enumerable: true,
  2381. configurable: true
  2382. });
  2383. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2384. /**
  2385. * Gets the current frame of the first RuntimeAnimation
  2386. * Used to synchronize Animatables
  2387. */
  2388. get: function () {
  2389. if (this._runtimeAnimations.length === 0) {
  2390. return 0;
  2391. }
  2392. return this._runtimeAnimations[0].currentFrame;
  2393. },
  2394. enumerable: true,
  2395. configurable: true
  2396. });
  2397. Object.defineProperty(Animatable.prototype, "weight", {
  2398. /**
  2399. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2400. */
  2401. get: function () {
  2402. return this._weight;
  2403. },
  2404. set: function (value) {
  2405. if (value === -1) { // -1 is ok and means no weight
  2406. this._weight = -1;
  2407. return;
  2408. }
  2409. // Else weight must be in [0, 1] range
  2410. this._weight = Math.min(Math.max(value, 0), 1.0);
  2411. },
  2412. enumerable: true,
  2413. configurable: true
  2414. });
  2415. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2416. /**
  2417. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2418. */
  2419. get: function () {
  2420. return this._speedRatio;
  2421. },
  2422. set: function (value) {
  2423. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2424. var animation = this._runtimeAnimations[index];
  2425. animation._prepareForSpeedRatioChange(value);
  2426. }
  2427. this._speedRatio = value;
  2428. },
  2429. enumerable: true,
  2430. configurable: true
  2431. });
  2432. // Methods
  2433. /**
  2434. * Synchronize and normalize current Animatable with a source Animatable
  2435. * This is useful when using animation weights and when animations are not of the same length
  2436. * @param root defines the root Animatable to synchronize with
  2437. * @returns the current Animatable
  2438. */
  2439. Animatable.prototype.syncWith = function (root) {
  2440. this._syncRoot = root;
  2441. if (root) {
  2442. // Make sure this animatable will animate after the root
  2443. var index = this._scene._activeAnimatables.indexOf(this);
  2444. if (index > -1) {
  2445. this._scene._activeAnimatables.splice(index, 1);
  2446. this._scene._activeAnimatables.push(this);
  2447. }
  2448. }
  2449. return this;
  2450. };
  2451. /**
  2452. * Gets the list of runtime animations
  2453. * @returns an array of RuntimeAnimation
  2454. */
  2455. Animatable.prototype.getAnimations = function () {
  2456. return this._runtimeAnimations;
  2457. };
  2458. /**
  2459. * Adds more animations to the current animatable
  2460. * @param target defines the target of the animations
  2461. * @param animations defines the new animations to add
  2462. */
  2463. Animatable.prototype.appendAnimations = function (target, animations) {
  2464. for (var index = 0; index < animations.length; index++) {
  2465. var animation = animations[index];
  2466. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this));
  2467. }
  2468. };
  2469. /**
  2470. * Gets the source animation for a specific property
  2471. * @param property defines the propertyu to look for
  2472. * @returns null or the source animation for the given property
  2473. */
  2474. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2475. var runtimeAnimations = this._runtimeAnimations;
  2476. for (var index = 0; index < runtimeAnimations.length; index++) {
  2477. if (runtimeAnimations[index].animation.targetProperty === property) {
  2478. return runtimeAnimations[index].animation;
  2479. }
  2480. }
  2481. return null;
  2482. };
  2483. /**
  2484. * Gets the runtime animation for a specific property
  2485. * @param property defines the propertyu to look for
  2486. * @returns null or the runtime animation for the given property
  2487. */
  2488. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2489. var runtimeAnimations = this._runtimeAnimations;
  2490. for (var index = 0; index < runtimeAnimations.length; index++) {
  2491. if (runtimeAnimations[index].animation.targetProperty === property) {
  2492. return runtimeAnimations[index];
  2493. }
  2494. }
  2495. return null;
  2496. };
  2497. /**
  2498. * Resets the animatable to its original state
  2499. */
  2500. Animatable.prototype.reset = function () {
  2501. var runtimeAnimations = this._runtimeAnimations;
  2502. for (var index = 0; index < runtimeAnimations.length; index++) {
  2503. runtimeAnimations[index].reset(true);
  2504. }
  2505. this._localDelayOffset = null;
  2506. this._pausedDelay = null;
  2507. };
  2508. /**
  2509. * Allows the animatable to blend with current running animations
  2510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2511. * @param blendingSpeed defines the blending speed to use
  2512. */
  2513. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2514. var runtimeAnimations = this._runtimeAnimations;
  2515. for (var index = 0; index < runtimeAnimations.length; index++) {
  2516. runtimeAnimations[index].animation.enableBlending = true;
  2517. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2518. }
  2519. };
  2520. /**
  2521. * Disable animation blending
  2522. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2523. */
  2524. Animatable.prototype.disableBlending = function () {
  2525. var runtimeAnimations = this._runtimeAnimations;
  2526. for (var index = 0; index < runtimeAnimations.length; index++) {
  2527. runtimeAnimations[index].animation.enableBlending = false;
  2528. }
  2529. };
  2530. /**
  2531. * Jump directly to a given frame
  2532. * @param frame defines the frame to jump to
  2533. */
  2534. Animatable.prototype.goToFrame = function (frame) {
  2535. var runtimeAnimations = this._runtimeAnimations;
  2536. if (runtimeAnimations[0]) {
  2537. var fps = runtimeAnimations[0].animation.framePerSecond;
  2538. var currentFrame = runtimeAnimations[0].currentFrame;
  2539. var adjustTime = frame - currentFrame;
  2540. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2541. if (this._localDelayOffset === null) {
  2542. this._localDelayOffset = 0;
  2543. }
  2544. this._localDelayOffset -= delay;
  2545. }
  2546. for (var index = 0; index < runtimeAnimations.length; index++) {
  2547. runtimeAnimations[index].goToFrame(frame);
  2548. }
  2549. };
  2550. /**
  2551. * Pause the animation
  2552. */
  2553. Animatable.prototype.pause = function () {
  2554. if (this._paused) {
  2555. return;
  2556. }
  2557. this._paused = true;
  2558. };
  2559. /**
  2560. * Restart the animation
  2561. */
  2562. Animatable.prototype.restart = function () {
  2563. this._paused = false;
  2564. };
  2565. Animatable.prototype._raiseOnAnimationEnd = function () {
  2566. if (this.onAnimationEnd) {
  2567. this.onAnimationEnd();
  2568. }
  2569. this.onAnimationEndObservable.notifyObservers(this);
  2570. };
  2571. /**
  2572. * Stop and delete the current animation
  2573. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2574. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2575. */
  2576. Animatable.prototype.stop = function (animationName, targetMask) {
  2577. if (animationName || targetMask) {
  2578. var idx = this._scene._activeAnimatables.indexOf(this);
  2579. if (idx > -1) {
  2580. var runtimeAnimations = this._runtimeAnimations;
  2581. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2582. var runtimeAnimation = runtimeAnimations[index];
  2583. if (animationName && runtimeAnimation.animation.name != animationName) {
  2584. continue;
  2585. }
  2586. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2587. continue;
  2588. }
  2589. runtimeAnimation.dispose();
  2590. runtimeAnimations.splice(index, 1);
  2591. }
  2592. if (runtimeAnimations.length == 0) {
  2593. this._scene._activeAnimatables.splice(idx, 1);
  2594. this._raiseOnAnimationEnd();
  2595. }
  2596. }
  2597. }
  2598. else {
  2599. var index = this._scene._activeAnimatables.indexOf(this);
  2600. if (index > -1) {
  2601. this._scene._activeAnimatables.splice(index, 1);
  2602. var runtimeAnimations = this._runtimeAnimations;
  2603. for (var index = 0; index < runtimeAnimations.length; index++) {
  2604. runtimeAnimations[index].dispose();
  2605. }
  2606. this._raiseOnAnimationEnd();
  2607. }
  2608. }
  2609. };
  2610. /**
  2611. * Wait asynchronously for the animation to end
  2612. * @returns a promise which will be fullfilled when the animation ends
  2613. */
  2614. Animatable.prototype.waitAsync = function () {
  2615. var _this = this;
  2616. return new Promise(function (resolve, reject) {
  2617. _this.onAnimationEndObservable.add(function () {
  2618. resolve(_this);
  2619. }, undefined, undefined, _this, true);
  2620. });
  2621. };
  2622. /** @hidden */
  2623. Animatable.prototype._animate = function (delay) {
  2624. var _this = this;
  2625. if (this._paused) {
  2626. this.animationStarted = false;
  2627. if (this._pausedDelay === null) {
  2628. this._pausedDelay = delay;
  2629. }
  2630. return true;
  2631. }
  2632. if (this._localDelayOffset === null) {
  2633. this._localDelayOffset = delay;
  2634. this._pausedDelay = null;
  2635. }
  2636. else if (this._pausedDelay !== null) {
  2637. this._localDelayOffset += delay - this._pausedDelay;
  2638. this._pausedDelay = null;
  2639. }
  2640. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2641. return true;
  2642. }
  2643. // Animating
  2644. var running = false;
  2645. var runtimeAnimations = this._runtimeAnimations;
  2646. var index;
  2647. for (index = 0; index < runtimeAnimations.length; index++) {
  2648. var animation = runtimeAnimations[index];
  2649. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2650. _this.onAnimationLoopObservable.notifyObservers(_this);
  2651. if (_this.onAnimationLoop) {
  2652. _this.onAnimationLoop();
  2653. }
  2654. });
  2655. running = running || isRunning;
  2656. }
  2657. this.animationStarted = running;
  2658. if (!running) {
  2659. if (this.disposeOnEnd) {
  2660. // Remove from active animatables
  2661. index = this._scene._activeAnimatables.indexOf(this);
  2662. this._scene._activeAnimatables.splice(index, 1);
  2663. // Dispose all runtime animations
  2664. for (index = 0; index < runtimeAnimations.length; index++) {
  2665. runtimeAnimations[index].dispose();
  2666. }
  2667. }
  2668. this._raiseOnAnimationEnd();
  2669. if (this.disposeOnEnd) {
  2670. this.onAnimationEnd = null;
  2671. this.onAnimationLoop = null;
  2672. this.onAnimationLoopObservable.clear();
  2673. this.onAnimationEndObservable.clear();
  2674. }
  2675. }
  2676. return running;
  2677. };
  2678. return Animatable;
  2679. }());
  2680. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2681. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  2682. return;
  2683. }
  2684. // Getting time
  2685. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2686. if (!this._animationTimeLast) {
  2687. if (this._pendingData.length > 0) {
  2688. return;
  2689. }
  2690. this._animationTimeLast = now;
  2691. }
  2692. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2693. this._animationTime += deltaTime;
  2694. this._animationTimeLast = now;
  2695. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2696. this._activeAnimatables[index]._animate(this._animationTime);
  2697. }
  2698. // Late animation bindings
  2699. this._processLateAnimationBindings();
  2700. };
  2701. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2702. if (weight === void 0) { weight = 1.0; }
  2703. if (speedRatio === void 0) { speedRatio = 1.0; }
  2704. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2705. returnedAnimatable.weight = weight;
  2706. return returnedAnimatable;
  2707. };
  2708. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2709. if (speedRatio === void 0) { speedRatio = 1.0; }
  2710. if (stopCurrent === void 0) { stopCurrent = true; }
  2711. if (from > to && speedRatio > 0) {
  2712. speedRatio *= -1;
  2713. }
  2714. if (stopCurrent) {
  2715. this.stopAnimation(target, undefined, targetMask);
  2716. }
  2717. if (!animatable) {
  2718. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2719. }
  2720. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2721. // Local animations
  2722. if (target.animations && shouldRunTargetAnimations) {
  2723. animatable.appendAnimations(target, target.animations);
  2724. }
  2725. // Children animations
  2726. if (target.getAnimatables) {
  2727. var animatables = target.getAnimatables();
  2728. for (var index = 0; index < animatables.length; index++) {
  2729. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2730. }
  2731. }
  2732. animatable.reset();
  2733. return animatable;
  2734. };
  2735. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2736. if (speedRatio === void 0) { speedRatio = 1.0; }
  2737. if (stopCurrent === void 0) { stopCurrent = true; }
  2738. var children = target.getDescendants(directDescendantsOnly);
  2739. var result = [];
  2740. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2741. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2742. var child = children_1[_i];
  2743. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2744. }
  2745. return result;
  2746. };
  2747. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2748. if (speedRatio === undefined) {
  2749. speedRatio = 1.0;
  2750. }
  2751. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2752. return animatable;
  2753. };
  2754. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2755. var children = target.getDescendants(directDescendantsOnly);
  2756. var result = [];
  2757. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2758. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2759. var child = children_2[_i];
  2760. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2761. }
  2762. return result;
  2763. };
  2764. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2765. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2766. if (this._activeAnimatables[index].target === target) {
  2767. return this._activeAnimatables[index];
  2768. }
  2769. }
  2770. return null;
  2771. };
  2772. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2773. var result = [];
  2774. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2775. if (this._activeAnimatables[index].target === target) {
  2776. result.push(this._activeAnimatables[index]);
  2777. }
  2778. }
  2779. return result;
  2780. };
  2781. /**
  2782. * Will stop the animation of the given target
  2783. * @param target - the target
  2784. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2785. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2786. */
  2787. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2788. var animatables = this.getAllAnimatablesByTarget(target);
  2789. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2790. var animatable = animatables_1[_i];
  2791. animatable.stop(animationName, targetMask);
  2792. }
  2793. };
  2794. /**
  2795. * Stops and removes all animations that have been applied to the scene
  2796. */
  2797. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2798. if (this._activeAnimatables) {
  2799. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2800. this._activeAnimatables[i].stop();
  2801. }
  2802. this._activeAnimatables = [];
  2803. }
  2804. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2805. var group = _a[_i];
  2806. group.stop();
  2807. }
  2808. };
  2809. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2810. var target = runtimeAnimation.target;
  2811. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2812. if (!target._lateAnimationHolders) {
  2813. target._lateAnimationHolders = {};
  2814. }
  2815. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2816. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2817. totalWeight: 0,
  2818. animations: [],
  2819. originalValue: originalValue
  2820. };
  2821. }
  2822. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2823. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2824. };
  2825. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2826. var normalizer = 1.0;
  2827. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2828. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2829. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2830. var startIndex = 0;
  2831. var originalAnimation = holder.animations[0];
  2832. var originalValue = holder.originalValue;
  2833. var scale = 1;
  2834. if (holder.totalWeight < 1.0) {
  2835. // We need to mix the original value in
  2836. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2837. scale = 1.0 - holder.totalWeight;
  2838. }
  2839. else {
  2840. startIndex = 1;
  2841. // We need to normalize the weights
  2842. normalizer = holder.totalWeight;
  2843. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2844. scale = originalAnimation.weight / normalizer;
  2845. if (scale == 1) {
  2846. return originalAnimation.currentValue;
  2847. }
  2848. }
  2849. finalScaling.scaleInPlace(scale);
  2850. finalPosition.scaleInPlace(scale);
  2851. finalQuaternion.scaleInPlace(scale);
  2852. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2853. var runtimeAnimation = holder.animations[animIndex];
  2854. var scale = runtimeAnimation.weight / normalizer;
  2855. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2856. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2857. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2858. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2859. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2860. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2861. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2862. }
  2863. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  2864. return originalAnimation._workValue;
  2865. };
  2866. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2867. var originalAnimation = holder.animations[0];
  2868. var originalValue = holder.originalValue;
  2869. if (holder.animations.length === 1) {
  2870. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2871. return refQuaternion;
  2872. }
  2873. var normalizer = 1.0;
  2874. var quaternions;
  2875. var weights;
  2876. if (holder.totalWeight < 1.0) {
  2877. var scale = 1.0 - holder.totalWeight;
  2878. quaternions = [];
  2879. weights = [];
  2880. quaternions.push(originalValue);
  2881. weights.push(scale);
  2882. }
  2883. else {
  2884. if (holder.animations.length === 2) { // Slerp as soon as we can
  2885. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2886. return refQuaternion;
  2887. }
  2888. quaternions = [];
  2889. weights = [];
  2890. normalizer = holder.totalWeight;
  2891. }
  2892. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2893. var runtimeAnimation = holder.animations[animIndex];
  2894. quaternions.push(runtimeAnimation.currentValue);
  2895. weights.push(runtimeAnimation.weight / normalizer);
  2896. }
  2897. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2898. var cumulativeAmount = 0;
  2899. var cumulativeQuaternion = null;
  2900. for (var index = 0; index < quaternions.length;) {
  2901. if (!cumulativeQuaternion) {
  2902. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2903. cumulativeQuaternion = refQuaternion;
  2904. cumulativeAmount = weights[index] + weights[index + 1];
  2905. index += 2;
  2906. continue;
  2907. }
  2908. cumulativeAmount += weights[index];
  2909. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2910. index++;
  2911. }
  2912. return cumulativeQuaternion;
  2913. };
  2914. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2915. if (!this._registeredForLateAnimationBindings.length) {
  2916. return;
  2917. }
  2918. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2919. var target = this._registeredForLateAnimationBindings.data[index];
  2920. for (var path in target._lateAnimationHolders) {
  2921. var holder = target._lateAnimationHolders[path];
  2922. var originalAnimation = holder.animations[0];
  2923. var originalValue = holder.originalValue;
  2924. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2925. var finalValue = target[path];
  2926. if (matrixDecomposeMode) {
  2927. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2928. }
  2929. else {
  2930. var quaternionMode = originalValue.w !== undefined;
  2931. if (quaternionMode) {
  2932. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2933. }
  2934. else {
  2935. var startIndex = 0;
  2936. var normalizer = 1.0;
  2937. if (holder.totalWeight < 1.0) {
  2938. // We need to mix the original value in
  2939. if (originalValue.scale) {
  2940. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2941. }
  2942. else {
  2943. finalValue = originalValue * (1.0 - holder.totalWeight);
  2944. }
  2945. }
  2946. else {
  2947. // We need to normalize the weights
  2948. normalizer = holder.totalWeight;
  2949. var scale_1 = originalAnimation.weight / normalizer;
  2950. if (scale_1 !== 1) {
  2951. if (originalAnimation.currentValue.scale) {
  2952. finalValue = originalAnimation.currentValue.scale(scale_1);
  2953. }
  2954. else {
  2955. finalValue = originalAnimation.currentValue * scale_1;
  2956. }
  2957. }
  2958. else {
  2959. finalValue = originalAnimation.currentValue;
  2960. }
  2961. startIndex = 1;
  2962. }
  2963. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2964. var runtimeAnimation = holder.animations[animIndex];
  2965. var scale = runtimeAnimation.weight / normalizer;
  2966. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2967. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2968. }
  2969. else {
  2970. finalValue += runtimeAnimation.currentValue * scale;
  2971. }
  2972. }
  2973. }
  2974. }
  2975. target[path] = finalValue;
  2976. }
  2977. target._lateAnimationHolders = {};
  2978. }
  2979. this._registeredForLateAnimationBindings.reset();
  2980. };
  2981. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2982. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2983. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2984. // all animation may be coming from a library skeleton, so may need to create animation
  2985. if (this.animations.length === 0) {
  2986. this.animations.push(new _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  2987. this.animations[0].setKeys([]);
  2988. }
  2989. // get animation info / verify there is such a range from the source bone
  2990. var sourceRange = source.animations[0].getRange(rangeName);
  2991. if (!sourceRange) {
  2992. return false;
  2993. }
  2994. var from = sourceRange.from;
  2995. var to = sourceRange.to;
  2996. var sourceKeys = source.animations[0].getKeys();
  2997. // rescaling prep
  2998. var sourceBoneLength = source.length;
  2999. var sourceParent = source.getParent();
  3000. var parent = this.getParent();
  3001. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3002. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3003. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3004. var destKeys = this.animations[0].getKeys();
  3005. // loop vars declaration
  3006. var orig;
  3007. var origTranslation;
  3008. var mat;
  3009. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3010. orig = sourceKeys[key];
  3011. if (orig.frame >= from && orig.frame <= to) {
  3012. if (rescaleAsRequired) {
  3013. mat = orig.value.clone();
  3014. // scale based on parent ratio, when bone has parent
  3015. if (parentScalingReqd) {
  3016. origTranslation = mat.getTranslation();
  3017. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3018. // scale based on skeleton dimension ratio when root bone, and value is passed
  3019. }
  3020. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3021. origTranslation = mat.getTranslation();
  3022. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3023. // use original when root bone, and no data for skelDimensionsRatio
  3024. }
  3025. else {
  3026. mat = orig.value;
  3027. }
  3028. }
  3029. else {
  3030. mat = orig.value;
  3031. }
  3032. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3033. }
  3034. }
  3035. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3036. return true;
  3037. };
  3038. /***/ }),
  3039. /***/ "./Animations/animation.ts":
  3040. /*!*********************************!*\
  3041. !*** ./Animations/animation.ts ***!
  3042. \*********************************/
  3043. /*! exports provided: Animation */
  3044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3045. "use strict";
  3046. __webpack_require__.r(__webpack_exports__);
  3047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3049. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3050. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3051. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3052. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3053. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3054. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3055. /**
  3056. * Class used to store any kind of animation
  3057. */
  3058. var Animation = /** @class */ (function () {
  3059. /**
  3060. * Initializes the animation
  3061. * @param name Name of the animation
  3062. * @param targetProperty Property to animate
  3063. * @param framePerSecond The frames per second of the animation
  3064. * @param dataType The data type of the animation
  3065. * @param loopMode The loop mode of the animation
  3066. * @param enableBlending Specifies if blending should be enabled
  3067. */
  3068. function Animation(
  3069. /**Name of the animation */
  3070. name,
  3071. /**Property to animate */
  3072. targetProperty,
  3073. /**The frames per second of the animation */
  3074. framePerSecond,
  3075. /**The data type of the animation */
  3076. dataType,
  3077. /**The loop mode of the animation */
  3078. loopMode,
  3079. /**Specifies if blending should be enabled */
  3080. enableBlending) {
  3081. this.name = name;
  3082. this.targetProperty = targetProperty;
  3083. this.framePerSecond = framePerSecond;
  3084. this.dataType = dataType;
  3085. this.loopMode = loopMode;
  3086. this.enableBlending = enableBlending;
  3087. /**
  3088. * @hidden Internal use only
  3089. */
  3090. this._runtimeAnimations = new Array();
  3091. /**
  3092. * The set of event that will be linked to this animation
  3093. */
  3094. this._events = new Array();
  3095. /**
  3096. * Stores the blending speed of the animation
  3097. */
  3098. this.blendingSpeed = 0.01;
  3099. /**
  3100. * Stores the animation ranges for the animation
  3101. */
  3102. this._ranges = {};
  3103. this.targetPropertyPath = targetProperty.split(".");
  3104. this.dataType = dataType;
  3105. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3106. }
  3107. /**
  3108. * @hidden Internal use
  3109. */
  3110. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3111. var dataType = undefined;
  3112. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3113. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3114. }
  3115. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3116. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3117. }
  3118. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3119. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3120. }
  3121. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3122. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3123. }
  3124. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3125. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3126. }
  3127. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3128. dataType = Animation.ANIMATIONTYPE_SIZE;
  3129. }
  3130. if (dataType == undefined) {
  3131. return null;
  3132. }
  3133. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3134. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3135. animation.setKeys(keys);
  3136. if (easingFunction !== undefined) {
  3137. animation.setEasingFunction(easingFunction);
  3138. }
  3139. return animation;
  3140. };
  3141. /**
  3142. * Sets up an animation
  3143. * @param property The property to animate
  3144. * @param animationType The animation type to apply
  3145. * @param framePerSecond The frames per second of the animation
  3146. * @param easingFunction The easing function used in the animation
  3147. * @returns The created animation
  3148. */
  3149. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3150. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3151. animation.setEasingFunction(easingFunction);
  3152. return animation;
  3153. };
  3154. /**
  3155. * Create and start an animation on a node
  3156. * @param name defines the name of the global animation that will be run on all nodes
  3157. * @param node defines the root node where the animation will take place
  3158. * @param targetProperty defines property to animate
  3159. * @param framePerSecond defines the number of frame per second yo use
  3160. * @param totalFrame defines the number of frames in total
  3161. * @param from defines the initial value
  3162. * @param to defines the final value
  3163. * @param loopMode defines which loop mode you want to use (off by default)
  3164. * @param easingFunction defines the easing function to use (linear by default)
  3165. * @param onAnimationEnd defines the callback to call when animation end
  3166. * @returns the animatable created for this animation
  3167. */
  3168. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3169. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3170. if (!animation) {
  3171. return null;
  3172. }
  3173. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3174. };
  3175. /**
  3176. * Create and start an animation on a node and its descendants
  3177. * @param name defines the name of the global animation that will be run on all nodes
  3178. * @param node defines the root node where the animation will take place
  3179. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  3180. * @param targetProperty defines property to animate
  3181. * @param framePerSecond defines the number of frame per second to use
  3182. * @param totalFrame defines the number of frames in total
  3183. * @param from defines the initial value
  3184. * @param to defines the final value
  3185. * @param loopMode defines which loop mode you want to use (off by default)
  3186. * @param easingFunction defines the easing function to use (linear by default)
  3187. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3188. * @returns the list of animatables created for all nodes
  3189. * @example https://www.babylonjs-playground.com/#MH0VLI
  3190. */
  3191. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3192. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3193. if (!animation) {
  3194. return null;
  3195. }
  3196. var scene = node.getScene();
  3197. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3198. };
  3199. /**
  3200. * Creates a new animation, merges it with the existing animations and starts it
  3201. * @param name Name of the animation
  3202. * @param node Node which contains the scene that begins the animations
  3203. * @param targetProperty Specifies which property to animate
  3204. * @param framePerSecond The frames per second of the animation
  3205. * @param totalFrame The total number of frames
  3206. * @param from The frame at the beginning of the animation
  3207. * @param to The frame at the end of the animation
  3208. * @param loopMode Specifies the loop mode of the animation
  3209. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3210. * @param onAnimationEnd Callback to run once the animation is complete
  3211. * @returns Nullable animation
  3212. */
  3213. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3214. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3215. if (!animation) {
  3216. return null;
  3217. }
  3218. node.animations.push(animation);
  3219. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3220. };
  3221. /**
  3222. * Transition property of an host to the target Value
  3223. * @param property The property to transition
  3224. * @param targetValue The target Value of the property
  3225. * @param host The object where the property to animate belongs
  3226. * @param scene Scene used to run the animation
  3227. * @param frameRate Framerate (in frame/s) to use
  3228. * @param transition The transition type we want to use
  3229. * @param duration The duration of the animation, in milliseconds
  3230. * @param onAnimationEnd Callback trigger at the end of the animation
  3231. * @returns Nullable animation
  3232. */
  3233. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3234. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3235. if (duration <= 0) {
  3236. host[property] = targetValue;
  3237. if (onAnimationEnd) {
  3238. onAnimationEnd();
  3239. }
  3240. return null;
  3241. }
  3242. var endFrame = frameRate * (duration / 1000);
  3243. transition.setKeys([{
  3244. frame: 0,
  3245. value: host[property].clone ? host[property].clone() : host[property]
  3246. },
  3247. {
  3248. frame: endFrame,
  3249. value: targetValue
  3250. }]);
  3251. if (!host.animations) {
  3252. host.animations = [];
  3253. }
  3254. host.animations.push(transition);
  3255. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3256. animation.onAnimationEnd = onAnimationEnd;
  3257. return animation;
  3258. };
  3259. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3260. /**
  3261. * Return the array of runtime animations currently using this animation
  3262. */
  3263. get: function () {
  3264. return this._runtimeAnimations;
  3265. },
  3266. enumerable: true,
  3267. configurable: true
  3268. });
  3269. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3270. /**
  3271. * Specifies if any of the runtime animations are currently running
  3272. */
  3273. get: function () {
  3274. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3275. var runtimeAnimation = _a[_i];
  3276. if (!runtimeAnimation.isStopped) {
  3277. return true;
  3278. }
  3279. }
  3280. return false;
  3281. },
  3282. enumerable: true,
  3283. configurable: true
  3284. });
  3285. // Methods
  3286. /**
  3287. * Converts the animation to a string
  3288. * @param fullDetails support for multiple levels of logging within scene loading
  3289. * @returns String form of the animation
  3290. */
  3291. Animation.prototype.toString = function (fullDetails) {
  3292. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3293. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3294. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3295. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3296. if (fullDetails) {
  3297. ret += ", Ranges: {";
  3298. var first = true;
  3299. for (var name in this._ranges) {
  3300. if (first) {
  3301. ret += ", ";
  3302. first = false;
  3303. }
  3304. ret += name;
  3305. }
  3306. ret += "}";
  3307. }
  3308. return ret;
  3309. };
  3310. /**
  3311. * Add an event to this animation
  3312. * @param event Event to add
  3313. */
  3314. Animation.prototype.addEvent = function (event) {
  3315. this._events.push(event);
  3316. };
  3317. /**
  3318. * Remove all events found at the given frame
  3319. * @param frame The frame to remove events from
  3320. */
  3321. Animation.prototype.removeEvents = function (frame) {
  3322. for (var index = 0; index < this._events.length; index++) {
  3323. if (this._events[index].frame === frame) {
  3324. this._events.splice(index, 1);
  3325. index--;
  3326. }
  3327. }
  3328. };
  3329. /**
  3330. * Retrieves all the events from the animation
  3331. * @returns Events from the animation
  3332. */
  3333. Animation.prototype.getEvents = function () {
  3334. return this._events;
  3335. };
  3336. /**
  3337. * Creates an animation range
  3338. * @param name Name of the animation range
  3339. * @param from Starting frame of the animation range
  3340. * @param to Ending frame of the animation
  3341. */
  3342. Animation.prototype.createRange = function (name, from, to) {
  3343. // check name not already in use; could happen for bones after serialized
  3344. if (!this._ranges[name]) {
  3345. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3346. }
  3347. };
  3348. /**
  3349. * Deletes an animation range by name
  3350. * @param name Name of the animation range to delete
  3351. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3352. */
  3353. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3354. if (deleteFrames === void 0) { deleteFrames = true; }
  3355. var range = this._ranges[name];
  3356. if (!range) {
  3357. return;
  3358. }
  3359. if (deleteFrames) {
  3360. var from = range.from;
  3361. var to = range.to;
  3362. // this loop MUST go high to low for multiple splices to work
  3363. for (var key = this._keys.length - 1; key >= 0; key--) {
  3364. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3365. this._keys.splice(key, 1);
  3366. }
  3367. }
  3368. }
  3369. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3370. };
  3371. /**
  3372. * Gets the animation range by name, or null if not defined
  3373. * @param name Name of the animation range
  3374. * @returns Nullable animation range
  3375. */
  3376. Animation.prototype.getRange = function (name) {
  3377. return this._ranges[name];
  3378. };
  3379. /**
  3380. * Gets the key frames from the animation
  3381. * @returns The key frames of the animation
  3382. */
  3383. Animation.prototype.getKeys = function () {
  3384. return this._keys;
  3385. };
  3386. /**
  3387. * Gets the highest frame rate of the animation
  3388. * @returns Highest frame rate of the animation
  3389. */
  3390. Animation.prototype.getHighestFrame = function () {
  3391. var ret = 0;
  3392. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3393. if (ret < this._keys[key].frame) {
  3394. ret = this._keys[key].frame;
  3395. }
  3396. }
  3397. return ret;
  3398. };
  3399. /**
  3400. * Gets the easing function of the animation
  3401. * @returns Easing function of the animation
  3402. */
  3403. Animation.prototype.getEasingFunction = function () {
  3404. return this._easingFunction;
  3405. };
  3406. /**
  3407. * Sets the easing function of the animation
  3408. * @param easingFunction A custom mathematical formula for animation
  3409. */
  3410. Animation.prototype.setEasingFunction = function (easingFunction) {
  3411. this._easingFunction = easingFunction;
  3412. };
  3413. /**
  3414. * Interpolates a scalar linearly
  3415. * @param startValue Start value of the animation curve
  3416. * @param endValue End value of the animation curve
  3417. * @param gradient Scalar amount to interpolate
  3418. * @returns Interpolated scalar value
  3419. */
  3420. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3421. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3422. };
  3423. /**
  3424. * Interpolates a scalar cubically
  3425. * @param startValue Start value of the animation curve
  3426. * @param outTangent End tangent of the animation
  3427. * @param endValue End value of the animation curve
  3428. * @param inTangent Start tangent of the animation curve
  3429. * @param gradient Scalar amount to interpolate
  3430. * @returns Interpolated scalar value
  3431. */
  3432. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3433. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3434. };
  3435. /**
  3436. * Interpolates a quaternion using a spherical linear interpolation
  3437. * @param startValue Start value of the animation curve
  3438. * @param endValue End value of the animation curve
  3439. * @param gradient Scalar amount to interpolate
  3440. * @returns Interpolated quaternion value
  3441. */
  3442. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3443. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3444. };
  3445. /**
  3446. * Interpolates a quaternion cubically
  3447. * @param startValue Start value of the animation curve
  3448. * @param outTangent End tangent of the animation curve
  3449. * @param endValue End value of the animation curve
  3450. * @param inTangent Start tangent of the animation curve
  3451. * @param gradient Scalar amount to interpolate
  3452. * @returns Interpolated quaternion value
  3453. */
  3454. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3455. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3456. };
  3457. /**
  3458. * Interpolates a Vector3 linearl
  3459. * @param startValue Start value of the animation curve
  3460. * @param endValue End value of the animation curve
  3461. * @param gradient Scalar amount to interpolate
  3462. * @returns Interpolated scalar value
  3463. */
  3464. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3465. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3466. };
  3467. /**
  3468. * Interpolates a Vector3 cubically
  3469. * @param startValue Start value of the animation curve
  3470. * @param outTangent End tangent of the animation
  3471. * @param endValue End value of the animation curve
  3472. * @param inTangent Start tangent of the animation curve
  3473. * @param gradient Scalar amount to interpolate
  3474. * @returns InterpolatedVector3 value
  3475. */
  3476. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3477. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3478. };
  3479. /**
  3480. * Interpolates a Vector2 linearly
  3481. * @param startValue Start value of the animation curve
  3482. * @param endValue End value of the animation curve
  3483. * @param gradient Scalar amount to interpolate
  3484. * @returns Interpolated Vector2 value
  3485. */
  3486. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3487. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3488. };
  3489. /**
  3490. * Interpolates a Vector2 cubically
  3491. * @param startValue Start value of the animation curve
  3492. * @param outTangent End tangent of the animation
  3493. * @param endValue End value of the animation curve
  3494. * @param inTangent Start tangent of the animation curve
  3495. * @param gradient Scalar amount to interpolate
  3496. * @returns Interpolated Vector2 value
  3497. */
  3498. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3499. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3500. };
  3501. /**
  3502. * Interpolates a size linearly
  3503. * @param startValue Start value of the animation curve
  3504. * @param endValue End value of the animation curve
  3505. * @param gradient Scalar amount to interpolate
  3506. * @returns Interpolated Size value
  3507. */
  3508. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3509. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3510. };
  3511. /**
  3512. * Interpolates a Color3 linearly
  3513. * @param startValue Start value of the animation curve
  3514. * @param endValue End value of the animation curve
  3515. * @param gradient Scalar amount to interpolate
  3516. * @returns Interpolated Color3 value
  3517. */
  3518. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3519. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3520. };
  3521. /**
  3522. * @hidden Internal use only
  3523. */
  3524. Animation.prototype._getKeyValue = function (value) {
  3525. if (typeof value === "function") {
  3526. return value();
  3527. }
  3528. return value;
  3529. };
  3530. /**
  3531. * @hidden Internal use only
  3532. */
  3533. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3534. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3535. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3536. }
  3537. var keys = this.getKeys();
  3538. if (keys.length === 1) {
  3539. return this._getKeyValue(keys[0].value);
  3540. }
  3541. // Try to get a hash to find the right key
  3542. var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
  3543. if (keys[startKeyIndex].frame >= currentFrame) {
  3544. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3545. startKeyIndex--;
  3546. }
  3547. }
  3548. for (var key = startKeyIndex; key < keys.length; key++) {
  3549. var endKey = keys[key + 1];
  3550. if (endKey.frame >= currentFrame) {
  3551. var startKey = keys[key];
  3552. var startValue = this._getKeyValue(startKey.value);
  3553. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3554. return startValue;
  3555. }
  3556. var endValue = this._getKeyValue(endKey.value);
  3557. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3558. var frameDelta = endKey.frame - startKey.frame;
  3559. // gradient : percent of currentFrame between the frame inf and the frame sup
  3560. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3561. // check for easingFunction and correction of gradient
  3562. var easingFunction = this.getEasingFunction();
  3563. if (easingFunction != null) {
  3564. gradient = easingFunction.ease(gradient);
  3565. }
  3566. switch (this.dataType) {
  3567. // Float
  3568. case Animation.ANIMATIONTYPE_FLOAT:
  3569. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3570. switch (loopMode) {
  3571. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3572. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3573. return floatValue;
  3574. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3575. return offsetValue * repeatCount + floatValue;
  3576. }
  3577. break;
  3578. // Quaternion
  3579. case Animation.ANIMATIONTYPE_QUATERNION:
  3580. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3581. switch (loopMode) {
  3582. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3583. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3584. return quatValue;
  3585. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3586. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3587. }
  3588. return quatValue;
  3589. // Vector3
  3590. case Animation.ANIMATIONTYPE_VECTOR3:
  3591. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3592. switch (loopMode) {
  3593. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3594. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3595. return vec3Value;
  3596. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3597. return vec3Value.add(offsetValue.scale(repeatCount));
  3598. }
  3599. // Vector2
  3600. case Animation.ANIMATIONTYPE_VECTOR2:
  3601. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3602. switch (loopMode) {
  3603. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3604. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3605. return vec2Value;
  3606. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3607. return vec2Value.add(offsetValue.scale(repeatCount));
  3608. }
  3609. // Size
  3610. case Animation.ANIMATIONTYPE_SIZE:
  3611. switch (loopMode) {
  3612. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3613. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3614. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3615. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3616. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3617. }
  3618. // Color3
  3619. case Animation.ANIMATIONTYPE_COLOR3:
  3620. switch (loopMode) {
  3621. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3622. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3623. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3624. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3625. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3626. }
  3627. // Matrix
  3628. case Animation.ANIMATIONTYPE_MATRIX:
  3629. switch (loopMode) {
  3630. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3631. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3632. if (Animation.AllowMatricesInterpolation) {
  3633. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3634. }
  3635. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3636. return startValue;
  3637. }
  3638. default:
  3639. break;
  3640. }
  3641. break;
  3642. }
  3643. }
  3644. return this._getKeyValue(keys[keys.length - 1].value);
  3645. };
  3646. /**
  3647. * Defines the function to use to interpolate matrices
  3648. * @param startValue defines the start matrix
  3649. * @param endValue defines the end matrix
  3650. * @param gradient defines the gradient between both matrices
  3651. * @param result defines an optional target matrix where to store the interpolation
  3652. * @returns the interpolated matrix
  3653. */
  3654. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3655. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3656. if (result) {
  3657. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3658. return result;
  3659. }
  3660. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3661. }
  3662. if (result) {
  3663. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3664. return result;
  3665. }
  3666. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3667. };
  3668. /**
  3669. * Makes a copy of the animation
  3670. * @returns Cloned animation
  3671. */
  3672. Animation.prototype.clone = function () {
  3673. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3674. clone.enableBlending = this.enableBlending;
  3675. clone.blendingSpeed = this.blendingSpeed;
  3676. if (this._keys) {
  3677. clone.setKeys(this._keys);
  3678. }
  3679. if (this._ranges) {
  3680. clone._ranges = {};
  3681. for (var name in this._ranges) {
  3682. var range = this._ranges[name];
  3683. if (!range) {
  3684. continue;
  3685. }
  3686. clone._ranges[name] = range.clone();
  3687. }
  3688. }
  3689. return clone;
  3690. };
  3691. /**
  3692. * Sets the key frames of the animation
  3693. * @param values The animation key frames to set
  3694. */
  3695. Animation.prototype.setKeys = function (values) {
  3696. this._keys = values.slice(0);
  3697. };
  3698. /**
  3699. * Serializes the animation to an object
  3700. * @returns Serialized object
  3701. */
  3702. Animation.prototype.serialize = function () {
  3703. var serializationObject = {};
  3704. serializationObject.name = this.name;
  3705. serializationObject.property = this.targetProperty;
  3706. serializationObject.framePerSecond = this.framePerSecond;
  3707. serializationObject.dataType = this.dataType;
  3708. serializationObject.loopBehavior = this.loopMode;
  3709. serializationObject.enableBlending = this.enableBlending;
  3710. serializationObject.blendingSpeed = this.blendingSpeed;
  3711. var dataType = this.dataType;
  3712. serializationObject.keys = [];
  3713. var keys = this.getKeys();
  3714. for (var index = 0; index < keys.length; index++) {
  3715. var animationKey = keys[index];
  3716. var key = {};
  3717. key.frame = animationKey.frame;
  3718. switch (dataType) {
  3719. case Animation.ANIMATIONTYPE_FLOAT:
  3720. key.values = [animationKey.value];
  3721. break;
  3722. case Animation.ANIMATIONTYPE_QUATERNION:
  3723. case Animation.ANIMATIONTYPE_MATRIX:
  3724. case Animation.ANIMATIONTYPE_VECTOR3:
  3725. case Animation.ANIMATIONTYPE_COLOR3:
  3726. key.values = animationKey.value.asArray();
  3727. break;
  3728. }
  3729. serializationObject.keys.push(key);
  3730. }
  3731. serializationObject.ranges = [];
  3732. for (var name in this._ranges) {
  3733. var source = this._ranges[name];
  3734. if (!source) {
  3735. continue;
  3736. }
  3737. var range = {};
  3738. range.name = name;
  3739. range.from = source.from;
  3740. range.to = source.to;
  3741. serializationObject.ranges.push(range);
  3742. }
  3743. return serializationObject;
  3744. };
  3745. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3746. /**
  3747. * Get the float animation type
  3748. */
  3749. get: function () {
  3750. return Animation._ANIMATIONTYPE_FLOAT;
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3756. /**
  3757. * Get the Vector3 animation type
  3758. */
  3759. get: function () {
  3760. return Animation._ANIMATIONTYPE_VECTOR3;
  3761. },
  3762. enumerable: true,
  3763. configurable: true
  3764. });
  3765. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3766. /**
  3767. * Get the Vector2 animation type
  3768. */
  3769. get: function () {
  3770. return Animation._ANIMATIONTYPE_VECTOR2;
  3771. },
  3772. enumerable: true,
  3773. configurable: true
  3774. });
  3775. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3776. /**
  3777. * Get the Size animation type
  3778. */
  3779. get: function () {
  3780. return Animation._ANIMATIONTYPE_SIZE;
  3781. },
  3782. enumerable: true,
  3783. configurable: true
  3784. });
  3785. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3786. /**
  3787. * Get the Quaternion animation type
  3788. */
  3789. get: function () {
  3790. return Animation._ANIMATIONTYPE_QUATERNION;
  3791. },
  3792. enumerable: true,
  3793. configurable: true
  3794. });
  3795. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3796. /**
  3797. * Get the Matrix animation type
  3798. */
  3799. get: function () {
  3800. return Animation._ANIMATIONTYPE_MATRIX;
  3801. },
  3802. enumerable: true,
  3803. configurable: true
  3804. });
  3805. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3806. /**
  3807. * Get the Color3 animation type
  3808. */
  3809. get: function () {
  3810. return Animation._ANIMATIONTYPE_COLOR3;
  3811. },
  3812. enumerable: true,
  3813. configurable: true
  3814. });
  3815. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3816. /**
  3817. * Get the Relative Loop Mode
  3818. */
  3819. get: function () {
  3820. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3826. /**
  3827. * Get the Cycle Loop Mode
  3828. */
  3829. get: function () {
  3830. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3831. },
  3832. enumerable: true,
  3833. configurable: true
  3834. });
  3835. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3836. /**
  3837. * Get the Constant Loop Mode
  3838. */
  3839. get: function () {
  3840. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3841. },
  3842. enumerable: true,
  3843. configurable: true
  3844. });
  3845. /** @hidden */
  3846. Animation._UniversalLerp = function (left, right, amount) {
  3847. var constructor = left.constructor;
  3848. if (constructor.Lerp) { // Lerp supported
  3849. return constructor.Lerp(left, right, amount);
  3850. }
  3851. else if (constructor.Slerp) { // Slerp supported
  3852. return constructor.Slerp(left, right, amount);
  3853. }
  3854. else if (left.toFixed) { // Number
  3855. return left * (1.0 - amount) + amount * right;
  3856. }
  3857. else { // Blending not supported
  3858. return right;
  3859. }
  3860. };
  3861. /**
  3862. * Parses an animation object and creates an animation
  3863. * @param parsedAnimation Parsed animation object
  3864. * @returns Animation object
  3865. */
  3866. Animation.Parse = function (parsedAnimation) {
  3867. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3868. var dataType = parsedAnimation.dataType;
  3869. var keys = [];
  3870. var data;
  3871. var index;
  3872. if (parsedAnimation.enableBlending) {
  3873. animation.enableBlending = parsedAnimation.enableBlending;
  3874. }
  3875. if (parsedAnimation.blendingSpeed) {
  3876. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3877. }
  3878. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3879. var key = parsedAnimation.keys[index];
  3880. var inTangent;
  3881. var outTangent;
  3882. switch (dataType) {
  3883. case Animation.ANIMATIONTYPE_FLOAT:
  3884. data = key.values[0];
  3885. if (key.values.length >= 1) {
  3886. inTangent = key.values[1];
  3887. }
  3888. if (key.values.length >= 2) {
  3889. outTangent = key.values[2];
  3890. }
  3891. break;
  3892. case Animation.ANIMATIONTYPE_QUATERNION:
  3893. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3894. if (key.values.length >= 8) {
  3895. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3896. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3897. inTangent = _inTangent;
  3898. }
  3899. }
  3900. if (key.values.length >= 12) {
  3901. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3902. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3903. outTangent = _outTangent;
  3904. }
  3905. }
  3906. break;
  3907. case Animation.ANIMATIONTYPE_MATRIX:
  3908. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3909. break;
  3910. case Animation.ANIMATIONTYPE_COLOR3:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3912. break;
  3913. case Animation.ANIMATIONTYPE_VECTOR3:
  3914. default:
  3915. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3916. break;
  3917. }
  3918. var keyData = {};
  3919. keyData.frame = key.frame;
  3920. keyData.value = data;
  3921. if (inTangent != undefined) {
  3922. keyData.inTangent = inTangent;
  3923. }
  3924. if (outTangent != undefined) {
  3925. keyData.outTangent = outTangent;
  3926. }
  3927. keys.push(keyData);
  3928. }
  3929. animation.setKeys(keys);
  3930. if (parsedAnimation.ranges) {
  3931. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3932. data = parsedAnimation.ranges[index];
  3933. animation.createRange(data.name, data.from, data.to);
  3934. }
  3935. }
  3936. return animation;
  3937. };
  3938. /**
  3939. * Appends the serialized animations from the source animations
  3940. * @param source Source containing the animations
  3941. * @param destination Target to store the animations
  3942. */
  3943. Animation.AppendSerializedAnimations = function (source, destination) {
  3944. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3945. };
  3946. /**
  3947. * Use matrix interpolation instead of using direct key value when animating matrices
  3948. */
  3949. Animation.AllowMatricesInterpolation = false;
  3950. /**
  3951. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3952. */
  3953. Animation.AllowMatrixDecomposeForInterpolation = true;
  3954. // Statics
  3955. /**
  3956. * Float animation type
  3957. */
  3958. Animation._ANIMATIONTYPE_FLOAT = 0;
  3959. /**
  3960. * Vector3 animation type
  3961. */
  3962. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3963. /**
  3964. * Quaternion animation type
  3965. */
  3966. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3967. /**
  3968. * Matrix animation type
  3969. */
  3970. Animation._ANIMATIONTYPE_MATRIX = 3;
  3971. /**
  3972. * Color3 animation type
  3973. */
  3974. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3975. /**
  3976. * Vector2 animation type
  3977. */
  3978. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3979. /**
  3980. * Size animation type
  3981. */
  3982. Animation._ANIMATIONTYPE_SIZE = 6;
  3983. /**
  3984. * Relative Loop Mode
  3985. */
  3986. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3987. /**
  3988. * Cycle Loop Mode
  3989. */
  3990. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3991. /**
  3992. * Constant Loop Mode
  3993. */
  3994. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3995. return Animation;
  3996. }());
  3997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3998. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3999. /***/ }),
  4000. /***/ "./Animations/animationEvent.ts":
  4001. /*!**************************************!*\
  4002. !*** ./Animations/animationEvent.ts ***!
  4003. \**************************************/
  4004. /*! exports provided: AnimationEvent */
  4005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4006. "use strict";
  4007. __webpack_require__.r(__webpack_exports__);
  4008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4009. /**
  4010. * Composed of a frame, and an action function
  4011. */
  4012. var AnimationEvent = /** @class */ (function () {
  4013. /**
  4014. * Initializes the animation event
  4015. * @param frame The frame for which the event is triggered
  4016. * @param action The event to perform when triggered
  4017. * @param onlyOnce Specifies if the event should be triggered only once
  4018. */
  4019. function AnimationEvent(
  4020. /** The frame for which the event is triggered **/
  4021. frame,
  4022. /** The event to perform when triggered **/
  4023. action,
  4024. /** Specifies if the event should be triggered only once**/
  4025. onlyOnce) {
  4026. this.frame = frame;
  4027. this.action = action;
  4028. this.onlyOnce = onlyOnce;
  4029. /**
  4030. * Specifies if the animation event is done
  4031. */
  4032. this.isDone = false;
  4033. }
  4034. /** @hidden */
  4035. AnimationEvent.prototype._clone = function () {
  4036. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4037. };
  4038. return AnimationEvent;
  4039. }());
  4040. /***/ }),
  4041. /***/ "./Animations/animationGroup.ts":
  4042. /*!**************************************!*\
  4043. !*** ./Animations/animationGroup.ts ***!
  4044. \**************************************/
  4045. /*! exports provided: TargetedAnimation, AnimationGroup */
  4046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4047. "use strict";
  4048. __webpack_require__.r(__webpack_exports__);
  4049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4051. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4053. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4054. /**
  4055. * This class defines the direct association between an animation and a target
  4056. */
  4057. var TargetedAnimation = /** @class */ (function () {
  4058. function TargetedAnimation() {
  4059. }
  4060. return TargetedAnimation;
  4061. }());
  4062. /**
  4063. * Use this class to create coordinated animations on multiple targets
  4064. */
  4065. var AnimationGroup = /** @class */ (function () {
  4066. /**
  4067. * Instantiates a new Animation Group.
  4068. * This helps managing several animations at once.
  4069. * @see http://doc.babylonjs.com/how_to/group
  4070. * @param name Defines the name of the group
  4071. * @param scene Defines the scene the group belongs to
  4072. */
  4073. function AnimationGroup(
  4074. /** The name of the animation group */
  4075. name, scene) {
  4076. if (scene === void 0) { scene = null; }
  4077. this.name = name;
  4078. this._targetedAnimations = new Array();
  4079. this._animatables = new Array();
  4080. this._from = Number.MAX_VALUE;
  4081. this._to = -Number.MAX_VALUE;
  4082. this._speedRatio = 1;
  4083. /**
  4084. * This observable will notify when one animation have ended
  4085. */
  4086. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4087. /**
  4088. * Observer raised when one animation loops
  4089. */
  4090. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4091. /**
  4092. * This observable will notify when all animations have ended.
  4093. */
  4094. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4095. /**
  4096. * This observable will notify when all animations have paused.
  4097. */
  4098. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4099. /**
  4100. * This observable will notify when all animations are playing.
  4101. */
  4102. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4103. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4104. this.uniqueId = this._scene.getUniqueId();
  4105. this._scene.animationGroups.push(this);
  4106. }
  4107. Object.defineProperty(AnimationGroup.prototype, "from", {
  4108. /**
  4109. * Gets the first frame
  4110. */
  4111. get: function () {
  4112. return this._from;
  4113. },
  4114. enumerable: true,
  4115. configurable: true
  4116. });
  4117. Object.defineProperty(AnimationGroup.prototype, "to", {
  4118. /**
  4119. * Gets the last frame
  4120. */
  4121. get: function () {
  4122. return this._to;
  4123. },
  4124. enumerable: true,
  4125. configurable: true
  4126. });
  4127. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4128. /**
  4129. * Define if the animations are started
  4130. */
  4131. get: function () {
  4132. return this._isStarted;
  4133. },
  4134. enumerable: true,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4138. /**
  4139. * Gets a value indicating that the current group is playing
  4140. */
  4141. get: function () {
  4142. return this._isStarted && !this._isPaused;
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4148. /**
  4149. * Gets or sets the speed ratio to use for all animations
  4150. */
  4151. get: function () {
  4152. return this._speedRatio;
  4153. },
  4154. /**
  4155. * Gets or sets the speed ratio to use for all animations
  4156. */
  4157. set: function (value) {
  4158. if (this._speedRatio === value) {
  4159. return;
  4160. }
  4161. this._speedRatio = value;
  4162. for (var index = 0; index < this._animatables.length; index++) {
  4163. var animatable = this._animatables[index];
  4164. animatable.speedRatio = this._speedRatio;
  4165. }
  4166. },
  4167. enumerable: true,
  4168. configurable: true
  4169. });
  4170. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4171. /**
  4172. * Gets the targeted animations for this animation group
  4173. */
  4174. get: function () {
  4175. return this._targetedAnimations;
  4176. },
  4177. enumerable: true,
  4178. configurable: true
  4179. });
  4180. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4181. /**
  4182. * returning the list of animatables controlled by this animation group.
  4183. */
  4184. get: function () {
  4185. return this._animatables;
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. /**
  4191. * Add an animation (with its target) in the group
  4192. * @param animation defines the animation we want to add
  4193. * @param target defines the target of the animation
  4194. * @returns the TargetedAnimation object
  4195. */
  4196. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4197. var targetedAnimation = {
  4198. animation: animation,
  4199. target: target
  4200. };
  4201. var keys = animation.getKeys();
  4202. if (this._from > keys[0].frame) {
  4203. this._from = keys[0].frame;
  4204. }
  4205. if (this._to < keys[keys.length - 1].frame) {
  4206. this._to = keys[keys.length - 1].frame;
  4207. }
  4208. this._targetedAnimations.push(targetedAnimation);
  4209. return targetedAnimation;
  4210. };
  4211. /**
  4212. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4213. * It can add constant keys at begin or end
  4214. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4215. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4216. * @returns the animation group
  4217. */
  4218. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4219. if (beginFrame === void 0) { beginFrame = null; }
  4220. if (endFrame === void 0) { endFrame = null; }
  4221. if (beginFrame == null) {
  4222. beginFrame = this._from;
  4223. }
  4224. if (endFrame == null) {
  4225. endFrame = this._to;
  4226. }
  4227. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4228. var targetedAnimation = this._targetedAnimations[index];
  4229. var keys = targetedAnimation.animation.getKeys();
  4230. var startKey = keys[0];
  4231. var endKey = keys[keys.length - 1];
  4232. if (startKey.frame > beginFrame) {
  4233. var newKey = {
  4234. frame: beginFrame,
  4235. value: startKey.value,
  4236. inTangent: startKey.inTangent,
  4237. outTangent: startKey.outTangent,
  4238. interpolation: startKey.interpolation
  4239. };
  4240. keys.splice(0, 0, newKey);
  4241. }
  4242. if (endKey.frame < endFrame) {
  4243. var newKey = {
  4244. frame: endFrame,
  4245. value: endKey.value,
  4246. inTangent: endKey.outTangent,
  4247. outTangent: endKey.outTangent,
  4248. interpolation: endKey.interpolation
  4249. };
  4250. keys.push(newKey);
  4251. }
  4252. }
  4253. this._from = beginFrame;
  4254. this._to = endFrame;
  4255. return this;
  4256. };
  4257. /**
  4258. * Start all animations on given targets
  4259. * @param loop defines if animations must loop
  4260. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4261. * @param from defines the from key (optional)
  4262. * @param to defines the to key (optional)
  4263. * @returns the current animation group
  4264. */
  4265. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4266. var _this = this;
  4267. if (loop === void 0) { loop = false; }
  4268. if (speedRatio === void 0) { speedRatio = 1; }
  4269. if (this._isStarted || this._targetedAnimations.length === 0) {
  4270. return this;
  4271. }
  4272. var _loop_1 = function (targetedAnimation) {
  4273. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4274. animatable.onAnimationEnd = function () {
  4275. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4276. _this._checkAnimationGroupEnded(animatable);
  4277. };
  4278. animatable.onAnimationLoop = function () {
  4279. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4280. };
  4281. this_1._animatables.push(animatable);
  4282. };
  4283. var this_1 = this;
  4284. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4285. var targetedAnimation = _a[_i];
  4286. _loop_1(targetedAnimation);
  4287. }
  4288. this._speedRatio = speedRatio;
  4289. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4290. this._speedRatio = -speedRatio;
  4291. }
  4292. this._isStarted = true;
  4293. this._isPaused = false;
  4294. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4295. return this;
  4296. };
  4297. /**
  4298. * Pause all animations
  4299. * @returns the animation group
  4300. */
  4301. AnimationGroup.prototype.pause = function () {
  4302. if (!this._isStarted) {
  4303. return this;
  4304. }
  4305. this._isPaused = true;
  4306. for (var index = 0; index < this._animatables.length; index++) {
  4307. var animatable = this._animatables[index];
  4308. animatable.pause();
  4309. }
  4310. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4311. return this;
  4312. };
  4313. /**
  4314. * Play all animations to initial state
  4315. * This function will start() the animations if they were not started or will restart() them if they were paused
  4316. * @param loop defines if animations must loop
  4317. * @returns the animation group
  4318. */
  4319. AnimationGroup.prototype.play = function (loop) {
  4320. // only if all animatables are ready and exist
  4321. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4322. if (loop !== undefined) {
  4323. for (var index = 0; index < this._animatables.length; index++) {
  4324. var animatable = this._animatables[index];
  4325. animatable.loopAnimation = loop;
  4326. }
  4327. }
  4328. this.restart();
  4329. }
  4330. else {
  4331. this.stop();
  4332. this.start(loop, this._speedRatio);
  4333. }
  4334. this._isPaused = false;
  4335. return this;
  4336. };
  4337. /**
  4338. * Reset all animations to initial state
  4339. * @returns the animation group
  4340. */
  4341. AnimationGroup.prototype.reset = function () {
  4342. if (!this._isStarted) {
  4343. return this;
  4344. }
  4345. for (var index = 0; index < this._animatables.length; index++) {
  4346. var animatable = this._animatables[index];
  4347. animatable.reset();
  4348. }
  4349. return this;
  4350. };
  4351. /**
  4352. * Restart animations from key 0
  4353. * @returns the animation group
  4354. */
  4355. AnimationGroup.prototype.restart = function () {
  4356. if (!this._isStarted) {
  4357. return this;
  4358. }
  4359. for (var index = 0; index < this._animatables.length; index++) {
  4360. var animatable = this._animatables[index];
  4361. animatable.restart();
  4362. }
  4363. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4364. return this;
  4365. };
  4366. /**
  4367. * Stop all animations
  4368. * @returns the animation group
  4369. */
  4370. AnimationGroup.prototype.stop = function () {
  4371. if (!this._isStarted) {
  4372. return this;
  4373. }
  4374. var list = this._animatables.slice();
  4375. for (var index = 0; index < list.length; index++) {
  4376. list[index].stop();
  4377. }
  4378. this._isStarted = false;
  4379. return this;
  4380. };
  4381. /**
  4382. * Set animation weight for all animatables
  4383. * @param weight defines the weight to use
  4384. * @return the animationGroup
  4385. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4386. */
  4387. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4388. for (var index = 0; index < this._animatables.length; index++) {
  4389. var animatable = this._animatables[index];
  4390. animatable.weight = weight;
  4391. }
  4392. return this;
  4393. };
  4394. /**
  4395. * Synchronize and normalize all animatables with a source animatable
  4396. * @param root defines the root animatable to synchronize with
  4397. * @return the animationGroup
  4398. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4399. */
  4400. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4401. for (var index = 0; index < this._animatables.length; index++) {
  4402. var animatable = this._animatables[index];
  4403. animatable.syncWith(root);
  4404. }
  4405. return this;
  4406. };
  4407. /**
  4408. * Goes to a specific frame in this animation group
  4409. * @param frame the frame number to go to
  4410. * @return the animationGroup
  4411. */
  4412. AnimationGroup.prototype.goToFrame = function (frame) {
  4413. if (!this._isStarted) {
  4414. return this;
  4415. }
  4416. for (var index = 0; index < this._animatables.length; index++) {
  4417. var animatable = this._animatables[index];
  4418. animatable.goToFrame(frame);
  4419. }
  4420. return this;
  4421. };
  4422. /**
  4423. * Dispose all associated resources
  4424. */
  4425. AnimationGroup.prototype.dispose = function () {
  4426. this._targetedAnimations = [];
  4427. this._animatables = [];
  4428. var index = this._scene.animationGroups.indexOf(this);
  4429. if (index > -1) {
  4430. this._scene.animationGroups.splice(index, 1);
  4431. }
  4432. this.onAnimationEndObservable.clear();
  4433. this.onAnimationGroupEndObservable.clear();
  4434. this.onAnimationGroupPauseObservable.clear();
  4435. this.onAnimationGroupPlayObservable.clear();
  4436. this.onAnimationLoopObservable.clear();
  4437. };
  4438. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4439. // animatable should be taken out of the array
  4440. var idx = this._animatables.indexOf(animatable);
  4441. if (idx > -1) {
  4442. this._animatables.splice(idx, 1);
  4443. }
  4444. // all animatables were removed? animation group ended!
  4445. if (this._animatables.length === 0) {
  4446. this._isStarted = false;
  4447. this.onAnimationGroupEndObservable.notifyObservers(this);
  4448. }
  4449. };
  4450. /**
  4451. * Clone the current animation group and returns a copy
  4452. * @param newName defines the name of the new group
  4453. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4454. * @returns the new aniamtion group
  4455. */
  4456. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4457. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4458. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4459. var targetAnimation = _a[_i];
  4460. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4461. }
  4462. return newGroup;
  4463. };
  4464. // Statics
  4465. /**
  4466. * Returns a new AnimationGroup object parsed from the source provided.
  4467. * @param parsedAnimationGroup defines the source
  4468. * @param scene defines the scene that will receive the animationGroup
  4469. * @returns a new AnimationGroup
  4470. */
  4471. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4472. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4473. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4474. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4475. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4476. var id = targetedAnimation.targetId;
  4477. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4478. var morphTarget = scene.getMorphTargetById(id);
  4479. if (morphTarget) {
  4480. animationGroup.addTargetedAnimation(animation, morphTarget);
  4481. }
  4482. }
  4483. else {
  4484. var targetNode = scene.getNodeByID(id);
  4485. if (targetNode != null) {
  4486. animationGroup.addTargetedAnimation(animation, targetNode);
  4487. }
  4488. }
  4489. }
  4490. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4491. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4492. }
  4493. return animationGroup;
  4494. };
  4495. /**
  4496. * Returns the string "AnimationGroup"
  4497. * @returns "AnimationGroup"
  4498. */
  4499. AnimationGroup.prototype.getClassName = function () {
  4500. return "AnimationGroup";
  4501. };
  4502. /**
  4503. * Creates a detailled string about the object
  4504. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4505. * @returns a string representing the object
  4506. */
  4507. AnimationGroup.prototype.toString = function (fullDetails) {
  4508. var ret = "Name: " + this.name;
  4509. ret += ", type: " + this.getClassName();
  4510. if (fullDetails) {
  4511. ret += ", from: " + this._from;
  4512. ret += ", to: " + this._to;
  4513. ret += ", isStarted: " + this._isStarted;
  4514. ret += ", speedRatio: " + this._speedRatio;
  4515. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4516. ret += ", animatables length: " + this._animatables;
  4517. }
  4518. return ret;
  4519. };
  4520. return AnimationGroup;
  4521. }());
  4522. /***/ }),
  4523. /***/ "./Animations/animationKey.ts":
  4524. /*!************************************!*\
  4525. !*** ./Animations/animationKey.ts ***!
  4526. \************************************/
  4527. /*! exports provided: AnimationKeyInterpolation */
  4528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4529. "use strict";
  4530. __webpack_require__.r(__webpack_exports__);
  4531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4532. /**
  4533. * Enum for the animation key frame interpolation type
  4534. */
  4535. var AnimationKeyInterpolation;
  4536. (function (AnimationKeyInterpolation) {
  4537. /**
  4538. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4539. */
  4540. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4541. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4542. /***/ }),
  4543. /***/ "./Animations/animationPropertiesOverride.ts":
  4544. /*!***************************************************!*\
  4545. !*** ./Animations/animationPropertiesOverride.ts ***!
  4546. \***************************************************/
  4547. /*! exports provided: AnimationPropertiesOverride */
  4548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4549. "use strict";
  4550. __webpack_require__.r(__webpack_exports__);
  4551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4552. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4553. /**
  4554. * Class used to override all child animations of a given target
  4555. */
  4556. var AnimationPropertiesOverride = /** @class */ (function () {
  4557. function AnimationPropertiesOverride() {
  4558. /**
  4559. * Gets or sets a value indicating if animation blending must be used
  4560. */
  4561. this.enableBlending = false;
  4562. /**
  4563. * Gets or sets the blending speed to use when enableBlending is true
  4564. */
  4565. this.blendingSpeed = 0.01;
  4566. /**
  4567. * Gets or sets the default loop mode to use
  4568. */
  4569. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4570. }
  4571. return AnimationPropertiesOverride;
  4572. }());
  4573. /***/ }),
  4574. /***/ "./Animations/animationRange.ts":
  4575. /*!**************************************!*\
  4576. !*** ./Animations/animationRange.ts ***!
  4577. \**************************************/
  4578. /*! exports provided: AnimationRange */
  4579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4580. "use strict";
  4581. __webpack_require__.r(__webpack_exports__);
  4582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4583. /**
  4584. * Represents the range of an animation
  4585. */
  4586. var AnimationRange = /** @class */ (function () {
  4587. /**
  4588. * Initializes the range of an animation
  4589. * @param name The name of the animation range
  4590. * @param from The starting frame of the animation
  4591. * @param to The ending frame of the animation
  4592. */
  4593. function AnimationRange(
  4594. /**The name of the animation range**/
  4595. name,
  4596. /**The starting frame of the animation */
  4597. from,
  4598. /**The ending frame of the animation*/
  4599. to) {
  4600. this.name = name;
  4601. this.from = from;
  4602. this.to = to;
  4603. }
  4604. /**
  4605. * Makes a copy of the animation range
  4606. * @returns A copy of the animation range
  4607. */
  4608. AnimationRange.prototype.clone = function () {
  4609. return new AnimationRange(this.name, this.from, this.to);
  4610. };
  4611. return AnimationRange;
  4612. }());
  4613. /***/ }),
  4614. /***/ "./Animations/easing.ts":
  4615. /*!******************************!*\
  4616. !*** ./Animations/easing.ts ***!
  4617. \******************************/
  4618. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4620. "use strict";
  4621. __webpack_require__.r(__webpack_exports__);
  4622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4636. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4637. /**
  4638. * Base class used for every default easing function.
  4639. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4640. */
  4641. var EasingFunction = /** @class */ (function () {
  4642. function EasingFunction() {
  4643. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4644. }
  4645. /**
  4646. * Sets the easing mode of the current function.
  4647. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4648. */
  4649. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4650. var n = Math.min(Math.max(easingMode, 0), 2);
  4651. this._easingMode = n;
  4652. };
  4653. /**
  4654. * Gets the current easing mode.
  4655. * @returns the easing mode
  4656. */
  4657. EasingFunction.prototype.getEasingMode = function () {
  4658. return this._easingMode;
  4659. };
  4660. /**
  4661. * @hidden
  4662. */
  4663. EasingFunction.prototype.easeInCore = function (gradient) {
  4664. throw new Error('You must implement this method');
  4665. };
  4666. /**
  4667. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4668. * of the easing function.
  4669. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4670. * @returns the corresponding value on the curve defined by the easing function
  4671. */
  4672. EasingFunction.prototype.ease = function (gradient) {
  4673. switch (this._easingMode) {
  4674. case EasingFunction.EASINGMODE_EASEIN:
  4675. return this.easeInCore(gradient);
  4676. case EasingFunction.EASINGMODE_EASEOUT:
  4677. return (1 - this.easeInCore(1 - gradient));
  4678. }
  4679. if (gradient >= 0.5) {
  4680. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4681. }
  4682. return (this.easeInCore(gradient * 2) * 0.5);
  4683. };
  4684. /**
  4685. * Interpolation follows the mathematical formula associated with the easing function.
  4686. */
  4687. EasingFunction.EASINGMODE_EASEIN = 0;
  4688. /**
  4689. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4690. */
  4691. EasingFunction.EASINGMODE_EASEOUT = 1;
  4692. /**
  4693. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4694. */
  4695. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4696. return EasingFunction;
  4697. }());
  4698. /**
  4699. * Easing function with a circle shape (see link below).
  4700. * @see https://easings.net/#easeInCirc
  4701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4702. */
  4703. var CircleEase = /** @class */ (function (_super) {
  4704. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4705. function CircleEase() {
  4706. return _super !== null && _super.apply(this, arguments) || this;
  4707. }
  4708. /** @hidden */
  4709. CircleEase.prototype.easeInCore = function (gradient) {
  4710. gradient = Math.max(0, Math.min(1, gradient));
  4711. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4712. };
  4713. return CircleEase;
  4714. }(EasingFunction));
  4715. /**
  4716. * Easing function with a ease back shape (see link below).
  4717. * @see https://easings.net/#easeInBack
  4718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4719. */
  4720. var BackEase = /** @class */ (function (_super) {
  4721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4722. /**
  4723. * Instantiates a back ease easing
  4724. * @see https://easings.net/#easeInBack
  4725. * @param amplitude Defines the amplitude of the function
  4726. */
  4727. function BackEase(
  4728. /** Defines the amplitude of the function */
  4729. amplitude) {
  4730. if (amplitude === void 0) { amplitude = 1; }
  4731. var _this = _super.call(this) || this;
  4732. _this.amplitude = amplitude;
  4733. return _this;
  4734. }
  4735. /** @hidden */
  4736. BackEase.prototype.easeInCore = function (gradient) {
  4737. var num = Math.max(0, this.amplitude);
  4738. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4739. };
  4740. return BackEase;
  4741. }(EasingFunction));
  4742. /**
  4743. * Easing function with a bouncing shape (see link below).
  4744. * @see https://easings.net/#easeInBounce
  4745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4746. */
  4747. var BounceEase = /** @class */ (function (_super) {
  4748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4749. /**
  4750. * Instantiates a bounce easing
  4751. * @see https://easings.net/#easeInBounce
  4752. * @param bounces Defines the number of bounces
  4753. * @param bounciness Defines the amplitude of the bounce
  4754. */
  4755. function BounceEase(
  4756. /** Defines the number of bounces */
  4757. bounces,
  4758. /** Defines the amplitude of the bounce */
  4759. bounciness) {
  4760. if (bounces === void 0) { bounces = 3; }
  4761. if (bounciness === void 0) { bounciness = 2; }
  4762. var _this = _super.call(this) || this;
  4763. _this.bounces = bounces;
  4764. _this.bounciness = bounciness;
  4765. return _this;
  4766. }
  4767. /** @hidden */
  4768. BounceEase.prototype.easeInCore = function (gradient) {
  4769. var y = Math.max(0.0, this.bounces);
  4770. var bounciness = this.bounciness;
  4771. if (bounciness <= 1.0) {
  4772. bounciness = 1.001;
  4773. }
  4774. var num9 = Math.pow(bounciness, y);
  4775. var num5 = 1.0 - bounciness;
  4776. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4777. var num15 = gradient * num4;
  4778. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4779. var num3 = Math.floor(num65);
  4780. var num13 = num3 + 1.0;
  4781. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4782. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4783. var num7 = (num8 + num12) * 0.5;
  4784. var num6 = gradient - num7;
  4785. var num2 = num7 - num8;
  4786. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4787. };
  4788. return BounceEase;
  4789. }(EasingFunction));
  4790. /**
  4791. * Easing function with a power of 3 shape (see link below).
  4792. * @see https://easings.net/#easeInCubic
  4793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4794. */
  4795. var CubicEase = /** @class */ (function (_super) {
  4796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4797. function CubicEase() {
  4798. return _super !== null && _super.apply(this, arguments) || this;
  4799. }
  4800. /** @hidden */
  4801. CubicEase.prototype.easeInCore = function (gradient) {
  4802. return (gradient * gradient * gradient);
  4803. };
  4804. return CubicEase;
  4805. }(EasingFunction));
  4806. /**
  4807. * Easing function with an elastic shape (see link below).
  4808. * @see https://easings.net/#easeInElastic
  4809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4810. */
  4811. var ElasticEase = /** @class */ (function (_super) {
  4812. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4813. /**
  4814. * Instantiates an elastic easing function
  4815. * @see https://easings.net/#easeInElastic
  4816. * @param oscillations Defines the number of oscillations
  4817. * @param springiness Defines the amplitude of the oscillations
  4818. */
  4819. function ElasticEase(
  4820. /** Defines the number of oscillations*/
  4821. oscillations,
  4822. /** Defines the amplitude of the oscillations*/
  4823. springiness) {
  4824. if (oscillations === void 0) { oscillations = 3; }
  4825. if (springiness === void 0) { springiness = 3; }
  4826. var _this = _super.call(this) || this;
  4827. _this.oscillations = oscillations;
  4828. _this.springiness = springiness;
  4829. return _this;
  4830. }
  4831. /** @hidden */
  4832. ElasticEase.prototype.easeInCore = function (gradient) {
  4833. var num2;
  4834. var num3 = Math.max(0.0, this.oscillations);
  4835. var num = Math.max(0.0, this.springiness);
  4836. if (num == 0) {
  4837. num2 = gradient;
  4838. }
  4839. else {
  4840. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4841. }
  4842. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4843. };
  4844. return ElasticEase;
  4845. }(EasingFunction));
  4846. /**
  4847. * Easing function with an exponential shape (see link below).
  4848. * @see https://easings.net/#easeInExpo
  4849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4850. */
  4851. var ExponentialEase = /** @class */ (function (_super) {
  4852. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4853. /**
  4854. * Instantiates an exponential easing function
  4855. * @see https://easings.net/#easeInExpo
  4856. * @param exponent Defines the exponent of the function
  4857. */
  4858. function ExponentialEase(
  4859. /** Defines the exponent of the function */
  4860. exponent) {
  4861. if (exponent === void 0) { exponent = 2; }
  4862. var _this = _super.call(this) || this;
  4863. _this.exponent = exponent;
  4864. return _this;
  4865. }
  4866. /** @hidden */
  4867. ExponentialEase.prototype.easeInCore = function (gradient) {
  4868. if (this.exponent <= 0) {
  4869. return gradient;
  4870. }
  4871. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4872. };
  4873. return ExponentialEase;
  4874. }(EasingFunction));
  4875. /**
  4876. * Easing function with a power shape (see link below).
  4877. * @see https://easings.net/#easeInQuad
  4878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4879. */
  4880. var PowerEase = /** @class */ (function (_super) {
  4881. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4882. /**
  4883. * Instantiates an power base easing function
  4884. * @see https://easings.net/#easeInQuad
  4885. * @param power Defines the power of the function
  4886. */
  4887. function PowerEase(
  4888. /** Defines the power of the function */
  4889. power) {
  4890. if (power === void 0) { power = 2; }
  4891. var _this = _super.call(this) || this;
  4892. _this.power = power;
  4893. return _this;
  4894. }
  4895. /** @hidden */
  4896. PowerEase.prototype.easeInCore = function (gradient) {
  4897. var y = Math.max(0.0, this.power);
  4898. return Math.pow(gradient, y);
  4899. };
  4900. return PowerEase;
  4901. }(EasingFunction));
  4902. /**
  4903. * Easing function with a power of 2 shape (see link below).
  4904. * @see https://easings.net/#easeInQuad
  4905. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4906. */
  4907. var QuadraticEase = /** @class */ (function (_super) {
  4908. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4909. function QuadraticEase() {
  4910. return _super !== null && _super.apply(this, arguments) || this;
  4911. }
  4912. /** @hidden */
  4913. QuadraticEase.prototype.easeInCore = function (gradient) {
  4914. return (gradient * gradient);
  4915. };
  4916. return QuadraticEase;
  4917. }(EasingFunction));
  4918. /**
  4919. * Easing function with a power of 4 shape (see link below).
  4920. * @see https://easings.net/#easeInQuart
  4921. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4922. */
  4923. var QuarticEase = /** @class */ (function (_super) {
  4924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4925. function QuarticEase() {
  4926. return _super !== null && _super.apply(this, arguments) || this;
  4927. }
  4928. /** @hidden */
  4929. QuarticEase.prototype.easeInCore = function (gradient) {
  4930. return (gradient * gradient * gradient * gradient);
  4931. };
  4932. return QuarticEase;
  4933. }(EasingFunction));
  4934. /**
  4935. * Easing function with a power of 5 shape (see link below).
  4936. * @see https://easings.net/#easeInQuint
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. var QuinticEase = /** @class */ (function (_super) {
  4940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4941. function QuinticEase() {
  4942. return _super !== null && _super.apply(this, arguments) || this;
  4943. }
  4944. /** @hidden */
  4945. QuinticEase.prototype.easeInCore = function (gradient) {
  4946. return (gradient * gradient * gradient * gradient * gradient);
  4947. };
  4948. return QuinticEase;
  4949. }(EasingFunction));
  4950. /**
  4951. * Easing function with a sin shape (see link below).
  4952. * @see https://easings.net/#easeInSine
  4953. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4954. */
  4955. var SineEase = /** @class */ (function (_super) {
  4956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4957. function SineEase() {
  4958. return _super !== null && _super.apply(this, arguments) || this;
  4959. }
  4960. /** @hidden */
  4961. SineEase.prototype.easeInCore = function (gradient) {
  4962. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4963. };
  4964. return SineEase;
  4965. }(EasingFunction));
  4966. /**
  4967. * Easing function with a bezier shape (see link below).
  4968. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. var BezierCurveEase = /** @class */ (function (_super) {
  4972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4973. /**
  4974. * Instantiates a bezier function
  4975. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4976. * @param x1 Defines the x component of the start tangent in the bezier curve
  4977. * @param y1 Defines the y component of the start tangent in the bezier curve
  4978. * @param x2 Defines the x component of the end tangent in the bezier curve
  4979. * @param y2 Defines the y component of the end tangent in the bezier curve
  4980. */
  4981. function BezierCurveEase(
  4982. /** Defines the x component of the start tangent in the bezier curve */
  4983. x1,
  4984. /** Defines the y component of the start tangent in the bezier curve */
  4985. y1,
  4986. /** Defines the x component of the end tangent in the bezier curve */
  4987. x2,
  4988. /** Defines the y component of the end tangent in the bezier curve */
  4989. y2) {
  4990. if (x1 === void 0) { x1 = 0; }
  4991. if (y1 === void 0) { y1 = 0; }
  4992. if (x2 === void 0) { x2 = 1; }
  4993. if (y2 === void 0) { y2 = 1; }
  4994. var _this = _super.call(this) || this;
  4995. _this.x1 = x1;
  4996. _this.y1 = y1;
  4997. _this.x2 = x2;
  4998. _this.y2 = y2;
  4999. return _this;
  5000. }
  5001. /** @hidden */
  5002. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5003. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5004. };
  5005. return BezierCurveEase;
  5006. }(EasingFunction));
  5007. /***/ }),
  5008. /***/ "./Animations/index.ts":
  5009. /*!*****************************!*\
  5010. !*** ./Animations/index.ts ***!
  5011. \*****************************/
  5012. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5014. "use strict";
  5015. __webpack_require__.r(__webpack_exports__);
  5016. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5018. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5020. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5023. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5025. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5039. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5041. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5043. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5045. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5047. /***/ }),
  5048. /***/ "./Animations/runtimeAnimation.ts":
  5049. /*!****************************************!*\
  5050. !*** ./Animations/runtimeAnimation.ts ***!
  5051. \****************************************/
  5052. /*! exports provided: RuntimeAnimation */
  5053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5054. "use strict";
  5055. __webpack_require__.r(__webpack_exports__);
  5056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5058. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5059. // Static values to help the garbage collector
  5060. // Quaternion
  5061. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5062. // Vector3
  5063. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5064. // Vector2
  5065. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5066. // Size
  5067. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5068. // Color3
  5069. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5070. /**
  5071. * Defines a runtime animation
  5072. */
  5073. var RuntimeAnimation = /** @class */ (function () {
  5074. /**
  5075. * Create a new RuntimeAnimation object
  5076. * @param target defines the target of the animation
  5077. * @param animation defines the source animation object
  5078. * @param scene defines the hosting scene
  5079. * @param host defines the initiating Animatable
  5080. */
  5081. function RuntimeAnimation(target, animation, scene, host) {
  5082. var _this = this;
  5083. this._events = new Array();
  5084. /**
  5085. * The current frame of the runtime animation
  5086. */
  5087. this._currentFrame = 0;
  5088. /**
  5089. * The original value of the runtime animation
  5090. */
  5091. this._originalValue = new Array();
  5092. /**
  5093. * The offsets cache of the runtime animation
  5094. */
  5095. this._offsetsCache = {};
  5096. /**
  5097. * The high limits cache of the runtime animation
  5098. */
  5099. this._highLimitsCache = {};
  5100. /**
  5101. * Specifies if the runtime animation has been stopped
  5102. */
  5103. this._stopped = false;
  5104. /**
  5105. * The blending factor of the runtime animation
  5106. */
  5107. this._blendingFactor = 0;
  5108. /**
  5109. * The target path of the runtime animation
  5110. */
  5111. this._targetPath = "";
  5112. /**
  5113. * The weight of the runtime animation
  5114. */
  5115. this._weight = 1.0;
  5116. /**
  5117. * The ratio offset of the runtime animation
  5118. */
  5119. this._ratioOffset = 0;
  5120. /**
  5121. * The previous delay of the runtime animation
  5122. */
  5123. this._previousDelay = 0;
  5124. /**
  5125. * The previous ratio of the runtime animation
  5126. */
  5127. this._previousRatio = 0;
  5128. this._animation = animation;
  5129. this._target = target;
  5130. this._scene = scene;
  5131. this._host = host;
  5132. animation._runtimeAnimations.push(this);
  5133. // Cloning events locally
  5134. var events = animation.getEvents();
  5135. if (events && events.length > 0) {
  5136. events.forEach(function (e) {
  5137. _this._events.push(e._clone());
  5138. });
  5139. }
  5140. }
  5141. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5142. /**
  5143. * Gets the current frame of the runtime animation
  5144. */
  5145. get: function () {
  5146. return this._currentFrame;
  5147. },
  5148. enumerable: true,
  5149. configurable: true
  5150. });
  5151. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5152. /**
  5153. * Gets the weight of the runtime animation
  5154. */
  5155. get: function () {
  5156. return this._weight;
  5157. },
  5158. enumerable: true,
  5159. configurable: true
  5160. });
  5161. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5162. /**
  5163. * Gets the current value of the runtime animation
  5164. */
  5165. get: function () {
  5166. return this._currentValue;
  5167. },
  5168. enumerable: true,
  5169. configurable: true
  5170. });
  5171. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5172. /**
  5173. * Gets the target path of the runtime animation
  5174. */
  5175. get: function () {
  5176. return this._targetPath;
  5177. },
  5178. enumerable: true,
  5179. configurable: true
  5180. });
  5181. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5182. /**
  5183. * Gets the actual target of the runtime animation
  5184. */
  5185. get: function () {
  5186. return this._activeTarget;
  5187. },
  5188. enumerable: true,
  5189. configurable: true
  5190. });
  5191. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5192. /**
  5193. * Gets the animation from the runtime animation
  5194. */
  5195. get: function () {
  5196. return this._animation;
  5197. },
  5198. enumerable: true,
  5199. configurable: true
  5200. });
  5201. /**
  5202. * Resets the runtime animation to the beginning
  5203. * @param restoreOriginal defines whether to restore the target property to the original value
  5204. */
  5205. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5206. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5207. if (restoreOriginal) {
  5208. if (this._target instanceof Array) {
  5209. var index = 0;
  5210. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5211. var target = _a[_i];
  5212. if (this._originalValue[index] !== undefined) {
  5213. this._setValue(target, this._originalValue[index], -1);
  5214. }
  5215. index++;
  5216. }
  5217. }
  5218. else {
  5219. if (this._originalValue[0] !== undefined) {
  5220. this._setValue(this._target, this._originalValue[0], -1);
  5221. }
  5222. }
  5223. }
  5224. this._offsetsCache = {};
  5225. this._highLimitsCache = {};
  5226. this._currentFrame = 0;
  5227. this._blendingFactor = 0;
  5228. this._originalValue = new Array();
  5229. // Events
  5230. for (var index = 0; index < this._events.length; index++) {
  5231. this._events[index].isDone = false;
  5232. }
  5233. };
  5234. /**
  5235. * Specifies if the runtime animation is stopped
  5236. * @returns Boolean specifying if the runtime animation is stopped
  5237. */
  5238. RuntimeAnimation.prototype.isStopped = function () {
  5239. return this._stopped;
  5240. };
  5241. /**
  5242. * Disposes of the runtime animation
  5243. */
  5244. RuntimeAnimation.prototype.dispose = function () {
  5245. var index = this._animation.runtimeAnimations.indexOf(this);
  5246. if (index > -1) {
  5247. this._animation.runtimeAnimations.splice(index, 1);
  5248. }
  5249. };
  5250. /**
  5251. * Interpolates the animation from the current frame
  5252. * @param currentFrame The frame to interpolate the animation to
  5253. * @param repeatCount The number of times that the animation should loop
  5254. * @param loopMode The type of looping mode to use
  5255. * @param offsetValue Animation offset value
  5256. * @param highLimitValue The high limit value
  5257. * @returns The interpolated value
  5258. */
  5259. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5260. this._currentFrame = currentFrame;
  5261. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5262. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5263. }
  5264. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5265. };
  5266. /**
  5267. * Apply the interpolated value to the target
  5268. * @param currentValue defines the value computed by the animation
  5269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5270. */
  5271. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5272. if (weight === void 0) { weight = 1.0; }
  5273. if (this._target instanceof Array) {
  5274. var index = 0;
  5275. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5276. var target = _a[_i];
  5277. this._setValue(target, currentValue, weight, index);
  5278. index++;
  5279. }
  5280. }
  5281. else {
  5282. this._setValue(this._target, currentValue, weight);
  5283. }
  5284. };
  5285. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5286. if (targetIndex === void 0) { targetIndex = 0; }
  5287. // Set value
  5288. var path;
  5289. var destination;
  5290. var targetPropertyPath = this._animation.targetPropertyPath;
  5291. if (targetPropertyPath.length > 1) {
  5292. var property = target[targetPropertyPath[0]];
  5293. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5294. property = property[targetPropertyPath[index]];
  5295. }
  5296. path = targetPropertyPath[targetPropertyPath.length - 1];
  5297. destination = property;
  5298. }
  5299. else {
  5300. path = targetPropertyPath[0];
  5301. destination = target;
  5302. }
  5303. this._targetPath = path;
  5304. this._activeTarget = destination;
  5305. this._weight = weight;
  5306. if (this._originalValue[targetIndex] === undefined) {
  5307. var originalValue = void 0;
  5308. if (destination.getRestPose && path === "_matrix") { // For bones
  5309. originalValue = destination.getRestPose();
  5310. }
  5311. else {
  5312. originalValue = destination[path];
  5313. }
  5314. if (originalValue && originalValue.clone) {
  5315. this._originalValue[targetIndex] = originalValue.clone();
  5316. }
  5317. else {
  5318. this._originalValue[targetIndex] = originalValue;
  5319. }
  5320. }
  5321. // Blending
  5322. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5323. if (enableBlending && this._blendingFactor <= 1.0) {
  5324. if (!this._originalBlendValue) {
  5325. var originalValue = destination[path];
  5326. if (originalValue.clone) {
  5327. this._originalBlendValue = originalValue.clone();
  5328. }
  5329. else {
  5330. this._originalBlendValue = originalValue;
  5331. }
  5332. }
  5333. if (this._originalBlendValue.m) { // Matrix
  5334. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5335. if (this._currentValue) {
  5336. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5337. }
  5338. else {
  5339. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5340. }
  5341. }
  5342. else {
  5343. if (this._currentValue) {
  5344. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5345. }
  5346. else {
  5347. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5348. }
  5349. }
  5350. }
  5351. else {
  5352. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5353. }
  5354. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5355. this._blendingFactor += blendingSpeed;
  5356. }
  5357. else {
  5358. this._currentValue = currentValue;
  5359. }
  5360. if (weight !== -1.0) {
  5361. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5362. }
  5363. else {
  5364. destination[path] = this._currentValue;
  5365. }
  5366. if (target.markAsDirty) {
  5367. target.markAsDirty(this._animation.targetProperty);
  5368. }
  5369. };
  5370. /**
  5371. * Gets the loop pmode of the runtime animation
  5372. * @returns Loop Mode
  5373. */
  5374. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5375. if (this._target && this._target.animationPropertiesOverride) {
  5376. return this._target.animationPropertiesOverride.loopMode;
  5377. }
  5378. return this._animation.loopMode;
  5379. };
  5380. /**
  5381. * Move the current animation to a given frame
  5382. * @param frame defines the frame to move to
  5383. */
  5384. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5385. var keys = this._animation.getKeys();
  5386. if (frame < keys[0].frame) {
  5387. frame = keys[0].frame;
  5388. }
  5389. else if (frame > keys[keys.length - 1].frame) {
  5390. frame = keys[keys.length - 1].frame;
  5391. }
  5392. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5393. this.setValue(currentValue, -1);
  5394. };
  5395. /**
  5396. * @hidden Internal use only
  5397. */
  5398. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5399. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5400. this._ratioOffset = this._previousRatio - newRatio;
  5401. };
  5402. /**
  5403. * Execute the current animation
  5404. * @param delay defines the delay to add to the current frame
  5405. * @param from defines the lower bound of the animation range
  5406. * @param to defines the upper bound of the animation range
  5407. * @param loop defines if the current animation must loop
  5408. * @param speedRatio defines the current speed ratio
  5409. * @param weight defines the weight of the animation (default is -1 so no weight)
  5410. * @param onLoop optional callback called when animation loops
  5411. * @returns a boolean indicating if the animation is running
  5412. */
  5413. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5414. if (weight === void 0) { weight = -1.0; }
  5415. var targetPropertyPath = this._animation.targetPropertyPath;
  5416. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5417. this._stopped = true;
  5418. return false;
  5419. }
  5420. var returnValue = true;
  5421. var keys = this._animation.getKeys();
  5422. var min = keys[0].frame;
  5423. var max = keys[keys.length - 1].frame;
  5424. // Add a start key at frame 0 if missing
  5425. if (min !== 0) {
  5426. var newKey = { frame: 0, value: keys[0].value };
  5427. keys.splice(0, 0, newKey);
  5428. }
  5429. // Check limits
  5430. if (from < min || from > max) {
  5431. from = min;
  5432. }
  5433. if (to < min || to > max) {
  5434. to = max;
  5435. }
  5436. var range = to - from;
  5437. var offsetValue;
  5438. // Compute ratio which represents the frame delta between from and to
  5439. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5440. var highLimitValue = 0;
  5441. this._previousDelay = delay;
  5442. this._previousRatio = ratio;
  5443. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5444. returnValue = false;
  5445. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5446. }
  5447. else {
  5448. // Get max value if required
  5449. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5450. var keyOffset = to.toString() + from.toString();
  5451. if (!this._offsetsCache[keyOffset]) {
  5452. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5453. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5454. switch (this._animation.dataType) {
  5455. // Float
  5456. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5457. this._offsetsCache[keyOffset] = toValue - fromValue;
  5458. break;
  5459. // Quaternion
  5460. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5461. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5462. break;
  5463. // Vector3
  5464. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5465. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5466. // Vector2
  5467. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5468. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5469. // Size
  5470. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5471. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5472. // Color3
  5473. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5474. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5475. default:
  5476. break;
  5477. }
  5478. this._highLimitsCache[keyOffset] = toValue;
  5479. }
  5480. highLimitValue = this._highLimitsCache[keyOffset];
  5481. offsetValue = this._offsetsCache[keyOffset];
  5482. }
  5483. }
  5484. if (offsetValue === undefined) {
  5485. switch (this._animation.dataType) {
  5486. // Float
  5487. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5488. offsetValue = 0;
  5489. break;
  5490. // Quaternion
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5492. offsetValue = _staticOffsetValueQuaternion;
  5493. break;
  5494. // Vector3
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5496. offsetValue = _staticOffsetValueVector3;
  5497. break;
  5498. // Vector2
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5500. offsetValue = _staticOffsetValueVector2;
  5501. break;
  5502. // Size
  5503. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5504. offsetValue = _staticOffsetValueSize;
  5505. break;
  5506. // Color3
  5507. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5508. offsetValue = _staticOffsetValueColor3;
  5509. }
  5510. }
  5511. // Compute value
  5512. var currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5513. // Need to normalize?
  5514. if (this._host && this._host.syncRoot) {
  5515. var syncRoot = this._host.syncRoot;
  5516. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5517. currentFrame = from + (to - from) * hostNormalizedFrame;
  5518. }
  5519. // Reset events if looping
  5520. var events = this._events;
  5521. if (range > 0 && this.currentFrame > currentFrame ||
  5522. range < 0 && this.currentFrame < currentFrame) {
  5523. if (onLoop) {
  5524. onLoop();
  5525. }
  5526. // Need to reset animation events
  5527. for (var index = 0; index < events.length; index++) {
  5528. if (!events[index].onlyOnce) {
  5529. // reset event, the animation is looping
  5530. events[index].isDone = false;
  5531. }
  5532. }
  5533. }
  5534. var repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5535. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5536. // Set value
  5537. this.setValue(currentValue, weight);
  5538. // Check events
  5539. for (var index = 0; index < events.length; index++) {
  5540. // Make sure current frame has passed event frame and that event frame is within the current range
  5541. // Also, handle both forward and reverse animations
  5542. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5543. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5544. var event = events[index];
  5545. if (!event.isDone) {
  5546. // If event should be done only once, remove it.
  5547. if (event.onlyOnce) {
  5548. events.splice(index, 1);
  5549. index--;
  5550. }
  5551. event.isDone = true;
  5552. event.action(currentFrame);
  5553. } // Don't do anything if the event has already be done.
  5554. }
  5555. }
  5556. if (!returnValue) {
  5557. this._stopped = true;
  5558. }
  5559. return returnValue;
  5560. };
  5561. return RuntimeAnimation;
  5562. }());
  5563. /***/ }),
  5564. /***/ "./Audio/analyser.ts":
  5565. /*!***************************!*\
  5566. !*** ./Audio/analyser.ts ***!
  5567. \***************************/
  5568. /*! exports provided: Analyser */
  5569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5570. "use strict";
  5571. __webpack_require__.r(__webpack_exports__);
  5572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5573. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5574. /**
  5575. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5577. */
  5578. var Analyser = /** @class */ (function () {
  5579. /**
  5580. * Creates a new analyser
  5581. * @param scene defines hosting scene
  5582. */
  5583. function Analyser(scene) {
  5584. /**
  5585. * Gets or sets the smoothing
  5586. * @ignorenaming
  5587. */
  5588. this.SMOOTHING = 0.75;
  5589. /**
  5590. * Gets or sets the FFT table size
  5591. * @ignorenaming
  5592. */
  5593. this.FFT_SIZE = 512;
  5594. /**
  5595. * Gets or sets the bar graph amplitude
  5596. * @ignorenaming
  5597. */
  5598. this.BARGRAPHAMPLITUDE = 256;
  5599. /**
  5600. * Gets or sets the position of the debug canvas
  5601. * @ignorenaming
  5602. */
  5603. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5604. /**
  5605. * Gets or sets the debug canvas size
  5606. * @ignorenaming
  5607. */
  5608. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5609. this._scene = scene;
  5610. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5611. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5612. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5613. this._webAudioAnalyser.minDecibels = -140;
  5614. this._webAudioAnalyser.maxDecibels = 0;
  5615. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5616. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5617. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5618. }
  5619. }
  5620. /**
  5621. * Get the number of data values you will have to play with for the visualization
  5622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5623. * @returns a number
  5624. */
  5625. Analyser.prototype.getFrequencyBinCount = function () {
  5626. if (this._audioEngine.canUseWebAudio) {
  5627. return this._webAudioAnalyser.frequencyBinCount;
  5628. }
  5629. else {
  5630. return 0;
  5631. }
  5632. };
  5633. /**
  5634. * Gets the current frequency data as a byte array
  5635. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5636. * @returns a Uint8Array
  5637. */
  5638. Analyser.prototype.getByteFrequencyData = function () {
  5639. if (this._audioEngine.canUseWebAudio) {
  5640. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5641. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5642. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5643. }
  5644. return this._byteFreqs;
  5645. };
  5646. /**
  5647. * Gets the current waveform as a byte array
  5648. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5649. * @returns a Uint8Array
  5650. */
  5651. Analyser.prototype.getByteTimeDomainData = function () {
  5652. if (this._audioEngine.canUseWebAudio) {
  5653. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5654. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5655. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5656. }
  5657. return this._byteTime;
  5658. };
  5659. /**
  5660. * Gets the current frequency data as a float array
  5661. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5662. * @returns a Float32Array
  5663. */
  5664. Analyser.prototype.getFloatFrequencyData = function () {
  5665. if (this._audioEngine.canUseWebAudio) {
  5666. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5667. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5668. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5669. }
  5670. return this._floatFreqs;
  5671. };
  5672. /**
  5673. * Renders the debug canvas
  5674. */
  5675. Analyser.prototype.drawDebugCanvas = function () {
  5676. var _this = this;
  5677. if (this._audioEngine.canUseWebAudio) {
  5678. if (!this._debugCanvas) {
  5679. this._debugCanvas = document.createElement("canvas");
  5680. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5681. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5682. this._debugCanvas.style.position = "absolute";
  5683. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5684. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5685. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5686. document.body.appendChild(this._debugCanvas);
  5687. this._registerFunc = function () {
  5688. _this.drawDebugCanvas();
  5689. };
  5690. this._scene.registerBeforeRender(this._registerFunc);
  5691. }
  5692. if (this._registerFunc && this._debugCanvasContext) {
  5693. var workingArray = this.getByteFrequencyData();
  5694. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5695. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5696. // Draw the frequency domain chart.
  5697. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5698. var value = workingArray[i];
  5699. var percent = value / this.BARGRAPHAMPLITUDE;
  5700. var height = this.DEBUGCANVASSIZE.height * percent;
  5701. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5702. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5703. var hue = i / this.getFrequencyBinCount() * 360;
  5704. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5705. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5706. }
  5707. }
  5708. }
  5709. };
  5710. /**
  5711. * Stops rendering the debug canvas and removes it
  5712. */
  5713. Analyser.prototype.stopDebugCanvas = function () {
  5714. if (this._debugCanvas) {
  5715. if (this._registerFunc) {
  5716. this._scene.unregisterBeforeRender(this._registerFunc);
  5717. this._registerFunc = null;
  5718. }
  5719. document.body.removeChild(this._debugCanvas);
  5720. this._debugCanvas = null;
  5721. this._debugCanvasContext = null;
  5722. }
  5723. };
  5724. /**
  5725. * Connects two audio nodes
  5726. * @param inputAudioNode defines first node to connect
  5727. * @param outputAudioNode defines second node to connect
  5728. */
  5729. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5730. if (this._audioEngine.canUseWebAudio) {
  5731. inputAudioNode.connect(this._webAudioAnalyser);
  5732. this._webAudioAnalyser.connect(outputAudioNode);
  5733. }
  5734. };
  5735. /**
  5736. * Releases all associated resources
  5737. */
  5738. Analyser.prototype.dispose = function () {
  5739. if (this._audioEngine.canUseWebAudio) {
  5740. this._webAudioAnalyser.disconnect();
  5741. }
  5742. };
  5743. return Analyser;
  5744. }());
  5745. /***/ }),
  5746. /***/ "./Audio/audioEngine.ts":
  5747. /*!******************************!*\
  5748. !*** ./Audio/audioEngine.ts ***!
  5749. \******************************/
  5750. /*! exports provided: AudioEngine */
  5751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5752. "use strict";
  5753. __webpack_require__.r(__webpack_exports__);
  5754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5755. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5756. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5757. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5758. // Sets the default audio engine to Babylon.js
  5759. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5760. /**
  5761. * This represents the default audio engine used in babylon.
  5762. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5764. */
  5765. var AudioEngine = /** @class */ (function () {
  5766. /**
  5767. * Instantiates a new audio engine.
  5768. *
  5769. * There should be only one per page as some browsers restrict the number
  5770. * of audio contexts you can create.
  5771. * @param hostElement defines the host element where to display the mute icon if necessary
  5772. */
  5773. function AudioEngine(hostElement) {
  5774. if (hostElement === void 0) { hostElement = null; }
  5775. var _this = this;
  5776. this._audioContext = null;
  5777. this._audioContextInitialized = false;
  5778. this._muteButton = null;
  5779. /**
  5780. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5781. */
  5782. this.canUseWebAudio = false;
  5783. /**
  5784. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5785. * @ignoreNaming
  5786. */
  5787. this.WarnedWebAudioUnsupported = false;
  5788. /**
  5789. * Gets whether or not mp3 are supported by your browser.
  5790. */
  5791. this.isMP3supported = false;
  5792. /**
  5793. * Gets whether or not ogg are supported by your browser.
  5794. */
  5795. this.isOGGsupported = false;
  5796. /**
  5797. * Gets whether audio has been unlocked on the device.
  5798. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5799. * a user interaction has happened.
  5800. */
  5801. this.unlocked = true;
  5802. /**
  5803. * Defines if the audio engine relies on a custom unlocked button.
  5804. * In this case, the embedded button will not be displayed.
  5805. */
  5806. this.useCustomUnlockedButton = false;
  5807. /**
  5808. * Event raised when audio has been unlocked on the browser.
  5809. */
  5810. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5811. /**
  5812. * Event raised when audio has been locked on the browser.
  5813. */
  5814. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5815. this._tryToRun = false;
  5816. this._onResize = function () {
  5817. _this._moveButtonToTopLeft();
  5818. };
  5819. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5820. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5821. this.canUseWebAudio = true;
  5822. }
  5823. var audioElem = document.createElement('audio');
  5824. this._hostElement = hostElement;
  5825. try {
  5826. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5827. this.isMP3supported = true;
  5828. }
  5829. }
  5830. catch (e) {
  5831. // protect error during capability check.
  5832. }
  5833. try {
  5834. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5835. this.isOGGsupported = true;
  5836. }
  5837. }
  5838. catch (e) {
  5839. // protect error during capability check.
  5840. }
  5841. }
  5842. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5843. /**
  5844. * Gets the current AudioContext if available.
  5845. */
  5846. get: function () {
  5847. if (!this._audioContextInitialized) {
  5848. this._initializeAudioContext();
  5849. }
  5850. else {
  5851. if (!this.unlocked && !this._muteButton) {
  5852. this._displayMuteButton();
  5853. }
  5854. }
  5855. return this._audioContext;
  5856. },
  5857. enumerable: true,
  5858. configurable: true
  5859. });
  5860. /**
  5861. * Flags the audio engine in Locked state.
  5862. * This happens due to new browser policies preventing audio to autoplay.
  5863. */
  5864. AudioEngine.prototype.lock = function () {
  5865. this._triggerSuspendedState();
  5866. };
  5867. /**
  5868. * Unlocks the audio engine once a user action has been done on the dom.
  5869. * This is helpful to resume play once browser policies have been satisfied.
  5870. */
  5871. AudioEngine.prototype.unlock = function () {
  5872. this._triggerRunningState();
  5873. };
  5874. AudioEngine.prototype._resumeAudioContext = function () {
  5875. var result;
  5876. if (this._audioContext.resume) {
  5877. result = this._audioContext.resume();
  5878. }
  5879. return result || Promise.resolve();
  5880. };
  5881. AudioEngine.prototype._initializeAudioContext = function () {
  5882. try {
  5883. if (this.canUseWebAudio) {
  5884. this._audioContext = new AudioContext();
  5885. // create a global volume gain node
  5886. this.masterGain = this._audioContext.createGain();
  5887. this.masterGain.gain.value = 1;
  5888. this.masterGain.connect(this._audioContext.destination);
  5889. this._audioContextInitialized = true;
  5890. if (this._audioContext.state === "running") {
  5891. // Do not wait for the promise to unlock.
  5892. this._triggerRunningState();
  5893. }
  5894. }
  5895. }
  5896. catch (e) {
  5897. this.canUseWebAudio = false;
  5898. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5899. }
  5900. };
  5901. AudioEngine.prototype._triggerRunningState = function () {
  5902. var _this = this;
  5903. if (this._tryToRun) {
  5904. return;
  5905. }
  5906. this._tryToRun = true;
  5907. this._resumeAudioContext()
  5908. .then(function () {
  5909. _this._tryToRun = false;
  5910. if (_this._muteButton) {
  5911. _this._hideMuteButton();
  5912. }
  5913. }).catch(function () {
  5914. _this._tryToRun = false;
  5915. _this.unlocked = false;
  5916. });
  5917. // Notify users that the audio stack is unlocked/unmuted
  5918. this.unlocked = true;
  5919. this.onAudioUnlockedObservable.notifyObservers(this);
  5920. };
  5921. AudioEngine.prototype._triggerSuspendedState = function () {
  5922. this.unlocked = false;
  5923. this.onAudioLockedObservable.notifyObservers(this);
  5924. this._displayMuteButton();
  5925. };
  5926. AudioEngine.prototype._displayMuteButton = function () {
  5927. var _this = this;
  5928. if (this.useCustomUnlockedButton || this._muteButton) {
  5929. return;
  5930. }
  5931. this._muteButton = document.createElement("BUTTON");
  5932. this._muteButton.className = "babylonUnmuteIcon";
  5933. this._muteButton.id = "babylonUnmuteIconBtn";
  5934. this._muteButton.title = "Unmute";
  5935. var css = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }";
  5936. var style = document.createElement('style');
  5937. style.appendChild(document.createTextNode(css));
  5938. document.getElementsByTagName('head')[0].appendChild(style);
  5939. document.body.appendChild(this._muteButton);
  5940. this._moveButtonToTopLeft();
  5941. this._muteButton.addEventListener('touchend', function () {
  5942. _this._triggerRunningState();
  5943. }, true);
  5944. this._muteButton.addEventListener('click', function () {
  5945. _this._triggerRunningState();
  5946. }, true);
  5947. window.addEventListener("resize", this._onResize);
  5948. };
  5949. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5950. if (this._hostElement && this._muteButton) {
  5951. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5952. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5953. }
  5954. };
  5955. AudioEngine.prototype._hideMuteButton = function () {
  5956. if (this._muteButton) {
  5957. document.body.removeChild(this._muteButton);
  5958. this._muteButton = null;
  5959. }
  5960. };
  5961. /**
  5962. * Destroy and release the resources associated with the audio ccontext.
  5963. */
  5964. AudioEngine.prototype.dispose = function () {
  5965. if (this.canUseWebAudio && this._audioContextInitialized) {
  5966. if (this._connectedAnalyser && this._audioContext) {
  5967. this._connectedAnalyser.stopDebugCanvas();
  5968. this._connectedAnalyser.dispose();
  5969. this.masterGain.disconnect();
  5970. this.masterGain.connect(this._audioContext.destination);
  5971. this._connectedAnalyser = null;
  5972. }
  5973. this.masterGain.gain.value = 1;
  5974. }
  5975. this.WarnedWebAudioUnsupported = false;
  5976. this._hideMuteButton();
  5977. window.removeEventListener("resize", this._onResize);
  5978. this.onAudioUnlockedObservable.clear();
  5979. this.onAudioLockedObservable.clear();
  5980. };
  5981. /**
  5982. * Gets the global volume sets on the master gain.
  5983. * @returns the global volume if set or -1 otherwise
  5984. */
  5985. AudioEngine.prototype.getGlobalVolume = function () {
  5986. if (this.canUseWebAudio && this._audioContextInitialized) {
  5987. return this.masterGain.gain.value;
  5988. }
  5989. else {
  5990. return -1;
  5991. }
  5992. };
  5993. /**
  5994. * Sets the global volume of your experience (sets on the master gain).
  5995. * @param newVolume Defines the new global volume of the application
  5996. */
  5997. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5998. if (this.canUseWebAudio && this._audioContextInitialized) {
  5999. this.masterGain.gain.value = newVolume;
  6000. }
  6001. };
  6002. /**
  6003. * Connect the audio engine to an audio analyser allowing some amazing
  6004. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6006. * @param analyser The analyser to connect to the engine
  6007. */
  6008. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6009. if (this._connectedAnalyser) {
  6010. this._connectedAnalyser.stopDebugCanvas();
  6011. }
  6012. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6013. this._connectedAnalyser = analyser;
  6014. this.masterGain.disconnect();
  6015. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6016. }
  6017. };
  6018. return AudioEngine;
  6019. }());
  6020. /***/ }),
  6021. /***/ "./Audio/audioSceneComponent.ts":
  6022. /*!**************************************!*\
  6023. !*** ./Audio/audioSceneComponent.ts ***!
  6024. \**************************************/
  6025. /*! exports provided: AudioSceneComponent */
  6026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6027. "use strict";
  6028. __webpack_require__.r(__webpack_exports__);
  6029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6030. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6031. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6032. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6033. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6034. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6035. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6036. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6037. // Adds the parser to the scene parsers.
  6038. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6039. // TODO: add sound
  6040. var loadedSounds = [];
  6041. var loadedSound;
  6042. container.sounds = container.sounds || [];
  6043. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6044. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6045. var parsedSound = parsedData.sounds[index];
  6046. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6047. if (!parsedSound.url) {
  6048. parsedSound.url = parsedSound.name;
  6049. }
  6050. if (!loadedSounds[parsedSound.url]) {
  6051. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6052. loadedSounds[parsedSound.url] = loadedSound;
  6053. container.sounds.push(loadedSound);
  6054. }
  6055. else {
  6056. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6057. }
  6058. }
  6059. else {
  6060. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6061. }
  6062. }
  6063. }
  6064. loadedSounds = [];
  6065. });
  6066. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6067. get: function () {
  6068. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6069. if (!compo) {
  6070. compo = new AudioSceneComponent(this);
  6071. this._addComponent(compo);
  6072. }
  6073. if (!this._mainSoundTrack) {
  6074. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6075. }
  6076. return this._mainSoundTrack;
  6077. },
  6078. enumerable: true,
  6079. configurable: true
  6080. });
  6081. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6082. var index;
  6083. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6084. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6085. return this.mainSoundTrack.soundCollection[index];
  6086. }
  6087. }
  6088. if (this.soundTracks) {
  6089. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6090. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6091. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6092. return this.soundTracks[sdIndex].soundCollection[index];
  6093. }
  6094. }
  6095. }
  6096. }
  6097. return null;
  6098. };
  6099. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6100. get: function () {
  6101. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6102. if (!compo) {
  6103. compo = new AudioSceneComponent(this);
  6104. this._addComponent(compo);
  6105. }
  6106. return compo.audioEnabled;
  6107. },
  6108. set: function (value) {
  6109. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6110. if (!compo) {
  6111. compo = new AudioSceneComponent(this);
  6112. this._addComponent(compo);
  6113. }
  6114. if (value) {
  6115. compo.enableAudio();
  6116. }
  6117. else {
  6118. compo.disableAudio();
  6119. }
  6120. },
  6121. enumerable: true,
  6122. configurable: true
  6123. });
  6124. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6125. get: function () {
  6126. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6127. if (!compo) {
  6128. compo = new AudioSceneComponent(this);
  6129. this._addComponent(compo);
  6130. }
  6131. return compo.headphone;
  6132. },
  6133. set: function (value) {
  6134. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6135. if (!compo) {
  6136. compo = new AudioSceneComponent(this);
  6137. this._addComponent(compo);
  6138. }
  6139. if (value) {
  6140. compo.switchAudioModeForHeadphones();
  6141. }
  6142. else {
  6143. compo.switchAudioModeForNormalSpeakers();
  6144. }
  6145. },
  6146. enumerable: true,
  6147. configurable: true
  6148. });
  6149. /**
  6150. * Defines the sound scene component responsible to manage any sounds
  6151. * in a given scene.
  6152. */
  6153. var AudioSceneComponent = /** @class */ (function () {
  6154. /**
  6155. * Creates a new instance of the component for the given scene
  6156. * @param scene Defines the scene to register the component in
  6157. */
  6158. function AudioSceneComponent(scene) {
  6159. /**
  6160. * The component name helpfull to identify the component in the list of scene components.
  6161. */
  6162. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6163. this._audioEnabled = true;
  6164. this._headphone = false;
  6165. this.scene = scene;
  6166. scene.soundTracks = new Array();
  6167. scene.sounds = new Array();
  6168. }
  6169. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6170. /**
  6171. * Gets whether audio is enabled or not.
  6172. * Please use related enable/disable method to switch state.
  6173. */
  6174. get: function () {
  6175. return this._audioEnabled;
  6176. },
  6177. enumerable: true,
  6178. configurable: true
  6179. });
  6180. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6181. /**
  6182. * Gets whether audio is outputing to headphone or not.
  6183. * Please use the according Switch methods to change output.
  6184. */
  6185. get: function () {
  6186. return this._headphone;
  6187. },
  6188. enumerable: true,
  6189. configurable: true
  6190. });
  6191. /**
  6192. * Registers the component in a given scene
  6193. */
  6194. AudioSceneComponent.prototype.register = function () {
  6195. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6196. };
  6197. /**
  6198. * Rebuilds the elements related to this component in case of
  6199. * context lost for instance.
  6200. */
  6201. AudioSceneComponent.prototype.rebuild = function () {
  6202. // Nothing to do here. (Not rendering related)
  6203. };
  6204. /**
  6205. * Serializes the component data to the specified json object
  6206. * @param serializationObject The object to serialize to
  6207. */
  6208. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6209. serializationObject.sounds = [];
  6210. if (this.scene.soundTracks) {
  6211. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6212. var soundtrack = this.scene.soundTracks[index];
  6213. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6214. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6215. }
  6216. }
  6217. }
  6218. };
  6219. /**
  6220. * Adds all the element from the container to the scene
  6221. * @param container the container holding the elements
  6222. */
  6223. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6224. var _this = this;
  6225. if (!container.sounds) {
  6226. return;
  6227. }
  6228. container.sounds.forEach(function (sound) {
  6229. sound.play();
  6230. sound.autoplay = true;
  6231. _this.scene.mainSoundTrack.AddSound(sound);
  6232. });
  6233. };
  6234. /**
  6235. * Removes all the elements in the container from the scene
  6236. * @param container contains the elements to remove
  6237. * @param dispose if the removed element should be disposed (default: false)
  6238. */
  6239. AudioSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  6240. var _this = this;
  6241. if (dispose === void 0) { dispose = false; }
  6242. if (!container.sounds) {
  6243. return;
  6244. }
  6245. container.sounds.forEach(function (sound) {
  6246. sound.stop();
  6247. sound.autoplay = false;
  6248. _this.scene.mainSoundTrack.RemoveSound(sound);
  6249. if (dispose) {
  6250. sound.dispose();
  6251. }
  6252. });
  6253. };
  6254. /**
  6255. * Disposes the component and the associated ressources.
  6256. */
  6257. AudioSceneComponent.prototype.dispose = function () {
  6258. var scene = this.scene;
  6259. if (scene._mainSoundTrack) {
  6260. scene.mainSoundTrack.dispose();
  6261. }
  6262. if (scene.soundTracks) {
  6263. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6264. scene.soundTracks[scIndex].dispose();
  6265. }
  6266. }
  6267. };
  6268. /**
  6269. * Disables audio in the associated scene.
  6270. */
  6271. AudioSceneComponent.prototype.disableAudio = function () {
  6272. var scene = this.scene;
  6273. this._audioEnabled = false;
  6274. var i;
  6275. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6276. scene.mainSoundTrack.soundCollection[i].pause();
  6277. }
  6278. if (scene.soundTracks) {
  6279. for (i = 0; i < scene.soundTracks.length; i++) {
  6280. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6281. scene.soundTracks[i].soundCollection[j].pause();
  6282. }
  6283. }
  6284. }
  6285. };
  6286. /**
  6287. * Enables audio in the associated scene.
  6288. */
  6289. AudioSceneComponent.prototype.enableAudio = function () {
  6290. var scene = this.scene;
  6291. this._audioEnabled = true;
  6292. var i;
  6293. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6294. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6295. scene.mainSoundTrack.soundCollection[i].play();
  6296. }
  6297. }
  6298. if (scene.soundTracks) {
  6299. for (i = 0; i < scene.soundTracks.length; i++) {
  6300. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6301. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6302. scene.soundTracks[i].soundCollection[j].play();
  6303. }
  6304. }
  6305. }
  6306. }
  6307. };
  6308. /**
  6309. * Switch audio to headphone output.
  6310. */
  6311. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6312. var scene = this.scene;
  6313. this._headphone = true;
  6314. scene.mainSoundTrack.switchPanningModelToHRTF();
  6315. if (scene.soundTracks) {
  6316. for (var i = 0; i < scene.soundTracks.length; i++) {
  6317. scene.soundTracks[i].switchPanningModelToHRTF();
  6318. }
  6319. }
  6320. };
  6321. /**
  6322. * Switch audio to normal speakers.
  6323. */
  6324. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6325. var scene = this.scene;
  6326. this._headphone = false;
  6327. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6328. if (scene.soundTracks) {
  6329. for (var i = 0; i < scene.soundTracks.length; i++) {
  6330. scene.soundTracks[i].switchPanningModelToEqualPower();
  6331. }
  6332. }
  6333. };
  6334. AudioSceneComponent.prototype._afterRender = function () {
  6335. var scene = this.scene;
  6336. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6337. return;
  6338. }
  6339. var listeningCamera;
  6340. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6341. if (scene.activeCameras.length > 0) {
  6342. listeningCamera = scene.activeCameras[0];
  6343. }
  6344. else {
  6345. listeningCamera = scene.activeCamera;
  6346. }
  6347. if (listeningCamera && audioEngine.audioContext) {
  6348. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6349. // for VR cameras
  6350. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6351. listeningCamera = listeningCamera.rigCameras[0];
  6352. }
  6353. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6354. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6355. cameraDirection.normalize();
  6356. // To avoid some errors on GearVR
  6357. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6358. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6359. }
  6360. var i;
  6361. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6362. var sound = scene.mainSoundTrack.soundCollection[i];
  6363. if (sound.useCustomAttenuation) {
  6364. sound.updateDistanceFromListener();
  6365. }
  6366. }
  6367. if (scene.soundTracks) {
  6368. for (i = 0; i < scene.soundTracks.length; i++) {
  6369. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6370. sound = scene.soundTracks[i].soundCollection[j];
  6371. if (sound.useCustomAttenuation) {
  6372. sound.updateDistanceFromListener();
  6373. }
  6374. }
  6375. }
  6376. }
  6377. }
  6378. };
  6379. return AudioSceneComponent;
  6380. }());
  6381. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6382. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6383. if (!compo) {
  6384. compo = new AudioSceneComponent(scene);
  6385. scene._addComponent(compo);
  6386. }
  6387. };
  6388. /***/ }),
  6389. /***/ "./Audio/index.ts":
  6390. /*!************************!*\
  6391. !*** ./Audio/index.ts ***!
  6392. \************************/
  6393. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6395. "use strict";
  6396. __webpack_require__.r(__webpack_exports__);
  6397. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6399. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6401. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6403. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6405. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6407. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6409. /***/ }),
  6410. /***/ "./Audio/sound.ts":
  6411. /*!************************!*\
  6412. !*** ./Audio/sound.ts ***!
  6413. \************************/
  6414. /*! exports provided: Sound */
  6415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6416. "use strict";
  6417. __webpack_require__.r(__webpack_exports__);
  6418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6419. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6420. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6421. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6422. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6423. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6424. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6425. /**
  6426. * Defines a sound that can be played in the application.
  6427. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6429. */
  6430. var Sound = /** @class */ (function () {
  6431. /**
  6432. * Create a sound and attach it to a scene
  6433. * @param name Name of your sound
  6434. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6435. * @param scene defines the scene the sound belongs to
  6436. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6437. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6438. */
  6439. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6440. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6441. var _this = this;
  6442. /**
  6443. * Does the sound autoplay once loaded.
  6444. */
  6445. this.autoplay = false;
  6446. /**
  6447. * Does the sound loop after it finishes playing once.
  6448. */
  6449. this.loop = false;
  6450. /**
  6451. * Does the sound use a custom attenuation curve to simulate the falloff
  6452. * happening when the source gets further away from the camera.
  6453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6454. */
  6455. this.useCustomAttenuation = false;
  6456. /**
  6457. * Is this sound currently played.
  6458. */
  6459. this.isPlaying = false;
  6460. /**
  6461. * Is this sound currently paused.
  6462. */
  6463. this.isPaused = false;
  6464. /**
  6465. * Does this sound enables spatial sound.
  6466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6467. */
  6468. this.spatialSound = false;
  6469. /**
  6470. * Define the reference distance the sound should be heard perfectly.
  6471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6472. */
  6473. this.refDistance = 1;
  6474. /**
  6475. * Define the roll off factor of spatial sounds.
  6476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6477. */
  6478. this.rolloffFactor = 1;
  6479. /**
  6480. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6482. */
  6483. this.maxDistance = 100;
  6484. /**
  6485. * Define the distance attenuation model the sound will follow.
  6486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6487. */
  6488. this.distanceModel = "linear";
  6489. /**
  6490. * Observable event when the current playing sound finishes.
  6491. */
  6492. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6493. this._panningModel = "equalpower";
  6494. this._playbackRate = 1;
  6495. this._streaming = false;
  6496. this._startTime = 0;
  6497. this._startOffset = 0;
  6498. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6499. /** @hidden */
  6500. this._positionInEmitterSpace = false;
  6501. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6502. this._volume = 1;
  6503. this._isReadyToPlay = false;
  6504. this._isDirectional = false;
  6505. // Used if you'd like to create a directional sound.
  6506. // If not set, the sound will be omnidirectional
  6507. this._coneInnerAngle = 360;
  6508. this._coneOuterAngle = 360;
  6509. this._coneOuterGain = 0;
  6510. this._isOutputConnected = false;
  6511. this._urlType = "Unknown";
  6512. this.name = name;
  6513. this._scene = scene;
  6514. Sound._SceneComponentInitialization(scene);
  6515. this._readyToPlayCallback = readyToPlayCallback;
  6516. // Default custom attenuation function is a linear attenuation
  6517. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6518. if (currentDistance < maxDistance) {
  6519. return currentVolume * (1 - currentDistance / maxDistance);
  6520. }
  6521. else {
  6522. return 0;
  6523. }
  6524. };
  6525. if (options) {
  6526. this.autoplay = options.autoplay || false;
  6527. this.loop = options.loop || false;
  6528. // if volume === 0, we need another way to check this option
  6529. if (options.volume !== undefined) {
  6530. this._volume = options.volume;
  6531. }
  6532. this.spatialSound = options.spatialSound || false;
  6533. this.maxDistance = options.maxDistance || 100;
  6534. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6535. this.rolloffFactor = options.rolloffFactor || 1;
  6536. this.refDistance = options.refDistance || 1;
  6537. this.distanceModel = options.distanceModel || "linear";
  6538. this._playbackRate = options.playbackRate || 1;
  6539. this._streaming = options.streaming || false;
  6540. }
  6541. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6542. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6543. this._soundGain.gain.value = this._volume;
  6544. this._inputAudioNode = this._soundGain;
  6545. this._outputAudioNode = this._soundGain;
  6546. if (this.spatialSound) {
  6547. this._createSpatialParameters();
  6548. }
  6549. this._scene.mainSoundTrack.AddSound(this);
  6550. var validParameter = true;
  6551. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6552. if (urlOrArrayBuffer) {
  6553. try {
  6554. if (typeof (urlOrArrayBuffer) === "string") {
  6555. this._urlType = "String";
  6556. }
  6557. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6558. this._urlType = "ArrayBuffer";
  6559. }
  6560. else if (urlOrArrayBuffer instanceof MediaStream) {
  6561. this._urlType = "MediaStream";
  6562. }
  6563. else if (Array.isArray(urlOrArrayBuffer)) {
  6564. this._urlType = "Array";
  6565. }
  6566. var urls = [];
  6567. var codecSupportedFound = false;
  6568. switch (this._urlType) {
  6569. case "MediaStream":
  6570. this._streaming = true;
  6571. this._isReadyToPlay = true;
  6572. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6573. if (this.autoplay) {
  6574. this.play();
  6575. }
  6576. if (this._readyToPlayCallback) {
  6577. this._readyToPlayCallback();
  6578. }
  6579. break;
  6580. case "ArrayBuffer":
  6581. if (urlOrArrayBuffer.byteLength > 0) {
  6582. codecSupportedFound = true;
  6583. this._soundLoaded(urlOrArrayBuffer);
  6584. }
  6585. break;
  6586. case "String":
  6587. urls.push(urlOrArrayBuffer);
  6588. case "Array":
  6589. if (urls.length === 0) {
  6590. urls = urlOrArrayBuffer;
  6591. }
  6592. // If we found a supported format, we load it immediately and stop the loop
  6593. for (var i = 0; i < urls.length; i++) {
  6594. var url = urls[i];
  6595. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6596. codecSupportedFound = true;
  6597. }
  6598. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6599. codecSupportedFound = true;
  6600. }
  6601. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6602. codecSupportedFound = true;
  6603. }
  6604. if (url.indexOf("blob:") !== -1) {
  6605. codecSupportedFound = true;
  6606. }
  6607. if (codecSupportedFound) {
  6608. // Loading sound using XHR2
  6609. if (!this._streaming) {
  6610. this._scene._loadFile(url, function (data) {
  6611. _this._soundLoaded(data);
  6612. }, undefined, true, true, function (exception) {
  6613. if (exception) {
  6614. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6615. }
  6616. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6617. _this._scene.mainSoundTrack.RemoveSound(_this);
  6618. });
  6619. }
  6620. // Streaming sound using HTML5 Audio tag
  6621. else {
  6622. this._htmlAudioElement = new Audio(url);
  6623. this._htmlAudioElement.controls = false;
  6624. this._htmlAudioElement.loop = this.loop;
  6625. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6626. this._htmlAudioElement.preload = "auto";
  6627. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6628. _this._isReadyToPlay = true;
  6629. if (_this.autoplay) {
  6630. _this.play();
  6631. }
  6632. if (_this._readyToPlayCallback) {
  6633. _this._readyToPlayCallback();
  6634. }
  6635. });
  6636. document.body.appendChild(this._htmlAudioElement);
  6637. this._htmlAudioElement.load();
  6638. }
  6639. break;
  6640. }
  6641. }
  6642. break;
  6643. default:
  6644. validParameter = false;
  6645. break;
  6646. }
  6647. if (!validParameter) {
  6648. _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.");
  6649. }
  6650. else {
  6651. if (!codecSupportedFound) {
  6652. this._isReadyToPlay = true;
  6653. // Simulating a ready to play event to avoid breaking code path
  6654. if (this._readyToPlayCallback) {
  6655. window.setTimeout(function () {
  6656. if (_this._readyToPlayCallback) {
  6657. _this._readyToPlayCallback();
  6658. }
  6659. }, 1000);
  6660. }
  6661. }
  6662. }
  6663. }
  6664. catch (ex) {
  6665. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6666. this._scene.mainSoundTrack.RemoveSound(this);
  6667. }
  6668. }
  6669. }
  6670. else {
  6671. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6672. this._scene.mainSoundTrack.AddSound(this);
  6673. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6674. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6675. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6676. }
  6677. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6678. if (this._readyToPlayCallback) {
  6679. window.setTimeout(function () {
  6680. if (_this._readyToPlayCallback) {
  6681. _this._readyToPlayCallback();
  6682. }
  6683. }, 1000);
  6684. }
  6685. }
  6686. }
  6687. /**
  6688. * Release the sound and its associated resources
  6689. */
  6690. Sound.prototype.dispose = function () {
  6691. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6692. if (this.isPlaying) {
  6693. this.stop();
  6694. }
  6695. this._isReadyToPlay = false;
  6696. if (this.soundTrackId === -1) {
  6697. this._scene.mainSoundTrack.RemoveSound(this);
  6698. }
  6699. else if (this._scene.soundTracks) {
  6700. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6701. }
  6702. if (this._soundGain) {
  6703. this._soundGain.disconnect();
  6704. this._soundGain = null;
  6705. }
  6706. if (this._soundPanner) {
  6707. this._soundPanner.disconnect();
  6708. this._soundPanner = null;
  6709. }
  6710. if (this._soundSource) {
  6711. this._soundSource.disconnect();
  6712. this._soundSource = null;
  6713. }
  6714. this._audioBuffer = null;
  6715. if (this._htmlAudioElement) {
  6716. this._htmlAudioElement.pause();
  6717. this._htmlAudioElement.src = "";
  6718. document.body.removeChild(this._htmlAudioElement);
  6719. }
  6720. if (this._streamingSource) {
  6721. this._streamingSource.disconnect();
  6722. }
  6723. if (this._connectedTransformNode && this._registerFunc) {
  6724. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6725. this._connectedTransformNode = null;
  6726. }
  6727. }
  6728. };
  6729. /**
  6730. * Gets if the sounds is ready to be played or not.
  6731. * @returns true if ready, otherwise false
  6732. */
  6733. Sound.prototype.isReady = function () {
  6734. return this._isReadyToPlay;
  6735. };
  6736. Sound.prototype._soundLoaded = function (audioData) {
  6737. var _this = this;
  6738. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6739. return;
  6740. }
  6741. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6742. _this._audioBuffer = buffer;
  6743. _this._isReadyToPlay = true;
  6744. if (_this.autoplay) {
  6745. _this.play();
  6746. }
  6747. if (_this._readyToPlayCallback) {
  6748. _this._readyToPlayCallback();
  6749. }
  6750. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6751. };
  6752. /**
  6753. * Sets the data of the sound from an audiobuffer
  6754. * @param audioBuffer The audioBuffer containing the data
  6755. */
  6756. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6757. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6758. this._audioBuffer = audioBuffer;
  6759. this._isReadyToPlay = true;
  6760. }
  6761. };
  6762. /**
  6763. * Updates the current sounds options such as maxdistance, loop...
  6764. * @param options A JSON object containing values named as the object properties
  6765. */
  6766. Sound.prototype.updateOptions = function (options) {
  6767. if (options) {
  6768. this.loop = options.loop || this.loop;
  6769. this.maxDistance = options.maxDistance || this.maxDistance;
  6770. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6771. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6772. this.refDistance = options.refDistance || this.refDistance;
  6773. this.distanceModel = options.distanceModel || this.distanceModel;
  6774. this._playbackRate = options.playbackRate || this._playbackRate;
  6775. this._updateSpatialParameters();
  6776. if (this.isPlaying) {
  6777. if (this._streaming && this._htmlAudioElement) {
  6778. this._htmlAudioElement.playbackRate = this._playbackRate;
  6779. }
  6780. else {
  6781. if (this._soundSource) {
  6782. this._soundSource.playbackRate.value = this._playbackRate;
  6783. }
  6784. }
  6785. }
  6786. }
  6787. };
  6788. Sound.prototype._createSpatialParameters = function () {
  6789. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6790. if (this._scene.headphone) {
  6791. this._panningModel = "HRTF";
  6792. }
  6793. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6794. this._updateSpatialParameters();
  6795. this._soundPanner.connect(this._outputAudioNode);
  6796. this._inputAudioNode = this._soundPanner;
  6797. }
  6798. };
  6799. Sound.prototype._updateSpatialParameters = function () {
  6800. if (this.spatialSound && this._soundPanner) {
  6801. if (this.useCustomAttenuation) {
  6802. // Tricks to disable in a way embedded Web Audio attenuation
  6803. this._soundPanner.distanceModel = "linear";
  6804. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6805. this._soundPanner.refDistance = 1;
  6806. this._soundPanner.rolloffFactor = 1;
  6807. this._soundPanner.panningModel = this._panningModel;
  6808. }
  6809. else {
  6810. this._soundPanner.distanceModel = this.distanceModel;
  6811. this._soundPanner.maxDistance = this.maxDistance;
  6812. this._soundPanner.refDistance = this.refDistance;
  6813. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6814. this._soundPanner.panningModel = this._panningModel;
  6815. }
  6816. }
  6817. };
  6818. /**
  6819. * Switch the panning model to HRTF:
  6820. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6822. */
  6823. Sound.prototype.switchPanningModelToHRTF = function () {
  6824. this._panningModel = "HRTF";
  6825. this._switchPanningModel();
  6826. };
  6827. /**
  6828. * Switch the panning model to Equal Power:
  6829. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6831. */
  6832. Sound.prototype.switchPanningModelToEqualPower = function () {
  6833. this._panningModel = "equalpower";
  6834. this._switchPanningModel();
  6835. };
  6836. Sound.prototype._switchPanningModel = function () {
  6837. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6838. this._soundPanner.panningModel = this._panningModel;
  6839. }
  6840. };
  6841. /**
  6842. * Connect this sound to a sound track audio node like gain...
  6843. * @param soundTrackAudioNode the sound track audio node to connect to
  6844. */
  6845. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6846. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6847. if (this._isOutputConnected) {
  6848. this._outputAudioNode.disconnect();
  6849. }
  6850. this._outputAudioNode.connect(soundTrackAudioNode);
  6851. this._isOutputConnected = true;
  6852. }
  6853. };
  6854. /**
  6855. * Transform this sound into a directional source
  6856. * @param coneInnerAngle Size of the inner cone in degree
  6857. * @param coneOuterAngle Size of the outer cone in degree
  6858. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6859. */
  6860. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6861. if (coneOuterAngle < coneInnerAngle) {
  6862. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6863. return;
  6864. }
  6865. this._coneInnerAngle = coneInnerAngle;
  6866. this._coneOuterAngle = coneOuterAngle;
  6867. this._coneOuterGain = coneOuterGain;
  6868. this._isDirectional = true;
  6869. if (this.isPlaying && this.loop) {
  6870. this.stop();
  6871. this.play();
  6872. }
  6873. };
  6874. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6875. /**
  6876. * Gets or sets the inner angle for the directional cone.
  6877. */
  6878. get: function () {
  6879. return this._coneInnerAngle;
  6880. },
  6881. /**
  6882. * Gets or sets the inner angle for the directional cone.
  6883. */
  6884. set: function (value) {
  6885. if (value != this._coneInnerAngle) {
  6886. if (this._coneOuterAngle < value) {
  6887. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6888. return;
  6889. }
  6890. this._coneInnerAngle = value;
  6891. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6892. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6893. }
  6894. }
  6895. },
  6896. enumerable: true,
  6897. configurable: true
  6898. });
  6899. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6900. /**
  6901. * Gets or sets the outer angle for the directional cone.
  6902. */
  6903. get: function () {
  6904. return this._coneOuterAngle;
  6905. },
  6906. /**
  6907. * Gets or sets the outer angle for the directional cone.
  6908. */
  6909. set: function (value) {
  6910. if (value != this._coneOuterAngle) {
  6911. if (value < this._coneInnerAngle) {
  6912. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6913. return;
  6914. }
  6915. this._coneOuterAngle = value;
  6916. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6917. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6918. }
  6919. }
  6920. },
  6921. enumerable: true,
  6922. configurable: true
  6923. });
  6924. /**
  6925. * Sets the position of the emitter if spatial sound is enabled
  6926. * @param newPosition Defines the new posisiton
  6927. */
  6928. Sound.prototype.setPosition = function (newPosition) {
  6929. this._position = newPosition;
  6930. 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)) {
  6931. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6932. }
  6933. };
  6934. /**
  6935. * Sets the local direction of the emitter if spatial sound is enabled
  6936. * @param newLocalDirection Defines the new local direction
  6937. */
  6938. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6939. this._localDirection = newLocalDirection;
  6940. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6941. this._updateDirection();
  6942. }
  6943. };
  6944. Sound.prototype._updateDirection = function () {
  6945. if (!this._connectedTransformNode || !this._soundPanner) {
  6946. return;
  6947. }
  6948. var mat = this._connectedTransformNode.getWorldMatrix();
  6949. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6950. direction.normalize();
  6951. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6952. };
  6953. /** @hidden */
  6954. Sound.prototype.updateDistanceFromListener = function () {
  6955. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6956. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6957. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6958. }
  6959. };
  6960. /**
  6961. * Sets a new custom attenuation function for the sound.
  6962. * @param callback Defines the function used for the attenuation
  6963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6964. */
  6965. Sound.prototype.setAttenuationFunction = function (callback) {
  6966. this._customAttenuationFunction = callback;
  6967. };
  6968. /**
  6969. * Play the sound
  6970. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6971. * @param offset (optional) Start the sound setting it at a specific time
  6972. */
  6973. Sound.prototype.play = function (time, offset) {
  6974. var _this = this;
  6975. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6976. try {
  6977. if (this._startOffset < 0) {
  6978. time = -this._startOffset;
  6979. this._startOffset = 0;
  6980. }
  6981. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6982. if (!this._soundSource || !this._streamingSource) {
  6983. if (this.spatialSound && this._soundPanner) {
  6984. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6985. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6986. }
  6987. if (this._isDirectional) {
  6988. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6989. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6990. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6991. if (this._connectedTransformNode) {
  6992. this._updateDirection();
  6993. }
  6994. else {
  6995. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6996. }
  6997. }
  6998. }
  6999. }
  7000. if (this._streaming) {
  7001. if (!this._streamingSource) {
  7002. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  7003. this._htmlAudioElement.onended = function () { _this._onended(); };
  7004. this._htmlAudioElement.playbackRate = this._playbackRate;
  7005. }
  7006. this._streamingSource.disconnect();
  7007. this._streamingSource.connect(this._inputAudioNode);
  7008. if (this._htmlAudioElement) {
  7009. // required to manage properly the new suspended default state of Chrome
  7010. // When the option 'streaming: true' is used, we need first to wait for
  7011. // the audio engine to be unlocked by a user gesture before trying to play
  7012. // an HTML Audio elememt
  7013. var tryToPlay = function () {
  7014. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7015. var playPromise = _this._htmlAudioElement.play();
  7016. // In browsers that don’t yet support this functionality,
  7017. // playPromise won’t be defined.
  7018. if (playPromise !== undefined) {
  7019. playPromise.catch(function (error) {
  7020. // Automatic playback failed.
  7021. // Waiting for the audio engine to be unlocked by user click on unmute
  7022. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7023. if (_this.loop || _this.autoplay) {
  7024. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7025. }
  7026. });
  7027. }
  7028. }
  7029. else {
  7030. if (_this.loop || _this.autoplay) {
  7031. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7032. }
  7033. }
  7034. };
  7035. tryToPlay();
  7036. }
  7037. }
  7038. else {
  7039. var tryToPlay = function () {
  7040. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7041. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7042. _this._soundSource.buffer = _this._audioBuffer;
  7043. _this._soundSource.connect(_this._inputAudioNode);
  7044. _this._soundSource.loop = _this.loop;
  7045. _this._soundSource.playbackRate.value = _this._playbackRate;
  7046. _this._soundSource.onended = function () { _this._onended(); };
  7047. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7048. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7049. }
  7050. };
  7051. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7052. // Wait a bit for FF as context seems late to be ready.
  7053. setTimeout(function () {
  7054. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7055. // Automatic playback failed.
  7056. // Waiting for the audio engine to be unlocked by user click on unmute
  7057. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7058. if (_this.loop || _this.autoplay) {
  7059. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7060. }
  7061. }
  7062. else {
  7063. tryToPlay();
  7064. }
  7065. }, 500);
  7066. }
  7067. else {
  7068. tryToPlay();
  7069. }
  7070. }
  7071. this._startTime = startTime;
  7072. this.isPlaying = true;
  7073. this.isPaused = false;
  7074. }
  7075. catch (ex) {
  7076. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7077. }
  7078. }
  7079. };
  7080. Sound.prototype._onended = function () {
  7081. this.isPlaying = false;
  7082. if (this.onended) {
  7083. this.onended();
  7084. }
  7085. this.onEndedObservable.notifyObservers(this);
  7086. };
  7087. /**
  7088. * Stop the sound
  7089. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7090. */
  7091. Sound.prototype.stop = function (time) {
  7092. var _this = this;
  7093. if (this.isPlaying) {
  7094. if (this._streaming) {
  7095. if (this._htmlAudioElement) {
  7096. this._htmlAudioElement.pause();
  7097. // Test needed for Firefox or it will generate an Invalid State Error
  7098. if (this._htmlAudioElement.currentTime > 0) {
  7099. this._htmlAudioElement.currentTime = 0;
  7100. }
  7101. }
  7102. else {
  7103. this._streamingSource.disconnect();
  7104. }
  7105. this.isPlaying = false;
  7106. }
  7107. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7108. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7109. this._soundSource.stop(stopTime);
  7110. this._soundSource.onended = function () { _this.isPlaying = false; };
  7111. if (!this.isPaused) {
  7112. this._startOffset = 0;
  7113. }
  7114. }
  7115. }
  7116. };
  7117. /**
  7118. * Put the sound in pause
  7119. */
  7120. Sound.prototype.pause = function () {
  7121. if (this.isPlaying) {
  7122. this.isPaused = true;
  7123. if (this._streaming) {
  7124. if (this._htmlAudioElement) {
  7125. this._htmlAudioElement.pause();
  7126. }
  7127. else {
  7128. this._streamingSource.disconnect();
  7129. }
  7130. }
  7131. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7132. this.stop(0);
  7133. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7134. }
  7135. }
  7136. };
  7137. /**
  7138. * Sets a dedicated volume for this sounds
  7139. * @param newVolume Define the new volume of the sound
  7140. * @param time Define in how long the sound should be at this value
  7141. */
  7142. Sound.prototype.setVolume = function (newVolume, time) {
  7143. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7144. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7145. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7146. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7147. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7148. }
  7149. else {
  7150. this._soundGain.gain.value = newVolume;
  7151. }
  7152. }
  7153. this._volume = newVolume;
  7154. };
  7155. /**
  7156. * Set the sound play back rate
  7157. * @param newPlaybackRate Define the playback rate the sound should be played at
  7158. */
  7159. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7160. this._playbackRate = newPlaybackRate;
  7161. if (this.isPlaying) {
  7162. if (this._streaming && this._htmlAudioElement) {
  7163. this._htmlAudioElement.playbackRate = this._playbackRate;
  7164. }
  7165. else if (this._soundSource) {
  7166. this._soundSource.playbackRate.value = this._playbackRate;
  7167. }
  7168. }
  7169. };
  7170. /**
  7171. * Gets the volume of the sound.
  7172. * @returns the volume of the sound
  7173. */
  7174. Sound.prototype.getVolume = function () {
  7175. return this._volume;
  7176. };
  7177. /**
  7178. * Attach the sound to a dedicated mesh
  7179. * @param transformNode The transform node to connect the sound with
  7180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7181. */
  7182. Sound.prototype.attachToMesh = function (transformNode) {
  7183. var _this = this;
  7184. if (this._connectedTransformNode && this._registerFunc) {
  7185. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7186. this._registerFunc = null;
  7187. }
  7188. this._connectedTransformNode = transformNode;
  7189. if (!this.spatialSound) {
  7190. this.spatialSound = true;
  7191. this._createSpatialParameters();
  7192. if (this.isPlaying && this.loop) {
  7193. this.stop();
  7194. this.play();
  7195. }
  7196. }
  7197. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7198. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7199. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7200. };
  7201. /**
  7202. * Detach the sound from the previously attached mesh
  7203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7204. */
  7205. Sound.prototype.detachFromMesh = function () {
  7206. if (this._connectedTransformNode && this._registerFunc) {
  7207. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7208. this._registerFunc = null;
  7209. this._connectedTransformNode = null;
  7210. }
  7211. };
  7212. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7213. if (!node.getBoundingInfo) {
  7214. return;
  7215. }
  7216. var mesh = node;
  7217. if (this._positionInEmitterSpace) {
  7218. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7219. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7220. }
  7221. else {
  7222. var boundingInfo = mesh.getBoundingInfo();
  7223. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7224. }
  7225. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7226. this._updateDirection();
  7227. }
  7228. };
  7229. /**
  7230. * Clone the current sound in the scene.
  7231. * @returns the new sound clone
  7232. */
  7233. Sound.prototype.clone = function () {
  7234. var _this = this;
  7235. if (!this._streaming) {
  7236. var setBufferAndRun = function () {
  7237. if (_this._isReadyToPlay) {
  7238. clonedSound._audioBuffer = _this.getAudioBuffer();
  7239. clonedSound._isReadyToPlay = true;
  7240. if (clonedSound.autoplay) {
  7241. clonedSound.play();
  7242. }
  7243. }
  7244. else {
  7245. window.setTimeout(setBufferAndRun, 300);
  7246. }
  7247. };
  7248. var currentOptions = {
  7249. autoplay: this.autoplay, loop: this.loop,
  7250. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7251. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7252. refDistance: this.refDistance, distanceModel: this.distanceModel
  7253. };
  7254. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7255. if (this.useCustomAttenuation) {
  7256. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7257. }
  7258. clonedSound.setPosition(this._position);
  7259. clonedSound.setPlaybackRate(this._playbackRate);
  7260. setBufferAndRun();
  7261. return clonedSound;
  7262. }
  7263. // Can't clone a streaming sound
  7264. else {
  7265. return null;
  7266. }
  7267. };
  7268. /**
  7269. * Gets the current underlying audio buffer containing the data
  7270. * @returns the audio buffer
  7271. */
  7272. Sound.prototype.getAudioBuffer = function () {
  7273. return this._audioBuffer;
  7274. };
  7275. /**
  7276. * Serializes the Sound in a JSON representation
  7277. * @returns the JSON representation of the sound
  7278. */
  7279. Sound.prototype.serialize = function () {
  7280. var serializationObject = {
  7281. name: this.name,
  7282. url: this.name,
  7283. autoplay: this.autoplay,
  7284. loop: this.loop,
  7285. volume: this._volume,
  7286. spatialSound: this.spatialSound,
  7287. maxDistance: this.maxDistance,
  7288. rolloffFactor: this.rolloffFactor,
  7289. refDistance: this.refDistance,
  7290. distanceModel: this.distanceModel,
  7291. playbackRate: this._playbackRate,
  7292. panningModel: this._panningModel,
  7293. soundTrackId: this.soundTrackId
  7294. };
  7295. if (this.spatialSound) {
  7296. if (this._connectedTransformNode) {
  7297. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7298. }
  7299. serializationObject.position = this._position.asArray();
  7300. serializationObject.refDistance = this.refDistance;
  7301. serializationObject.distanceModel = this.distanceModel;
  7302. serializationObject.isDirectional = this._isDirectional;
  7303. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7304. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7305. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7306. serializationObject.coneOuterGain = this._coneOuterGain;
  7307. }
  7308. return serializationObject;
  7309. };
  7310. /**
  7311. * Parse a JSON representation of a sound to innstantiate in a given scene
  7312. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7313. * @param scene Define the scene the new parsed sound should be created in
  7314. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7315. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7316. * @returns the newly parsed sound
  7317. */
  7318. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7319. var soundName = parsedSound.name;
  7320. var soundUrl;
  7321. if (parsedSound.url) {
  7322. soundUrl = rootUrl + parsedSound.url;
  7323. }
  7324. else {
  7325. soundUrl = rootUrl + soundName;
  7326. }
  7327. var options = {
  7328. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7329. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7330. rolloffFactor: parsedSound.rolloffFactor,
  7331. refDistance: parsedSound.refDistance,
  7332. distanceModel: parsedSound.distanceModel,
  7333. playbackRate: parsedSound.playbackRate
  7334. };
  7335. var newSound;
  7336. if (!sourceSound) {
  7337. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7338. scene._addPendingData(newSound);
  7339. }
  7340. else {
  7341. var setBufferAndRun = function () {
  7342. if (sourceSound._isReadyToPlay) {
  7343. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7344. newSound._isReadyToPlay = true;
  7345. if (newSound.autoplay) {
  7346. newSound.play();
  7347. }
  7348. }
  7349. else {
  7350. window.setTimeout(setBufferAndRun, 300);
  7351. }
  7352. };
  7353. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7354. setBufferAndRun();
  7355. }
  7356. if (parsedSound.position) {
  7357. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7358. newSound.setPosition(soundPosition);
  7359. }
  7360. if (parsedSound.isDirectional) {
  7361. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7362. if (parsedSound.localDirectionToMesh) {
  7363. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7364. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7365. }
  7366. }
  7367. if (parsedSound.connectedMeshId) {
  7368. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7369. if (connectedMesh) {
  7370. newSound.attachToMesh(connectedMesh);
  7371. }
  7372. }
  7373. return newSound;
  7374. };
  7375. /** @hidden */
  7376. Sound._SceneComponentInitialization = function (_) {
  7377. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7378. };
  7379. return Sound;
  7380. }());
  7381. /***/ }),
  7382. /***/ "./Audio/soundTrack.ts":
  7383. /*!*****************************!*\
  7384. !*** ./Audio/soundTrack.ts ***!
  7385. \*****************************/
  7386. /*! exports provided: SoundTrack */
  7387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7388. "use strict";
  7389. __webpack_require__.r(__webpack_exports__);
  7390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7391. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7392. /**
  7393. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7394. * It will be also used in a future release to apply effects on a specific track.
  7395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7396. */
  7397. var SoundTrack = /** @class */ (function () {
  7398. /**
  7399. * Creates a new sound track.
  7400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7401. * @param scene Define the scene the sound track belongs to
  7402. * @param options
  7403. */
  7404. function SoundTrack(scene, options) {
  7405. if (options === void 0) { options = {}; }
  7406. /**
  7407. * The unique identifier of the sound track in the scene.
  7408. */
  7409. this.id = -1;
  7410. this._isMainTrack = false;
  7411. this._isInitialized = false;
  7412. this._scene = scene;
  7413. this.soundCollection = new Array();
  7414. this._options = options;
  7415. if (!this._isMainTrack && this._scene.soundTracks) {
  7416. this._scene.soundTracks.push(this);
  7417. this.id = this._scene.soundTracks.length - 1;
  7418. }
  7419. }
  7420. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7421. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7422. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7423. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7424. if (this._options) {
  7425. if (this._options.volume) {
  7426. this._outputAudioNode.gain.value = this._options.volume;
  7427. }
  7428. if (this._options.mainTrack) {
  7429. this._isMainTrack = this._options.mainTrack;
  7430. }
  7431. }
  7432. this._isInitialized = true;
  7433. }
  7434. };
  7435. /**
  7436. * Release the sound track and its associated resources
  7437. */
  7438. SoundTrack.prototype.dispose = function () {
  7439. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7440. if (this._connectedAnalyser) {
  7441. this._connectedAnalyser.stopDebugCanvas();
  7442. }
  7443. while (this.soundCollection.length) {
  7444. this.soundCollection[0].dispose();
  7445. }
  7446. if (this._outputAudioNode) {
  7447. this._outputAudioNode.disconnect();
  7448. }
  7449. this._outputAudioNode = null;
  7450. }
  7451. };
  7452. /**
  7453. * Adds a sound to this sound track
  7454. * @param sound define the cound to add
  7455. * @ignoreNaming
  7456. */
  7457. SoundTrack.prototype.AddSound = function (sound) {
  7458. if (!this._isInitialized) {
  7459. this._initializeSoundTrackAudioGraph();
  7460. }
  7461. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7462. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7463. }
  7464. if (sound.soundTrackId) {
  7465. if (sound.soundTrackId === -1) {
  7466. this._scene.mainSoundTrack.RemoveSound(sound);
  7467. }
  7468. else if (this._scene.soundTracks) {
  7469. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7470. }
  7471. }
  7472. this.soundCollection.push(sound);
  7473. sound.soundTrackId = this.id;
  7474. };
  7475. /**
  7476. * Removes a sound to this sound track
  7477. * @param sound define the cound to remove
  7478. * @ignoreNaming
  7479. */
  7480. SoundTrack.prototype.RemoveSound = function (sound) {
  7481. var index = this.soundCollection.indexOf(sound);
  7482. if (index !== -1) {
  7483. this.soundCollection.splice(index, 1);
  7484. }
  7485. };
  7486. /**
  7487. * Set a global volume for the full sound track.
  7488. * @param newVolume Define the new volume of the sound track
  7489. */
  7490. SoundTrack.prototype.setVolume = function (newVolume) {
  7491. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7492. this._outputAudioNode.gain.value = newVolume;
  7493. }
  7494. };
  7495. /**
  7496. * Switch the panning model to HRTF:
  7497. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7499. */
  7500. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7501. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7502. for (var i = 0; i < this.soundCollection.length; i++) {
  7503. this.soundCollection[i].switchPanningModelToHRTF();
  7504. }
  7505. }
  7506. };
  7507. /**
  7508. * Switch the panning model to Equal Power:
  7509. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7511. */
  7512. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7513. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7514. for (var i = 0; i < this.soundCollection.length; i++) {
  7515. this.soundCollection[i].switchPanningModelToEqualPower();
  7516. }
  7517. }
  7518. };
  7519. /**
  7520. * Connect the sound track to an audio analyser allowing some amazing
  7521. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7523. * @param analyser The analyser to connect to the engine
  7524. */
  7525. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7526. if (this._connectedAnalyser) {
  7527. this._connectedAnalyser.stopDebugCanvas();
  7528. }
  7529. this._connectedAnalyser = analyser;
  7530. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7531. this._outputAudioNode.disconnect();
  7532. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7533. }
  7534. };
  7535. return SoundTrack;
  7536. }());
  7537. /***/ }),
  7538. /***/ "./Audio/weightedsound.ts":
  7539. /*!********************************!*\
  7540. !*** ./Audio/weightedsound.ts ***!
  7541. \********************************/
  7542. /*! exports provided: WeightedSound */
  7543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7544. "use strict";
  7545. __webpack_require__.r(__webpack_exports__);
  7546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7547. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7548. /**
  7549. * Wraps one or more Sound objects and selects one with random weight for playback.
  7550. */
  7551. var WeightedSound = /** @class */ (function () {
  7552. /**
  7553. * Creates a new WeightedSound from the list of sounds given.
  7554. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7555. * @param sounds Array of Sounds that will be selected from.
  7556. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7557. */
  7558. function WeightedSound(loop, sounds, weights) {
  7559. var _this = this;
  7560. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7561. this.loop = false;
  7562. this._coneInnerAngle = 360;
  7563. this._coneOuterAngle = 360;
  7564. this._volume = 1;
  7565. /** A Sound is currently playing. */
  7566. this.isPlaying = false;
  7567. /** A Sound is currently paused. */
  7568. this.isPaused = false;
  7569. this._sounds = [];
  7570. this._weights = [];
  7571. if (sounds.length !== weights.length) {
  7572. throw new Error('Sounds length does not equal weights length');
  7573. }
  7574. this.loop = loop;
  7575. this._weights = weights;
  7576. // Normalize the weights
  7577. var weightSum = 0;
  7578. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7579. var weight = weights_1[_i];
  7580. weightSum += weight;
  7581. }
  7582. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7583. for (var i = 0; i < this._weights.length; i++) {
  7584. this._weights[i] *= invWeightSum;
  7585. }
  7586. this._sounds = sounds;
  7587. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7588. var sound = _b[_a];
  7589. sound.onEndedObservable.add(function () { _this._onended(); });
  7590. }
  7591. }
  7592. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7593. /**
  7594. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7595. */
  7596. get: function () {
  7597. return this._coneInnerAngle;
  7598. },
  7599. /**
  7600. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7601. */
  7602. set: function (value) {
  7603. if (value !== this._coneInnerAngle) {
  7604. if (this._coneOuterAngle < value) {
  7605. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7606. return;
  7607. }
  7608. this._coneInnerAngle = value;
  7609. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7610. var sound = _a[_i];
  7611. sound.directionalConeInnerAngle = value;
  7612. }
  7613. }
  7614. },
  7615. enumerable: true,
  7616. configurable: true
  7617. });
  7618. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7619. /**
  7620. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7621. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7622. */
  7623. get: function () {
  7624. return this._coneOuterAngle;
  7625. },
  7626. /**
  7627. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7628. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7629. */
  7630. set: function (value) {
  7631. if (value !== this._coneOuterAngle) {
  7632. if (value < this._coneInnerAngle) {
  7633. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7634. return;
  7635. }
  7636. this._coneOuterAngle = value;
  7637. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7638. var sound = _a[_i];
  7639. sound.directionalConeOuterAngle = value;
  7640. }
  7641. }
  7642. },
  7643. enumerable: true,
  7644. configurable: true
  7645. });
  7646. Object.defineProperty(WeightedSound.prototype, "volume", {
  7647. /**
  7648. * Playback volume.
  7649. */
  7650. get: function () {
  7651. return this._volume;
  7652. },
  7653. /**
  7654. * Playback volume.
  7655. */
  7656. set: function (value) {
  7657. if (value !== this._volume) {
  7658. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7659. var sound = _a[_i];
  7660. sound.setVolume(value);
  7661. }
  7662. }
  7663. },
  7664. enumerable: true,
  7665. configurable: true
  7666. });
  7667. WeightedSound.prototype._onended = function () {
  7668. if (this._currentIndex !== undefined) {
  7669. this._sounds[this._currentIndex].autoplay = false;
  7670. }
  7671. if (this.loop && this.isPlaying) {
  7672. this.play();
  7673. }
  7674. else {
  7675. this.isPlaying = false;
  7676. }
  7677. };
  7678. /**
  7679. * Suspend playback
  7680. */
  7681. WeightedSound.prototype.pause = function () {
  7682. this.isPaused = true;
  7683. if (this._currentIndex !== undefined) {
  7684. this._sounds[this._currentIndex].pause();
  7685. }
  7686. };
  7687. /**
  7688. * Stop playback
  7689. */
  7690. WeightedSound.prototype.stop = function () {
  7691. this.isPlaying = false;
  7692. if (this._currentIndex !== undefined) {
  7693. this._sounds[this._currentIndex].stop();
  7694. }
  7695. };
  7696. /**
  7697. * Start playback.
  7698. * @param startOffset Position the clip head at a specific time in seconds.
  7699. */
  7700. WeightedSound.prototype.play = function (startOffset) {
  7701. if (!this.isPaused) {
  7702. this.stop();
  7703. var randomValue = Math.random();
  7704. var total = 0;
  7705. for (var i = 0; i < this._weights.length; i++) {
  7706. total += this._weights[i];
  7707. if (randomValue <= total) {
  7708. this._currentIndex = i;
  7709. break;
  7710. }
  7711. }
  7712. }
  7713. var sound = this._sounds[this._currentIndex];
  7714. if (sound.isReady()) {
  7715. sound.play(0, this.isPaused ? undefined : startOffset);
  7716. }
  7717. else {
  7718. sound.autoplay = true;
  7719. }
  7720. this.isPlaying = true;
  7721. this.isPaused = false;
  7722. };
  7723. return WeightedSound;
  7724. }());
  7725. /***/ }),
  7726. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7727. /*!***************************************************!*\
  7728. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7729. \***************************************************/
  7730. /*! exports provided: AutoRotationBehavior */
  7731. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7732. "use strict";
  7733. __webpack_require__.r(__webpack_exports__);
  7734. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7735. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7736. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7737. /**
  7738. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7739. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7740. */
  7741. var AutoRotationBehavior = /** @class */ (function () {
  7742. function AutoRotationBehavior() {
  7743. this._zoomStopsAnimation = false;
  7744. this._idleRotationSpeed = 0.05;
  7745. this._idleRotationWaitTime = 2000;
  7746. this._idleRotationSpinupTime = 2000;
  7747. this._isPointerDown = false;
  7748. this._lastFrameTime = null;
  7749. this._lastInteractionTime = -Infinity;
  7750. this._cameraRotationSpeed = 0;
  7751. this._lastFrameRadius = 0;
  7752. }
  7753. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7754. /**
  7755. * Gets the name of the behavior.
  7756. */
  7757. get: function () {
  7758. return "AutoRotation";
  7759. },
  7760. enumerable: true,
  7761. configurable: true
  7762. });
  7763. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7764. /**
  7765. * Gets the flag that indicates if user zooming should stop animation.
  7766. */
  7767. get: function () {
  7768. return this._zoomStopsAnimation;
  7769. },
  7770. /**
  7771. * Sets the flag that indicates if user zooming should stop animation.
  7772. */
  7773. set: function (flag) {
  7774. this._zoomStopsAnimation = flag;
  7775. },
  7776. enumerable: true,
  7777. configurable: true
  7778. });
  7779. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7780. /**
  7781. * Gets the default speed at which the camera rotates around the model.
  7782. */
  7783. get: function () {
  7784. return this._idleRotationSpeed;
  7785. },
  7786. /**
  7787. * Sets the default speed at which the camera rotates around the model.
  7788. */
  7789. set: function (speed) {
  7790. this._idleRotationSpeed = speed;
  7791. },
  7792. enumerable: true,
  7793. configurable: true
  7794. });
  7795. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7796. /**
  7797. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7798. */
  7799. get: function () {
  7800. return this._idleRotationWaitTime;
  7801. },
  7802. /**
  7803. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7804. */
  7805. set: function (time) {
  7806. this._idleRotationWaitTime = time;
  7807. },
  7808. enumerable: true,
  7809. configurable: true
  7810. });
  7811. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7812. /**
  7813. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7814. */
  7815. get: function () {
  7816. return this._idleRotationSpinupTime;
  7817. },
  7818. /**
  7819. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7820. */
  7821. set: function (time) {
  7822. this._idleRotationSpinupTime = time;
  7823. },
  7824. enumerable: true,
  7825. configurable: true
  7826. });
  7827. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7828. /**
  7829. * Gets a value indicating if the camera is currently rotating because of this behavior
  7830. */
  7831. get: function () {
  7832. return Math.abs(this._cameraRotationSpeed) > 0;
  7833. },
  7834. enumerable: true,
  7835. configurable: true
  7836. });
  7837. /**
  7838. * Initializes the behavior.
  7839. */
  7840. AutoRotationBehavior.prototype.init = function () {
  7841. // Do notihng
  7842. };
  7843. /**
  7844. * Attaches the behavior to its arc rotate camera.
  7845. * @param camera Defines the camera to attach the behavior to
  7846. */
  7847. AutoRotationBehavior.prototype.attach = function (camera) {
  7848. var _this = this;
  7849. this._attachedCamera = camera;
  7850. var scene = this._attachedCamera.getScene();
  7851. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7852. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7853. _this._isPointerDown = true;
  7854. return;
  7855. }
  7856. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7857. _this._isPointerDown = false;
  7858. }
  7859. });
  7860. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7861. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7862. var dt = 0;
  7863. if (_this._lastFrameTime != null) {
  7864. dt = now - _this._lastFrameTime;
  7865. }
  7866. _this._lastFrameTime = now;
  7867. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7868. _this._applyUserInteraction();
  7869. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7870. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7871. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7872. // Step camera rotation by rotation speed
  7873. if (_this._attachedCamera) {
  7874. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7875. }
  7876. });
  7877. };
  7878. /**
  7879. * Detaches the behavior from its current arc rotate camera.
  7880. */
  7881. AutoRotationBehavior.prototype.detach = function () {
  7882. if (!this._attachedCamera) {
  7883. return;
  7884. }
  7885. var scene = this._attachedCamera.getScene();
  7886. if (this._onPrePointerObservableObserver) {
  7887. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7888. }
  7889. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7890. this._attachedCamera = null;
  7891. };
  7892. /**
  7893. * Returns true if user is scrolling.
  7894. * @return true if user is scrolling.
  7895. */
  7896. AutoRotationBehavior.prototype._userIsZooming = function () {
  7897. if (!this._attachedCamera) {
  7898. return false;
  7899. }
  7900. return this._attachedCamera.inertialRadiusOffset !== 0;
  7901. };
  7902. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7903. if (!this._attachedCamera) {
  7904. return false;
  7905. }
  7906. var zoomHasHitLimit = false;
  7907. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7908. zoomHasHitLimit = true;
  7909. }
  7910. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7911. this._lastFrameRadius = this._attachedCamera.radius;
  7912. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7913. };
  7914. /**
  7915. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7916. */
  7917. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7918. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7919. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7920. }
  7921. };
  7922. // Tools
  7923. AutoRotationBehavior.prototype._userIsMoving = function () {
  7924. if (!this._attachedCamera) {
  7925. return false;
  7926. }
  7927. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7928. this._attachedCamera.inertialBetaOffset !== 0 ||
  7929. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7930. this._attachedCamera.inertialPanningX !== 0 ||
  7931. this._attachedCamera.inertialPanningY !== 0 ||
  7932. this._isPointerDown;
  7933. };
  7934. return AutoRotationBehavior;
  7935. }());
  7936. /***/ }),
  7937. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7938. /*!***********************************************!*\
  7939. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7940. \***********************************************/
  7941. /*! exports provided: BouncingBehavior */
  7942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7943. "use strict";
  7944. __webpack_require__.r(__webpack_exports__);
  7945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7946. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7947. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7948. /**
  7949. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7950. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7951. */
  7952. var BouncingBehavior = /** @class */ (function () {
  7953. function BouncingBehavior() {
  7954. /**
  7955. * The duration of the animation, in milliseconds
  7956. */
  7957. this.transitionDuration = 450;
  7958. /**
  7959. * Length of the distance animated by the transition when lower radius is reached
  7960. */
  7961. this.lowerRadiusTransitionRange = 2;
  7962. /**
  7963. * Length of the distance animated by the transition when upper radius is reached
  7964. */
  7965. this.upperRadiusTransitionRange = -2;
  7966. this._autoTransitionRange = false;
  7967. // Animations
  7968. this._radiusIsAnimating = false;
  7969. this._radiusBounceTransition = null;
  7970. this._animatables = new Array();
  7971. }
  7972. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7973. /**
  7974. * Gets the name of the behavior.
  7975. */
  7976. get: function () {
  7977. return "Bouncing";
  7978. },
  7979. enumerable: true,
  7980. configurable: true
  7981. });
  7982. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7983. /**
  7984. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7985. */
  7986. get: function () {
  7987. return this._autoTransitionRange;
  7988. },
  7989. /**
  7990. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7991. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7992. */
  7993. set: function (value) {
  7994. var _this = this;
  7995. if (this._autoTransitionRange === value) {
  7996. return;
  7997. }
  7998. this._autoTransitionRange = value;
  7999. var camera = this._attachedCamera;
  8000. if (!camera) {
  8001. return;
  8002. }
  8003. if (value) {
  8004. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8005. if (!mesh) {
  8006. return;
  8007. }
  8008. mesh.computeWorldMatrix(true);
  8009. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8010. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8011. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8012. });
  8013. }
  8014. else if (this._onMeshTargetChangedObserver) {
  8015. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8016. }
  8017. },
  8018. enumerable: true,
  8019. configurable: true
  8020. });
  8021. /**
  8022. * Initializes the behavior.
  8023. */
  8024. BouncingBehavior.prototype.init = function () {
  8025. // Do notihng
  8026. };
  8027. /**
  8028. * Attaches the behavior to its arc rotate camera.
  8029. * @param camera Defines the camera to attach the behavior to
  8030. */
  8031. BouncingBehavior.prototype.attach = function (camera) {
  8032. var _this = this;
  8033. this._attachedCamera = camera;
  8034. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8035. if (!_this._attachedCamera) {
  8036. return;
  8037. }
  8038. // Add the bounce animation to the lower radius limit
  8039. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8040. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8041. }
  8042. // Add the bounce animation to the upper radius limit
  8043. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8044. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8045. }
  8046. });
  8047. };
  8048. /**
  8049. * Detaches the behavior from its current arc rotate camera.
  8050. */
  8051. BouncingBehavior.prototype.detach = function () {
  8052. if (!this._attachedCamera) {
  8053. return;
  8054. }
  8055. if (this._onAfterCheckInputsObserver) {
  8056. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8057. }
  8058. if (this._onMeshTargetChangedObserver) {
  8059. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8060. }
  8061. this._attachedCamera = null;
  8062. };
  8063. /**
  8064. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8065. * @param radiusLimit The limit to check against.
  8066. * @return Bool to indicate if at limit.
  8067. */
  8068. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8069. if (!this._attachedCamera) {
  8070. return false;
  8071. }
  8072. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8073. return true;
  8074. }
  8075. return false;
  8076. };
  8077. /**
  8078. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8079. * @param radiusDelta The delta by which to animate to. Can be negative.
  8080. */
  8081. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8082. var _this = this;
  8083. if (!this._attachedCamera) {
  8084. return;
  8085. }
  8086. if (!this._radiusBounceTransition) {
  8087. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8088. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8089. }
  8090. // Prevent zoom until bounce has completed
  8091. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8092. this._attachedCamera.wheelPrecision = Infinity;
  8093. this._attachedCamera.inertialRadiusOffset = 0;
  8094. // Animate to the radius limit
  8095. this.stopAllAnimations();
  8096. this._radiusIsAnimating = true;
  8097. 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(); });
  8098. if (animatable) {
  8099. this._animatables.push(animatable);
  8100. }
  8101. };
  8102. /**
  8103. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8104. */
  8105. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8106. this._radiusIsAnimating = false;
  8107. if (this._attachedCamera) {
  8108. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8109. }
  8110. };
  8111. /**
  8112. * Stops and removes all animations that have been applied to the camera
  8113. */
  8114. BouncingBehavior.prototype.stopAllAnimations = function () {
  8115. if (this._attachedCamera) {
  8116. this._attachedCamera.animations = [];
  8117. }
  8118. while (this._animatables.length) {
  8119. this._animatables[0].onAnimationEnd = null;
  8120. this._animatables[0].stop();
  8121. this._animatables.shift();
  8122. }
  8123. };
  8124. /**
  8125. * The easing function used by animations
  8126. */
  8127. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8128. /**
  8129. * The easing mode used by animations
  8130. */
  8131. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8132. return BouncingBehavior;
  8133. }());
  8134. /***/ }),
  8135. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8136. /*!**********************************************!*\
  8137. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8138. \**********************************************/
  8139. /*! exports provided: FramingBehavior */
  8140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8141. "use strict";
  8142. __webpack_require__.r(__webpack_exports__);
  8143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8144. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8145. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8146. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8147. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8148. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8149. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8150. /**
  8151. * 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.
  8152. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8153. */
  8154. var FramingBehavior = /** @class */ (function () {
  8155. function FramingBehavior() {
  8156. this._mode = FramingBehavior.FitFrustumSidesMode;
  8157. this._radiusScale = 1.0;
  8158. this._positionScale = 0.5;
  8159. this._defaultElevation = 0.3;
  8160. this._elevationReturnTime = 1500;
  8161. this._elevationReturnWaitTime = 1000;
  8162. this._zoomStopsAnimation = false;
  8163. this._framingTime = 1500;
  8164. /**
  8165. * Define if the behavior should automatically change the configured
  8166. * camera limits and sensibilities.
  8167. */
  8168. this.autoCorrectCameraLimitsAndSensibility = true;
  8169. this._isPointerDown = false;
  8170. this._lastInteractionTime = -Infinity;
  8171. // Framing control
  8172. this._animatables = new Array();
  8173. this._betaIsAnimating = false;
  8174. }
  8175. Object.defineProperty(FramingBehavior.prototype, "name", {
  8176. /**
  8177. * Gets the name of the behavior.
  8178. */
  8179. get: function () {
  8180. return "Framing";
  8181. },
  8182. enumerable: true,
  8183. configurable: true
  8184. });
  8185. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8186. /**
  8187. * Gets current mode used by the behavior.
  8188. */
  8189. get: function () {
  8190. return this._mode;
  8191. },
  8192. /**
  8193. * Sets the current mode used by the behavior
  8194. */
  8195. set: function (mode) {
  8196. this._mode = mode;
  8197. },
  8198. enumerable: true,
  8199. configurable: true
  8200. });
  8201. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8202. /**
  8203. * Gets the scale applied to the radius
  8204. */
  8205. get: function () {
  8206. return this._radiusScale;
  8207. },
  8208. /**
  8209. * Sets the scale applied to the radius (1 by default)
  8210. */
  8211. set: function (radius) {
  8212. this._radiusScale = radius;
  8213. },
  8214. enumerable: true,
  8215. configurable: true
  8216. });
  8217. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8218. /**
  8219. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8220. */
  8221. get: function () {
  8222. return this._positionScale;
  8223. },
  8224. /**
  8225. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8226. */
  8227. set: function (scale) {
  8228. this._positionScale = scale;
  8229. },
  8230. enumerable: true,
  8231. configurable: true
  8232. });
  8233. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8234. /**
  8235. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8236. * behaviour is triggered, in radians.
  8237. */
  8238. get: function () {
  8239. return this._defaultElevation;
  8240. },
  8241. /**
  8242. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8243. * behaviour is triggered, in radians.
  8244. */
  8245. set: function (elevation) {
  8246. this._defaultElevation = elevation;
  8247. },
  8248. enumerable: true,
  8249. configurable: true
  8250. });
  8251. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8252. /**
  8253. * Gets the time (in milliseconds) taken to return to the default beta position.
  8254. * Negative value indicates camera should not return to default.
  8255. */
  8256. get: function () {
  8257. return this._elevationReturnTime;
  8258. },
  8259. /**
  8260. * Sets the time (in milliseconds) taken to return to the default beta position.
  8261. * Negative value indicates camera should not return to default.
  8262. */
  8263. set: function (speed) {
  8264. this._elevationReturnTime = speed;
  8265. },
  8266. enumerable: true,
  8267. configurable: true
  8268. });
  8269. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8270. /**
  8271. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8272. */
  8273. get: function () {
  8274. return this._elevationReturnWaitTime;
  8275. },
  8276. /**
  8277. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8278. */
  8279. set: function (time) {
  8280. this._elevationReturnWaitTime = time;
  8281. },
  8282. enumerable: true,
  8283. configurable: true
  8284. });
  8285. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8286. /**
  8287. * Gets the flag that indicates if user zooming should stop animation.
  8288. */
  8289. get: function () {
  8290. return this._zoomStopsAnimation;
  8291. },
  8292. /**
  8293. * Sets the flag that indicates if user zooming should stop animation.
  8294. */
  8295. set: function (flag) {
  8296. this._zoomStopsAnimation = flag;
  8297. },
  8298. enumerable: true,
  8299. configurable: true
  8300. });
  8301. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8302. /**
  8303. * Gets the transition time when framing the mesh, in milliseconds
  8304. */
  8305. get: function () {
  8306. return this._framingTime;
  8307. },
  8308. /**
  8309. * Sets the transition time when framing the mesh, in milliseconds
  8310. */
  8311. set: function (time) {
  8312. this._framingTime = time;
  8313. },
  8314. enumerable: true,
  8315. configurable: true
  8316. });
  8317. /**
  8318. * Initializes the behavior.
  8319. */
  8320. FramingBehavior.prototype.init = function () {
  8321. // Do notihng
  8322. };
  8323. /**
  8324. * Attaches the behavior to its arc rotate camera.
  8325. * @param camera Defines the camera to attach the behavior to
  8326. */
  8327. FramingBehavior.prototype.attach = function (camera) {
  8328. var _this = this;
  8329. this._attachedCamera = camera;
  8330. var scene = this._attachedCamera.getScene();
  8331. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8332. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8333. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8334. _this._isPointerDown = true;
  8335. return;
  8336. }
  8337. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8338. _this._isPointerDown = false;
  8339. }
  8340. });
  8341. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8342. if (mesh) {
  8343. _this.zoomOnMesh(mesh);
  8344. }
  8345. });
  8346. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8347. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8348. _this._applyUserInteraction();
  8349. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8350. // back to the default position after a given timeout
  8351. _this._maintainCameraAboveGround();
  8352. });
  8353. };
  8354. /**
  8355. * Detaches the behavior from its current arc rotate camera.
  8356. */
  8357. FramingBehavior.prototype.detach = function () {
  8358. if (!this._attachedCamera) {
  8359. return;
  8360. }
  8361. var scene = this._attachedCamera.getScene();
  8362. if (this._onPrePointerObservableObserver) {
  8363. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8364. }
  8365. if (this._onAfterCheckInputsObserver) {
  8366. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8367. }
  8368. if (this._onMeshTargetChangedObserver) {
  8369. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8370. }
  8371. this._attachedCamera = null;
  8372. };
  8373. /**
  8374. * Targets the given mesh and updates zoom level accordingly.
  8375. * @param mesh The mesh to target.
  8376. * @param radius Optional. If a cached radius position already exists, overrides default.
  8377. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8378. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8379. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8380. */
  8381. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8382. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8383. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8384. mesh.computeWorldMatrix(true);
  8385. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8386. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8387. };
  8388. /**
  8389. * Targets the given mesh with its children and updates zoom level accordingly.
  8390. * @param mesh The mesh to target.
  8391. * @param radius Optional. If a cached radius position already exists, overrides default.
  8392. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8393. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8394. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8395. */
  8396. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8397. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8398. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8399. mesh.computeWorldMatrix(true);
  8400. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8401. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8402. };
  8403. /**
  8404. * Targets the given meshes with their children and updates zoom level accordingly.
  8405. * @param meshes The mesh to target.
  8406. * @param radius Optional. If a cached radius position already exists, overrides default.
  8407. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8408. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8409. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8410. */
  8411. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8412. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8413. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8414. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8415. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8416. for (var i = 0; i < meshes.length; i++) {
  8417. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8418. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8419. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8420. }
  8421. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8422. };
  8423. /**
  8424. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8425. * @param minimumWorld Determines the smaller position of the bounding box extend
  8426. * @param maximumWorld Determines the bigger position of the bounding box extend
  8427. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8428. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8429. */
  8430. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8431. var _this = this;
  8432. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8433. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8434. var zoomTarget;
  8435. if (!this._attachedCamera) {
  8436. return;
  8437. }
  8438. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8439. var bottom = minimumWorld.y;
  8440. var top = maximumWorld.y;
  8441. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8442. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8443. if (focusOnOriginXZ) {
  8444. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8445. }
  8446. else {
  8447. var centerWorld = minimumWorld.add(radiusWorld);
  8448. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8449. }
  8450. if (!this._vectorTransition) {
  8451. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8452. }
  8453. this._betaIsAnimating = true;
  8454. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8455. if (animatable) {
  8456. this._animatables.push(animatable);
  8457. }
  8458. // sets the radius and lower radius bounds
  8459. // Small delta ensures camera is not always at lower zoom limit.
  8460. var radius = 0;
  8461. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8462. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8463. if (this.autoCorrectCameraLimitsAndSensibility) {
  8464. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8465. }
  8466. radius = position;
  8467. }
  8468. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8469. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8470. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8471. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8472. }
  8473. }
  8474. // Set sensibilities
  8475. if (this.autoCorrectCameraLimitsAndSensibility) {
  8476. var extend = maximumWorld.subtract(minimumWorld).length();
  8477. this._attachedCamera.panningSensibility = 5000 / extend;
  8478. this._attachedCamera.wheelPrecision = 100 / radius;
  8479. }
  8480. // transition to new radius
  8481. if (!this._radiusTransition) {
  8482. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8483. }
  8484. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8485. _this.stopAllAnimations();
  8486. if (onAnimationEnd) {
  8487. onAnimationEnd();
  8488. }
  8489. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8490. _this._attachedCamera.storeState();
  8491. }
  8492. });
  8493. if (animatable) {
  8494. this._animatables.push(animatable);
  8495. }
  8496. };
  8497. /**
  8498. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8499. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8500. * frustum width.
  8501. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8502. * to fully enclose the mesh in the viewing frustum.
  8503. */
  8504. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8505. var size = maximumWorld.subtract(minimumWorld);
  8506. var boxVectorGlobalDiagonal = size.length();
  8507. var frustumSlope = this._getFrustumSlope();
  8508. // Formula for setting distance
  8509. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8510. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8511. // Horizon distance
  8512. var radius = radiusWithoutFraming * this._radiusScale;
  8513. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8514. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8515. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8516. var camera = this._attachedCamera;
  8517. if (!camera) {
  8518. return 0;
  8519. }
  8520. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8521. // Don't exceed the requested limit
  8522. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8523. }
  8524. // Don't exceed the upper radius limit
  8525. if (camera.upperRadiusLimit) {
  8526. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8527. }
  8528. return distance;
  8529. };
  8530. /**
  8531. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8532. * is automatically returned to its default position (expected to be above ground plane).
  8533. */
  8534. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8535. var _this = this;
  8536. if (this._elevationReturnTime < 0) {
  8537. return;
  8538. }
  8539. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8540. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8541. var limitBeta = Math.PI * 0.5;
  8542. // Bring the camera back up if below the ground plane
  8543. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8544. this._betaIsAnimating = true;
  8545. //Transition to new position
  8546. this.stopAllAnimations();
  8547. if (!this._betaTransition) {
  8548. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8549. }
  8550. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8551. _this._clearAnimationLocks();
  8552. _this.stopAllAnimations();
  8553. });
  8554. if (animatabe) {
  8555. this._animatables.push(animatabe);
  8556. }
  8557. }
  8558. };
  8559. /**
  8560. * Returns the frustum slope based on the canvas ratio and camera FOV
  8561. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8562. */
  8563. FramingBehavior.prototype._getFrustumSlope = function () {
  8564. // Calculate the viewport ratio
  8565. // Aspect Ratio is Height/Width.
  8566. var camera = this._attachedCamera;
  8567. if (!camera) {
  8568. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8569. }
  8570. var engine = camera.getScene().getEngine();
  8571. var aspectRatio = engine.getAspectRatio(camera);
  8572. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8573. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8574. var frustumSlopeY = Math.tan(camera.fov / 2);
  8575. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8576. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8577. // along the forward vector.
  8578. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8579. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8580. };
  8581. /**
  8582. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8583. */
  8584. FramingBehavior.prototype._clearAnimationLocks = function () {
  8585. this._betaIsAnimating = false;
  8586. };
  8587. /**
  8588. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8589. */
  8590. FramingBehavior.prototype._applyUserInteraction = function () {
  8591. if (this.isUserIsMoving) {
  8592. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8593. this.stopAllAnimations();
  8594. this._clearAnimationLocks();
  8595. }
  8596. };
  8597. /**
  8598. * Stops and removes all animations that have been applied to the camera
  8599. */
  8600. FramingBehavior.prototype.stopAllAnimations = function () {
  8601. if (this._attachedCamera) {
  8602. this._attachedCamera.animations = [];
  8603. }
  8604. while (this._animatables.length) {
  8605. if (this._animatables[0]) {
  8606. this._animatables[0].onAnimationEnd = null;
  8607. this._animatables[0].stop();
  8608. }
  8609. this._animatables.shift();
  8610. }
  8611. };
  8612. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8613. /**
  8614. * Gets a value indicating if the user is moving the camera
  8615. */
  8616. get: function () {
  8617. if (!this._attachedCamera) {
  8618. return false;
  8619. }
  8620. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8621. this._attachedCamera.inertialBetaOffset !== 0 ||
  8622. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8623. this._attachedCamera.inertialPanningX !== 0 ||
  8624. this._attachedCamera.inertialPanningY !== 0 ||
  8625. this._isPointerDown;
  8626. },
  8627. enumerable: true,
  8628. configurable: true
  8629. });
  8630. /**
  8631. * The easing function used by animations
  8632. */
  8633. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8634. /**
  8635. * The easing mode used by animations
  8636. */
  8637. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8638. // Statics
  8639. /**
  8640. * The camera can move all the way towards the mesh.
  8641. */
  8642. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8643. /**
  8644. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8645. */
  8646. FramingBehavior.FitFrustumSidesMode = 1;
  8647. return FramingBehavior;
  8648. }());
  8649. /***/ }),
  8650. /***/ "./Behaviors/Cameras/index.ts":
  8651. /*!************************************!*\
  8652. !*** ./Behaviors/Cameras/index.ts ***!
  8653. \************************************/
  8654. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8656. "use strict";
  8657. __webpack_require__.r(__webpack_exports__);
  8658. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8660. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8662. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8664. /***/ }),
  8665. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8666. /*!*************************************************!*\
  8667. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8668. \*************************************************/
  8669. /*! exports provided: AttachToBoxBehavior */
  8670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8671. "use strict";
  8672. __webpack_require__.r(__webpack_exports__);
  8673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8674. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8675. /**
  8676. * @hidden
  8677. */
  8678. var FaceDirectionInfo = /** @class */ (function () {
  8679. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8680. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8681. if (diff === void 0) { diff = 0; }
  8682. if (ignore === void 0) { ignore = false; }
  8683. this.direction = direction;
  8684. this.rotatedDirection = rotatedDirection;
  8685. this.diff = diff;
  8686. this.ignore = ignore;
  8687. }
  8688. return FaceDirectionInfo;
  8689. }());
  8690. /**
  8691. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8692. */
  8693. var AttachToBoxBehavior = /** @class */ (function () {
  8694. /**
  8695. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8696. * @param ui The transform node that should be attched to the mesh
  8697. */
  8698. function AttachToBoxBehavior(ui) {
  8699. this.ui = ui;
  8700. /**
  8701. * The name of the behavior
  8702. */
  8703. this.name = "AttachToBoxBehavior";
  8704. /**
  8705. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8706. */
  8707. this.distanceAwayFromFace = 0.15;
  8708. /**
  8709. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8710. */
  8711. this.distanceAwayFromBottomOfFace = 0.15;
  8712. 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))];
  8713. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8714. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8715. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8716. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8717. /* Does nothing */
  8718. }
  8719. /**
  8720. * Initializes the behavior
  8721. */
  8722. AttachToBoxBehavior.prototype.init = function () {
  8723. /* Does nothing */
  8724. };
  8725. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8726. var _this = this;
  8727. // Go over each face and calculate the angle between the face's normal and targetDirection
  8728. this._faceVectors.forEach(function (v) {
  8729. if (!_this._target.rotationQuaternion) {
  8730. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8731. }
  8732. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8733. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8734. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8735. });
  8736. // Return the face information of the one with the normal closeset to target direction
  8737. return this._faceVectors.reduce(function (min, p) {
  8738. if (min.ignore) {
  8739. return p;
  8740. }
  8741. else if (p.ignore) {
  8742. return min;
  8743. }
  8744. else {
  8745. return min.diff < p.diff ? min : p;
  8746. }
  8747. }, this._faceVectors[0]);
  8748. };
  8749. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8750. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8751. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8752. this._lookAtTmpMatrix.invert();
  8753. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8754. };
  8755. /**
  8756. * Attaches the AttachToBoxBehavior to the passed in mesh
  8757. * @param target The mesh that the specified node will be attached to
  8758. */
  8759. AttachToBoxBehavior.prototype.attach = function (target) {
  8760. var _this = this;
  8761. this._target = target;
  8762. this._scene = this._target.getScene();
  8763. // Every frame, update the app bars position
  8764. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8765. if (!_this._scene.activeCamera) {
  8766. return;
  8767. }
  8768. // Find the face closest to the cameras position
  8769. var cameraPos = _this._scene.activeCamera.position;
  8770. if (_this._scene.activeCamera.devicePosition) {
  8771. cameraPos = _this._scene.activeCamera.devicePosition;
  8772. }
  8773. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8774. if (_this._scene.activeCamera.leftCamera) {
  8775. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8776. }
  8777. else {
  8778. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8779. }
  8780. // Get camera up direction
  8781. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8782. // Ignore faces to not select a parrelel face for the up vector of the UI
  8783. _this._faceVectors.forEach(function (v) {
  8784. if (facing.direction.x && v.direction.x) {
  8785. v.ignore = true;
  8786. }
  8787. if (facing.direction.y && v.direction.y) {
  8788. v.ignore = true;
  8789. }
  8790. if (facing.direction.z && v.direction.z) {
  8791. v.ignore = true;
  8792. }
  8793. });
  8794. var facingUp = _this._closestFace(_this._tmpVector);
  8795. // Unignore faces
  8796. _this._faceVectors.forEach(function (v) {
  8797. v.ignore = false;
  8798. });
  8799. // Position the app bar on that face
  8800. _this.ui.position.copyFrom(target.position);
  8801. if (facing.direction.x) {
  8802. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8803. _this.ui.position.addInPlace(_this._tmpVector);
  8804. }
  8805. if (facing.direction.y) {
  8806. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8807. _this.ui.position.addInPlace(_this._tmpVector);
  8808. }
  8809. if (facing.direction.z) {
  8810. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8811. _this.ui.position.addInPlace(_this._tmpVector);
  8812. }
  8813. // Rotate to be oriented properly to the camera
  8814. if (!_this.ui.rotationQuaternion) {
  8815. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8816. }
  8817. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8818. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8819. // Place ui the correct distance from the bottom of the mesh
  8820. if (facingUp.direction.x) {
  8821. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8822. }
  8823. if (facingUp.direction.y) {
  8824. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8825. }
  8826. if (facingUp.direction.z) {
  8827. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8828. }
  8829. _this.ui.position.addInPlace(_this._tmpVector);
  8830. });
  8831. };
  8832. /**
  8833. * Detaches the behavior from the mesh
  8834. */
  8835. AttachToBoxBehavior.prototype.detach = function () {
  8836. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8837. };
  8838. return AttachToBoxBehavior;
  8839. }());
  8840. /***/ }),
  8841. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8842. /*!***********************************************!*\
  8843. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8844. \***********************************************/
  8845. /*! exports provided: FadeInOutBehavior */
  8846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8847. "use strict";
  8848. __webpack_require__.r(__webpack_exports__);
  8849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8850. /**
  8851. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8852. */
  8853. var FadeInOutBehavior = /** @class */ (function () {
  8854. /**
  8855. * Instatiates the FadeInOutBehavior
  8856. */
  8857. function FadeInOutBehavior() {
  8858. var _this = this;
  8859. /**
  8860. * Time in milliseconds to delay before fading in (Default: 0)
  8861. */
  8862. this.delay = 0;
  8863. /**
  8864. * Time in milliseconds for the mesh to fade in (Default: 300)
  8865. */
  8866. this.fadeInTime = 300;
  8867. this._millisecondsPerFrame = 1000 / 60;
  8868. this._hovered = false;
  8869. this._hoverValue = 0;
  8870. this._ownerNode = null;
  8871. this._update = function () {
  8872. if (_this._ownerNode) {
  8873. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8874. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8875. if (_this._ownerNode.visibility > 1) {
  8876. _this._setAllVisibility(_this._ownerNode, 1);
  8877. _this._hoverValue = _this.fadeInTime + _this.delay;
  8878. return;
  8879. }
  8880. else if (_this._ownerNode.visibility < 0) {
  8881. _this._setAllVisibility(_this._ownerNode, 0);
  8882. if (_this._hoverValue < 0) {
  8883. _this._hoverValue = 0;
  8884. return;
  8885. }
  8886. }
  8887. setTimeout(_this._update, _this._millisecondsPerFrame);
  8888. }
  8889. };
  8890. }
  8891. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8892. /**
  8893. * The name of the behavior
  8894. */
  8895. get: function () {
  8896. return "FadeInOut";
  8897. },
  8898. enumerable: true,
  8899. configurable: true
  8900. });
  8901. /**
  8902. * Initializes the behavior
  8903. */
  8904. FadeInOutBehavior.prototype.init = function () {
  8905. };
  8906. /**
  8907. * Attaches the fade behavior on the passed in mesh
  8908. * @param ownerNode The mesh that will be faded in/out once attached
  8909. */
  8910. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8911. this._ownerNode = ownerNode;
  8912. this._setAllVisibility(this._ownerNode, 0);
  8913. };
  8914. /**
  8915. * Detaches the behavior from the mesh
  8916. */
  8917. FadeInOutBehavior.prototype.detach = function () {
  8918. this._ownerNode = null;
  8919. };
  8920. /**
  8921. * Triggers the mesh to begin fading in or out
  8922. * @param value if the object should fade in or out (true to fade in)
  8923. */
  8924. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8925. this._hovered = value;
  8926. this._update();
  8927. };
  8928. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8929. var _this = this;
  8930. mesh.visibility = value;
  8931. mesh.getChildMeshes().forEach(function (c) {
  8932. _this._setAllVisibility(c, value);
  8933. });
  8934. };
  8935. return FadeInOutBehavior;
  8936. }());
  8937. /***/ }),
  8938. /***/ "./Behaviors/Meshes/index.ts":
  8939. /*!***********************************!*\
  8940. !*** ./Behaviors/Meshes/index.ts ***!
  8941. \***********************************/
  8942. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8944. "use strict";
  8945. __webpack_require__.r(__webpack_exports__);
  8946. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8948. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8950. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8952. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8954. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8956. /***/ }),
  8957. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8958. /*!*******************************************************!*\
  8959. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8960. \*******************************************************/
  8961. /*! exports provided: MultiPointerScaleBehavior */
  8962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8963. "use strict";
  8964. __webpack_require__.r(__webpack_exports__);
  8965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8966. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8967. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8968. /**
  8969. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8970. */
  8971. var MultiPointerScaleBehavior = /** @class */ (function () {
  8972. /**
  8973. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8974. */
  8975. function MultiPointerScaleBehavior() {
  8976. this._startDistance = 0;
  8977. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8978. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8979. this._sceneRenderObserver = null;
  8980. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8981. this._dragBehaviorA.moveAttached = false;
  8982. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8983. this._dragBehaviorB.moveAttached = false;
  8984. }
  8985. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8986. /**
  8987. * The name of the behavior
  8988. */
  8989. get: function () {
  8990. return "MultiPointerScale";
  8991. },
  8992. enumerable: true,
  8993. configurable: true
  8994. });
  8995. /**
  8996. * Initializes the behavior
  8997. */
  8998. MultiPointerScaleBehavior.prototype.init = function () { };
  8999. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  9000. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  9001. };
  9002. /**
  9003. * Attaches the scale behavior the passed in mesh
  9004. * @param ownerNode The mesh that will be scaled around once attached
  9005. */
  9006. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9007. var _this = this;
  9008. this._ownerNode = ownerNode;
  9009. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9010. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9011. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9012. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9013. _this._dragBehaviorA.releaseDrag();
  9014. }
  9015. else {
  9016. _this._initialScale.copyFrom(ownerNode.scaling);
  9017. _this._startDistance = _this._getCurrentDistance();
  9018. }
  9019. }
  9020. });
  9021. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9022. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9023. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9024. _this._dragBehaviorB.releaseDrag();
  9025. }
  9026. else {
  9027. _this._initialScale.copyFrom(ownerNode.scaling);
  9028. _this._startDistance = _this._getCurrentDistance();
  9029. }
  9030. }
  9031. });
  9032. // Once both drag behaviors are active scale based on the distance between the two pointers
  9033. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9034. behavior.onDragObservable.add(function () {
  9035. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9036. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9037. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9038. }
  9039. });
  9040. });
  9041. ownerNode.addBehavior(this._dragBehaviorA);
  9042. ownerNode.addBehavior(this._dragBehaviorB);
  9043. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9044. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9045. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9046. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9047. if (change.length() > 0.01) {
  9048. ownerNode.scaling.addInPlace(change);
  9049. }
  9050. }
  9051. });
  9052. };
  9053. /**
  9054. * Detaches the behavior from the mesh
  9055. */
  9056. MultiPointerScaleBehavior.prototype.detach = function () {
  9057. var _this = this;
  9058. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9059. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9060. behavior.onDragStartObservable.clear();
  9061. behavior.onDragObservable.clear();
  9062. _this._ownerNode.removeBehavior(behavior);
  9063. });
  9064. };
  9065. return MultiPointerScaleBehavior;
  9066. }());
  9067. /***/ }),
  9068. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9069. /*!*************************************************!*\
  9070. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9071. \*************************************************/
  9072. /*! exports provided: PointerDragBehavior */
  9073. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9074. "use strict";
  9075. __webpack_require__.r(__webpack_exports__);
  9076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9077. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9078. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9079. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9080. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9081. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9082. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9083. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9084. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9085. /**
  9086. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9087. */
  9088. var PointerDragBehavior = /** @class */ (function () {
  9089. /**
  9090. * Creates a pointer drag behavior that can be attached to a mesh
  9091. * @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)
  9092. */
  9093. function PointerDragBehavior(options) {
  9094. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9095. /**
  9096. * 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)
  9097. */
  9098. this.maxDragAngle = 0;
  9099. /**
  9100. * @hidden
  9101. */
  9102. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9103. /**
  9104. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9105. */
  9106. this.currentDraggingPointerID = -1;
  9107. /**
  9108. * If the behavior is currently in a dragging state
  9109. */
  9110. this.dragging = false;
  9111. /**
  9112. * 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)
  9113. */
  9114. this.dragDeltaRatio = 0.2;
  9115. /**
  9116. * If the drag plane orientation should be updated during the dragging (Default: true)
  9117. */
  9118. this.updateDragPlane = true;
  9119. // Debug mode will display drag planes to help visualize behavior
  9120. this._debugMode = false;
  9121. this._moving = false;
  9122. /**
  9123. * Fires each time the attached mesh is dragged with the pointer
  9124. * * delta between last drag position and current drag position in world space
  9125. * * dragDistance along the drag axis
  9126. * * dragPlaneNormal normal of the current drag plane used during the drag
  9127. * * dragPlanePoint in world space where the drag intersects the drag plane
  9128. */
  9129. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9130. /**
  9131. * Fires each time a drag begins (eg. mouse down on mesh)
  9132. */
  9133. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9134. /**
  9135. * Fires each time a drag ends (eg. mouse release after drag)
  9136. */
  9137. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9138. /**
  9139. * If the attached mesh should be moved when dragged
  9140. */
  9141. this.moveAttached = true;
  9142. /**
  9143. * If the drag behavior will react to drag events (Default: true)
  9144. */
  9145. this.enabled = true;
  9146. /**
  9147. * If camera controls should be detached during the drag
  9148. */
  9149. this.detachCameraControls = true;
  9150. /**
  9151. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9152. */
  9153. this.useObjectOrienationForDragging = true;
  9154. /**
  9155. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9156. */
  9157. this.validateDrag = function (targetPosition) { return true; };
  9158. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9159. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9160. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9161. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9162. this._attachedElement = null;
  9163. 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"]());
  9164. this._lastPointerRay = {};
  9165. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9166. // Variables to avoid instantiation in the below method
  9167. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9168. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9169. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9170. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9171. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9172. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9173. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9174. this._options = options ? options : {};
  9175. var optionCount = 0;
  9176. if (this._options.dragAxis) {
  9177. optionCount++;
  9178. }
  9179. if (this._options.dragPlaneNormal) {
  9180. optionCount++;
  9181. }
  9182. if (optionCount > 1) {
  9183. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9184. }
  9185. }
  9186. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9187. /**
  9188. * The name of the behavior
  9189. */
  9190. get: function () {
  9191. return "PointerDrag";
  9192. },
  9193. enumerable: true,
  9194. configurable: true
  9195. });
  9196. /**
  9197. * Initializes the behavior
  9198. */
  9199. PointerDragBehavior.prototype.init = function () { };
  9200. /**
  9201. * Attaches the drag behavior the passed in mesh
  9202. * @param ownerNode The mesh that will be dragged around once attached
  9203. */
  9204. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9205. var _this = this;
  9206. this._scene = ownerNode.getScene();
  9207. this._attachedNode = ownerNode;
  9208. // Initialize drag plane to not interfere with existing scene
  9209. if (!PointerDragBehavior._planeScene) {
  9210. if (this._debugMode) {
  9211. PointerDragBehavior._planeScene = this._scene;
  9212. }
  9213. else {
  9214. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9215. PointerDragBehavior._planeScene.detachControl();
  9216. this._scene.getEngine().scenes.pop();
  9217. this._scene.onDisposeObservable.addOnce(function () {
  9218. PointerDragBehavior._planeScene.dispose();
  9219. PointerDragBehavior._planeScene = null;
  9220. });
  9221. }
  9222. }
  9223. 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);
  9224. // State of the drag
  9225. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9226. var pickPredicate = function (m) {
  9227. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9228. };
  9229. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9230. if (!_this.enabled) {
  9231. return;
  9232. }
  9233. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9234. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9235. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9236. }
  9237. }
  9238. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9239. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9240. _this.releaseDrag();
  9241. }
  9242. }
  9243. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9244. var pointerId = pointerInfo.event.pointerId;
  9245. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9246. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9247. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9248. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9249. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9250. }
  9251. _this.currentDraggingPointerID = pointerId;
  9252. }
  9253. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9254. if (!_this._lastPointerRay[pointerId]) {
  9255. _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"]());
  9256. }
  9257. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9258. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9259. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9260. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9261. _this._moveDrag(pointerInfo.pickInfo.ray);
  9262. }
  9263. }
  9264. }
  9265. });
  9266. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9267. if (_this._moving && _this.moveAttached) {
  9268. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9269. // Slowly move mesh to avoid jitter
  9270. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9271. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9272. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9273. if (_this.validateDrag(_this._tmpVector)) {
  9274. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9275. }
  9276. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9277. }
  9278. });
  9279. };
  9280. /**
  9281. * Force relase the drag action by code.
  9282. */
  9283. PointerDragBehavior.prototype.releaseDrag = function () {
  9284. this.dragging = false;
  9285. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9286. this.currentDraggingPointerID = -1;
  9287. this._moving = false;
  9288. // Reattach camera controls
  9289. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9290. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9291. }
  9292. };
  9293. /**
  9294. * Simulates the start of a pointer drag event on the behavior
  9295. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9296. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9297. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9298. */
  9299. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9300. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9301. this._startDrag(pointerId, fromRay, startPickedPoint);
  9302. var lastRay = this._lastPointerRay[pointerId];
  9303. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9304. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9305. }
  9306. if (lastRay) {
  9307. // if there was a last pointer ray drag the object there
  9308. this._moveDrag(lastRay);
  9309. }
  9310. };
  9311. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9312. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9313. return;
  9314. }
  9315. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9316. // Create start ray from the camera to the object
  9317. if (fromRay) {
  9318. this._startDragRay.direction.copyFrom(fromRay.direction);
  9319. this._startDragRay.origin.copyFrom(fromRay.origin);
  9320. }
  9321. else {
  9322. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9323. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9324. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9325. }
  9326. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9327. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9328. if (pickedPoint) {
  9329. this.dragging = true;
  9330. this.currentDraggingPointerID = pointerId;
  9331. this.lastDragPosition.copyFrom(pickedPoint);
  9332. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9333. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9334. // Detatch camera controls
  9335. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9336. if (this._scene.activeCamera.inputs.attachedElement) {
  9337. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9338. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9339. }
  9340. else {
  9341. this._attachedElement = null;
  9342. }
  9343. }
  9344. }
  9345. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9346. };
  9347. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9348. this._moving = true;
  9349. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9350. if (pickedPoint) {
  9351. if (this.updateDragPlane) {
  9352. this._updateDragPlanePosition(ray, pickedPoint);
  9353. }
  9354. var dragLength = 0;
  9355. // depending on the drag mode option drag accordingly
  9356. if (this._options.dragAxis) {
  9357. // Convert local drag axis to world
  9358. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9359. // Project delta drag from the drag plane onto the drag axis
  9360. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9361. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9362. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9363. }
  9364. else {
  9365. dragLength = this._dragDelta.length();
  9366. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9367. }
  9368. this._targetPosition.addInPlace(this._dragDelta);
  9369. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9370. this.lastDragPosition.copyFrom(pickedPoint);
  9371. }
  9372. };
  9373. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9374. var _this = this;
  9375. if (!ray) {
  9376. return null;
  9377. }
  9378. // Calculate angle between plane normal and ray
  9379. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9380. // Correct if ray is casted from oposite side
  9381. if (angle > Math.PI / 2) {
  9382. angle = Math.PI - angle;
  9383. }
  9384. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9385. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9386. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9387. // Invert ray direction along the towards object axis
  9388. this._tmpVector.copyFrom(ray.direction);
  9389. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9390. this._alternatePickedPoint.normalize();
  9391. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9392. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9393. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9394. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9395. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9396. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9397. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9398. return this._alternatePickedPoint;
  9399. }
  9400. else {
  9401. return null;
  9402. }
  9403. }
  9404. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9405. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9406. return pickResult.pickedPoint;
  9407. }
  9408. else {
  9409. return null;
  9410. }
  9411. };
  9412. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9413. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9414. this._pointA.copyFrom(dragPlanePosition);
  9415. if (this._options.dragAxis) {
  9416. 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);
  9417. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9418. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9419. ray.origin.subtractToRef(this._pointA, this._pointC);
  9420. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9421. // Get perpendicular line from direction to camera and drag axis
  9422. this._pointB.subtractToRef(this._pointA, this._lineA);
  9423. this._pointC.subtractToRef(this._pointA, this._lineB);
  9424. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9425. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9426. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9427. this._lookAt.normalize();
  9428. this._dragPlane.position.copyFrom(this._pointA);
  9429. this._pointA.addToRef(this._lookAt, this._lookAt);
  9430. this._dragPlane.lookAt(this._lookAt);
  9431. }
  9432. else if (this._options.dragPlaneNormal) {
  9433. 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);
  9434. this._dragPlane.position.copyFrom(this._pointA);
  9435. this._pointA.addToRef(this._localAxis, this._lookAt);
  9436. this._dragPlane.lookAt(this._lookAt);
  9437. }
  9438. else {
  9439. this._dragPlane.position.copyFrom(this._pointA);
  9440. this._dragPlane.lookAt(ray.origin);
  9441. }
  9442. // Update the position of the drag plane so it doesn't get out of sync with the node (eg. when moving back and forth quickly)
  9443. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9444. this._dragPlane.computeWorldMatrix(true);
  9445. };
  9446. /**
  9447. * Detaches the behavior from the mesh
  9448. */
  9449. PointerDragBehavior.prototype.detach = function () {
  9450. if (this._pointerObserver) {
  9451. this._scene.onPointerObservable.remove(this._pointerObserver);
  9452. }
  9453. if (this._beforeRenderObserver) {
  9454. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9455. }
  9456. this.releaseDrag();
  9457. };
  9458. PointerDragBehavior._AnyMouseID = -2;
  9459. return PointerDragBehavior;
  9460. }());
  9461. /***/ }),
  9462. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9463. /*!************************************************!*\
  9464. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9465. \************************************************/
  9466. /*! exports provided: SixDofDragBehavior */
  9467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9468. "use strict";
  9469. __webpack_require__.r(__webpack_exports__);
  9470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9471. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9472. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9473. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9474. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9475. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9476. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9477. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9478. /**
  9479. * 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
  9480. */
  9481. var SixDofDragBehavior = /** @class */ (function () {
  9482. /**
  9483. * 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
  9484. */
  9485. function SixDofDragBehavior() {
  9486. this._sceneRenderObserver = null;
  9487. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9488. this._moving = false;
  9489. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9490. /**
  9491. * 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)
  9492. */
  9493. this.zDragFactor = 3;
  9494. /**
  9495. * If the object should rotate to face the drag origin
  9496. */
  9497. this.rotateDraggedObject = true;
  9498. /**
  9499. * If the behavior is currently in a dragging state
  9500. */
  9501. this.dragging = false;
  9502. /**
  9503. * 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)
  9504. */
  9505. this.dragDeltaRatio = 0.2;
  9506. /**
  9507. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9508. */
  9509. this.currentDraggingPointerID = -1;
  9510. /**
  9511. * If camera controls should be detached during the drag
  9512. */
  9513. this.detachCameraControls = true;
  9514. /**
  9515. * Fires each time a drag starts
  9516. */
  9517. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9518. /**
  9519. * Fires each time a drag ends (eg. mouse release after drag)
  9520. */
  9521. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9522. }
  9523. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9524. /**
  9525. * The name of the behavior
  9526. */
  9527. get: function () {
  9528. return "SixDofDrag";
  9529. },
  9530. enumerable: true,
  9531. configurable: true
  9532. });
  9533. /**
  9534. * Initializes the behavior
  9535. */
  9536. SixDofDragBehavior.prototype.init = function () { };
  9537. /**
  9538. * Attaches the scale behavior the passed in mesh
  9539. * @param ownerNode The mesh that will be scaled around once attached
  9540. */
  9541. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9542. var _this = this;
  9543. this._ownerNode = ownerNode;
  9544. this._scene = this._ownerNode.getScene();
  9545. if (!SixDofDragBehavior._virtualScene) {
  9546. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9547. SixDofDragBehavior._virtualScene.detachControl();
  9548. this._scene.getEngine().scenes.pop();
  9549. }
  9550. var pickedMesh = null;
  9551. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9552. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9553. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9554. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9555. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9556. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9557. var pickPredicate = function (m) {
  9558. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9559. };
  9560. var attachedElement = null;
  9561. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9562. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9563. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9564. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9565. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9566. }
  9567. pickedMesh = _this._ownerNode;
  9568. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9569. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9570. // Set position and orientation of the controller
  9571. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9572. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9573. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9574. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9575. pickedMesh.computeWorldMatrix();
  9576. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9577. if (!pickedMesh.rotationQuaternion) {
  9578. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9579. }
  9580. var oldParent = pickedMesh.parent;
  9581. pickedMesh.setParent(null);
  9582. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9583. pickedMesh.setParent(oldParent);
  9584. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9585. // Update state
  9586. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9587. _this.dragging = true;
  9588. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9589. // Detatch camera controls
  9590. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9591. if (_this._scene.activeCamera.inputs.attachedElement) {
  9592. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9593. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9594. }
  9595. else {
  9596. attachedElement = null;
  9597. }
  9598. }
  9599. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9600. _this.onDragStartObservable.notifyObservers({});
  9601. }
  9602. }
  9603. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9604. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9605. _this.dragging = false;
  9606. _this._moving = false;
  9607. _this.currentDraggingPointerID = -1;
  9608. pickedMesh = null;
  9609. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9610. // Reattach camera controls
  9611. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9612. _this._scene.activeCamera.attachControl(attachedElement, true);
  9613. }
  9614. _this.onDragEndObservable.notifyObservers({});
  9615. }
  9616. }
  9617. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9618. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9619. var zDragFactor = _this.zDragFactor;
  9620. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9621. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9622. zDragFactor = 0;
  9623. }
  9624. // Calculate controller drag distance in controller space
  9625. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9626. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9627. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9628. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9629. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9630. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9631. if (_this._virtualDragMesh.position.z < 0) {
  9632. _this._virtualDragMesh.position.z = 0;
  9633. }
  9634. // Update the controller position
  9635. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9636. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9637. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9638. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9639. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9640. if (pickedMesh.parent) {
  9641. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9642. }
  9643. if (!_this._moving) {
  9644. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9645. }
  9646. _this._moving = true;
  9647. }
  9648. }
  9649. });
  9650. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9651. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9652. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9653. if (_this.dragging && _this._moving && pickedMesh) {
  9654. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9655. // Slowly move mesh to avoid jitter
  9656. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9657. if (_this.rotateDraggedObject) {
  9658. // Get change in rotation
  9659. tmpQuaternion.copyFrom(_this._startingOrientation);
  9660. tmpQuaternion.x = -tmpQuaternion.x;
  9661. tmpQuaternion.y = -tmpQuaternion.y;
  9662. tmpQuaternion.z = -tmpQuaternion.z;
  9663. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9664. // Convert change in rotation to only y axis rotation
  9665. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9666. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9667. // Slowly move mesh to avoid jitter
  9668. var oldParent = pickedMesh.parent;
  9669. // Only rotate the mesh if it's parent has uniform scaling
  9670. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9671. pickedMesh.setParent(null);
  9672. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9673. pickedMesh.setParent(oldParent);
  9674. }
  9675. }
  9676. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9677. }
  9678. });
  9679. };
  9680. /**
  9681. * Detaches the behavior from the mesh
  9682. */
  9683. SixDofDragBehavior.prototype.detach = function () {
  9684. if (this._scene) {
  9685. this._scene.onPointerObservable.remove(this._pointerObserver);
  9686. }
  9687. if (this._ownerNode) {
  9688. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9689. }
  9690. if (this._virtualOriginMesh) {
  9691. this._virtualOriginMesh.dispose();
  9692. }
  9693. if (this._virtualDragMesh) {
  9694. this._virtualDragMesh.dispose();
  9695. }
  9696. this.onDragEndObservable.clear();
  9697. this.onDragStartObservable.clear();
  9698. };
  9699. return SixDofDragBehavior;
  9700. }());
  9701. /***/ }),
  9702. /***/ "./Behaviors/index.ts":
  9703. /*!****************************!*\
  9704. !*** ./Behaviors/index.ts ***!
  9705. \****************************/
  9706. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9708. "use strict";
  9709. __webpack_require__.r(__webpack_exports__);
  9710. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9714. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9720. /***/ }),
  9721. /***/ "./Bones/bone.ts":
  9722. /*!***********************!*\
  9723. !*** ./Bones/bone.ts ***!
  9724. \***********************/
  9725. /*! exports provided: Bone */
  9726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9727. "use strict";
  9728. __webpack_require__.r(__webpack_exports__);
  9729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9730. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9731. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9732. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9733. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9734. /**
  9735. * Class used to store bone information
  9736. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9737. */
  9738. var Bone = /** @class */ (function (_super) {
  9739. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9740. /**
  9741. * Create a new bone
  9742. * @param name defines the bone name
  9743. * @param skeleton defines the parent skeleton
  9744. * @param parentBone defines the parent (can be null if the bone is the root)
  9745. * @param localMatrix defines the local matrix
  9746. * @param restPose defines the rest pose matrix
  9747. * @param baseMatrix defines the base matrix
  9748. * @param index defines index of the bone in the hiearchy
  9749. */
  9750. function Bone(
  9751. /**
  9752. * defines the bone name
  9753. */
  9754. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9755. if (parentBone === void 0) { parentBone = null; }
  9756. if (localMatrix === void 0) { localMatrix = null; }
  9757. if (restPose === void 0) { restPose = null; }
  9758. if (baseMatrix === void 0) { baseMatrix = null; }
  9759. if (index === void 0) { index = null; }
  9760. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9761. _this.name = name;
  9762. /**
  9763. * Gets the list of child bones
  9764. */
  9765. _this.children = new Array();
  9766. /** Gets the animations associated with this bone */
  9767. _this.animations = new Array();
  9768. /**
  9769. * @hidden Internal only
  9770. * Set this value to map this bone to a different index in the transform matrices
  9771. * Set this value to -1 to exclude the bone from the transform matrices
  9772. */
  9773. _this._index = null;
  9774. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9775. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9776. _this._scalingDeterminant = 1;
  9777. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9778. _this._needToDecompose = true;
  9779. _this._needToCompose = false;
  9780. /** @hidden */
  9781. _this._linkedTransformNode = null;
  9782. _this._skeleton = skeleton;
  9783. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9784. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9785. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9786. _this._index = index;
  9787. skeleton.bones.push(_this);
  9788. _this.setParent(parentBone, false);
  9789. if (baseMatrix || localMatrix) {
  9790. _this._updateDifferenceMatrix();
  9791. }
  9792. return _this;
  9793. }
  9794. Object.defineProperty(Bone.prototype, "_matrix", {
  9795. /** @hidden */
  9796. get: function () {
  9797. this._compose();
  9798. return this._localMatrix;
  9799. },
  9800. /** @hidden */
  9801. set: function (value) {
  9802. this._localMatrix.copyFrom(value);
  9803. this._needToDecompose = true;
  9804. },
  9805. enumerable: true,
  9806. configurable: true
  9807. });
  9808. /**
  9809. * Gets the current object class name.
  9810. * @return the class name
  9811. */
  9812. Bone.prototype.getClassName = function () {
  9813. return "Bone";
  9814. };
  9815. // Members
  9816. /**
  9817. * Gets the parent skeleton
  9818. * @returns a skeleton
  9819. */
  9820. Bone.prototype.getSkeleton = function () {
  9821. return this._skeleton;
  9822. };
  9823. /**
  9824. * Gets parent bone
  9825. * @returns a bone or null if the bone is the root of the bone hierarchy
  9826. */
  9827. Bone.prototype.getParent = function () {
  9828. return this._parent;
  9829. };
  9830. /**
  9831. * Returns an array containing the root bones
  9832. * @returns an array containing the root bones
  9833. */
  9834. Bone.prototype.getChildren = function () {
  9835. return this.children;
  9836. };
  9837. /**
  9838. * Sets the parent bone
  9839. * @param parent defines the parent (can be null if the bone is the root)
  9840. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9841. */
  9842. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9843. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9844. if (this._parent === parent) {
  9845. return;
  9846. }
  9847. if (this._parent) {
  9848. var index = this._parent.children.indexOf(this);
  9849. if (index !== -1) {
  9850. this._parent.children.splice(index, 1);
  9851. }
  9852. }
  9853. this._parent = parent;
  9854. if (this._parent) {
  9855. this._parent.children.push(this);
  9856. }
  9857. if (updateDifferenceMatrix) {
  9858. this._updateDifferenceMatrix();
  9859. }
  9860. this.markAsDirty();
  9861. };
  9862. /**
  9863. * Gets the local matrix
  9864. * @returns a matrix
  9865. */
  9866. Bone.prototype.getLocalMatrix = function () {
  9867. this._compose();
  9868. return this._localMatrix;
  9869. };
  9870. /**
  9871. * Gets the base matrix (initial matrix which remains unchanged)
  9872. * @returns a matrix
  9873. */
  9874. Bone.prototype.getBaseMatrix = function () {
  9875. return this._baseMatrix;
  9876. };
  9877. /**
  9878. * Gets the rest pose matrix
  9879. * @returns a matrix
  9880. */
  9881. Bone.prototype.getRestPose = function () {
  9882. return this._restPose;
  9883. };
  9884. /**
  9885. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9886. */
  9887. Bone.prototype.getWorldMatrix = function () {
  9888. return this._worldTransform;
  9889. };
  9890. /**
  9891. * Sets the local matrix to rest pose matrix
  9892. */
  9893. Bone.prototype.returnToRest = function () {
  9894. this.updateMatrix(this._restPose.clone());
  9895. };
  9896. /**
  9897. * Gets the inverse of the absolute transform matrix.
  9898. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9899. * @returns a matrix
  9900. */
  9901. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9902. return this._invertedAbsoluteTransform;
  9903. };
  9904. /**
  9905. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9906. * @returns a matrix
  9907. */
  9908. Bone.prototype.getAbsoluteTransform = function () {
  9909. return this._absoluteTransform;
  9910. };
  9911. /**
  9912. * Links with the given transform node.
  9913. * The local matrix of this bone is copied from the transform node every frame.
  9914. * @param transformNode defines the transform node to link to
  9915. */
  9916. Bone.prototype.linkTransformNode = function (transformNode) {
  9917. if (this._linkedTransformNode) {
  9918. this._skeleton._numBonesWithLinkedTransformNode--;
  9919. }
  9920. this._linkedTransformNode = transformNode;
  9921. if (this._linkedTransformNode) {
  9922. this._skeleton._numBonesWithLinkedTransformNode++;
  9923. }
  9924. };
  9925. Object.defineProperty(Bone.prototype, "position", {
  9926. // Properties (matches AbstractMesh properties)
  9927. /** Gets or sets current position (in local space) */
  9928. get: function () {
  9929. this._decompose();
  9930. return this._localPosition;
  9931. },
  9932. set: function (newPosition) {
  9933. this._decompose();
  9934. this._localPosition.copyFrom(newPosition);
  9935. this._markAsDirtyAndCompose();
  9936. },
  9937. enumerable: true,
  9938. configurable: true
  9939. });
  9940. Object.defineProperty(Bone.prototype, "rotation", {
  9941. /** Gets or sets current rotation (in local space) */
  9942. get: function () {
  9943. return this.getRotation();
  9944. },
  9945. set: function (newRotation) {
  9946. this.setRotation(newRotation);
  9947. },
  9948. enumerable: true,
  9949. configurable: true
  9950. });
  9951. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9952. /** Gets or sets current rotation quaternion (in local space) */
  9953. get: function () {
  9954. this._decompose();
  9955. return this._localRotation;
  9956. },
  9957. set: function (newRotation) {
  9958. this.setRotationQuaternion(newRotation);
  9959. },
  9960. enumerable: true,
  9961. configurable: true
  9962. });
  9963. Object.defineProperty(Bone.prototype, "scaling", {
  9964. /** Gets or sets current scaling (in local space) */
  9965. get: function () {
  9966. return this.getScale();
  9967. },
  9968. set: function (newScaling) {
  9969. this.setScale(newScaling);
  9970. },
  9971. enumerable: true,
  9972. configurable: true
  9973. });
  9974. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9975. /**
  9976. * Gets the animation properties override
  9977. */
  9978. get: function () {
  9979. return this._skeleton.animationPropertiesOverride;
  9980. },
  9981. enumerable: true,
  9982. configurable: true
  9983. });
  9984. // Methods
  9985. Bone.prototype._decompose = function () {
  9986. if (!this._needToDecompose) {
  9987. return;
  9988. }
  9989. this._needToDecompose = false;
  9990. if (!this._localScaling) {
  9991. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9992. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9993. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9994. }
  9995. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9996. };
  9997. Bone.prototype._compose = function () {
  9998. if (!this._needToCompose) {
  9999. return;
  10000. }
  10001. this._needToCompose = false;
  10002. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  10003. };
  10004. /**
  10005. * Update the base and local matrices
  10006. * @param matrix defines the new base or local matrix
  10007. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10008. * @param updateLocalMatrix defines if the local matrix should be updated
  10009. */
  10010. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10011. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10012. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10013. this._baseMatrix.copyFrom(matrix);
  10014. if (updateDifferenceMatrix) {
  10015. this._updateDifferenceMatrix();
  10016. }
  10017. if (updateLocalMatrix) {
  10018. this._localMatrix.copyFrom(matrix);
  10019. this._markAsDirtyAndDecompose();
  10020. }
  10021. else {
  10022. this.markAsDirty();
  10023. }
  10024. };
  10025. /** @hidden */
  10026. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10027. if (updateChildren === void 0) { updateChildren = true; }
  10028. if (!rootMatrix) {
  10029. rootMatrix = this._baseMatrix;
  10030. }
  10031. if (this._parent) {
  10032. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10033. }
  10034. else {
  10035. this._absoluteTransform.copyFrom(rootMatrix);
  10036. }
  10037. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10038. if (updateChildren) {
  10039. for (var index = 0; index < this.children.length; index++) {
  10040. this.children[index]._updateDifferenceMatrix();
  10041. }
  10042. }
  10043. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10044. };
  10045. /**
  10046. * Flag the bone as dirty (Forcing it to update everything)
  10047. */
  10048. Bone.prototype.markAsDirty = function () {
  10049. this._currentRenderId++;
  10050. this._childRenderId++;
  10051. this._skeleton._markAsDirty();
  10052. };
  10053. Bone.prototype._markAsDirtyAndCompose = function () {
  10054. this.markAsDirty();
  10055. this._needToCompose = true;
  10056. };
  10057. Bone.prototype._markAsDirtyAndDecompose = function () {
  10058. this.markAsDirty();
  10059. this._needToDecompose = true;
  10060. };
  10061. /**
  10062. * Translate the bone in local or world space
  10063. * @param vec The amount to translate the bone
  10064. * @param space The space that the translation is in
  10065. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10066. */
  10067. Bone.prototype.translate = function (vec, space, mesh) {
  10068. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10069. var lm = this.getLocalMatrix();
  10070. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10071. lm.addAtIndex(12, vec.x);
  10072. lm.addAtIndex(13, vec.y);
  10073. lm.addAtIndex(14, vec.z);
  10074. }
  10075. else {
  10076. var wm = null;
  10077. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10078. if (mesh) {
  10079. wm = mesh.getWorldMatrix();
  10080. }
  10081. this._skeleton.computeAbsoluteTransforms();
  10082. var tmat = Bone._tmpMats[0];
  10083. var tvec = Bone._tmpVecs[0];
  10084. if (this._parent) {
  10085. if (mesh && wm) {
  10086. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10087. tmat.multiplyToRef(wm, tmat);
  10088. }
  10089. else {
  10090. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10091. }
  10092. }
  10093. tmat.setTranslationFromFloats(0, 0, 0);
  10094. tmat.invert();
  10095. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10096. lm.addAtIndex(12, tvec.x);
  10097. lm.addAtIndex(13, tvec.y);
  10098. lm.addAtIndex(14, tvec.z);
  10099. }
  10100. this._markAsDirtyAndDecompose();
  10101. };
  10102. /**
  10103. * Set the postion of the bone in local or world space
  10104. * @param position The position to set the bone
  10105. * @param space The space that the position is in
  10106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10107. */
  10108. Bone.prototype.setPosition = function (position, space, mesh) {
  10109. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10110. var lm = this.getLocalMatrix();
  10111. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10112. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10113. }
  10114. else {
  10115. var wm = null;
  10116. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10117. if (mesh) {
  10118. wm = mesh.getWorldMatrix();
  10119. }
  10120. this._skeleton.computeAbsoluteTransforms();
  10121. var tmat = Bone._tmpMats[0];
  10122. var vec = Bone._tmpVecs[0];
  10123. if (this._parent) {
  10124. if (mesh && wm) {
  10125. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10126. tmat.multiplyToRef(wm, tmat);
  10127. }
  10128. else {
  10129. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10130. }
  10131. }
  10132. tmat.invert();
  10133. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10134. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10135. }
  10136. this._markAsDirtyAndDecompose();
  10137. };
  10138. /**
  10139. * Set the absolute position of the bone (world space)
  10140. * @param position The position to set the bone
  10141. * @param mesh The mesh that this bone is attached to
  10142. */
  10143. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10144. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10145. };
  10146. /**
  10147. * Scale the bone on the x, y and z axes (in local space)
  10148. * @param x The amount to scale the bone on the x axis
  10149. * @param y The amount to scale the bone on the y axis
  10150. * @param z The amount to scale the bone on the z axis
  10151. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10152. */
  10153. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10154. if (scaleChildren === void 0) { scaleChildren = false; }
  10155. var locMat = this.getLocalMatrix();
  10156. // Apply new scaling on top of current local matrix
  10157. var scaleMat = Bone._tmpMats[0];
  10158. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10159. scaleMat.multiplyToRef(locMat, locMat);
  10160. // Invert scaling matrix and apply the inverse to all children
  10161. scaleMat.invert();
  10162. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10163. var child = _a[_i];
  10164. var cm = child.getLocalMatrix();
  10165. cm.multiplyToRef(scaleMat, cm);
  10166. cm.multiplyAtIndex(12, x);
  10167. cm.multiplyAtIndex(13, y);
  10168. cm.multiplyAtIndex(14, z);
  10169. child._markAsDirtyAndDecompose();
  10170. }
  10171. this._markAsDirtyAndDecompose();
  10172. if (scaleChildren) {
  10173. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10174. var child = _c[_b];
  10175. child.scale(x, y, z, scaleChildren);
  10176. }
  10177. }
  10178. };
  10179. /**
  10180. * Set the bone scaling in local space
  10181. * @param scale defines the scaling vector
  10182. */
  10183. Bone.prototype.setScale = function (scale) {
  10184. this._decompose();
  10185. this._localScaling.copyFrom(scale);
  10186. this._markAsDirtyAndCompose();
  10187. };
  10188. /**
  10189. * Gets the current scaling in local space
  10190. * @returns the current scaling vector
  10191. */
  10192. Bone.prototype.getScale = function () {
  10193. this._decompose();
  10194. return this._localScaling;
  10195. };
  10196. /**
  10197. * Gets the current scaling in local space and stores it in a target vector
  10198. * @param result defines the target vector
  10199. */
  10200. Bone.prototype.getScaleToRef = function (result) {
  10201. this._decompose();
  10202. result.copyFrom(this._localScaling);
  10203. };
  10204. /**
  10205. * Set the yaw, pitch, and roll of the bone in local or world space
  10206. * @param yaw The rotation of the bone on the y axis
  10207. * @param pitch The rotation of the bone on the x axis
  10208. * @param roll The rotation of the bone on the z axis
  10209. * @param space The space that the axes of rotation are in
  10210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10211. */
  10212. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10213. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10214. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10215. var quat = Bone._tmpQuat;
  10216. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10217. this.setRotationQuaternion(quat, space, mesh);
  10218. return;
  10219. }
  10220. var rotMatInv = Bone._tmpMats[0];
  10221. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10222. return;
  10223. }
  10224. var rotMat = Bone._tmpMats[1];
  10225. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10226. rotMatInv.multiplyToRef(rotMat, rotMat);
  10227. this._rotateWithMatrix(rotMat, space, mesh);
  10228. };
  10229. /**
  10230. * Add a rotation to the bone on an axis in local or world space
  10231. * @param axis The axis to rotate the bone on
  10232. * @param amount The amount to rotate the bone
  10233. * @param space The space that the axis is in
  10234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10235. */
  10236. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10237. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10238. var rmat = Bone._tmpMats[0];
  10239. rmat.setTranslationFromFloats(0, 0, 0);
  10240. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10241. this._rotateWithMatrix(rmat, space, mesh);
  10242. };
  10243. /**
  10244. * Set the rotation of the bone to a particular axis angle in local or world space
  10245. * @param axis The axis to rotate the bone on
  10246. * @param angle The angle that the bone should be rotated to
  10247. * @param space The space that the axis is in
  10248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10249. */
  10250. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10251. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10252. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10253. var quat = Bone._tmpQuat;
  10254. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10255. this.setRotationQuaternion(quat, space, mesh);
  10256. return;
  10257. }
  10258. var rotMatInv = Bone._tmpMats[0];
  10259. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10260. return;
  10261. }
  10262. var rotMat = Bone._tmpMats[1];
  10263. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10264. rotMatInv.multiplyToRef(rotMat, rotMat);
  10265. this._rotateWithMatrix(rotMat, space, mesh);
  10266. };
  10267. /**
  10268. * Set the euler rotation of the bone in local of world space
  10269. * @param rotation The euler rotation that the bone should be set to
  10270. * @param space The space that the rotation is in
  10271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10272. */
  10273. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10274. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10275. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10276. };
  10277. /**
  10278. * Set the quaternion rotation of the bone in local of world space
  10279. * @param quat The quaternion rotation that the bone should be set to
  10280. * @param space The space that the rotation is in
  10281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10282. */
  10283. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10284. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10285. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10286. this._decompose();
  10287. this._localRotation.copyFrom(quat);
  10288. this._markAsDirtyAndCompose();
  10289. return;
  10290. }
  10291. var rotMatInv = Bone._tmpMats[0];
  10292. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10293. return;
  10294. }
  10295. var rotMat = Bone._tmpMats[1];
  10296. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10297. rotMatInv.multiplyToRef(rotMat, rotMat);
  10298. this._rotateWithMatrix(rotMat, space, mesh);
  10299. };
  10300. /**
  10301. * Set the rotation matrix of the bone in local of world space
  10302. * @param rotMat The rotation matrix that the bone should be set to
  10303. * @param space The space that the rotation is in
  10304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10305. */
  10306. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10307. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10308. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10309. var quat = Bone._tmpQuat;
  10310. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10311. this.setRotationQuaternion(quat, space, mesh);
  10312. return;
  10313. }
  10314. var rotMatInv = Bone._tmpMats[0];
  10315. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10316. return;
  10317. }
  10318. var rotMat2 = Bone._tmpMats[1];
  10319. rotMat2.copyFrom(rotMat);
  10320. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10321. this._rotateWithMatrix(rotMat2, space, mesh);
  10322. };
  10323. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10324. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10325. var lmat = this.getLocalMatrix();
  10326. var lx = lmat.m[12];
  10327. var ly = lmat.m[13];
  10328. var lz = lmat.m[14];
  10329. var parent = this.getParent();
  10330. var parentScale = Bone._tmpMats[3];
  10331. var parentScaleInv = Bone._tmpMats[4];
  10332. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10333. if (mesh) {
  10334. parentScale.copyFrom(mesh.getWorldMatrix());
  10335. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10336. }
  10337. else {
  10338. parentScale.copyFrom(parent.getAbsoluteTransform());
  10339. }
  10340. parentScaleInv.copyFrom(parentScale);
  10341. parentScaleInv.invert();
  10342. lmat.multiplyToRef(parentScale, lmat);
  10343. lmat.multiplyToRef(rmat, lmat);
  10344. lmat.multiplyToRef(parentScaleInv, lmat);
  10345. }
  10346. else {
  10347. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10348. parentScale.copyFrom(mesh.getWorldMatrix());
  10349. parentScaleInv.copyFrom(parentScale);
  10350. parentScaleInv.invert();
  10351. lmat.multiplyToRef(parentScale, lmat);
  10352. lmat.multiplyToRef(rmat, lmat);
  10353. lmat.multiplyToRef(parentScaleInv, lmat);
  10354. }
  10355. else {
  10356. lmat.multiplyToRef(rmat, lmat);
  10357. }
  10358. }
  10359. lmat.setTranslationFromFloats(lx, ly, lz);
  10360. this.computeAbsoluteTransforms();
  10361. this._markAsDirtyAndDecompose();
  10362. };
  10363. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10364. var scaleMatrix = Bone._tmpMats[2];
  10365. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10366. if (mesh) {
  10367. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10368. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10369. }
  10370. rotMatInv.invert();
  10371. if (isNaN(rotMatInv.m[0])) {
  10372. // Matrix failed to invert.
  10373. // This can happen if scale is zero for example.
  10374. return false;
  10375. }
  10376. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10377. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10378. return true;
  10379. };
  10380. /**
  10381. * Get the position of the bone in local or world space
  10382. * @param space The space that the returned position is in
  10383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10384. * @returns The position of the bone
  10385. */
  10386. Bone.prototype.getPosition = function (space, mesh) {
  10387. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10388. if (mesh === void 0) { mesh = null; }
  10389. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10390. this.getPositionToRef(space, mesh, pos);
  10391. return pos;
  10392. };
  10393. /**
  10394. * Copy the position of the bone to a vector3 in local or world space
  10395. * @param space The space that the returned position is in
  10396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10397. * @param result The vector3 to copy the position to
  10398. */
  10399. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10400. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10401. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10402. var lm = this.getLocalMatrix();
  10403. result.x = lm.m[12];
  10404. result.y = lm.m[13];
  10405. result.z = lm.m[14];
  10406. }
  10407. else {
  10408. var wm = null;
  10409. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10410. if (mesh) {
  10411. wm = mesh.getWorldMatrix();
  10412. }
  10413. this._skeleton.computeAbsoluteTransforms();
  10414. var tmat = Bone._tmpMats[0];
  10415. if (mesh && wm) {
  10416. tmat.copyFrom(this.getAbsoluteTransform());
  10417. tmat.multiplyToRef(wm, tmat);
  10418. }
  10419. else {
  10420. tmat = this.getAbsoluteTransform();
  10421. }
  10422. result.x = tmat.m[12];
  10423. result.y = tmat.m[13];
  10424. result.z = tmat.m[14];
  10425. }
  10426. };
  10427. /**
  10428. * Get the absolute position of the bone (world space)
  10429. * @param mesh The mesh that this bone is attached to
  10430. * @returns The absolute position of the bone
  10431. */
  10432. Bone.prototype.getAbsolutePosition = function (mesh) {
  10433. if (mesh === void 0) { mesh = null; }
  10434. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10435. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10436. return pos;
  10437. };
  10438. /**
  10439. * Copy the absolute position of the bone (world space) to the result param
  10440. * @param mesh The mesh that this bone is attached to
  10441. * @param result The vector3 to copy the absolute position to
  10442. */
  10443. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10444. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10445. };
  10446. /**
  10447. * Compute the absolute transforms of this bone and its children
  10448. */
  10449. Bone.prototype.computeAbsoluteTransforms = function () {
  10450. this._compose();
  10451. if (this._parent) {
  10452. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10453. }
  10454. else {
  10455. this._absoluteTransform.copyFrom(this._localMatrix);
  10456. var poseMatrix = this._skeleton.getPoseMatrix();
  10457. if (poseMatrix) {
  10458. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10459. }
  10460. }
  10461. var children = this.children;
  10462. var len = children.length;
  10463. for (var i = 0; i < len; i++) {
  10464. children[i].computeAbsoluteTransforms();
  10465. }
  10466. };
  10467. /**
  10468. * Get the world direction from an axis that is in the local space of the bone
  10469. * @param localAxis The local direction that is used to compute the world direction
  10470. * @param mesh The mesh that this bone is attached to
  10471. * @returns The world direction
  10472. */
  10473. Bone.prototype.getDirection = function (localAxis, mesh) {
  10474. if (mesh === void 0) { mesh = null; }
  10475. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10476. this.getDirectionToRef(localAxis, mesh, result);
  10477. return result;
  10478. };
  10479. /**
  10480. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10481. * @param localAxis The local direction that is used to compute the world direction
  10482. * @param mesh The mesh that this bone is attached to
  10483. * @param result The vector3 that the world direction will be copied to
  10484. */
  10485. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10486. if (mesh === void 0) { mesh = null; }
  10487. var wm = null;
  10488. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10489. if (mesh) {
  10490. wm = mesh.getWorldMatrix();
  10491. }
  10492. this._skeleton.computeAbsoluteTransforms();
  10493. var mat = Bone._tmpMats[0];
  10494. mat.copyFrom(this.getAbsoluteTransform());
  10495. if (mesh && wm) {
  10496. mat.multiplyToRef(wm, mat);
  10497. }
  10498. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10499. result.normalize();
  10500. };
  10501. /**
  10502. * Get the euler rotation of the bone in local or world space
  10503. * @param space The space that the rotation should be in
  10504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10505. * @returns The euler rotation
  10506. */
  10507. Bone.prototype.getRotation = function (space, mesh) {
  10508. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10509. if (mesh === void 0) { mesh = null; }
  10510. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10511. this.getRotationToRef(space, mesh, result);
  10512. return result;
  10513. };
  10514. /**
  10515. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10516. * @param space The space that the rotation should be in
  10517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10518. * @param result The vector3 that the rotation should be copied to
  10519. */
  10520. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10521. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10522. if (mesh === void 0) { mesh = null; }
  10523. var quat = Bone._tmpQuat;
  10524. this.getRotationQuaternionToRef(space, mesh, quat);
  10525. quat.toEulerAnglesToRef(result);
  10526. };
  10527. /**
  10528. * Get the quaternion rotation of the bone in either local or world space
  10529. * @param space The space that the rotation should be in
  10530. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10531. * @returns The quaternion rotation
  10532. */
  10533. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10534. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10535. if (mesh === void 0) { mesh = null; }
  10536. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10537. this.getRotationQuaternionToRef(space, mesh, result);
  10538. return result;
  10539. };
  10540. /**
  10541. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10542. * @param space The space that the rotation should be in
  10543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10544. * @param result The quaternion that the rotation should be copied to
  10545. */
  10546. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10547. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10548. if (mesh === void 0) { mesh = null; }
  10549. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10550. this._decompose();
  10551. result.copyFrom(this._localRotation);
  10552. }
  10553. else {
  10554. var mat = Bone._tmpMats[0];
  10555. var amat = this.getAbsoluteTransform();
  10556. if (mesh) {
  10557. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10558. }
  10559. else {
  10560. mat.copyFrom(amat);
  10561. }
  10562. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10563. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10564. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10565. mat.decompose(undefined, result, undefined);
  10566. }
  10567. };
  10568. /**
  10569. * Get the rotation matrix of the bone in local or world space
  10570. * @param space The space that the rotation should be in
  10571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10572. * @returns The rotation matrix
  10573. */
  10574. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10575. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10576. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10577. this.getRotationMatrixToRef(space, mesh, result);
  10578. return result;
  10579. };
  10580. /**
  10581. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10582. * @param space The space that the rotation should be in
  10583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10584. * @param result The quaternion that the rotation should be copied to
  10585. */
  10586. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10587. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10588. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10589. this.getLocalMatrix().getRotationMatrixToRef(result);
  10590. }
  10591. else {
  10592. var mat = Bone._tmpMats[0];
  10593. var amat = this.getAbsoluteTransform();
  10594. if (mesh) {
  10595. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10596. }
  10597. else {
  10598. mat.copyFrom(amat);
  10599. }
  10600. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10601. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10602. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10603. mat.getRotationMatrixToRef(result);
  10604. }
  10605. };
  10606. /**
  10607. * Get the world position of a point that is in the local space of the bone
  10608. * @param position The local position
  10609. * @param mesh The mesh that this bone is attached to
  10610. * @returns The world position
  10611. */
  10612. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10613. if (mesh === void 0) { mesh = null; }
  10614. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10615. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10616. return result;
  10617. };
  10618. /**
  10619. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10620. * @param position The local position
  10621. * @param mesh The mesh that this bone is attached to
  10622. * @param result The vector3 that the world position should be copied to
  10623. */
  10624. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10625. if (mesh === void 0) { mesh = null; }
  10626. var wm = null;
  10627. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10628. if (mesh) {
  10629. wm = mesh.getWorldMatrix();
  10630. }
  10631. this._skeleton.computeAbsoluteTransforms();
  10632. var tmat = Bone._tmpMats[0];
  10633. if (mesh && wm) {
  10634. tmat.copyFrom(this.getAbsoluteTransform());
  10635. tmat.multiplyToRef(wm, tmat);
  10636. }
  10637. else {
  10638. tmat = this.getAbsoluteTransform();
  10639. }
  10640. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10641. };
  10642. /**
  10643. * Get the local position of a point that is in world space
  10644. * @param position The world position
  10645. * @param mesh The mesh that this bone is attached to
  10646. * @returns The local position
  10647. */
  10648. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10649. if (mesh === void 0) { mesh = null; }
  10650. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10651. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10652. return result;
  10653. };
  10654. /**
  10655. * Get the local position of a point that is in world space and copy it to the result param
  10656. * @param position The world position
  10657. * @param mesh The mesh that this bone is attached to
  10658. * @param result The vector3 that the local position should be copied to
  10659. */
  10660. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10661. if (mesh === void 0) { mesh = null; }
  10662. var wm = null;
  10663. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10664. if (mesh) {
  10665. wm = mesh.getWorldMatrix();
  10666. }
  10667. this._skeleton.computeAbsoluteTransforms();
  10668. var tmat = Bone._tmpMats[0];
  10669. tmat.copyFrom(this.getAbsoluteTransform());
  10670. if (mesh && wm) {
  10671. tmat.multiplyToRef(wm, tmat);
  10672. }
  10673. tmat.invert();
  10674. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10675. };
  10676. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10677. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10678. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10679. return Bone;
  10680. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10681. /***/ }),
  10682. /***/ "./Bones/boneIKController.ts":
  10683. /*!***********************************!*\
  10684. !*** ./Bones/boneIKController.ts ***!
  10685. \***********************************/
  10686. /*! exports provided: BoneIKController */
  10687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10688. "use strict";
  10689. __webpack_require__.r(__webpack_exports__);
  10690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10691. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10692. /**
  10693. * Class used to apply inverse kinematics to bones
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10695. */
  10696. var BoneIKController = /** @class */ (function () {
  10697. /**
  10698. * Creates a new BoneIKController
  10699. * @param mesh defines the mesh to control
  10700. * @param bone defines the bone to control
  10701. * @param options defines options to set up the controller
  10702. */
  10703. function BoneIKController(mesh, bone, options) {
  10704. /**
  10705. * Gets or sets the target position
  10706. */
  10707. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10708. /**
  10709. * Gets or sets the pole target position
  10710. */
  10711. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10712. /**
  10713. * Gets or sets the pole target local offset
  10714. */
  10715. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10716. /**
  10717. * Gets or sets the pole angle
  10718. */
  10719. this.poleAngle = 0;
  10720. /**
  10721. * 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)
  10722. */
  10723. this.slerpAmount = 1;
  10724. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10725. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10726. this._bone2Ang = Math.PI;
  10727. this._maxAngle = Math.PI;
  10728. this._rightHandedSystem = false;
  10729. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10730. this._slerping = false;
  10731. this._adjustRoll = 0;
  10732. this._bone2 = bone;
  10733. this._bone1 = bone.getParent();
  10734. if (!this._bone1) {
  10735. return;
  10736. }
  10737. this.mesh = mesh;
  10738. var bonePos = bone.getPosition();
  10739. if (bone.getAbsoluteTransform().determinant() > 0) {
  10740. this._rightHandedSystem = true;
  10741. this._bendAxis.x = 0;
  10742. this._bendAxis.y = 0;
  10743. this._bendAxis.z = -1;
  10744. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10745. this._adjustRoll = Math.PI * .5;
  10746. this._bendAxis.z = 1;
  10747. }
  10748. }
  10749. if (this._bone1.length) {
  10750. var boneScale1 = this._bone1.getScale();
  10751. var boneScale2 = this._bone2.getScale();
  10752. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10753. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10754. }
  10755. else if (this._bone1.children[0]) {
  10756. mesh.computeWorldMatrix(true);
  10757. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10758. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10759. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10760. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10761. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10762. }
  10763. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10764. this.maxAngle = Math.PI;
  10765. if (options) {
  10766. if (options.targetMesh) {
  10767. this.targetMesh = options.targetMesh;
  10768. this.targetMesh.computeWorldMatrix(true);
  10769. }
  10770. if (options.poleTargetMesh) {
  10771. this.poleTargetMesh = options.poleTargetMesh;
  10772. this.poleTargetMesh.computeWorldMatrix(true);
  10773. }
  10774. else if (options.poleTargetBone) {
  10775. this.poleTargetBone = options.poleTargetBone;
  10776. }
  10777. else if (this._bone1.getParent()) {
  10778. this.poleTargetBone = this._bone1.getParent();
  10779. }
  10780. if (options.poleTargetLocalOffset) {
  10781. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10782. }
  10783. if (options.poleAngle) {
  10784. this.poleAngle = options.poleAngle;
  10785. }
  10786. if (options.bendAxis) {
  10787. this._bendAxis.copyFrom(options.bendAxis);
  10788. }
  10789. if (options.maxAngle) {
  10790. this.maxAngle = options.maxAngle;
  10791. }
  10792. if (options.slerpAmount) {
  10793. this.slerpAmount = options.slerpAmount;
  10794. }
  10795. }
  10796. }
  10797. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10798. /**
  10799. * Gets or sets maximum allowed angle
  10800. */
  10801. get: function () {
  10802. return this._maxAngle;
  10803. },
  10804. set: function (value) {
  10805. this._setMaxAngle(value);
  10806. },
  10807. enumerable: true,
  10808. configurable: true
  10809. });
  10810. BoneIKController.prototype._setMaxAngle = function (ang) {
  10811. if (ang < 0) {
  10812. ang = 0;
  10813. }
  10814. if (ang > Math.PI || ang == undefined) {
  10815. ang = Math.PI;
  10816. }
  10817. this._maxAngle = ang;
  10818. var a = this._bone1Length;
  10819. var b = this._bone2Length;
  10820. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10821. };
  10822. /**
  10823. * Force the controller to update the bones
  10824. */
  10825. BoneIKController.prototype.update = function () {
  10826. var bone1 = this._bone1;
  10827. if (!bone1) {
  10828. return;
  10829. }
  10830. var target = this.targetPosition;
  10831. var poleTarget = this.poleTargetPosition;
  10832. var mat1 = BoneIKController._tmpMats[0];
  10833. var mat2 = BoneIKController._tmpMats[1];
  10834. if (this.targetMesh) {
  10835. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10836. }
  10837. if (this.poleTargetBone) {
  10838. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10839. }
  10840. else if (this.poleTargetMesh) {
  10841. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10842. }
  10843. var bonePos = BoneIKController._tmpVecs[0];
  10844. var zaxis = BoneIKController._tmpVecs[1];
  10845. var xaxis = BoneIKController._tmpVecs[2];
  10846. var yaxis = BoneIKController._tmpVecs[3];
  10847. var upAxis = BoneIKController._tmpVecs[4];
  10848. var _tmpQuat = BoneIKController._tmpQuat;
  10849. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10850. poleTarget.subtractToRef(bonePos, upAxis);
  10851. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10852. upAxis.y = 1;
  10853. }
  10854. else {
  10855. upAxis.normalize();
  10856. }
  10857. target.subtractToRef(bonePos, yaxis);
  10858. yaxis.normalize();
  10859. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10860. zaxis.normalize();
  10861. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10862. xaxis.normalize();
  10863. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10864. var a = this._bone1Length;
  10865. var b = this._bone2Length;
  10866. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10867. if (this._maxReach > 0) {
  10868. c = Math.min(this._maxReach, c);
  10869. }
  10870. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10871. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10872. if (acosa > 1) {
  10873. acosa = 1;
  10874. }
  10875. if (acosb > 1) {
  10876. acosb = 1;
  10877. }
  10878. if (acosa < -1) {
  10879. acosa = -1;
  10880. }
  10881. if (acosb < -1) {
  10882. acosb = -1;
  10883. }
  10884. var angA = Math.acos(acosa);
  10885. var angB = Math.acos(acosb);
  10886. var angC = -angA - angB;
  10887. if (this._rightHandedSystem) {
  10888. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10889. mat2.multiplyToRef(mat1, mat1);
  10890. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10891. mat2.multiplyToRef(mat1, mat1);
  10892. }
  10893. else {
  10894. var _tmpVec = BoneIKController._tmpVecs[5];
  10895. _tmpVec.copyFrom(this._bendAxis);
  10896. _tmpVec.x *= -1;
  10897. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10898. mat2.multiplyToRef(mat1, mat1);
  10899. }
  10900. if (this.poleAngle) {
  10901. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10902. mat1.multiplyToRef(mat2, mat1);
  10903. }
  10904. if (this._bone1) {
  10905. if (this.slerpAmount < 1) {
  10906. if (!this._slerping) {
  10907. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10908. }
  10909. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10910. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10911. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10912. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10913. this._slerping = true;
  10914. }
  10915. else {
  10916. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10917. this._bone1Mat.copyFrom(mat1);
  10918. this._slerping = false;
  10919. }
  10920. }
  10921. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10922. this._bone2Ang = angC;
  10923. };
  10924. 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()];
  10925. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10926. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10927. return BoneIKController;
  10928. }());
  10929. /***/ }),
  10930. /***/ "./Bones/boneLookController.ts":
  10931. /*!*************************************!*\
  10932. !*** ./Bones/boneLookController.ts ***!
  10933. \*************************************/
  10934. /*! exports provided: BoneLookController */
  10935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10936. "use strict";
  10937. __webpack_require__.r(__webpack_exports__);
  10938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10939. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10941. /**
  10942. * Class used to make a bone look toward a point in space
  10943. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10944. */
  10945. var BoneLookController = /** @class */ (function () {
  10946. /**
  10947. * Create a BoneLookController
  10948. * @param mesh the mesh that the bone belongs to
  10949. * @param bone the bone that will be looking to the target
  10950. * @param target the target Vector3 to look at
  10951. * @param options optional settings:
  10952. * * maxYaw: the maximum angle the bone will yaw to
  10953. * * minYaw: the minimum angle the bone will yaw to
  10954. * * maxPitch: the maximum angle the bone will pitch to
  10955. * * minPitch: the minimum angle the bone will yaw to
  10956. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10957. * * upAxis: the up axis of the coordinate system
  10958. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10959. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10960. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10961. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10962. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10963. * * adjustRoll: used to make an adjustment to the roll of the bone
  10964. **/
  10965. function BoneLookController(mesh, bone, target, options) {
  10966. /**
  10967. * The up axis of the coordinate system that is used when the bone is rotated
  10968. */
  10969. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10970. /**
  10971. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10972. */
  10973. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10974. /**
  10975. * Used to make an adjustment to the yaw of the bone
  10976. */
  10977. this.adjustYaw = 0;
  10978. /**
  10979. * Used to make an adjustment to the pitch of the bone
  10980. */
  10981. this.adjustPitch = 0;
  10982. /**
  10983. * Used to make an adjustment to the roll of the bone
  10984. */
  10985. this.adjustRoll = 0;
  10986. /**
  10987. * 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)
  10988. */
  10989. this.slerpAmount = 1;
  10990. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10991. this._slerping = false;
  10992. this._firstFrameSkipped = false;
  10993. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10994. this.mesh = mesh;
  10995. this.bone = bone;
  10996. this.target = target;
  10997. if (options) {
  10998. if (options.adjustYaw) {
  10999. this.adjustYaw = options.adjustYaw;
  11000. }
  11001. if (options.adjustPitch) {
  11002. this.adjustPitch = options.adjustPitch;
  11003. }
  11004. if (options.adjustRoll) {
  11005. this.adjustRoll = options.adjustRoll;
  11006. }
  11007. if (options.maxYaw != null) {
  11008. this.maxYaw = options.maxYaw;
  11009. }
  11010. else {
  11011. this.maxYaw = Math.PI;
  11012. }
  11013. if (options.minYaw != null) {
  11014. this.minYaw = options.minYaw;
  11015. }
  11016. else {
  11017. this.minYaw = -Math.PI;
  11018. }
  11019. if (options.maxPitch != null) {
  11020. this.maxPitch = options.maxPitch;
  11021. }
  11022. else {
  11023. this.maxPitch = Math.PI;
  11024. }
  11025. if (options.minPitch != null) {
  11026. this.minPitch = options.minPitch;
  11027. }
  11028. else {
  11029. this.minPitch = -Math.PI;
  11030. }
  11031. if (options.slerpAmount != null) {
  11032. this.slerpAmount = options.slerpAmount;
  11033. }
  11034. if (options.upAxis != null) {
  11035. this.upAxis = options.upAxis;
  11036. }
  11037. if (options.upAxisSpace != null) {
  11038. this.upAxisSpace = options.upAxisSpace;
  11039. }
  11040. if (options.yawAxis != null || options.pitchAxis != null) {
  11041. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11042. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11043. if (options.yawAxis != null) {
  11044. newYawAxis = options.yawAxis.clone();
  11045. newYawAxis.normalize();
  11046. }
  11047. if (options.pitchAxis != null) {
  11048. newPitchAxis = options.pitchAxis.clone();
  11049. newPitchAxis.normalize();
  11050. }
  11051. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11052. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11053. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11054. this._transformYawPitchInv = this._transformYawPitch.clone();
  11055. this._transformYawPitch.invert();
  11056. }
  11057. }
  11058. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11059. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11060. }
  11061. }
  11062. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11063. /**
  11064. * Gets or sets the minimum yaw angle that the bone can look to
  11065. */
  11066. get: function () {
  11067. return this._minYaw;
  11068. },
  11069. set: function (value) {
  11070. this._minYaw = value;
  11071. this._minYawSin = Math.sin(value);
  11072. this._minYawCos = Math.cos(value);
  11073. if (this._maxYaw != null) {
  11074. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11075. this._yawRange = this._maxYaw - this._minYaw;
  11076. }
  11077. },
  11078. enumerable: true,
  11079. configurable: true
  11080. });
  11081. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11082. /**
  11083. * Gets or sets the maximum yaw angle that the bone can look to
  11084. */
  11085. get: function () {
  11086. return this._maxYaw;
  11087. },
  11088. set: function (value) {
  11089. this._maxYaw = value;
  11090. this._maxYawSin = Math.sin(value);
  11091. this._maxYawCos = Math.cos(value);
  11092. if (this._minYaw != null) {
  11093. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11094. this._yawRange = this._maxYaw - this._minYaw;
  11095. }
  11096. },
  11097. enumerable: true,
  11098. configurable: true
  11099. });
  11100. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11101. /**
  11102. * Gets or sets the minimum pitch angle that the bone can look to
  11103. */
  11104. get: function () {
  11105. return this._minPitch;
  11106. },
  11107. set: function (value) {
  11108. this._minPitch = value;
  11109. this._minPitchTan = Math.tan(value);
  11110. },
  11111. enumerable: true,
  11112. configurable: true
  11113. });
  11114. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11115. /**
  11116. * Gets or sets the maximum pitch angle that the bone can look to
  11117. */
  11118. get: function () {
  11119. return this._maxPitch;
  11120. },
  11121. set: function (value) {
  11122. this._maxPitch = value;
  11123. this._maxPitchTan = Math.tan(value);
  11124. },
  11125. enumerable: true,
  11126. configurable: true
  11127. });
  11128. /**
  11129. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11130. */
  11131. BoneLookController.prototype.update = function () {
  11132. //skip the first frame when slerping so that the mesh rotation is correct
  11133. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11134. this._firstFrameSkipped = true;
  11135. return;
  11136. }
  11137. var bone = this.bone;
  11138. var bonePos = BoneLookController._tmpVecs[0];
  11139. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11140. var target = this.target;
  11141. var _tmpMat1 = BoneLookController._tmpMats[0];
  11142. var _tmpMat2 = BoneLookController._tmpMats[1];
  11143. var mesh = this.mesh;
  11144. var parentBone = bone.getParent();
  11145. var upAxis = BoneLookController._tmpVecs[1];
  11146. upAxis.copyFrom(this.upAxis);
  11147. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11148. if (this._transformYawPitch) {
  11149. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11150. }
  11151. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11152. }
  11153. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11154. mesh.getDirectionToRef(upAxis, upAxis);
  11155. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11156. upAxis.normalize();
  11157. }
  11158. }
  11159. var checkYaw = false;
  11160. var checkPitch = false;
  11161. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11162. checkYaw = true;
  11163. }
  11164. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11165. checkPitch = true;
  11166. }
  11167. if (checkYaw || checkPitch) {
  11168. var spaceMat = BoneLookController._tmpMats[2];
  11169. var spaceMatInv = BoneLookController._tmpMats[3];
  11170. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11171. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11172. }
  11173. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11174. spaceMat.copyFrom(mesh.getWorldMatrix());
  11175. }
  11176. else {
  11177. var forwardAxis = BoneLookController._tmpVecs[2];
  11178. forwardAxis.copyFrom(this._fowardAxis);
  11179. if (this._transformYawPitch) {
  11180. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11181. }
  11182. if (parentBone) {
  11183. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11184. }
  11185. else {
  11186. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11187. }
  11188. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11189. rightAxis.normalize();
  11190. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11191. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11192. }
  11193. spaceMat.invertToRef(spaceMatInv);
  11194. var xzlen = null;
  11195. if (checkPitch) {
  11196. var localTarget = BoneLookController._tmpVecs[3];
  11197. target.subtractToRef(bonePos, localTarget);
  11198. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11199. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11200. var pitch = Math.atan2(localTarget.y, xzlen);
  11201. var newPitch = pitch;
  11202. if (pitch > this._maxPitch) {
  11203. localTarget.y = this._maxPitchTan * xzlen;
  11204. newPitch = this._maxPitch;
  11205. }
  11206. else if (pitch < this._minPitch) {
  11207. localTarget.y = this._minPitchTan * xzlen;
  11208. newPitch = this._minPitch;
  11209. }
  11210. if (pitch != newPitch) {
  11211. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11212. localTarget.addInPlace(bonePos);
  11213. target = localTarget;
  11214. }
  11215. }
  11216. if (checkYaw) {
  11217. var localTarget = BoneLookController._tmpVecs[4];
  11218. target.subtractToRef(bonePos, localTarget);
  11219. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11220. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11221. var newYaw = yaw;
  11222. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11223. if (xzlen == null) {
  11224. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11225. }
  11226. if (this._yawRange > Math.PI) {
  11227. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11228. localTarget.z = this._maxYawCos * xzlen;
  11229. localTarget.x = this._maxYawSin * xzlen;
  11230. newYaw = this._maxYaw;
  11231. }
  11232. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11233. localTarget.z = this._minYawCos * xzlen;
  11234. localTarget.x = this._minYawSin * xzlen;
  11235. newYaw = this._minYaw;
  11236. }
  11237. }
  11238. else {
  11239. if (yaw > this._maxYaw) {
  11240. localTarget.z = this._maxYawCos * xzlen;
  11241. localTarget.x = this._maxYawSin * xzlen;
  11242. newYaw = this._maxYaw;
  11243. }
  11244. else if (yaw < this._minYaw) {
  11245. localTarget.z = this._minYawCos * xzlen;
  11246. localTarget.x = this._minYawSin * xzlen;
  11247. newYaw = this._minYaw;
  11248. }
  11249. }
  11250. }
  11251. if (this._slerping && this._yawRange > Math.PI) {
  11252. //are we going to be crossing into the min/max region?
  11253. var boneFwd = BoneLookController._tmpVecs[8];
  11254. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11255. if (this._transformYawPitch) {
  11256. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11257. }
  11258. var boneRotMat = BoneLookController._tmpMats[4];
  11259. this._boneQuat.toRotationMatrix(boneRotMat);
  11260. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11261. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11262. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11263. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11264. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11265. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11266. if (angBtwTar > angBtwMidYaw) {
  11267. if (xzlen == null) {
  11268. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11269. }
  11270. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11271. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11272. if (angBtwMin < angBtwMax) {
  11273. newYaw = boneYaw + Math.PI * .75;
  11274. localTarget.z = Math.cos(newYaw) * xzlen;
  11275. localTarget.x = Math.sin(newYaw) * xzlen;
  11276. }
  11277. else {
  11278. newYaw = boneYaw - Math.PI * .75;
  11279. localTarget.z = Math.cos(newYaw) * xzlen;
  11280. localTarget.x = Math.sin(newYaw) * xzlen;
  11281. }
  11282. }
  11283. }
  11284. if (yaw != newYaw) {
  11285. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11286. localTarget.addInPlace(bonePos);
  11287. target = localTarget;
  11288. }
  11289. }
  11290. }
  11291. var zaxis = BoneLookController._tmpVecs[5];
  11292. var xaxis = BoneLookController._tmpVecs[6];
  11293. var yaxis = BoneLookController._tmpVecs[7];
  11294. var _tmpQuat = BoneLookController._tmpQuat;
  11295. target.subtractToRef(bonePos, zaxis);
  11296. zaxis.normalize();
  11297. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11298. xaxis.normalize();
  11299. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11300. yaxis.normalize();
  11301. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11302. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11303. return;
  11304. }
  11305. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11306. return;
  11307. }
  11308. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11309. return;
  11310. }
  11311. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11312. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11313. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11314. }
  11315. if (this.slerpAmount < 1) {
  11316. if (!this._slerping) {
  11317. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11318. }
  11319. if (this._transformYawPitch) {
  11320. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11321. }
  11322. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11323. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11324. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11325. this._slerping = true;
  11326. }
  11327. else {
  11328. if (this._transformYawPitch) {
  11329. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11330. }
  11331. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11332. this._slerping = false;
  11333. }
  11334. };
  11335. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11336. var angDiff = ang2 - ang1;
  11337. angDiff %= Math.PI * 2;
  11338. if (angDiff > Math.PI) {
  11339. angDiff -= Math.PI * 2;
  11340. }
  11341. else if (angDiff < -Math.PI) {
  11342. angDiff += Math.PI * 2;
  11343. }
  11344. return angDiff;
  11345. };
  11346. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11347. ang1 %= (2 * Math.PI);
  11348. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11349. ang2 %= (2 * Math.PI);
  11350. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11351. var ab = 0;
  11352. if (ang1 < ang2) {
  11353. ab = ang2 - ang1;
  11354. }
  11355. else {
  11356. ab = ang1 - ang2;
  11357. }
  11358. if (ab > Math.PI) {
  11359. ab = Math.PI * 2 - ab;
  11360. }
  11361. return ab;
  11362. };
  11363. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11364. ang %= (2 * Math.PI);
  11365. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11366. ang1 %= (2 * Math.PI);
  11367. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11368. ang2 %= (2 * Math.PI);
  11369. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11370. if (ang1 < ang2) {
  11371. if (ang > ang1 && ang < ang2) {
  11372. return true;
  11373. }
  11374. }
  11375. else {
  11376. if (ang > ang2 && ang < ang1) {
  11377. return true;
  11378. }
  11379. }
  11380. return false;
  11381. };
  11382. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11383. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11384. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11385. return BoneLookController;
  11386. }());
  11387. /***/ }),
  11388. /***/ "./Bones/index.ts":
  11389. /*!************************!*\
  11390. !*** ./Bones/index.ts ***!
  11391. \************************/
  11392. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11394. "use strict";
  11395. __webpack_require__.r(__webpack_exports__);
  11396. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11398. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11400. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11402. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11404. /***/ }),
  11405. /***/ "./Bones/skeleton.ts":
  11406. /*!***************************!*\
  11407. !*** ./Bones/skeleton.ts ***!
  11408. \***************************/
  11409. /*! exports provided: Skeleton */
  11410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11411. "use strict";
  11412. __webpack_require__.r(__webpack_exports__);
  11413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11414. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11415. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11416. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11417. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11418. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11419. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11420. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11421. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11422. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11423. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11424. /**
  11425. * Class used to handle skinning animations
  11426. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11427. */
  11428. var Skeleton = /** @class */ (function () {
  11429. /**
  11430. * Creates a new skeleton
  11431. * @param name defines the skeleton name
  11432. * @param id defines the skeleton Id
  11433. * @param scene defines the hosting scene
  11434. */
  11435. function Skeleton(
  11436. /** defines the skeleton name */
  11437. name,
  11438. /** defines the skeleton Id */
  11439. id, scene) {
  11440. this.name = name;
  11441. this.id = id;
  11442. /**
  11443. * Defines the list of child bones
  11444. */
  11445. this.bones = new Array();
  11446. /**
  11447. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11448. */
  11449. this.needInitialSkinMatrix = false;
  11450. /**
  11451. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11452. */
  11453. this.overrideMesh = null;
  11454. this._isDirty = true;
  11455. this._meshesWithPoseMatrix = new Array();
  11456. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11457. this._ranges = {};
  11458. this._lastAbsoluteTransformsUpdateId = -1;
  11459. this._canUseTextureForBones = false;
  11460. this._uniqueId = 0;
  11461. /** @hidden */
  11462. this._numBonesWithLinkedTransformNode = 0;
  11463. /**
  11464. * Specifies if the skeleton should be serialized
  11465. */
  11466. this.doNotSerialize = false;
  11467. this._useTextureToStoreBoneMatrices = true;
  11468. this._animationPropertiesOverride = null;
  11469. // Events
  11470. /**
  11471. * An observable triggered before computing the skeleton's matrices
  11472. */
  11473. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11474. this.bones = [];
  11475. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11476. this._uniqueId = this._scene.getUniqueId();
  11477. this._scene.addSkeleton(this);
  11478. //make sure it will recalculate the matrix next time prepare is called.
  11479. this._isDirty = true;
  11480. var engineCaps = this._scene.getEngine().getCaps();
  11481. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11482. }
  11483. Object.defineProperty(Skeleton.prototype, "useTextureToStoreBoneMatrices", {
  11484. /**
  11485. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11486. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11487. */
  11488. get: function () {
  11489. return this._useTextureToStoreBoneMatrices;
  11490. },
  11491. set: function (value) {
  11492. this._useTextureToStoreBoneMatrices = value;
  11493. this._markAsDirty();
  11494. },
  11495. enumerable: true,
  11496. configurable: true
  11497. });
  11498. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11499. /**
  11500. * Gets or sets the animation properties override
  11501. */
  11502. get: function () {
  11503. if (!this._animationPropertiesOverride) {
  11504. return this._scene.animationPropertiesOverride;
  11505. }
  11506. return this._animationPropertiesOverride;
  11507. },
  11508. set: function (value) {
  11509. this._animationPropertiesOverride = value;
  11510. },
  11511. enumerable: true,
  11512. configurable: true
  11513. });
  11514. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11515. /**
  11516. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11517. */
  11518. get: function () {
  11519. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11520. },
  11521. enumerable: true,
  11522. configurable: true
  11523. });
  11524. Object.defineProperty(Skeleton.prototype, "uniqueId", {
  11525. /**
  11526. * Gets the unique ID of this skeleton
  11527. */
  11528. get: function () {
  11529. return this._uniqueId;
  11530. },
  11531. enumerable: true,
  11532. configurable: true
  11533. });
  11534. /**
  11535. * Gets the current object class name.
  11536. * @return the class name
  11537. */
  11538. Skeleton.prototype.getClassName = function () {
  11539. return "Skeleton";
  11540. };
  11541. /**
  11542. * Returns an array containing the root bones
  11543. * @returns an array containing the root bones
  11544. */
  11545. Skeleton.prototype.getChildren = function () {
  11546. return this.bones.filter(function (b) { return !b.getParent(); });
  11547. };
  11548. // Members
  11549. /**
  11550. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11551. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11552. * @returns a Float32Array containing matrices data
  11553. */
  11554. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11555. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11556. return mesh._bonesTransformMatrices;
  11557. }
  11558. if (!this._transformMatrices) {
  11559. this.prepare();
  11560. }
  11561. return this._transformMatrices;
  11562. };
  11563. /**
  11564. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11565. * @returns a raw texture containing the data
  11566. */
  11567. Skeleton.prototype.getTransformMatrixTexture = function () {
  11568. return this._transformMatrixTexture;
  11569. };
  11570. /**
  11571. * Gets the current hosting scene
  11572. * @returns a scene object
  11573. */
  11574. Skeleton.prototype.getScene = function () {
  11575. return this._scene;
  11576. };
  11577. // Methods
  11578. /**
  11579. * Gets a string representing the current skeleton data
  11580. * @param fullDetails defines a boolean indicating if we want a verbose version
  11581. * @returns a string representing the current skeleton data
  11582. */
  11583. Skeleton.prototype.toString = function (fullDetails) {
  11584. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11585. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11586. if (fullDetails) {
  11587. ret += ", Ranges: {";
  11588. var first = true;
  11589. for (var name_1 in this._ranges) {
  11590. if (first) {
  11591. ret += ", ";
  11592. first = false;
  11593. }
  11594. ret += name_1;
  11595. }
  11596. ret += "}";
  11597. }
  11598. return ret;
  11599. };
  11600. /**
  11601. * Get bone's index searching by name
  11602. * @param name defines bone's name to search for
  11603. * @return the indice of the bone. Returns -1 if not found
  11604. */
  11605. Skeleton.prototype.getBoneIndexByName = function (name) {
  11606. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11607. if (this.bones[boneIndex].name === name) {
  11608. return boneIndex;
  11609. }
  11610. }
  11611. return -1;
  11612. };
  11613. /**
  11614. * Creater a new animation range
  11615. * @param name defines the name of the range
  11616. * @param from defines the start key
  11617. * @param to defines the end key
  11618. */
  11619. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11620. // check name not already in use
  11621. if (!this._ranges[name]) {
  11622. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11623. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11624. if (this.bones[i].animations[0]) {
  11625. this.bones[i].animations[0].createRange(name, from, to);
  11626. }
  11627. }
  11628. }
  11629. };
  11630. /**
  11631. * Delete a specific animation range
  11632. * @param name defines the name of the range
  11633. * @param deleteFrames defines if frames must be removed as well
  11634. */
  11635. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11636. if (deleteFrames === void 0) { deleteFrames = true; }
  11637. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11638. if (this.bones[i].animations[0]) {
  11639. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11640. }
  11641. }
  11642. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11643. };
  11644. /**
  11645. * Gets a specific animation range
  11646. * @param name defines the name of the range to look for
  11647. * @returns the requested animation range or null if not found
  11648. */
  11649. Skeleton.prototype.getAnimationRange = function (name) {
  11650. return this._ranges[name];
  11651. };
  11652. /**
  11653. * Gets the list of all animation ranges defined on this skeleton
  11654. * @returns an array
  11655. */
  11656. Skeleton.prototype.getAnimationRanges = function () {
  11657. var animationRanges = [];
  11658. var name;
  11659. for (name in this._ranges) {
  11660. animationRanges.push(this._ranges[name]);
  11661. }
  11662. return animationRanges;
  11663. };
  11664. /**
  11665. * Copy animation range from a source skeleton.
  11666. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11667. * @param source defines the source skeleton
  11668. * @param name defines the name of the range to copy
  11669. * @param rescaleAsRequired defines if rescaling must be applied if required
  11670. * @returns true if operation was successful
  11671. */
  11672. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11673. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11674. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11675. return false;
  11676. }
  11677. var ret = true;
  11678. var frameOffset = this._getHighestAnimationFrame() + 1;
  11679. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11680. var boneDict = {};
  11681. var sourceBones = source.bones;
  11682. var nBones;
  11683. var i;
  11684. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11685. boneDict[sourceBones[i].name] = sourceBones[i];
  11686. }
  11687. if (this.bones.length !== sourceBones.length) {
  11688. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11689. ret = false;
  11690. }
  11691. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11692. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11693. var boneName = this.bones[i].name;
  11694. var sourceBone = boneDict[boneName];
  11695. if (sourceBone) {
  11696. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11697. }
  11698. else {
  11699. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11700. ret = false;
  11701. }
  11702. }
  11703. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11704. var range = source.getAnimationRange(name);
  11705. if (range) {
  11706. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11707. }
  11708. return ret;
  11709. };
  11710. /**
  11711. * Forces the skeleton to go to rest pose
  11712. */
  11713. Skeleton.prototype.returnToRest = function () {
  11714. for (var index = 0; index < this.bones.length; index++) {
  11715. this.bones[index].returnToRest();
  11716. }
  11717. };
  11718. Skeleton.prototype._getHighestAnimationFrame = function () {
  11719. var ret = 0;
  11720. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11721. if (this.bones[i].animations[0]) {
  11722. var highest = this.bones[i].animations[0].getHighestFrame();
  11723. if (ret < highest) {
  11724. ret = highest;
  11725. }
  11726. }
  11727. }
  11728. return ret;
  11729. };
  11730. /**
  11731. * Begin a specific animation range
  11732. * @param name defines the name of the range to start
  11733. * @param loop defines if looping must be turned on (false by default)
  11734. * @param speedRatio defines the speed ratio to apply (1 by default)
  11735. * @param onAnimationEnd defines a callback which will be called when animation will end
  11736. * @returns a new animatable
  11737. */
  11738. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11739. var range = this.getAnimationRange(name);
  11740. if (!range) {
  11741. return null;
  11742. }
  11743. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11744. };
  11745. /** @hidden */
  11746. Skeleton.prototype._markAsDirty = function () {
  11747. this._isDirty = true;
  11748. };
  11749. /** @hidden */
  11750. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11751. this._meshesWithPoseMatrix.push(mesh);
  11752. };
  11753. /** @hidden */
  11754. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11755. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11756. if (index > -1) {
  11757. this._meshesWithPoseMatrix.splice(index, 1);
  11758. }
  11759. };
  11760. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11761. this.onBeforeComputeObservable.notifyObservers(this);
  11762. for (var index = 0; index < this.bones.length; index++) {
  11763. var bone = this.bones[index];
  11764. var parentBone = bone.getParent();
  11765. if (parentBone) {
  11766. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11767. }
  11768. else {
  11769. if (initialSkinMatrix) {
  11770. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11771. }
  11772. else {
  11773. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11774. }
  11775. }
  11776. if (bone._index !== -1) {
  11777. var mappedIndex = bone._index === null ? index : bone._index;
  11778. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11779. }
  11780. }
  11781. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11782. };
  11783. /**
  11784. * Build all resources required to render a skeleton
  11785. */
  11786. Skeleton.prototype.prepare = function () {
  11787. // Update the local matrix of bones with linked transform nodes.
  11788. if (this._numBonesWithLinkedTransformNode > 0) {
  11789. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11790. var bone_1 = _a[_i];
  11791. if (bone_1._linkedTransformNode) {
  11792. // Computing the world matrix also computes the local matrix.
  11793. bone_1._linkedTransformNode.computeWorldMatrix();
  11794. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11795. bone_1.markAsDirty();
  11796. }
  11797. }
  11798. }
  11799. if (!this._isDirty) {
  11800. return;
  11801. }
  11802. if (this.needInitialSkinMatrix) {
  11803. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11804. var mesh = this._meshesWithPoseMatrix[index];
  11805. var poseMatrix = mesh.getPoseMatrix();
  11806. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11807. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11808. }
  11809. if (this._synchronizedWithMesh !== mesh) {
  11810. this._synchronizedWithMesh = mesh;
  11811. // Prepare bones
  11812. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11813. var bone = this.bones[boneIndex];
  11814. if (!bone.getParent()) {
  11815. var matrix = bone.getBaseMatrix();
  11816. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11817. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11818. }
  11819. }
  11820. }
  11821. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11822. }
  11823. }
  11824. else {
  11825. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11826. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11827. if (this.isUsingTextureForMatrices) {
  11828. if (this._transformMatrixTexture) {
  11829. this._transformMatrixTexture.dispose();
  11830. }
  11831. this._transformMatrixTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__["RawTexture"].CreateRGBATexture(this._transformMatrices, (this.bones.length + 1) * 4, 1, this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_FLOAT);
  11832. }
  11833. }
  11834. this._computeTransformMatrices(this._transformMatrices, null);
  11835. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11836. this._transformMatrixTexture.update(this._transformMatrices);
  11837. }
  11838. }
  11839. this._isDirty = false;
  11840. this._scene._activeBones.addCount(this.bones.length, false);
  11841. };
  11842. /**
  11843. * Gets the list of animatables currently running for this skeleton
  11844. * @returns an array of animatables
  11845. */
  11846. Skeleton.prototype.getAnimatables = function () {
  11847. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11848. this._animatables = [];
  11849. for (var index = 0; index < this.bones.length; index++) {
  11850. this._animatables.push(this.bones[index]);
  11851. }
  11852. }
  11853. return this._animatables;
  11854. };
  11855. /**
  11856. * Clone the current skeleton
  11857. * @param name defines the name of the new skeleton
  11858. * @param id defines the id of the enw skeleton
  11859. * @returns the new skeleton
  11860. */
  11861. Skeleton.prototype.clone = function (name, id) {
  11862. var result = new Skeleton(name, id || name, this._scene);
  11863. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11864. for (var index = 0; index < this.bones.length; index++) {
  11865. var source = this.bones[index];
  11866. var parentBone = null;
  11867. var parent_1 = source.getParent();
  11868. if (parent_1) {
  11869. var parentIndex = this.bones.indexOf(parent_1);
  11870. parentBone = result.bones[parentIndex];
  11871. }
  11872. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11873. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11874. }
  11875. if (this._ranges) {
  11876. result._ranges = {};
  11877. for (var rangeName in this._ranges) {
  11878. var range = this._ranges[rangeName];
  11879. if (range) {
  11880. result._ranges[rangeName] = range.clone();
  11881. }
  11882. }
  11883. }
  11884. this._isDirty = true;
  11885. return result;
  11886. };
  11887. /**
  11888. * Enable animation blending for this skeleton
  11889. * @param blendingSpeed defines the blending speed to apply
  11890. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11891. */
  11892. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11893. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11894. this.bones.forEach(function (bone) {
  11895. bone.animations.forEach(function (animation) {
  11896. animation.enableBlending = true;
  11897. animation.blendingSpeed = blendingSpeed;
  11898. });
  11899. });
  11900. };
  11901. /**
  11902. * Releases all resources associated with the current skeleton
  11903. */
  11904. Skeleton.prototype.dispose = function () {
  11905. this._meshesWithPoseMatrix = [];
  11906. // Animations
  11907. this.getScene().stopAnimation(this);
  11908. // Remove from scene
  11909. this.getScene().removeSkeleton(this);
  11910. if (this._transformMatrixTexture) {
  11911. this._transformMatrixTexture.dispose();
  11912. this._transformMatrixTexture = null;
  11913. }
  11914. };
  11915. /**
  11916. * Serialize the skeleton in a JSON object
  11917. * @returns a JSON object
  11918. */
  11919. Skeleton.prototype.serialize = function () {
  11920. var serializationObject = {};
  11921. serializationObject.name = this.name;
  11922. serializationObject.id = this.id;
  11923. if (this.dimensionsAtRest) {
  11924. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11925. }
  11926. serializationObject.bones = [];
  11927. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11928. for (var index = 0; index < this.bones.length; index++) {
  11929. var bone = this.bones[index];
  11930. var parent_2 = bone.getParent();
  11931. var serializedBone = {
  11932. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11933. name: bone.name,
  11934. matrix: bone.getBaseMatrix().toArray(),
  11935. rest: bone.getRestPose().toArray()
  11936. };
  11937. serializationObject.bones.push(serializedBone);
  11938. if (bone.length) {
  11939. serializedBone.length = bone.length;
  11940. }
  11941. if (bone.metadata) {
  11942. serializedBone.metadata = bone.metadata;
  11943. }
  11944. if (bone.animations && bone.animations.length > 0) {
  11945. serializedBone.animation = bone.animations[0].serialize();
  11946. }
  11947. serializationObject.ranges = [];
  11948. for (var name in this._ranges) {
  11949. var source = this._ranges[name];
  11950. if (!source) {
  11951. continue;
  11952. }
  11953. var range = {};
  11954. range.name = name;
  11955. range.from = source.from;
  11956. range.to = source.to;
  11957. serializationObject.ranges.push(range);
  11958. }
  11959. }
  11960. return serializationObject;
  11961. };
  11962. /**
  11963. * Creates a new skeleton from serialized data
  11964. * @param parsedSkeleton defines the serialized data
  11965. * @param scene defines the hosting scene
  11966. * @returns a new skeleton
  11967. */
  11968. Skeleton.Parse = function (parsedSkeleton, scene) {
  11969. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11970. if (parsedSkeleton.dimensionsAtRest) {
  11971. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11972. }
  11973. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11974. var index;
  11975. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11976. var parsedBone = parsedSkeleton.bones[index];
  11977. var parentBone = null;
  11978. if (parsedBone.parentBoneIndex > -1) {
  11979. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11980. }
  11981. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11982. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11983. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11984. bone.id = parsedBone.id;
  11985. }
  11986. if (parsedBone.length) {
  11987. bone.length = parsedBone.length;
  11988. }
  11989. if (parsedBone.metadata) {
  11990. bone.metadata = parsedBone.metadata;
  11991. }
  11992. if (parsedBone.animation) {
  11993. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11994. }
  11995. }
  11996. // placed after bones, so createAnimationRange can cascade down
  11997. if (parsedSkeleton.ranges) {
  11998. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11999. var data = parsedSkeleton.ranges[index];
  12000. skeleton.createAnimationRange(data.name, data.from, data.to);
  12001. }
  12002. }
  12003. return skeleton;
  12004. };
  12005. /**
  12006. * Compute all node absolute transforms
  12007. * @param forceUpdate defines if computation must be done even if cache is up to date
  12008. */
  12009. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  12010. if (forceUpdate === void 0) { forceUpdate = false; }
  12011. var renderId = this._scene.getRenderId();
  12012. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  12013. this.bones[0].computeAbsoluteTransforms();
  12014. this._lastAbsoluteTransformsUpdateId = renderId;
  12015. }
  12016. };
  12017. /**
  12018. * Gets the root pose matrix
  12019. * @returns a matrix
  12020. */
  12021. Skeleton.prototype.getPoseMatrix = function () {
  12022. var poseMatrix = null;
  12023. if (this._meshesWithPoseMatrix.length > 0) {
  12024. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  12025. }
  12026. return poseMatrix;
  12027. };
  12028. /**
  12029. * Sorts bones per internal index
  12030. */
  12031. Skeleton.prototype.sortBones = function () {
  12032. var bones = new Array();
  12033. var visited = new Array(this.bones.length);
  12034. for (var index = 0; index < this.bones.length; index++) {
  12035. this._sortBones(index, bones, visited);
  12036. }
  12037. this.bones = bones;
  12038. };
  12039. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12040. if (visited[index]) {
  12041. return;
  12042. }
  12043. visited[index] = true;
  12044. var bone = this.bones[index];
  12045. if (bone._index === undefined) {
  12046. bone._index = index;
  12047. }
  12048. var parentBone = bone.getParent();
  12049. if (parentBone) {
  12050. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12051. }
  12052. bones.push(bone);
  12053. };
  12054. return Skeleton;
  12055. }());
  12056. /***/ }),
  12057. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12058. /*!***************************************************!*\
  12059. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12060. \***************************************************/
  12061. /*! exports provided: BaseCameraPointersInput */
  12062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12063. "use strict";
  12064. __webpack_require__.r(__webpack_exports__);
  12065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12066. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12067. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12068. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12069. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12070. /**
  12071. * Base class for Camera Pointer Inputs.
  12072. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12073. * for example usage.
  12074. */
  12075. var BaseCameraPointersInput = /** @class */ (function () {
  12076. function BaseCameraPointersInput() {
  12077. /**
  12078. * Defines the buttons associated with the input to handle camera move.
  12079. */
  12080. this.buttons = [0, 1, 2];
  12081. }
  12082. /**
  12083. * Attach the input controls to a specific dom element to get the input from.
  12084. * @param element Defines the element the controls should be listened from
  12085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12086. */
  12087. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12088. var _this = this;
  12089. var engine = this.camera.getEngine();
  12090. var previousPinchSquaredDistance = 0;
  12091. var previousMultiTouchPanPosition = null;
  12092. this.pointA = null;
  12093. this.pointB = null;
  12094. this._altKey = false;
  12095. this._ctrlKey = false;
  12096. this._metaKey = false;
  12097. this._shiftKey = false;
  12098. this._buttonsPressed = 0;
  12099. this._pointerInput = function (p, s) {
  12100. var evt = p.event;
  12101. var isTouch = evt.pointerType === "touch";
  12102. if (engine.isInVRExclusivePointerMode) {
  12103. return;
  12104. }
  12105. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12106. _this.buttons.indexOf(evt.button) === -1) {
  12107. return;
  12108. }
  12109. var srcElement = (evt.srcElement || evt.target);
  12110. _this._altKey = evt.altKey;
  12111. _this._ctrlKey = evt.ctrlKey;
  12112. _this._metaKey = evt.metaKey;
  12113. _this._shiftKey = evt.shiftKey;
  12114. _this._buttonsPressed = evt.buttons;
  12115. if (engine.isPointerLock) {
  12116. var offsetX = evt.movementX ||
  12117. evt.mozMovementX ||
  12118. evt.webkitMovementX ||
  12119. evt.msMovementX ||
  12120. 0;
  12121. var offsetY = evt.movementY ||
  12122. evt.mozMovementY ||
  12123. evt.webkitMovementY ||
  12124. evt.msMovementY ||
  12125. 0;
  12126. _this.onTouch(null, offsetX, offsetY);
  12127. _this.pointA = null;
  12128. _this.pointB = null;
  12129. }
  12130. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12131. try {
  12132. srcElement.setPointerCapture(evt.pointerId);
  12133. }
  12134. catch (e) {
  12135. //Nothing to do with the error. Execution will continue.
  12136. }
  12137. if (_this.pointA === null) {
  12138. _this.pointA = { x: evt.clientX,
  12139. y: evt.clientY,
  12140. pointerId: evt.pointerId,
  12141. type: evt.pointerType };
  12142. }
  12143. else if (_this.pointB === null) {
  12144. _this.pointB = { x: evt.clientX,
  12145. y: evt.clientY,
  12146. pointerId: evt.pointerId,
  12147. type: evt.pointerType };
  12148. }
  12149. _this.onButtonDown(evt);
  12150. if (!noPreventDefault) {
  12151. evt.preventDefault();
  12152. element.focus();
  12153. }
  12154. }
  12155. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12156. _this.onDoubleTap(evt.pointerType);
  12157. }
  12158. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12159. try {
  12160. srcElement.releasePointerCapture(evt.pointerId);
  12161. }
  12162. catch (e) {
  12163. //Nothing to do with the error.
  12164. }
  12165. if (!isTouch) {
  12166. _this.pointB = null; // Mouse and pen are mono pointer
  12167. }
  12168. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12169. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12170. //when changing orientation while pinching camera,
  12171. //one pointer stay pressed forever if we don't release all pointers
  12172. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12173. if (engine._badOS) {
  12174. _this.pointA = _this.pointB = null;
  12175. }
  12176. else {
  12177. //only remove the impacted pointer in case of multitouch allowing on most
  12178. //platforms switching from rotate to zoom and pan seamlessly.
  12179. if (_this.pointB && _this.pointA && _this.pointA.pointerId == evt.pointerId) {
  12180. _this.pointA = _this.pointB;
  12181. _this.pointB = null;
  12182. }
  12183. else if (_this.pointA && _this.pointB &&
  12184. _this.pointB.pointerId == evt.pointerId) {
  12185. _this.pointB = null;
  12186. }
  12187. else {
  12188. _this.pointA = _this.pointB = null;
  12189. }
  12190. }
  12191. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12192. // Previous pinch data is populated but a button has been lifted
  12193. // so pinch has ended.
  12194. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12195. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12196. );
  12197. previousPinchSquaredDistance = 0;
  12198. previousMultiTouchPanPosition = null;
  12199. }
  12200. _this.onButtonUp(evt);
  12201. if (!noPreventDefault) {
  12202. evt.preventDefault();
  12203. }
  12204. }
  12205. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12206. if (!noPreventDefault) {
  12207. evt.preventDefault();
  12208. }
  12209. // One button down
  12210. if (_this.pointA && _this.pointB === null) {
  12211. var offsetX = evt.clientX - _this.pointA.x;
  12212. var offsetY = evt.clientY - _this.pointA.y;
  12213. _this.onTouch(_this.pointA, offsetX, offsetY);
  12214. _this.pointA.x = evt.clientX;
  12215. _this.pointA.y = evt.clientY;
  12216. }
  12217. // Two buttons down: pinch
  12218. else if (_this.pointA && _this.pointB) {
  12219. var ed = (_this.pointA.pointerId === evt.pointerId) ?
  12220. _this.pointA : _this.pointB;
  12221. ed.x = evt.clientX;
  12222. ed.y = evt.clientY;
  12223. var distX = _this.pointA.x - _this.pointB.x;
  12224. var distY = _this.pointA.y - _this.pointB.y;
  12225. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12226. var multiTouchPanPosition = { x: (_this.pointA.x + _this.pointB.x) / 2,
  12227. y: (_this.pointA.y + _this.pointB.y) / 2,
  12228. pointerId: evt.pointerId,
  12229. type: p.type };
  12230. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12231. previousMultiTouchPanPosition = multiTouchPanPosition;
  12232. previousPinchSquaredDistance = pinchSquaredDistance;
  12233. }
  12234. }
  12235. };
  12236. 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 |
  12237. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12238. this._onLostFocus = function () {
  12239. _this.pointA = _this.pointB = null;
  12240. previousPinchSquaredDistance = 0;
  12241. previousMultiTouchPanPosition = null;
  12242. _this.onLostFocus();
  12243. };
  12244. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12245. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12246. { name: "blur", handler: this._onLostFocus }
  12247. ]);
  12248. };
  12249. /**
  12250. * Detach the current controls from the specified dom element.
  12251. * @param element Defines the element to stop listening the inputs from
  12252. */
  12253. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12254. if (this._onLostFocus) {
  12255. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12256. { name: "blur", handler: this._onLostFocus }
  12257. ]);
  12258. }
  12259. if (element && this._observer) {
  12260. this.camera.getScene().onPointerObservable.remove(this._observer);
  12261. this._observer = null;
  12262. if (this.onContextMenu) {
  12263. element.removeEventListener("contextmenu", this.onContextMenu);
  12264. }
  12265. this._onLostFocus = null;
  12266. }
  12267. this._altKey = false;
  12268. this._ctrlKey = false;
  12269. this._metaKey = false;
  12270. this._shiftKey = false;
  12271. this._buttonsPressed = 0;
  12272. };
  12273. /**
  12274. * Gets the class name of the current input.
  12275. * @returns the class name
  12276. */
  12277. BaseCameraPointersInput.prototype.getClassName = function () {
  12278. return "BaseCameraPointersInput";
  12279. };
  12280. /**
  12281. * Get the friendly name associated with the input class.
  12282. * @returns the input friendly name
  12283. */
  12284. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12285. return "pointers";
  12286. };
  12287. /**
  12288. * Called on pointer POINTERDOUBLETAP event.
  12289. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12290. */
  12291. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12292. };
  12293. /**
  12294. * Called on pointer POINTERMOVE event if only a single touch is active.
  12295. * Override this method to provide functionality.
  12296. */
  12297. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12298. };
  12299. /**
  12300. * Called on pointer POINTERMOVE event if multiple touches are active.
  12301. * Override this method to provide functionality.
  12302. */
  12303. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12304. };
  12305. /**
  12306. * Called on JS contextmenu event.
  12307. * Override this method to provide functionality.
  12308. */
  12309. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12310. evt.preventDefault();
  12311. };
  12312. /**
  12313. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12314. * press.
  12315. * Override this method to provide functionality.
  12316. */
  12317. BaseCameraPointersInput.prototype.onButtonDown = function (evt) {
  12318. };
  12319. /**
  12320. * Called each time a new POINTERUP event occurs. Ie, for each button
  12321. * release.
  12322. * Override this method to provide functionality.
  12323. */
  12324. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12325. };
  12326. /**
  12327. * Called when window becomes inactive.
  12328. * Override this method to provide functionality.
  12329. */
  12330. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12331. };
  12332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12334. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12335. return BaseCameraPointersInput;
  12336. }());
  12337. /***/ }),
  12338. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12339. /*!*******************************************************!*\
  12340. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12341. \*******************************************************/
  12342. /*! exports provided: ArcRotateCameraGamepadInput */
  12343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12344. "use strict";
  12345. __webpack_require__.r(__webpack_exports__);
  12346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12347. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12348. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12349. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12350. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12351. /**
  12352. * Manage the gamepad inputs to control an arc rotate camera.
  12353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12354. */
  12355. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12356. function ArcRotateCameraGamepadInput() {
  12357. /**
  12358. * Defines the gamepad rotation sensiblity.
  12359. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12360. */
  12361. this.gamepadRotationSensibility = 80;
  12362. /**
  12363. * Defines the gamepad move sensiblity.
  12364. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12365. */
  12366. this.gamepadMoveSensibility = 40;
  12367. }
  12368. /**
  12369. * Attach the input controls to a specific dom element to get the input from.
  12370. * @param element Defines the element the controls should be listened from
  12371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12372. */
  12373. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12374. var _this = this;
  12375. var manager = this.camera.getScene().gamepadManager;
  12376. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12377. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12378. // prioritize XBOX gamepads.
  12379. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12380. _this.gamepad = gamepad;
  12381. }
  12382. }
  12383. });
  12384. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12385. if (_this.gamepad === gamepad) {
  12386. _this.gamepad = null;
  12387. }
  12388. });
  12389. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12390. };
  12391. /**
  12392. * Detach the current controls from the specified dom element.
  12393. * @param element Defines the element to stop listening the inputs from
  12394. */
  12395. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12396. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12397. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12398. this.gamepad = null;
  12399. };
  12400. /**
  12401. * Update the current camera state depending on the inputs that have been used this frame.
  12402. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12403. */
  12404. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12405. if (this.gamepad) {
  12406. var camera = this.camera;
  12407. var RSValues = this.gamepad.rightStick;
  12408. if (RSValues) {
  12409. if (RSValues.x != 0) {
  12410. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12411. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12412. camera.inertialAlphaOffset += normalizedRX;
  12413. }
  12414. }
  12415. if (RSValues.y != 0) {
  12416. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12417. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12418. camera.inertialBetaOffset += normalizedRY;
  12419. }
  12420. }
  12421. }
  12422. var LSValues = this.gamepad.leftStick;
  12423. if (LSValues && LSValues.y != 0) {
  12424. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12425. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12426. this.camera.inertialRadiusOffset -= normalizedLY;
  12427. }
  12428. }
  12429. }
  12430. };
  12431. /**
  12432. * Gets the class name of the current intput.
  12433. * @returns the class name
  12434. */
  12435. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12436. return "ArcRotateCameraGamepadInput";
  12437. };
  12438. /**
  12439. * Get the friendly name associated with the input class.
  12440. * @returns the input friendly name
  12441. */
  12442. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12443. return "gamepad";
  12444. };
  12445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12447. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12450. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12451. return ArcRotateCameraGamepadInput;
  12452. }());
  12453. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12454. /***/ }),
  12455. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12456. /*!************************************************************!*\
  12457. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12458. \************************************************************/
  12459. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12461. "use strict";
  12462. __webpack_require__.r(__webpack_exports__);
  12463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12464. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12465. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12466. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12467. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12468. /**
  12469. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12471. */
  12472. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12473. function ArcRotateCameraKeyboardMoveInput() {
  12474. /**
  12475. * Defines the list of key codes associated with the up action (increase alpha)
  12476. */
  12477. this.keysUp = [38];
  12478. /**
  12479. * Defines the list of key codes associated with the down action (decrease alpha)
  12480. */
  12481. this.keysDown = [40];
  12482. /**
  12483. * Defines the list of key codes associated with the left action (increase beta)
  12484. */
  12485. this.keysLeft = [37];
  12486. /**
  12487. * Defines the list of key codes associated with the right action (decrease beta)
  12488. */
  12489. this.keysRight = [39];
  12490. /**
  12491. * Defines the list of key codes associated with the reset action.
  12492. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12493. */
  12494. this.keysReset = [220];
  12495. /**
  12496. * Defines the panning sensibility of the inputs.
  12497. * (How fast is the camera paning)
  12498. */
  12499. this.panningSensibility = 50.0;
  12500. /**
  12501. * Defines the zooming sensibility of the inputs.
  12502. * (How fast is the camera zooming)
  12503. */
  12504. this.zoomingSensibility = 25.0;
  12505. /**
  12506. * Defines wether maintaining the alt key down switch the movement mode from
  12507. * orientation to zoom.
  12508. */
  12509. this.useAltToZoom = true;
  12510. /**
  12511. * Rotation speed of the camera
  12512. */
  12513. this.angularSpeed = 0.01;
  12514. this._keys = new Array();
  12515. }
  12516. /**
  12517. * Attach the input controls to a specific dom element to get the input from.
  12518. * @param element Defines the element the controls should be listened from
  12519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12520. */
  12521. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12522. var _this = this;
  12523. if (this._onCanvasBlurObserver) {
  12524. return;
  12525. }
  12526. this._scene = this.camera.getScene();
  12527. this._engine = this._scene.getEngine();
  12528. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12529. _this._keys = [];
  12530. });
  12531. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12532. var evt = info.event;
  12533. if (!evt.metaKey) {
  12534. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12535. _this._ctrlPressed = evt.ctrlKey;
  12536. _this._altPressed = evt.altKey;
  12537. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12538. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12539. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12540. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12541. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12542. var index = _this._keys.indexOf(evt.keyCode);
  12543. if (index === -1) {
  12544. _this._keys.push(evt.keyCode);
  12545. }
  12546. if (evt.preventDefault) {
  12547. if (!noPreventDefault) {
  12548. evt.preventDefault();
  12549. }
  12550. }
  12551. }
  12552. }
  12553. else {
  12554. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12555. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12556. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12557. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12558. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12559. var index = _this._keys.indexOf(evt.keyCode);
  12560. if (index >= 0) {
  12561. _this._keys.splice(index, 1);
  12562. }
  12563. if (evt.preventDefault) {
  12564. if (!noPreventDefault) {
  12565. evt.preventDefault();
  12566. }
  12567. }
  12568. }
  12569. }
  12570. }
  12571. });
  12572. };
  12573. /**
  12574. * Detach the current controls from the specified dom element.
  12575. * @param element Defines the element to stop listening the inputs from
  12576. */
  12577. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12578. if (this._scene) {
  12579. if (this._onKeyboardObserver) {
  12580. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12581. }
  12582. if (this._onCanvasBlurObserver) {
  12583. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12584. }
  12585. this._onKeyboardObserver = null;
  12586. this._onCanvasBlurObserver = null;
  12587. }
  12588. this._keys = [];
  12589. };
  12590. /**
  12591. * Update the current camera state depending on the inputs that have been used this frame.
  12592. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12593. */
  12594. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12595. if (this._onKeyboardObserver) {
  12596. var camera = this.camera;
  12597. for (var index = 0; index < this._keys.length; index++) {
  12598. var keyCode = this._keys[index];
  12599. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12600. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12601. camera.inertialPanningX -= 1 / this.panningSensibility;
  12602. }
  12603. else {
  12604. camera.inertialAlphaOffset -= this.angularSpeed;
  12605. }
  12606. }
  12607. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12608. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12609. camera.inertialPanningY += 1 / this.panningSensibility;
  12610. }
  12611. else if (this._altPressed && this.useAltToZoom) {
  12612. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12613. }
  12614. else {
  12615. camera.inertialBetaOffset -= this.angularSpeed;
  12616. }
  12617. }
  12618. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12619. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12620. camera.inertialPanningX += 1 / this.panningSensibility;
  12621. }
  12622. else {
  12623. camera.inertialAlphaOffset += this.angularSpeed;
  12624. }
  12625. }
  12626. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12627. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12628. camera.inertialPanningY -= 1 / this.panningSensibility;
  12629. }
  12630. else if (this._altPressed && this.useAltToZoom) {
  12631. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12632. }
  12633. else {
  12634. camera.inertialBetaOffset += this.angularSpeed;
  12635. }
  12636. }
  12637. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12638. if (camera.useInputToRestoreState) {
  12639. camera.restoreState();
  12640. }
  12641. }
  12642. }
  12643. }
  12644. };
  12645. /**
  12646. * Gets the class name of the current intput.
  12647. * @returns the class name
  12648. */
  12649. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12650. return "ArcRotateCameraKeyboardMoveInput";
  12651. };
  12652. /**
  12653. * Get the friendly name associated with the input class.
  12654. * @returns the input friendly name
  12655. */
  12656. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12657. return "keyboard";
  12658. };
  12659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12661. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12664. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12667. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12670. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12673. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12676. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12679. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12682. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12685. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12686. return ArcRotateCameraKeyboardMoveInput;
  12687. }());
  12688. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12689. /***/ }),
  12690. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12691. /*!**********************************************************!*\
  12692. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12693. \**********************************************************/
  12694. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12696. "use strict";
  12697. __webpack_require__.r(__webpack_exports__);
  12698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12699. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12700. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12701. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12702. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12703. /**
  12704. * Manage the mouse wheel inputs to control an arc rotate camera.
  12705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12706. */
  12707. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12708. function ArcRotateCameraMouseWheelInput() {
  12709. /**
  12710. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12711. */
  12712. this.wheelPrecision = 3.0;
  12713. /**
  12714. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12715. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12716. */
  12717. this.wheelDeltaPercentage = 0;
  12718. }
  12719. /**
  12720. * Attach the input controls to a specific dom element to get the input from.
  12721. * @param element Defines the element the controls should be listened from
  12722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12723. */
  12724. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12725. var _this = this;
  12726. this._wheel = function (p, s) {
  12727. //sanity check - this should be a PointerWheel event.
  12728. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12729. return;
  12730. }
  12731. var event = p.event;
  12732. var delta = 0;
  12733. var mouseWheelLegacyEvent = event;
  12734. if (mouseWheelLegacyEvent.wheelDelta) {
  12735. if (_this.wheelDeltaPercentage) {
  12736. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12737. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12738. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12739. }
  12740. else {
  12741. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12742. }
  12743. }
  12744. else {
  12745. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12746. }
  12747. }
  12748. else {
  12749. var deltaValue = event.deltaY || event.detail;
  12750. delta = -deltaValue / _this.wheelPrecision;
  12751. }
  12752. if (delta) {
  12753. _this.camera.inertialRadiusOffset += delta;
  12754. }
  12755. if (event.preventDefault) {
  12756. if (!noPreventDefault) {
  12757. event.preventDefault();
  12758. }
  12759. }
  12760. };
  12761. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12762. };
  12763. /**
  12764. * Detach the current controls from the specified dom element.
  12765. * @param element Defines the element to stop listening the inputs from
  12766. */
  12767. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12768. if (this._observer && element) {
  12769. this.camera.getScene().onPointerObservable.remove(this._observer);
  12770. this._observer = null;
  12771. this._wheel = null;
  12772. }
  12773. };
  12774. /**
  12775. * Gets the class name of the current intput.
  12776. * @returns the class name
  12777. */
  12778. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12779. return "ArcRotateCameraMouseWheelInput";
  12780. };
  12781. /**
  12782. * Get the friendly name associated with the input class.
  12783. * @returns the input friendly name
  12784. */
  12785. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12786. return "mousewheel";
  12787. };
  12788. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12790. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12791. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12792. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12793. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12794. return ArcRotateCameraMouseWheelInput;
  12795. }());
  12796. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12797. /***/ }),
  12798. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12799. /*!********************************************************!*\
  12800. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12801. \********************************************************/
  12802. /*! exports provided: ArcRotateCameraPointersInput */
  12803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12804. "use strict";
  12805. __webpack_require__.r(__webpack_exports__);
  12806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12807. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12808. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12809. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12810. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  12811. /**
  12812. * Manage the pointers inputs to control an arc rotate camera.
  12813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12814. */
  12815. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  12816. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  12817. function ArcRotateCameraPointersInput() {
  12818. var _this = _super !== null && _super.apply(this, arguments) || this;
  12819. /**
  12820. * Defines the buttons associated with the input to handle camera move.
  12821. */
  12822. _this.buttons = [0, 1, 2];
  12823. /**
  12824. * Defines the pointer angular sensibility along the X axis or how fast is
  12825. * the camera rotating.
  12826. */
  12827. _this.angularSensibilityX = 1000.0;
  12828. /**
  12829. * Defines the pointer angular sensibility along the Y axis or how fast is
  12830. * the camera rotating.
  12831. */
  12832. _this.angularSensibilityY = 1000.0;
  12833. /**
  12834. * Defines the pointer pinch precision or how fast is the camera zooming.
  12835. */
  12836. _this.pinchPrecision = 12.0;
  12837. /**
  12838. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  12839. * from 0.
  12840. * It defines the percentage of current camera.radius to use as delta when
  12841. * pinch zoom is used.
  12842. */
  12843. _this.pinchDeltaPercentage = 0;
  12844. /**
  12845. * Defines the pointer panning sensibility or how fast is the camera moving.
  12846. */
  12847. _this.panningSensibility = 1000.0;
  12848. /**
  12849. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12850. */
  12851. _this.multiTouchPanning = true;
  12852. /**
  12853. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  12854. * zoom (pinch) through multitouch.
  12855. */
  12856. _this.multiTouchPanAndZoom = true;
  12857. /**
  12858. * Revers pinch action direction.
  12859. */
  12860. _this.pinchInwards = true;
  12861. _this._isPanClick = false;
  12862. _this._twoFingerActivityCount = 0;
  12863. _this._isPinching = false;
  12864. return _this;
  12865. }
  12866. /**
  12867. * Gets the class name of the current input.
  12868. * @returns the class name
  12869. */
  12870. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12871. return "ArcRotateCameraPointersInput";
  12872. };
  12873. /**
  12874. * Called on pointer POINTERMOVE event if only a single touch is active.
  12875. */
  12876. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12877. if (this.panningSensibility !== 0 &&
  12878. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  12879. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  12880. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  12881. }
  12882. else {
  12883. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  12884. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  12885. }
  12886. };
  12887. /**
  12888. * Called on pointer POINTERDOUBLETAP event.
  12889. */
  12890. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  12891. if (this.camera.useInputToRestoreState) {
  12892. this.camera.restoreState();
  12893. }
  12894. };
  12895. /**
  12896. * Called on pointer POINTERMOVE event if multiple touches are active.
  12897. */
  12898. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12899. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  12900. // First time this method is called for new pinch.
  12901. // Next time this is called there will be a
  12902. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  12903. return;
  12904. }
  12905. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  12906. // Last time this method is called at the end of a pinch.
  12907. return;
  12908. }
  12909. var direction = this.pinchInwards ? 1 : -1;
  12910. if (this.multiTouchPanAndZoom) {
  12911. if (this.pinchDeltaPercentage) {
  12912. this.camera.inertialRadiusOffset +=
  12913. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12914. this.camera.radius * this.pinchDeltaPercentage;
  12915. }
  12916. else {
  12917. this.camera.inertialRadiusOffset +=
  12918. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12919. (this.pinchPrecision * direction *
  12920. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12921. }
  12922. if (this.panningSensibility !== 0 &&
  12923. previousMultiTouchPanPosition && multiTouchPanPosition) {
  12924. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12925. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12926. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12927. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12928. }
  12929. }
  12930. else {
  12931. this._twoFingerActivityCount++;
  12932. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  12933. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12934. if (this._isPinching ||
  12935. (this._twoFingerActivityCount < 20 &&
  12936. Math.abs(pinchDistance - previousPinchDistance) >
  12937. this.camera.pinchToPanMaxDistance)) {
  12938. // Since pinch has not been active long, assume we intend to zoom.
  12939. if (this.pinchDeltaPercentage) {
  12940. this.camera.inertialRadiusOffset +=
  12941. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12942. this.camera.radius * this.pinchDeltaPercentage;
  12943. }
  12944. else {
  12945. this.camera.inertialRadiusOffset +=
  12946. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12947. (this.pinchPrecision * direction *
  12948. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12949. }
  12950. // Since we are pinching, remain pinching on next iteration.
  12951. this._isPinching = true;
  12952. }
  12953. else {
  12954. // Pause between pinch starting and moving implies not a zoom event.
  12955. // Pan instead.
  12956. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  12957. multiTouchPanPosition && previousMultiTouchPanPosition) {
  12958. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12959. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12960. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12961. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12962. }
  12963. }
  12964. }
  12965. };
  12966. /**
  12967. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12968. * press.
  12969. */
  12970. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt) {
  12971. this._isPanClick = evt.button === this.camera._panningMouseButton;
  12972. };
  12973. /**
  12974. * Called each time a new POINTERUP event occurs. Ie, for each button
  12975. * release.
  12976. */
  12977. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  12978. this._twoFingerActivityCount = 0;
  12979. this._isPinching = false;
  12980. };
  12981. /**
  12982. * Called when window becomes inactive.
  12983. */
  12984. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  12985. this._isPanClick = false;
  12986. this._twoFingerActivityCount = 0;
  12987. this._isPinching = false;
  12988. };
  12989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12991. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12994. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12995. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12997. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13000. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  13001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13003. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  13004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13006. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  13007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13009. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  13010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13012. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  13013. return ArcRotateCameraPointersInput;
  13014. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  13015. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  13016. ArcRotateCameraPointersInput;
  13017. /***/ }),
  13018. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  13019. /*!*******************************************************************!*\
  13020. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  13021. \*******************************************************************/
  13022. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  13023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13024. "use strict";
  13025. __webpack_require__.r(__webpack_exports__);
  13026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  13027. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13028. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  13029. /**
  13030. * Add orientation input support to the input manager.
  13031. * @returns the current input manager
  13032. */
  13033. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13034. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13035. return this;
  13036. };
  13037. /**
  13038. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13040. */
  13041. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13042. /**
  13043. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13044. */
  13045. function ArcRotateCameraVRDeviceOrientationInput() {
  13046. /**
  13047. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13048. */
  13049. this.alphaCorrection = 1;
  13050. /**
  13051. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13052. */
  13053. this.gammaCorrection = 1;
  13054. this._alpha = 0;
  13055. this._gamma = 0;
  13056. this._dirty = false;
  13057. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13058. }
  13059. /**
  13060. * Attach the input controls to a specific dom element to get the input from.
  13061. * @param element Defines the element the controls should be listened from
  13062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13063. */
  13064. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13065. this.camera.attachControl(element, noPreventDefault);
  13066. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13067. };
  13068. /** @hidden */
  13069. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13070. if (evt.alpha !== null) {
  13071. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13072. }
  13073. if (evt.gamma !== null) {
  13074. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13075. }
  13076. this._dirty = true;
  13077. };
  13078. /**
  13079. * Update the current camera state depending on the inputs that have been used this frame.
  13080. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13081. */
  13082. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13083. if (this._dirty) {
  13084. this._dirty = false;
  13085. if (this._gamma < 0) {
  13086. this._gamma = 180 + this._gamma;
  13087. }
  13088. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13089. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13090. }
  13091. };
  13092. /**
  13093. * Detach the current controls from the specified dom element.
  13094. * @param element Defines the element to stop listening the inputs from
  13095. */
  13096. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13097. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13098. };
  13099. /**
  13100. * Gets the class name of the current intput.
  13101. * @returns the class name
  13102. */
  13103. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13104. return "ArcRotateCameraVRDeviceOrientationInput";
  13105. };
  13106. /**
  13107. * Get the friendly name associated with the input class.
  13108. * @returns the input friendly name
  13109. */
  13110. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13111. return "VRDeviceOrientation";
  13112. };
  13113. return ArcRotateCameraVRDeviceOrientationInput;
  13114. }());
  13115. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13116. /***/ }),
  13117. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13118. /*!**************************************************!*\
  13119. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13120. \**************************************************/
  13121. /*! exports provided: FlyCameraKeyboardInput */
  13122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13123. "use strict";
  13124. __webpack_require__.r(__webpack_exports__);
  13125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13126. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13127. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13128. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13129. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13130. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13131. /**
  13132. * Listen to keyboard events to control the camera.
  13133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13134. */
  13135. var FlyCameraKeyboardInput = /** @class */ (function () {
  13136. function FlyCameraKeyboardInput() {
  13137. /**
  13138. * The list of keyboard keys used to control the forward move of the camera.
  13139. */
  13140. this.keysForward = [87];
  13141. /**
  13142. * The list of keyboard keys used to control the backward move of the camera.
  13143. */
  13144. this.keysBackward = [83];
  13145. /**
  13146. * The list of keyboard keys used to control the forward move of the camera.
  13147. */
  13148. this.keysUp = [69];
  13149. /**
  13150. * The list of keyboard keys used to control the backward move of the camera.
  13151. */
  13152. this.keysDown = [81];
  13153. /**
  13154. * The list of keyboard keys used to control the right strafe move of the camera.
  13155. */
  13156. this.keysRight = [68];
  13157. /**
  13158. * The list of keyboard keys used to control the left strafe move of the camera.
  13159. */
  13160. this.keysLeft = [65];
  13161. this._keys = new Array();
  13162. }
  13163. /**
  13164. * Attach the input controls to a specific dom element to get the input from.
  13165. * @param element Defines the element the controls should be listened from
  13166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13167. */
  13168. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13169. var _this = this;
  13170. if (this._onCanvasBlurObserver) {
  13171. return;
  13172. }
  13173. this._scene = this.camera.getScene();
  13174. this._engine = this._scene.getEngine();
  13175. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13176. _this._keys = [];
  13177. });
  13178. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13179. var evt = info.event;
  13180. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13181. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13182. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13183. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13184. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13185. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13186. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13187. var index = _this._keys.indexOf(evt.keyCode);
  13188. if (index === -1) {
  13189. _this._keys.push(evt.keyCode);
  13190. }
  13191. if (!noPreventDefault) {
  13192. evt.preventDefault();
  13193. }
  13194. }
  13195. }
  13196. else {
  13197. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13198. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13199. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13200. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13201. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13202. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13203. var index = _this._keys.indexOf(evt.keyCode);
  13204. if (index >= 0) {
  13205. _this._keys.splice(index, 1);
  13206. }
  13207. if (!noPreventDefault) {
  13208. evt.preventDefault();
  13209. }
  13210. }
  13211. }
  13212. });
  13213. };
  13214. /**
  13215. * Detach the current controls from the specified dom element.
  13216. * @param element Defines the element to stop listening the inputs from
  13217. */
  13218. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13219. if (this._scene) {
  13220. if (this._onKeyboardObserver) {
  13221. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13222. }
  13223. if (this._onCanvasBlurObserver) {
  13224. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13225. }
  13226. this._onKeyboardObserver = null;
  13227. this._onCanvasBlurObserver = null;
  13228. }
  13229. this._keys = [];
  13230. };
  13231. /**
  13232. * Gets the class name of the current intput.
  13233. * @returns the class name
  13234. */
  13235. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13236. return "FlyCameraKeyboardInput";
  13237. };
  13238. /** @hidden */
  13239. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13240. this._keys = [];
  13241. };
  13242. /**
  13243. * Get the friendly name associated with the input class.
  13244. * @returns the input friendly name
  13245. */
  13246. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13247. return "keyboard";
  13248. };
  13249. /**
  13250. * Update the current camera state depending on the inputs that have been used this frame.
  13251. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13252. */
  13253. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13254. if (this._onKeyboardObserver) {
  13255. var camera = this.camera;
  13256. // Keyboard
  13257. for (var index = 0; index < this._keys.length; index++) {
  13258. var keyCode = this._keys[index];
  13259. var speed = camera._computeLocalCameraSpeed();
  13260. if (this.keysForward.indexOf(keyCode) !== -1) {
  13261. camera._localDirection.copyFromFloats(0, 0, speed);
  13262. }
  13263. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13264. camera._localDirection.copyFromFloats(0, 0, -speed);
  13265. }
  13266. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13267. camera._localDirection.copyFromFloats(0, speed, 0);
  13268. }
  13269. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13270. camera._localDirection.copyFromFloats(0, -speed, 0);
  13271. }
  13272. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13273. camera._localDirection.copyFromFloats(speed, 0, 0);
  13274. }
  13275. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13276. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13277. }
  13278. if (camera.getScene().useRightHandedSystem) {
  13279. camera._localDirection.z *= -1;
  13280. }
  13281. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13282. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13283. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13284. }
  13285. }
  13286. };
  13287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13289. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13292. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13295. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13298. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13301. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13304. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13305. return FlyCameraKeyboardInput;
  13306. }());
  13307. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13308. /***/ }),
  13309. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13310. /*!***********************************************!*\
  13311. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13312. \***********************************************/
  13313. /*! exports provided: FlyCameraMouseInput */
  13314. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13315. "use strict";
  13316. __webpack_require__.r(__webpack_exports__);
  13317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13318. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13319. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13320. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13321. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13322. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13323. /**
  13324. * Listen to mouse events to control the camera.
  13325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13326. */
  13327. var FlyCameraMouseInput = /** @class */ (function () {
  13328. /**
  13329. * Listen to mouse events to control the camera.
  13330. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13332. */
  13333. function FlyCameraMouseInput(touchEnabled) {
  13334. if (touchEnabled === void 0) { touchEnabled = true; }
  13335. /**
  13336. * Defines the buttons associated with the input to handle camera rotation.
  13337. */
  13338. this.buttons = [0, 1, 2];
  13339. /**
  13340. * Assign buttons for Yaw control.
  13341. */
  13342. this.buttonsYaw = [-1, 0, 1];
  13343. /**
  13344. * Assign buttons for Pitch control.
  13345. */
  13346. this.buttonsPitch = [-1, 0, 1];
  13347. /**
  13348. * Assign buttons for Roll control.
  13349. */
  13350. this.buttonsRoll = [2];
  13351. /**
  13352. * Detect if any button is being pressed while mouse is moved.
  13353. * -1 = Mouse locked.
  13354. * 0 = Left button.
  13355. * 1 = Middle Button.
  13356. * 2 = Right Button.
  13357. */
  13358. this.activeButton = -1;
  13359. /**
  13360. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13361. * Higher values reduce its sensitivity.
  13362. */
  13363. this.angularSensibility = 1000.0;
  13364. this.previousPosition = null;
  13365. }
  13366. /**
  13367. * Attach the mouse control to the HTML DOM element.
  13368. * @param element Defines the element that listens to the input events.
  13369. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13370. */
  13371. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13372. var _this = this;
  13373. this.element = element;
  13374. this.noPreventDefault = noPreventDefault;
  13375. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13376. _this._pointerInput(p, s);
  13377. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13378. // Correct Roll by rate, if enabled.
  13379. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13380. if (_this.camera.rollCorrect) {
  13381. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13382. }
  13383. });
  13384. // Helper function to keep 'this'.
  13385. this._mousemoveCallback = function (e) {
  13386. _this._onMouseMove(e);
  13387. };
  13388. element.addEventListener("mousemove", this._mousemoveCallback, false);
  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. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13395. if (this._observer && element) {
  13396. this.camera.getScene().onPointerObservable.remove(this._observer);
  13397. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13398. if (this._mousemoveCallback) {
  13399. element.removeEventListener("mousemove", this._mousemoveCallback);
  13400. }
  13401. this._observer = null;
  13402. this._rollObserver = null;
  13403. this.previousPosition = null;
  13404. this.noPreventDefault = undefined;
  13405. }
  13406. };
  13407. /**
  13408. * Gets the class name of the current input.
  13409. * @returns the class name.
  13410. */
  13411. FlyCameraMouseInput.prototype.getClassName = function () {
  13412. return "FlyCameraMouseInput";
  13413. };
  13414. /**
  13415. * Get the friendly name associated with the input class.
  13416. * @returns the input's friendly name.
  13417. */
  13418. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13419. return "mouse";
  13420. };
  13421. // Track mouse movement, when the pointer is not locked.
  13422. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13423. var e = p.event;
  13424. var camera = this.camera;
  13425. var engine = camera.getEngine();
  13426. if (engine.isInVRExclusivePointerMode) {
  13427. return;
  13428. }
  13429. if (!this.touchEnabled && e.pointerType === "touch") {
  13430. return;
  13431. }
  13432. // Mouse is moved but an unknown mouse button is pressed.
  13433. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13434. return;
  13435. }
  13436. var srcElement = (e.srcElement || e.target);
  13437. // Mouse down.
  13438. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13439. try {
  13440. srcElement.setPointerCapture(e.pointerId);
  13441. }
  13442. catch (e) {
  13443. // Nothing to do with the error. Execution continues.
  13444. }
  13445. this.previousPosition = {
  13446. x: e.clientX,
  13447. y: e.clientY
  13448. };
  13449. this.activeButton = e.button;
  13450. if (!this.noPreventDefault) {
  13451. e.preventDefault();
  13452. this.element.focus();
  13453. }
  13454. }
  13455. else
  13456. // Mouse up.
  13457. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13458. try {
  13459. srcElement.releasePointerCapture(e.pointerId);
  13460. }
  13461. catch (e) {
  13462. // Nothing to do with the error. Execution continues.
  13463. }
  13464. this.activeButton = -1;
  13465. this.previousPosition = null;
  13466. if (!this.noPreventDefault) {
  13467. e.preventDefault();
  13468. }
  13469. }
  13470. else
  13471. // Mouse move.
  13472. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13473. if (!this.previousPosition || engine.isPointerLock) {
  13474. return;
  13475. }
  13476. var offsetX = e.clientX - this.previousPosition.x;
  13477. var offsetY = e.clientY - this.previousPosition.y;
  13478. this.rotateCamera(offsetX, offsetY);
  13479. this.previousPosition = {
  13480. x: e.clientX,
  13481. y: e.clientY
  13482. };
  13483. if (!this.noPreventDefault) {
  13484. e.preventDefault();
  13485. }
  13486. }
  13487. };
  13488. // Track mouse movement, when pointer is locked.
  13489. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13490. var camera = this.camera;
  13491. var engine = camera.getEngine();
  13492. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13493. return;
  13494. }
  13495. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13496. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13497. this.rotateCamera(offsetX, offsetY);
  13498. this.previousPosition = null;
  13499. if (!this.noPreventDefault) {
  13500. e.preventDefault();
  13501. }
  13502. };
  13503. /**
  13504. * Rotate camera by mouse offset.
  13505. */
  13506. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13507. var _this = this;
  13508. var camera = this.camera;
  13509. var scene = this.camera.getScene();
  13510. if (scene.useRightHandedSystem) {
  13511. offsetX *= -1;
  13512. }
  13513. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13514. offsetX *= -1;
  13515. }
  13516. var x = offsetX / this.angularSensibility;
  13517. var y = offsetY / this.angularSensibility;
  13518. // Initialize to current rotation.
  13519. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13520. var rotationChange;
  13521. // Pitch.
  13522. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13523. // Apply change in Radians to vector Angle.
  13524. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13525. // Apply Pitch to quaternion.
  13526. currentRotation.multiplyInPlace(rotationChange);
  13527. }
  13528. // Yaw.
  13529. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13530. // Apply change in Radians to vector Angle.
  13531. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13532. // Apply Yaw to quaternion.
  13533. currentRotation.multiplyInPlace(rotationChange);
  13534. // Add Roll, if banked turning is enabled, within Roll limit.
  13535. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13536. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13537. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13538. // Apply change in Radians to vector Angle.
  13539. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13540. // Apply Yaw to quaternion.
  13541. currentRotation.multiplyInPlace(rotationChange);
  13542. }
  13543. }
  13544. // Roll.
  13545. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13546. // Apply change in Radians to vector Angle.
  13547. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13548. // Track Rolling.
  13549. camera._trackRoll -= x;
  13550. // Apply Pitch to quaternion.
  13551. currentRotation.multiplyInPlace(rotationChange);
  13552. }
  13553. // Apply rotationQuaternion to Euler camera.rotation.
  13554. currentRotation.toEulerAnglesToRef(camera.rotation);
  13555. };
  13556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13558. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13561. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13562. return FlyCameraMouseInput;
  13563. }());
  13564. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13565. /***/ }),
  13566. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13567. /*!*********************************************************!*\
  13568. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13569. \*********************************************************/
  13570. /*! exports provided: FollowCameraKeyboardMoveInput */
  13571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13572. "use strict";
  13573. __webpack_require__.r(__webpack_exports__);
  13574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13575. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13576. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13577. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13578. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13579. /**
  13580. * Manage the keyboard inputs to control the movement of a follow camera.
  13581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13582. */
  13583. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13584. function FollowCameraKeyboardMoveInput() {
  13585. /**
  13586. * Defines the list of key codes associated with the up action (increase heightOffset)
  13587. */
  13588. this.keysHeightOffsetIncr = [38];
  13589. /**
  13590. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13591. */
  13592. this.keysHeightOffsetDecr = [40];
  13593. /**
  13594. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13595. */
  13596. this.keysHeightOffsetModifierAlt = false;
  13597. /**
  13598. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13599. */
  13600. this.keysHeightOffsetModifierCtrl = false;
  13601. /**
  13602. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13603. */
  13604. this.keysHeightOffsetModifierShift = false;
  13605. /**
  13606. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13607. */
  13608. this.keysRotationOffsetIncr = [37];
  13609. /**
  13610. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13611. */
  13612. this.keysRotationOffsetDecr = [39];
  13613. /**
  13614. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13615. */
  13616. this.keysRotationOffsetModifierAlt = false;
  13617. /**
  13618. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13619. */
  13620. this.keysRotationOffsetModifierCtrl = false;
  13621. /**
  13622. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13623. */
  13624. this.keysRotationOffsetModifierShift = false;
  13625. /**
  13626. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13627. */
  13628. this.keysRadiusIncr = [40];
  13629. /**
  13630. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13631. */
  13632. this.keysRadiusDecr = [38];
  13633. /**
  13634. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13635. */
  13636. this.keysRadiusModifierAlt = true;
  13637. /**
  13638. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13639. */
  13640. this.keysRadiusModifierCtrl = false;
  13641. /**
  13642. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13643. */
  13644. this.keysRadiusModifierShift = false;
  13645. /**
  13646. * Defines the rate of change of heightOffset.
  13647. */
  13648. this.heightSensibility = 1;
  13649. /**
  13650. * Defines the rate of change of rotationOffset.
  13651. */
  13652. this.rotationSensibility = 1;
  13653. /**
  13654. * Defines the rate of change of radius.
  13655. */
  13656. this.radiusSensibility = 1;
  13657. this._keys = new Array();
  13658. }
  13659. /**
  13660. * Attach the input controls to a specific dom element to get the input from.
  13661. * @param element Defines the element the controls should be listened from
  13662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13663. */
  13664. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13665. var _this = this;
  13666. if (this._onCanvasBlurObserver) {
  13667. return;
  13668. }
  13669. this._scene = this.camera.getScene();
  13670. this._engine = this._scene.getEngine();
  13671. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13672. _this._keys = [];
  13673. });
  13674. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13675. var evt = info.event;
  13676. if (!evt.metaKey) {
  13677. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13678. _this._ctrlPressed = evt.ctrlKey;
  13679. _this._altPressed = evt.altKey;
  13680. _this._shiftPressed = evt.shiftKey;
  13681. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13682. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13683. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13684. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13685. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13686. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13687. var index = _this._keys.indexOf(evt.keyCode);
  13688. if (index === -1) {
  13689. _this._keys.push(evt.keyCode);
  13690. }
  13691. if (evt.preventDefault) {
  13692. if (!noPreventDefault) {
  13693. evt.preventDefault();
  13694. }
  13695. }
  13696. }
  13697. }
  13698. else {
  13699. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13700. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13701. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13702. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13703. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13704. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13705. var index = _this._keys.indexOf(evt.keyCode);
  13706. if (index >= 0) {
  13707. _this._keys.splice(index, 1);
  13708. }
  13709. if (evt.preventDefault) {
  13710. if (!noPreventDefault) {
  13711. evt.preventDefault();
  13712. }
  13713. }
  13714. }
  13715. }
  13716. }
  13717. });
  13718. };
  13719. /**
  13720. * Detach the current controls from the specified dom element.
  13721. * @param element Defines the element to stop listening the inputs from
  13722. */
  13723. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13724. if (this._scene) {
  13725. if (this._onKeyboardObserver) {
  13726. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13727. }
  13728. if (this._onCanvasBlurObserver) {
  13729. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13730. }
  13731. this._onKeyboardObserver = null;
  13732. this._onCanvasBlurObserver = null;
  13733. }
  13734. this._keys = [];
  13735. };
  13736. /**
  13737. * Update the current camera state depending on the inputs that have been used this frame.
  13738. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13739. */
  13740. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13741. var _this = this;
  13742. if (this._onKeyboardObserver) {
  13743. this._keys.forEach(function (keyCode) {
  13744. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13745. _this._modifierHeightOffset()) {
  13746. _this.camera.heightOffset += _this.heightSensibility;
  13747. }
  13748. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13749. _this._modifierHeightOffset()) {
  13750. _this.camera.heightOffset -= _this.heightSensibility;
  13751. }
  13752. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13753. _this._modifierRotationOffset()) {
  13754. _this.camera.rotationOffset += _this.rotationSensibility;
  13755. _this.camera.rotationOffset %= 360;
  13756. }
  13757. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13758. _this._modifierRotationOffset()) {
  13759. _this.camera.rotationOffset -= _this.rotationSensibility;
  13760. _this.camera.rotationOffset %= 360;
  13761. }
  13762. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13763. _this._modifierRadius()) {
  13764. _this.camera.radius += _this.radiusSensibility;
  13765. }
  13766. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13767. _this._modifierRadius()) {
  13768. _this.camera.radius -= _this.radiusSensibility;
  13769. }
  13770. });
  13771. }
  13772. };
  13773. /**
  13774. * Gets the class name of the current input.
  13775. * @returns the class name
  13776. */
  13777. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13778. return "FollowCameraKeyboardMoveInput";
  13779. };
  13780. /**
  13781. * Get the friendly name associated with the input class.
  13782. * @returns the input friendly name
  13783. */
  13784. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13785. return "keyboard";
  13786. };
  13787. /**
  13788. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13789. * allow modification of the heightOffset value.
  13790. */
  13791. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13792. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13793. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13794. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13795. };
  13796. /**
  13797. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13798. * allow modification of the rotationOffset value.
  13799. */
  13800. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13801. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13802. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13803. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13804. };
  13805. /**
  13806. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13807. * allow modification of the radius value.
  13808. */
  13809. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13810. return (this.keysRadiusModifierAlt === this._altPressed &&
  13811. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13812. this.keysRadiusModifierShift === this._shiftPressed);
  13813. };
  13814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13816. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13819. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13822. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13825. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13828. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13831. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13834. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13837. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13838. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13839. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13840. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13841. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13843. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13846. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13849. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13852. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13855. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13858. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13861. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13864. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13867. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13868. return FollowCameraKeyboardMoveInput;
  13869. }());
  13870. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13871. /***/ }),
  13872. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13873. /*!*******************************************************!*\
  13874. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13875. \*******************************************************/
  13876. /*! exports provided: FollowCameraMouseWheelInput */
  13877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13878. "use strict";
  13879. __webpack_require__.r(__webpack_exports__);
  13880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13881. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13882. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13883. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13884. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13885. /**
  13886. * Manage the mouse wheel inputs to control a follow camera.
  13887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13888. */
  13889. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13890. function FollowCameraMouseWheelInput() {
  13891. /**
  13892. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  13893. */
  13894. this.axisControlRadius = true;
  13895. /**
  13896. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  13897. */
  13898. this.axisControlHeight = false;
  13899. /**
  13900. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  13901. */
  13902. this.axisControlRotation = false;
  13903. /**
  13904. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13905. * relation to mouseWheel events.
  13906. */
  13907. this.wheelPrecision = 3.0;
  13908. /**
  13909. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13910. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13911. */
  13912. this.wheelDeltaPercentage = 0;
  13913. }
  13914. /**
  13915. * Attach the input controls to a specific dom element to get the input from.
  13916. * @param element Defines the element the controls should be listened from
  13917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13918. */
  13919. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13920. var _this = this;
  13921. this._wheel = function (p, s) {
  13922. // sanity check - this should be a PointerWheel event.
  13923. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13924. return;
  13925. }
  13926. var event = p.event;
  13927. var delta = 0;
  13928. // Chrome, Safari: event.deltaY
  13929. // IE: event.wheelDelta
  13930. // Firefox: event.detail (inverted)
  13931. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13932. if (_this.wheelDeltaPercentage) {
  13933. console.assert((_this.axisControlRadius +
  13934. _this.axisControlHeight +
  13935. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13936. "controlls ONE axis. " +
  13937. "Currently enabled: " +
  13938. "axisControlRadius: " + _this.axisControlRadius +
  13939. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13940. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13941. if (_this.axisControlRadius) {
  13942. delta =
  13943. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13944. _this.camera.radius;
  13945. }
  13946. else if (_this.axisControlHeight) {
  13947. delta =
  13948. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13949. _this.camera.heightOffset;
  13950. }
  13951. else if (_this.axisControlRotation) {
  13952. delta =
  13953. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13954. _this.camera.rotationOffset;
  13955. }
  13956. }
  13957. else {
  13958. delta = wheelDelta * _this.wheelPrecision;
  13959. }
  13960. if (delta) {
  13961. if (_this.axisControlRadius) {
  13962. _this.camera.radius += delta;
  13963. }
  13964. else if (_this.axisControlHeight) {
  13965. _this.camera.heightOffset -= delta;
  13966. }
  13967. else if (_this.axisControlRotation) {
  13968. _this.camera.rotationOffset -= delta;
  13969. }
  13970. }
  13971. if (event.preventDefault) {
  13972. if (!noPreventDefault) {
  13973. event.preventDefault();
  13974. }
  13975. }
  13976. };
  13977. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13978. };
  13979. /**
  13980. * Detach the current controls from the specified dom element.
  13981. * @param element Defines the element to stop listening the inputs from
  13982. */
  13983. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13984. if (this._observer && element) {
  13985. this.camera.getScene().onPointerObservable.remove(this._observer);
  13986. this._observer = null;
  13987. this._wheel = null;
  13988. }
  13989. };
  13990. /**
  13991. * Gets the class name of the current intput.
  13992. * @returns the class name
  13993. */
  13994. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13995. return "ArcRotateCameraMouseWheelInput";
  13996. };
  13997. /**
  13998. * Get the friendly name associated with the input class.
  13999. * @returns the input friendly name
  14000. */
  14001. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  14002. return "mousewheel";
  14003. };
  14004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14006. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  14007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14009. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  14010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14012. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  14013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14015. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  14016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14018. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  14019. return FollowCameraMouseWheelInput;
  14020. }());
  14021. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  14022. /***/ }),
  14023. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  14024. /*!*****************************************************!*\
  14025. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  14026. \*****************************************************/
  14027. /*! exports provided: FollowCameraPointersInput */
  14028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14029. "use strict";
  14030. __webpack_require__.r(__webpack_exports__);
  14031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14032. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14033. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14034. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14035. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14036. /**
  14037. * Manage the pointers inputs to control an follow camera.
  14038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14039. */
  14040. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14041. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14042. function FollowCameraPointersInput() {
  14043. var _this = _super !== null && _super.apply(this, arguments) || this;
  14044. /**
  14045. * Defines the pointer angular sensibility along the X axis or how fast is
  14046. * the camera rotating.
  14047. * A negative number will reverse the axis direction.
  14048. */
  14049. _this.angularSensibilityX = 1;
  14050. /**
  14051. * Defines the pointer angular sensibility along the Y axis or how fast is
  14052. * the camera rotating.
  14053. * A negative number will reverse the axis direction.
  14054. */
  14055. _this.angularSensibilityY = 1;
  14056. /**
  14057. * Defines the pointer pinch precision or how fast is the camera zooming.
  14058. * A negative number will reverse the axis direction.
  14059. */
  14060. _this.pinchPrecision = 10000.0;
  14061. /**
  14062. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14063. * from 0.
  14064. * It defines the percentage of current camera.radius to use as delta when
  14065. * pinch zoom is used.
  14066. */
  14067. _this.pinchDeltaPercentage = 0;
  14068. /**
  14069. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14070. */
  14071. _this.axisXControlRadius = false;
  14072. /**
  14073. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14074. */
  14075. _this.axisXControlHeight = false;
  14076. /**
  14077. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14078. */
  14079. _this.axisXControlRotation = true;
  14080. /**
  14081. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14082. */
  14083. _this.axisYControlRadius = false;
  14084. /**
  14085. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14086. */
  14087. _this.axisYControlHeight = true;
  14088. /**
  14089. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14090. */
  14091. _this.axisYControlRotation = false;
  14092. /**
  14093. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14094. */
  14095. _this.axisPinchControlRadius = true;
  14096. /**
  14097. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14098. */
  14099. _this.axisPinchControlHeight = false;
  14100. /**
  14101. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14102. */
  14103. _this.axisPinchControlRotation = false;
  14104. /**
  14105. * Log error messages if basic misconfiguration has occurred.
  14106. */
  14107. _this.warningEnable = true;
  14108. /* Check for obvious misconfiguration. */
  14109. _this._warningCounter = 0;
  14110. return _this;
  14111. }
  14112. /**
  14113. * Gets the class name of the current input.
  14114. * @returns the class name
  14115. */
  14116. FollowCameraPointersInput.prototype.getClassName = function () {
  14117. return "FollowCameraPointersInput";
  14118. };
  14119. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14120. this._warning();
  14121. if (this.axisXControlRotation) {
  14122. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14123. }
  14124. else if (this.axisYControlRotation) {
  14125. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14126. }
  14127. if (this.axisXControlHeight) {
  14128. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14129. }
  14130. else if (this.axisYControlHeight) {
  14131. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14132. }
  14133. if (this.axisXControlRadius) {
  14134. this.camera.radius -= offsetX / this.angularSensibilityY;
  14135. }
  14136. else if (this.axisYControlRadius) {
  14137. this.camera.radius -= offsetY / this.angularSensibilityY;
  14138. }
  14139. };
  14140. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14141. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14142. // First time this method is called for new pinch.
  14143. // Next time this is called there will be a
  14144. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14145. return;
  14146. }
  14147. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14148. // Last time this method is called at the end of a pinch.
  14149. return;
  14150. }
  14151. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14152. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14153. if (this.pinchDeltaPercentage) {
  14154. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14155. if (this.axisPinchControlRotation) {
  14156. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14157. }
  14158. if (this.axisPinchControlHeight) {
  14159. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14160. }
  14161. if (this.axisPinchControlRadius) {
  14162. this.camera.radius -= pinchDelta * this.camera.radius;
  14163. }
  14164. }
  14165. else {
  14166. if (this.axisPinchControlRotation) {
  14167. this.camera.rotationOffset += pinchDelta;
  14168. }
  14169. if (this.axisPinchControlHeight) {
  14170. this.camera.heightOffset += pinchDelta;
  14171. }
  14172. if (this.axisPinchControlRadius) {
  14173. this.camera.radius -= pinchDelta;
  14174. }
  14175. }
  14176. };
  14177. FollowCameraPointersInput.prototype._warning = function () {
  14178. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14179. return;
  14180. }
  14181. var warn = "It probably only makes sense to control ONE camera " +
  14182. "property with each pointer axis. Set 'warningEnable = false' " +
  14183. "if you are sure. Currently enabled: ";
  14184. console.assert((this.axisXControlRotation +
  14185. this.axisXControlHeight +
  14186. this.axisXControlRadius) <= 1, warn +
  14187. "axisXControlRotation: " + this.axisXControlRotation +
  14188. ", axisXControlHeight: " + this.axisXControlHeight +
  14189. ", axisXControlRadius: " + this.axisXControlRadius);
  14190. console.assert((this.axisYControlRotation +
  14191. this.axisYControlHeight +
  14192. this.axisYControlRadius) <= 1, warn +
  14193. "axisYControlRotation: " + this.axisYControlRotation +
  14194. ", axisYControlHeight: " + this.axisYControlHeight +
  14195. ", axisYControlRadius: " + this.axisYControlRadius);
  14196. console.assert((this.axisPinchControlRotation +
  14197. this.axisPinchControlHeight +
  14198. this.axisPinchControlRadius) <= 1, warn +
  14199. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14200. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14201. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14202. };
  14203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14205. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14208. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14211. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14214. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14217. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14220. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14223. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14226. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14229. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14232. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14235. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14238. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14241. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14242. return FollowCameraPointersInput;
  14243. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14244. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14245. /***/ }),
  14246. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14247. /*!************************************************************!*\
  14248. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14249. \************************************************************/
  14250. /*! exports provided: FreeCameraDeviceOrientationInput */
  14251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14252. "use strict";
  14253. __webpack_require__.r(__webpack_exports__);
  14254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14255. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14256. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14257. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14258. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14259. /**
  14260. * Add orientation input support to the input manager.
  14261. * @returns the current input manager
  14262. */
  14263. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14264. this.add(new FreeCameraDeviceOrientationInput());
  14265. return this;
  14266. };
  14267. /**
  14268. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14269. * Screen rotation is taken into account.
  14270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14271. */
  14272. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14273. /**
  14274. * Instantiates a new input
  14275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14276. */
  14277. function FreeCameraDeviceOrientationInput() {
  14278. var _this = this;
  14279. this._screenOrientationAngle = 0;
  14280. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14281. this._alpha = 0;
  14282. this._beta = 0;
  14283. this._gamma = 0;
  14284. this._orientationChanged = function () {
  14285. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14286. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14287. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14288. };
  14289. this._deviceOrientation = function (evt) {
  14290. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14291. _this._beta = evt.beta !== null ? evt.beta : 0;
  14292. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14293. };
  14294. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14295. this._orientationChanged();
  14296. }
  14297. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14298. /**
  14299. * Define the camera controlled by the input.
  14300. */
  14301. get: function () {
  14302. return this._camera;
  14303. },
  14304. set: function (camera) {
  14305. this._camera = camera;
  14306. if (this._camera != null && !this._camera.rotationQuaternion) {
  14307. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14308. }
  14309. },
  14310. enumerable: true,
  14311. configurable: true
  14312. });
  14313. /**
  14314. * Attach the input controls to a specific dom element to get the input from.
  14315. * @param element Defines the element the controls should be listened from
  14316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14317. */
  14318. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14319. window.addEventListener("orientationchange", this._orientationChanged);
  14320. window.addEventListener("deviceorientation", this._deviceOrientation);
  14321. //In certain cases, the attach control is called AFTER orientation was changed,
  14322. //So this is needed.
  14323. this._orientationChanged();
  14324. };
  14325. /**
  14326. * Detach the current controls from the specified dom element.
  14327. * @param element Defines the element to stop listening the inputs from
  14328. */
  14329. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14330. window.removeEventListener("orientationchange", this._orientationChanged);
  14331. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14332. this._alpha = 0;
  14333. };
  14334. /**
  14335. * Update the current camera state depending on the inputs that have been used this frame.
  14336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14337. */
  14338. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14339. //if no device orientation provided, don't update the rotation.
  14340. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14341. if (!this._alpha) {
  14342. return;
  14343. }
  14344. _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);
  14345. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14346. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14347. //Mirror on XY Plane
  14348. this._camera.rotationQuaternion.z *= -1;
  14349. this._camera.rotationQuaternion.w *= -1;
  14350. };
  14351. /**
  14352. * Gets the class name of the current intput.
  14353. * @returns the class name
  14354. */
  14355. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14356. return "FreeCameraDeviceOrientationInput";
  14357. };
  14358. /**
  14359. * Get the friendly name associated with the input class.
  14360. * @returns the input friendly name
  14361. */
  14362. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14363. return "deviceOrientation";
  14364. };
  14365. return FreeCameraDeviceOrientationInput;
  14366. }());
  14367. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14368. /***/ }),
  14369. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14370. /*!**************************************************!*\
  14371. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14372. \**************************************************/
  14373. /*! exports provided: FreeCameraGamepadInput */
  14374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14375. "use strict";
  14376. __webpack_require__.r(__webpack_exports__);
  14377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14378. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14379. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14380. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14381. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14382. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14383. /**
  14384. * Manage the gamepad inputs to control a free camera.
  14385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14386. */
  14387. var FreeCameraGamepadInput = /** @class */ (function () {
  14388. function FreeCameraGamepadInput() {
  14389. /**
  14390. * Defines the gamepad rotation sensiblity.
  14391. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14392. */
  14393. this.gamepadAngularSensibility = 200;
  14394. /**
  14395. * Defines the gamepad move sensiblity.
  14396. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14397. */
  14398. this.gamepadMoveSensibility = 40;
  14399. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14400. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14401. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14402. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14403. }
  14404. /**
  14405. * Attach the input controls to a specific dom element to get the input from.
  14406. * @param element Defines the element the controls should be listened from
  14407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14408. */
  14409. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14410. var _this = this;
  14411. var manager = this.camera.getScene().gamepadManager;
  14412. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14413. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14414. // prioritize XBOX gamepads.
  14415. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14416. _this.gamepad = gamepad;
  14417. }
  14418. }
  14419. });
  14420. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14421. if (_this.gamepad === gamepad) {
  14422. _this.gamepad = null;
  14423. }
  14424. });
  14425. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14426. };
  14427. /**
  14428. * Detach the current controls from the specified dom element.
  14429. * @param element Defines the element to stop listening the inputs from
  14430. */
  14431. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14432. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14433. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14434. this.gamepad = null;
  14435. };
  14436. /**
  14437. * Update the current camera state depending on the inputs that have been used this frame.
  14438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14439. */
  14440. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14441. if (this.gamepad && this.gamepad.leftStick) {
  14442. var camera = this.camera;
  14443. var LSValues = this.gamepad.leftStick;
  14444. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14445. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14446. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14447. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14448. var RSValues = this.gamepad.rightStick;
  14449. if (RSValues) {
  14450. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14451. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14452. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14453. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14454. }
  14455. else {
  14456. RSValues = { x: 0, y: 0 };
  14457. }
  14458. if (!camera.rotationQuaternion) {
  14459. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14460. }
  14461. else {
  14462. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14463. }
  14464. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14465. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14466. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14467. camera.cameraDirection.addInPlace(this._deltaTransform);
  14468. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14469. camera.cameraRotation.addInPlace(this._vector2);
  14470. }
  14471. };
  14472. /**
  14473. * Gets the class name of the current intput.
  14474. * @returns the class name
  14475. */
  14476. FreeCameraGamepadInput.prototype.getClassName = function () {
  14477. return "FreeCameraGamepadInput";
  14478. };
  14479. /**
  14480. * Get the friendly name associated with the input class.
  14481. * @returns the input friendly name
  14482. */
  14483. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14484. return "gamepad";
  14485. };
  14486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14488. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14491. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14492. return FreeCameraGamepadInput;
  14493. }());
  14494. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14495. /***/ }),
  14496. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14497. /*!*******************************************************!*\
  14498. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14499. \*******************************************************/
  14500. /*! exports provided: FreeCameraKeyboardMoveInput */
  14501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14502. "use strict";
  14503. __webpack_require__.r(__webpack_exports__);
  14504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14505. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14506. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14507. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14508. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14509. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14510. /**
  14511. * Manage the keyboard inputs to control the movement of a free camera.
  14512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14513. */
  14514. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14515. function FreeCameraKeyboardMoveInput() {
  14516. /**
  14517. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14518. */
  14519. this.keysUp = [38];
  14520. /**
  14521. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14522. */
  14523. this.keysDown = [40];
  14524. /**
  14525. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14526. */
  14527. this.keysLeft = [37];
  14528. /**
  14529. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14530. */
  14531. this.keysRight = [39];
  14532. this._keys = new Array();
  14533. }
  14534. /**
  14535. * Attach the input controls to a specific dom element to get the input from.
  14536. * @param element Defines the element the controls should be listened from
  14537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14538. */
  14539. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14540. var _this = this;
  14541. if (this._onCanvasBlurObserver) {
  14542. return;
  14543. }
  14544. this._scene = this.camera.getScene();
  14545. this._engine = this._scene.getEngine();
  14546. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14547. _this._keys = [];
  14548. });
  14549. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14550. var evt = info.event;
  14551. if (!evt.metaKey) {
  14552. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14553. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14554. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14555. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14556. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14557. var index = _this._keys.indexOf(evt.keyCode);
  14558. if (index === -1) {
  14559. _this._keys.push(evt.keyCode);
  14560. }
  14561. if (!noPreventDefault) {
  14562. evt.preventDefault();
  14563. }
  14564. }
  14565. }
  14566. else {
  14567. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14568. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14569. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14570. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14571. var index = _this._keys.indexOf(evt.keyCode);
  14572. if (index >= 0) {
  14573. _this._keys.splice(index, 1);
  14574. }
  14575. if (!noPreventDefault) {
  14576. evt.preventDefault();
  14577. }
  14578. }
  14579. }
  14580. }
  14581. });
  14582. };
  14583. /**
  14584. * Detach the current controls from the specified dom element.
  14585. * @param element Defines the element to stop listening the inputs from
  14586. */
  14587. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14588. if (this._scene) {
  14589. if (this._onKeyboardObserver) {
  14590. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14591. }
  14592. if (this._onCanvasBlurObserver) {
  14593. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14594. }
  14595. this._onKeyboardObserver = null;
  14596. this._onCanvasBlurObserver = null;
  14597. }
  14598. this._keys = [];
  14599. };
  14600. /**
  14601. * Update the current camera state depending on the inputs that have been used this frame.
  14602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14603. */
  14604. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14605. if (this._onKeyboardObserver) {
  14606. var camera = this.camera;
  14607. // Keyboard
  14608. for (var index = 0; index < this._keys.length; index++) {
  14609. var keyCode = this._keys[index];
  14610. var speed = camera._computeLocalCameraSpeed();
  14611. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14612. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14613. }
  14614. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14615. camera._localDirection.copyFromFloats(0, 0, speed);
  14616. }
  14617. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14618. camera._localDirection.copyFromFloats(speed, 0, 0);
  14619. }
  14620. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14621. camera._localDirection.copyFromFloats(0, 0, -speed);
  14622. }
  14623. if (camera.getScene().useRightHandedSystem) {
  14624. camera._localDirection.z *= -1;
  14625. }
  14626. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14627. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14628. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14629. }
  14630. }
  14631. };
  14632. /**
  14633. * Gets the class name of the current intput.
  14634. * @returns the class name
  14635. */
  14636. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14637. return "FreeCameraKeyboardMoveInput";
  14638. };
  14639. /** @hidden */
  14640. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14641. this._keys = [];
  14642. };
  14643. /**
  14644. * Get the friendly name associated with the input class.
  14645. * @returns the input friendly name
  14646. */
  14647. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14648. return "keyboard";
  14649. };
  14650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14652. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14655. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14658. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14661. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14662. return FreeCameraKeyboardMoveInput;
  14663. }());
  14664. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14665. /***/ }),
  14666. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14667. /*!************************************************!*\
  14668. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14669. \************************************************/
  14670. /*! exports provided: FreeCameraMouseInput */
  14671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14672. "use strict";
  14673. __webpack_require__.r(__webpack_exports__);
  14674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14675. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14676. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14677. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14678. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14679. /**
  14680. * Manage the mouse inputs to control the movement of a free camera.
  14681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14682. */
  14683. var FreeCameraMouseInput = /** @class */ (function () {
  14684. /**
  14685. * Manage the mouse inputs to control the movement of a free camera.
  14686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14687. * @param touchEnabled Defines if touch is enabled or not
  14688. */
  14689. function FreeCameraMouseInput(
  14690. /**
  14691. * Define if touch is enabled in the mouse input
  14692. */
  14693. touchEnabled) {
  14694. if (touchEnabled === void 0) { touchEnabled = true; }
  14695. this.touchEnabled = touchEnabled;
  14696. /**
  14697. * Defines the buttons associated with the input to handle camera move.
  14698. */
  14699. this.buttons = [0, 1, 2];
  14700. /**
  14701. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14702. */
  14703. this.angularSensibility = 2000.0;
  14704. this.previousPosition = null;
  14705. }
  14706. /**
  14707. * Attach the input controls to a specific dom element to get the input from.
  14708. * @param element Defines the element the controls should be listened from
  14709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14710. */
  14711. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14712. var _this = this;
  14713. var engine = this.camera.getEngine();
  14714. if (!this._pointerInput) {
  14715. this._pointerInput = function (p) {
  14716. var evt = p.event;
  14717. if (engine.isInVRExclusivePointerMode) {
  14718. return;
  14719. }
  14720. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14721. return;
  14722. }
  14723. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14724. return;
  14725. }
  14726. var srcElement = (evt.srcElement || evt.target);
  14727. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14728. try {
  14729. srcElement.setPointerCapture(evt.pointerId);
  14730. }
  14731. catch (e) {
  14732. //Nothing to do with the error. Execution will continue.
  14733. }
  14734. _this.previousPosition = {
  14735. x: evt.clientX,
  14736. y: evt.clientY
  14737. };
  14738. if (!noPreventDefault) {
  14739. evt.preventDefault();
  14740. element.focus();
  14741. }
  14742. }
  14743. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14744. try {
  14745. srcElement.releasePointerCapture(evt.pointerId);
  14746. }
  14747. catch (e) {
  14748. //Nothing to do with the error.
  14749. }
  14750. _this.previousPosition = null;
  14751. if (!noPreventDefault) {
  14752. evt.preventDefault();
  14753. }
  14754. }
  14755. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14756. if (!_this.previousPosition || engine.isPointerLock) {
  14757. return;
  14758. }
  14759. var offsetX = evt.clientX - _this.previousPosition.x;
  14760. if (_this.camera.getScene().useRightHandedSystem) {
  14761. offsetX *= -1;
  14762. }
  14763. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14764. offsetX *= -1;
  14765. }
  14766. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14767. var offsetY = evt.clientY - _this.previousPosition.y;
  14768. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14769. _this.previousPosition = {
  14770. x: evt.clientX,
  14771. y: evt.clientY
  14772. };
  14773. if (!noPreventDefault) {
  14774. evt.preventDefault();
  14775. }
  14776. }
  14777. };
  14778. }
  14779. this._onMouseMove = function (evt) {
  14780. if (!engine.isPointerLock) {
  14781. return;
  14782. }
  14783. if (engine.isInVRExclusivePointerMode) {
  14784. return;
  14785. }
  14786. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14787. if (_this.camera.getScene().useRightHandedSystem) {
  14788. offsetX *= -1;
  14789. }
  14790. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14791. offsetX *= -1;
  14792. }
  14793. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14794. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14795. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14796. _this.previousPosition = null;
  14797. if (!noPreventDefault) {
  14798. evt.preventDefault();
  14799. }
  14800. };
  14801. 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);
  14802. element.addEventListener("mousemove", this._onMouseMove, false);
  14803. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  14804. };
  14805. /**
  14806. * Called on JS contextmenu event.
  14807. * Override this method to provide functionality.
  14808. */
  14809. FreeCameraMouseInput.prototype.onContextMenu = function (evt) {
  14810. evt.preventDefault();
  14811. };
  14812. /**
  14813. * Detach the current controls from the specified dom element.
  14814. * @param element Defines the element to stop listening the inputs from
  14815. */
  14816. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14817. if (this._observer && element) {
  14818. this.camera.getScene().onPointerObservable.remove(this._observer);
  14819. if (this._onMouseMove) {
  14820. element.removeEventListener("mousemove", this._onMouseMove);
  14821. }
  14822. if (this.onContextMenu) {
  14823. element.removeEventListener("contextmenu", this.onContextMenu);
  14824. }
  14825. this._observer = null;
  14826. this._onMouseMove = null;
  14827. this.previousPosition = null;
  14828. }
  14829. };
  14830. /**
  14831. * Gets the class name of the current intput.
  14832. * @returns the class name
  14833. */
  14834. FreeCameraMouseInput.prototype.getClassName = function () {
  14835. return "FreeCameraMouseInput";
  14836. };
  14837. /**
  14838. * Get the friendly name associated with the input class.
  14839. * @returns the input friendly name
  14840. */
  14841. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14842. return "mouse";
  14843. };
  14844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14846. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14849. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14850. return FreeCameraMouseInput;
  14851. }());
  14852. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14853. /***/ }),
  14854. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14855. /*!************************************************!*\
  14856. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14857. \************************************************/
  14858. /*! exports provided: FreeCameraTouchInput */
  14859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14860. "use strict";
  14861. __webpack_require__.r(__webpack_exports__);
  14862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14863. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14864. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14865. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14866. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14867. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14868. /**
  14869. * Manage the touch inputs to control the movement of a free camera.
  14870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14871. */
  14872. var FreeCameraTouchInput = /** @class */ (function () {
  14873. function FreeCameraTouchInput() {
  14874. /**
  14875. * Defines the touch sensibility for rotation.
  14876. * The higher the faster.
  14877. */
  14878. this.touchAngularSensibility = 200000.0;
  14879. /**
  14880. * Defines the touch sensibility for move.
  14881. * The higher the faster.
  14882. */
  14883. this.touchMoveSensibility = 250.0;
  14884. this._offsetX = null;
  14885. this._offsetY = null;
  14886. this._pointerPressed = new Array();
  14887. }
  14888. /**
  14889. * Attach the input controls to a specific dom element to get the input from.
  14890. * @param element Defines the element the controls should be listened from
  14891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14892. */
  14893. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14894. var _this = this;
  14895. var previousPosition = null;
  14896. if (this._pointerInput === undefined) {
  14897. this._onLostFocus = function () {
  14898. _this._offsetX = null;
  14899. _this._offsetY = null;
  14900. };
  14901. this._pointerInput = function (p) {
  14902. var evt = p.event;
  14903. if (evt.pointerType === "mouse") {
  14904. return;
  14905. }
  14906. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14907. if (!noPreventDefault) {
  14908. evt.preventDefault();
  14909. }
  14910. _this._pointerPressed.push(evt.pointerId);
  14911. if (_this._pointerPressed.length !== 1) {
  14912. return;
  14913. }
  14914. previousPosition = {
  14915. x: evt.clientX,
  14916. y: evt.clientY
  14917. };
  14918. }
  14919. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14920. if (!noPreventDefault) {
  14921. evt.preventDefault();
  14922. }
  14923. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14924. if (index === -1) {
  14925. return;
  14926. }
  14927. _this._pointerPressed.splice(index, 1);
  14928. if (index != 0) {
  14929. return;
  14930. }
  14931. previousPosition = null;
  14932. _this._offsetX = null;
  14933. _this._offsetY = null;
  14934. }
  14935. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14936. if (!noPreventDefault) {
  14937. evt.preventDefault();
  14938. }
  14939. if (!previousPosition) {
  14940. return;
  14941. }
  14942. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14943. if (index != 0) {
  14944. return;
  14945. }
  14946. _this._offsetX = evt.clientX - previousPosition.x;
  14947. _this._offsetY = -(evt.clientY - previousPosition.y);
  14948. }
  14949. };
  14950. }
  14951. 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);
  14952. if (this._onLostFocus) {
  14953. element.addEventListener("blur", this._onLostFocus);
  14954. }
  14955. };
  14956. /**
  14957. * Detach the current controls from the specified dom element.
  14958. * @param element Defines the element to stop listening the inputs from
  14959. */
  14960. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14961. if (this._pointerInput && element) {
  14962. if (this._observer) {
  14963. this.camera.getScene().onPointerObservable.remove(this._observer);
  14964. this._observer = null;
  14965. }
  14966. if (this._onLostFocus) {
  14967. element.removeEventListener("blur", this._onLostFocus);
  14968. this._onLostFocus = null;
  14969. }
  14970. this._pointerPressed = [];
  14971. this._offsetX = null;
  14972. this._offsetY = null;
  14973. }
  14974. };
  14975. /**
  14976. * Update the current camera state depending on the inputs that have been used this frame.
  14977. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14978. */
  14979. FreeCameraTouchInput.prototype.checkInputs = function () {
  14980. if (this._offsetX && this._offsetY) {
  14981. var camera = this.camera;
  14982. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14983. if (this._pointerPressed.length > 1) {
  14984. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14985. }
  14986. else {
  14987. var speed = camera._computeLocalCameraSpeed();
  14988. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14989. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14990. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14991. }
  14992. }
  14993. };
  14994. /**
  14995. * Gets the class name of the current intput.
  14996. * @returns the class name
  14997. */
  14998. FreeCameraTouchInput.prototype.getClassName = function () {
  14999. return "FreeCameraTouchInput";
  15000. };
  15001. /**
  15002. * Get the friendly name associated with the input class.
  15003. * @returns the input friendly name
  15004. */
  15005. FreeCameraTouchInput.prototype.getSimpleName = function () {
  15006. return "touch";
  15007. };
  15008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15010. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  15011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15013. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  15014. return FreeCameraTouchInput;
  15015. }());
  15016. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  15017. /***/ }),
  15018. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  15019. /*!**********************************************************!*\
  15020. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  15021. \**********************************************************/
  15022. /*! exports provided: FreeCameraVirtualJoystickInput */
  15023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15024. "use strict";
  15025. __webpack_require__.r(__webpack_exports__);
  15026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  15027. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  15028. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15029. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15030. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  15031. /**
  15032. * Add virtual joystick input support to the input manager.
  15033. * @returns the current input manager
  15034. */
  15035. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  15036. this.add(new FreeCameraVirtualJoystickInput());
  15037. return this;
  15038. };
  15039. /**
  15040. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  15041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15042. */
  15043. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15044. function FreeCameraVirtualJoystickInput() {
  15045. }
  15046. /**
  15047. * Gets the left stick of the virtual joystick.
  15048. * @returns The virtual Joystick
  15049. */
  15050. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15051. return this._leftjoystick;
  15052. };
  15053. /**
  15054. * Gets the right stick of the virtual joystick.
  15055. * @returns The virtual Joystick
  15056. */
  15057. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15058. return this._rightjoystick;
  15059. };
  15060. /**
  15061. * Update the current camera state depending on the inputs that have been used this frame.
  15062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15063. */
  15064. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15065. if (this._leftjoystick) {
  15066. var camera = this.camera;
  15067. var speed = camera._computeLocalCameraSpeed() * 50;
  15068. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15069. 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);
  15070. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15071. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15072. if (!this._leftjoystick.pressed) {
  15073. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15074. }
  15075. if (!this._rightjoystick.pressed) {
  15076. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15077. }
  15078. }
  15079. };
  15080. /**
  15081. * Attach the input controls to a specific dom element to get the input from.
  15082. * @param element Defines the element the controls should be listened from
  15083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15084. */
  15085. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15086. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15087. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15088. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15089. this._leftjoystick.setJoystickSensibility(0.15);
  15090. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15091. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15092. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15093. this._rightjoystick.reverseUpDown = true;
  15094. this._rightjoystick.setJoystickSensibility(0.05);
  15095. this._rightjoystick.setJoystickColor("yellow");
  15096. };
  15097. /**
  15098. * Detach the current controls from the specified dom element.
  15099. * @param element Defines the element to stop listening the inputs from
  15100. */
  15101. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15102. this._leftjoystick.releaseCanvas();
  15103. this._rightjoystick.releaseCanvas();
  15104. };
  15105. /**
  15106. * Gets the class name of the current intput.
  15107. * @returns the class name
  15108. */
  15109. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15110. return "FreeCameraVirtualJoystickInput";
  15111. };
  15112. /**
  15113. * Get the friendly name associated with the input class.
  15114. * @returns the input friendly name
  15115. */
  15116. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15117. return "virtualJoystick";
  15118. };
  15119. return FreeCameraVirtualJoystickInput;
  15120. }());
  15121. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15122. /***/ }),
  15123. /***/ "./Cameras/Inputs/index.ts":
  15124. /*!*********************************!*\
  15125. !*** ./Cameras/Inputs/index.ts ***!
  15126. \*********************************/
  15127. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15129. "use strict";
  15130. __webpack_require__.r(__webpack_exports__);
  15131. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15133. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15135. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15137. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15139. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15141. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15143. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15145. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15147. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15149. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15151. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15153. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15155. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15157. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15159. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15161. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15163. /***/ }),
  15164. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15165. /*!*********************************************************!*\
  15166. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15167. \*********************************************************/
  15168. /*! no exports provided */
  15169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15170. "use strict";
  15171. __webpack_require__.r(__webpack_exports__);
  15172. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15173. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15174. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15175. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15176. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15177. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15178. };
  15179. /***/ }),
  15180. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15181. /*!*************************************************!*\
  15182. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  15183. \*************************************************/
  15184. /*! no exports provided */
  15185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15186. "use strict";
  15187. __webpack_require__.r(__webpack_exports__);
  15188. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15189. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15190. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15191. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15192. 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;
  15193. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15194. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15195. };
  15196. /***/ }),
  15197. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15198. /*!***************************************!*\
  15199. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15200. \***************************************/
  15201. /*! no exports provided */
  15202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15203. "use strict";
  15204. __webpack_require__.r(__webpack_exports__);
  15205. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15206. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15207. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15208. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15209. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15210. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15211. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  15212. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15213. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15214. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15215. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15216. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15217. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15218. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15219. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15220. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15221. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15222. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15223. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15224. // For multiview on a webVR camera
  15225. // First multiview will be rendered to camera._multiviewTexture
  15226. // Then this postprocess will run on each eye to copy the right texture to each eye
  15227. if (metrics.multiviewEnabled) {
  15228. if (!camera.getScene().getEngine().getCaps().multiview) {
  15229. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  15230. metrics.multiviewEnabled = false;
  15231. }
  15232. else {
  15233. camera._useMultiviewToSingleView = true;
  15234. camera._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRMultiviewToSingleview"]("VRMultiviewToSingleview", camera, 1.0);
  15235. }
  15236. }
  15237. if (metrics.compensateDistortion) {
  15238. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15239. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15240. }
  15241. };
  15242. /***/ }),
  15243. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15244. /*!******************************************!*\
  15245. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15246. \******************************************/
  15247. /*! no exports provided */
  15248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15249. "use strict";
  15250. __webpack_require__.r(__webpack_exports__);
  15251. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15252. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15253. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15254. if (rigParams.vrDisplay) {
  15255. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15256. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15257. //Left eye
  15258. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15259. camera._rigCameras[0].setCameraRigParameter("left", true);
  15260. //leaving this for future reference
  15261. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15262. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15263. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15264. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15265. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15266. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15267. camera._rigCameras[0].parent = camera;
  15268. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15269. //Right eye
  15270. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15271. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15272. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15273. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15274. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15275. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15276. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15277. camera._rigCameras[1].parent = camera;
  15278. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15279. }
  15280. };
  15281. /***/ }),
  15282. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15283. /*!*********************************************************!*\
  15284. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15285. \*********************************************************/
  15286. /*! exports provided: AnaglyphArcRotateCamera */
  15287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15288. "use strict";
  15289. __webpack_require__.r(__webpack_exports__);
  15290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15291. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15292. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15293. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15294. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15295. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15296. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15297. // Side effect import to define the stereoscopic mode.
  15298. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15299. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15300. });
  15301. /**
  15302. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15303. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15304. */
  15305. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15306. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15307. /**
  15308. * Creates a new AnaglyphArcRotateCamera
  15309. * @param name defines camera name
  15310. * @param alpha defines alpha angle (in radians)
  15311. * @param beta defines beta angle (in radians)
  15312. * @param radius defines radius
  15313. * @param target defines camera target
  15314. * @param interaxialDistance defines distance between each color axis
  15315. * @param scene defines the hosting scene
  15316. */
  15317. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15318. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15319. _this.interaxialDistance = interaxialDistance;
  15320. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15321. return _this;
  15322. }
  15323. /**
  15324. * Gets camera class name
  15325. * @returns AnaglyphArcRotateCamera
  15326. */
  15327. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15328. return "AnaglyphArcRotateCamera";
  15329. };
  15330. return AnaglyphArcRotateCamera;
  15331. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15332. /***/ }),
  15333. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15334. /*!****************************************************!*\
  15335. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15336. \****************************************************/
  15337. /*! exports provided: AnaglyphFreeCamera */
  15338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15339. "use strict";
  15340. __webpack_require__.r(__webpack_exports__);
  15341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  15342. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15343. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15344. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15345. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15346. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15347. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15348. // Side effect import to define the stereoscopic mode.
  15349. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  15350. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15351. });
  15352. /**
  15353. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15354. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15355. */
  15356. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15357. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15358. /**
  15359. * Creates a new AnaglyphFreeCamera
  15360. * @param name defines camera name
  15361. * @param position defines initial position
  15362. * @param interaxialDistance defines distance between each color axis
  15363. * @param scene defines the hosting scene
  15364. */
  15365. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  15366. var _this = _super.call(this, name, position, scene) || this;
  15367. _this.interaxialDistance = interaxialDistance;
  15368. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15369. return _this;
  15370. }
  15371. /**
  15372. * Gets camera class name
  15373. * @returns AnaglyphFreeCamera
  15374. */
  15375. AnaglyphFreeCamera.prototype.getClassName = function () {
  15376. return "AnaglyphFreeCamera";
  15377. };
  15378. return AnaglyphFreeCamera;
  15379. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15380. /***/ }),
  15381. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15382. /*!*******************************************************!*\
  15383. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15384. \*******************************************************/
  15385. /*! exports provided: AnaglyphGamepadCamera */
  15386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15387. "use strict";
  15388. __webpack_require__.r(__webpack_exports__);
  15389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  15390. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15391. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15392. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15393. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15394. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15395. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15396. // Side effect import to define the stereoscopic mode.
  15397. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  15398. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15399. });
  15400. /**
  15401. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15402. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15403. */
  15404. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15405. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15406. /**
  15407. * Creates a new AnaglyphGamepadCamera
  15408. * @param name defines camera name
  15409. * @param position defines initial position
  15410. * @param interaxialDistance defines distance between each color axis
  15411. * @param scene defines the hosting scene
  15412. */
  15413. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  15414. var _this = _super.call(this, name, position, scene) || this;
  15415. _this.interaxialDistance = interaxialDistance;
  15416. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15417. return _this;
  15418. }
  15419. /**
  15420. * Gets camera class name
  15421. * @returns AnaglyphGamepadCamera
  15422. */
  15423. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15424. return "AnaglyphGamepadCamera";
  15425. };
  15426. return AnaglyphGamepadCamera;
  15427. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15428. /***/ }),
  15429. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15430. /*!*********************************************************!*\
  15431. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15432. \*********************************************************/
  15433. /*! exports provided: AnaglyphUniversalCamera */
  15434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15435. "use strict";
  15436. __webpack_require__.r(__webpack_exports__);
  15437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15438. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15439. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15440. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15441. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15442. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15443. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15444. // Side effect import to define the stereoscopic mode.
  15445. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15446. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15447. });
  15448. /**
  15449. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15450. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15451. */
  15452. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15453. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15454. /**
  15455. * Creates a new AnaglyphUniversalCamera
  15456. * @param name defines camera name
  15457. * @param position defines initial position
  15458. * @param interaxialDistance defines distance between each color axis
  15459. * @param scene defines the hosting scene
  15460. */
  15461. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15462. var _this = _super.call(this, name, position, scene) || this;
  15463. _this.interaxialDistance = interaxialDistance;
  15464. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15465. return _this;
  15466. }
  15467. /**
  15468. * Gets camera class name
  15469. * @returns AnaglyphUniversalCamera
  15470. */
  15471. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15472. return "AnaglyphUniversalCamera";
  15473. };
  15474. return AnaglyphUniversalCamera;
  15475. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15476. /***/ }),
  15477. /***/ "./Cameras/Stereoscopic/index.ts":
  15478. /*!***************************************!*\
  15479. !*** ./Cameras/Stereoscopic/index.ts ***!
  15480. \***************************************/
  15481. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15483. "use strict";
  15484. __webpack_require__.r(__webpack_exports__);
  15485. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15487. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15489. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15491. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15493. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15495. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15497. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15499. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15501. /***/ }),
  15502. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15503. /*!*************************************************************!*\
  15504. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15505. \*************************************************************/
  15506. /*! exports provided: StereoscopicArcRotateCamera */
  15507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15508. "use strict";
  15509. __webpack_require__.r(__webpack_exports__);
  15510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15511. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15512. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15513. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15514. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15515. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15516. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15517. // Side effect import to define the stereoscopic mode.
  15518. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15519. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15520. });
  15521. /**
  15522. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15523. * @see http://doc.babylonjs.com/features/cameras
  15524. */
  15525. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15526. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15527. /**
  15528. * Creates a new StereoscopicArcRotateCamera
  15529. * @param name defines camera name
  15530. * @param alpha defines alpha angle (in radians)
  15531. * @param beta defines beta angle (in radians)
  15532. * @param radius defines radius
  15533. * @param target defines camera target
  15534. * @param interaxialDistance defines distance between each color axis
  15535. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15536. * @param scene defines the hosting scene
  15537. */
  15538. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15539. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15540. _this.interaxialDistance = interaxialDistance;
  15541. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15542. _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 });
  15543. return _this;
  15544. }
  15545. /**
  15546. * Gets camera class name
  15547. * @returns StereoscopicArcRotateCamera
  15548. */
  15549. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15550. return "StereoscopicArcRotateCamera";
  15551. };
  15552. return StereoscopicArcRotateCamera;
  15553. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15554. /***/ }),
  15555. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15556. /*!********************************************************!*\
  15557. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15558. \********************************************************/
  15559. /*! exports provided: StereoscopicFreeCamera */
  15560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15561. "use strict";
  15562. __webpack_require__.r(__webpack_exports__);
  15563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15564. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15565. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15566. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15567. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15568. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15569. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15570. // Side effect import to define the stereoscopic mode.
  15571. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15572. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15573. });
  15574. /**
  15575. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15576. * @see http://doc.babylonjs.com/features/cameras
  15577. */
  15578. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15579. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15580. /**
  15581. * Creates a new StereoscopicFreeCamera
  15582. * @param name defines camera name
  15583. * @param position defines initial position
  15584. * @param interaxialDistance defines distance between each color axis
  15585. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15586. * @param scene defines the hosting scene
  15587. */
  15588. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15589. var _this = _super.call(this, name, position, scene) || this;
  15590. _this.interaxialDistance = interaxialDistance;
  15591. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15592. _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 });
  15593. return _this;
  15594. }
  15595. /**
  15596. * Gets camera class name
  15597. * @returns StereoscopicFreeCamera
  15598. */
  15599. StereoscopicFreeCamera.prototype.getClassName = function () {
  15600. return "StereoscopicFreeCamera";
  15601. };
  15602. return StereoscopicFreeCamera;
  15603. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15604. /***/ }),
  15605. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15606. /*!***********************************************************!*\
  15607. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15608. \***********************************************************/
  15609. /*! exports provided: StereoscopicGamepadCamera */
  15610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15611. "use strict";
  15612. __webpack_require__.r(__webpack_exports__);
  15613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15615. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15616. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15617. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15618. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15619. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15620. // Side effect import to define the stereoscopic mode.
  15621. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15622. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15623. });
  15624. /**
  15625. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15626. * @see http://doc.babylonjs.com/features/cameras
  15627. */
  15628. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15629. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15630. /**
  15631. * Creates a new StereoscopicGamepadCamera
  15632. * @param name defines camera name
  15633. * @param position defines initial position
  15634. * @param interaxialDistance defines distance between each color axis
  15635. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15636. * @param scene defines the hosting scene
  15637. */
  15638. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15639. var _this = _super.call(this, name, position, scene) || this;
  15640. _this.interaxialDistance = interaxialDistance;
  15641. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15642. _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 });
  15643. return _this;
  15644. }
  15645. /**
  15646. * Gets camera class name
  15647. * @returns StereoscopicGamepadCamera
  15648. */
  15649. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15650. return "StereoscopicGamepadCamera";
  15651. };
  15652. return StereoscopicGamepadCamera;
  15653. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15654. /***/ }),
  15655. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15656. /*!*************************************************************!*\
  15657. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15658. \*************************************************************/
  15659. /*! exports provided: StereoscopicUniversalCamera */
  15660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15661. "use strict";
  15662. __webpack_require__.r(__webpack_exports__);
  15663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15664. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15665. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15666. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15667. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15668. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15669. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15670. // Side effect import to define the stereoscopic mode.
  15671. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15672. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15673. });
  15674. /**
  15675. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15676. * @see http://doc.babylonjs.com/features/cameras
  15677. */
  15678. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15679. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15680. /**
  15681. * Creates a new StereoscopicUniversalCamera
  15682. * @param name defines camera name
  15683. * @param position defines initial position
  15684. * @param interaxialDistance defines distance between each color axis
  15685. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15686. * @param scene defines the hosting scene
  15687. */
  15688. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15689. var _this = _super.call(this, name, position, scene) || this;
  15690. _this.interaxialDistance = interaxialDistance;
  15691. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15692. _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 });
  15693. return _this;
  15694. }
  15695. /**
  15696. * Gets camera class name
  15697. * @returns StereoscopicUniversalCamera
  15698. */
  15699. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15700. return "StereoscopicUniversalCamera";
  15701. };
  15702. return StereoscopicUniversalCamera;
  15703. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15704. /***/ }),
  15705. /***/ "./Cameras/VR/index.ts":
  15706. /*!*****************************!*\
  15707. !*** ./Cameras/VR/index.ts ***!
  15708. \*****************************/
  15709. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15711. "use strict";
  15712. __webpack_require__.r(__webpack_exports__);
  15713. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15715. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15717. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15719. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15721. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  15723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15724. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15726. /***/ }),
  15727. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15728. /*!***************************************!*\
  15729. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15730. \***************************************/
  15731. /*! exports provided: VRCameraMetrics */
  15732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15733. "use strict";
  15734. __webpack_require__.r(__webpack_exports__);
  15735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15736. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15737. /**
  15738. * This represents all the required metrics to create a VR camera.
  15739. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15740. */
  15741. var VRCameraMetrics = /** @class */ (function () {
  15742. function VRCameraMetrics() {
  15743. /**
  15744. * Define if the current vr camera should compensate the distortion of the lense or not.
  15745. */
  15746. this.compensateDistortion = true;
  15747. /**
  15748. * Defines if multiview should be enabled when rendering (Default: false)
  15749. */
  15750. this.multiviewEnabled = false;
  15751. }
  15752. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15753. /**
  15754. * Gets the rendering aspect ratio based on the provided resolutions.
  15755. */
  15756. get: function () {
  15757. return this.hResolution / (2 * this.vResolution);
  15758. },
  15759. enumerable: true,
  15760. configurable: true
  15761. });
  15762. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15763. /**
  15764. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15765. */
  15766. get: function () {
  15767. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15768. },
  15769. enumerable: true,
  15770. configurable: true
  15771. });
  15772. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15773. /**
  15774. * @hidden
  15775. */
  15776. get: function () {
  15777. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15778. var h = (4 * meters) / this.hScreenSize;
  15779. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15780. },
  15781. enumerable: true,
  15782. configurable: true
  15783. });
  15784. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15785. /**
  15786. * @hidden
  15787. */
  15788. get: function () {
  15789. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15790. var h = (4 * meters) / this.hScreenSize;
  15791. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15792. },
  15793. enumerable: true,
  15794. configurable: true
  15795. });
  15796. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15797. /**
  15798. * @hidden
  15799. */
  15800. get: function () {
  15801. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15802. },
  15803. enumerable: true,
  15804. configurable: true
  15805. });
  15806. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15807. /**
  15808. * @hidden
  15809. */
  15810. get: function () {
  15811. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15812. },
  15813. enumerable: true,
  15814. configurable: true
  15815. });
  15816. /**
  15817. * Get the default VRMetrics based on the most generic setup.
  15818. * @returns the default vr metrics
  15819. */
  15820. VRCameraMetrics.GetDefault = function () {
  15821. var result = new VRCameraMetrics();
  15822. result.hResolution = 1280;
  15823. result.vResolution = 800;
  15824. result.hScreenSize = 0.149759993;
  15825. result.vScreenSize = 0.0935999975;
  15826. result.vScreenCenter = 0.0467999987;
  15827. result.eyeToScreenDistance = 0.0410000011;
  15828. result.lensSeparationDistance = 0.0635000020;
  15829. result.interpupillaryDistance = 0.0640000030;
  15830. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15831. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15832. result.postProcessScaleFactor = 1.714605507808412;
  15833. result.lensCenterOffset = 0.151976421;
  15834. return result;
  15835. };
  15836. return VRCameraMetrics;
  15837. }());
  15838. /***/ }),
  15839. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15840. /*!**********************************************************!*\
  15841. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15842. \**********************************************************/
  15843. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15845. "use strict";
  15846. __webpack_require__.r(__webpack_exports__);
  15847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15848. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15849. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15850. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15851. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15852. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15853. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15854. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15855. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15856. // Side effect import to define the stereoscopic mode.
  15857. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15858. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15859. });
  15860. /**
  15861. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15862. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15863. */
  15864. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15865. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15866. /**
  15867. * Creates a new VRDeviceOrientationArcRotateCamera
  15868. * @param name defines camera name
  15869. * @param alpha defines the camera rotation along the logitudinal axis
  15870. * @param beta defines the camera rotation along the latitudinal axis
  15871. * @param radius defines the camera distance from its target
  15872. * @param target defines the camera target
  15873. * @param scene defines the scene the camera belongs to
  15874. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15875. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15876. */
  15877. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15878. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15879. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15880. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15881. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15882. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15883. _this.inputs.addVRDeviceOrientation();
  15884. return _this;
  15885. }
  15886. /**
  15887. * Gets camera class name
  15888. * @returns VRDeviceOrientationArcRotateCamera
  15889. */
  15890. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15891. return "VRDeviceOrientationArcRotateCamera";
  15892. };
  15893. return VRDeviceOrientationArcRotateCamera;
  15894. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15895. /***/ }),
  15896. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15897. /*!*****************************************************!*\
  15898. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15899. \*****************************************************/
  15900. /*! exports provided: VRDeviceOrientationFreeCamera */
  15901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15902. "use strict";
  15903. __webpack_require__.r(__webpack_exports__);
  15904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15905. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15906. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15907. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15908. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15909. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15910. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15911. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15912. // Side effect import to define the stereoscopic mode.
  15913. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15914. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15915. });
  15916. /**
  15917. * Camera used to simulate VR rendering (based on FreeCamera)
  15918. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15919. */
  15920. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15921. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15922. /**
  15923. * Creates a new VRDeviceOrientationFreeCamera
  15924. * @param name defines camera name
  15925. * @param position defines the start position of the camera
  15926. * @param scene defines the scene the camera belongs to
  15927. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15928. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15929. */
  15930. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15931. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15932. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15933. var _this = _super.call(this, name, position, scene) || this;
  15934. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15935. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15936. return _this;
  15937. }
  15938. /**
  15939. * Gets camera class name
  15940. * @returns VRDeviceOrientationFreeCamera
  15941. */
  15942. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15943. return "VRDeviceOrientationFreeCamera";
  15944. };
  15945. return VRDeviceOrientationFreeCamera;
  15946. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15947. /***/ }),
  15948. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15949. /*!********************************************************!*\
  15950. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15951. \********************************************************/
  15952. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15954. "use strict";
  15955. __webpack_require__.r(__webpack_exports__);
  15956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15957. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15958. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15959. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15960. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15961. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15962. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15963. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15964. });
  15965. /**
  15966. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15967. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15968. */
  15969. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15970. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15971. /**
  15972. * Creates a new VRDeviceOrientationGamepadCamera
  15973. * @param name defines camera name
  15974. * @param position defines the start position of the camera
  15975. * @param scene defines the scene the camera belongs to
  15976. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15977. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15978. */
  15979. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15980. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15981. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15982. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15983. _this.inputs.addGamepad();
  15984. return _this;
  15985. }
  15986. /**
  15987. * Gets camera class name
  15988. * @returns VRDeviceOrientationGamepadCamera
  15989. */
  15990. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15991. return "VRDeviceOrientationGamepadCamera";
  15992. };
  15993. return VRDeviceOrientationGamepadCamera;
  15994. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15995. /***/ }),
  15996. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15997. /*!******************************************!*\
  15998. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15999. \******************************************/
  16000. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  16001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16002. "use strict";
  16003. __webpack_require__.r(__webpack_exports__);
  16004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  16005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  16006. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16007. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  16008. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16009. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16010. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  16011. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  16012. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16013. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  16014. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  16015. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16016. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16017. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16018. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  16019. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  16020. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  16021. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  16022. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  16023. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  16024. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  16025. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  16026. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  16027. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  16028. /* harmony import */ var _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Cameras/VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16029. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  16030. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  16031. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  16032. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16033. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  16034. var VRExperienceHelperGazer = /** @class */ (function () {
  16035. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  16036. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  16037. this.scene = scene;
  16038. /** @hidden */
  16039. this._pointerDownOnMeshAsked = false;
  16040. /** @hidden */
  16041. this._isActionableMesh = false;
  16042. /** @hidden */
  16043. this._teleportationRequestInitiated = false;
  16044. /** @hidden */
  16045. this._teleportationBackRequestInitiated = false;
  16046. /** @hidden */
  16047. this._rotationRightAsked = false;
  16048. /** @hidden */
  16049. this._rotationLeftAsked = false;
  16050. /** @hidden */
  16051. this._dpadPressed = true;
  16052. /** @hidden */
  16053. this._activePointer = false;
  16054. this._id = VRExperienceHelperGazer._idCounter++;
  16055. // Gaze tracker
  16056. if (!gazeTrackerToClone) {
  16057. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16058. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16059. this._gazeTracker.isPickable = false;
  16060. this._gazeTracker.isVisible = false;
  16061. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  16062. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  16063. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16064. targetMat.backFaceCulling = false;
  16065. this._gazeTracker.material = targetMat;
  16066. }
  16067. else {
  16068. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16069. }
  16070. }
  16071. /** @hidden */
  16072. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16073. 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));
  16074. };
  16075. /** @hidden */
  16076. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16077. this._pointerDownOnMeshAsked = true;
  16078. if (this._currentHit) {
  16079. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16080. }
  16081. };
  16082. /** @hidden */
  16083. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16084. if (this._currentHit) {
  16085. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16086. }
  16087. this._pointerDownOnMeshAsked = false;
  16088. };
  16089. /** @hidden */
  16090. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16091. this._activePointer = true;
  16092. };
  16093. /** @hidden */
  16094. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16095. this._activePointer = false;
  16096. };
  16097. /** @hidden */
  16098. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16099. if (distance === void 0) { distance = 100; }
  16100. };
  16101. VRExperienceHelperGazer.prototype.dispose = function () {
  16102. this._interactionsEnabled = false;
  16103. this._teleportationEnabled = false;
  16104. if (this._gazeTracker) {
  16105. this._gazeTracker.dispose();
  16106. }
  16107. };
  16108. VRExperienceHelperGazer._idCounter = 0;
  16109. return VRExperienceHelperGazer;
  16110. }());
  16111. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16112. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16113. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16114. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16115. _this.webVRController = webVRController;
  16116. // Laser pointer
  16117. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16118. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  16119. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16120. laserPointerMaterial.alpha = 0.6;
  16121. _this._laserPointer.material = laserPointerMaterial;
  16122. _this._laserPointer.rotation.x = Math.PI / 2;
  16123. _this._laserPointer.position.z = -0.5;
  16124. _this._laserPointer.isVisible = false;
  16125. _this._laserPointer.isPickable = false;
  16126. if (!webVRController.mesh) {
  16127. // Create an empty mesh that is used prior to loading the high quality model
  16128. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  16129. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  16130. preloadPointerPose.rotation.x = -0.7;
  16131. preloadMesh.addChild(preloadPointerPose);
  16132. webVRController.attachToMesh(preloadMesh);
  16133. }
  16134. _this._setLaserPointerParent(webVRController.mesh);
  16135. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16136. _this._setLaserPointerParent(mesh);
  16137. });
  16138. return _this;
  16139. }
  16140. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16141. return this.webVRController.getForwardRay(length);
  16142. };
  16143. /** @hidden */
  16144. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16145. _super.prototype._activatePointer.call(this);
  16146. this._laserPointer.isVisible = true;
  16147. };
  16148. /** @hidden */
  16149. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16150. _super.prototype._deactivatePointer.call(this);
  16151. this._laserPointer.isVisible = false;
  16152. };
  16153. /** @hidden */
  16154. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16155. this._laserPointer.material.emissiveColor = color;
  16156. };
  16157. /** @hidden */
  16158. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16159. var makeNotPick = function (root) {
  16160. root.isPickable = false;
  16161. root.getChildMeshes().forEach(function (c) {
  16162. makeNotPick(c);
  16163. });
  16164. };
  16165. makeNotPick(mesh);
  16166. var meshChildren = mesh.getChildren(undefined, false);
  16167. var laserParent = mesh;
  16168. this.webVRController._pointingPoseNode = null;
  16169. for (var i = 0; i < meshChildren.length; i++) {
  16170. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16171. laserParent = meshChildren[i];
  16172. this.webVRController._pointingPoseNode = laserParent;
  16173. break;
  16174. }
  16175. }
  16176. this._laserPointer.parent = laserParent;
  16177. };
  16178. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16179. if (distance === void 0) { distance = 100; }
  16180. this._laserPointer.scaling.y = distance;
  16181. this._laserPointer.position.z = -distance / 2;
  16182. };
  16183. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16184. _super.prototype.dispose.call(this);
  16185. this._laserPointer.dispose();
  16186. if (this._meshAttachedObserver) {
  16187. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16188. }
  16189. };
  16190. return VRExperienceHelperControllerGazer;
  16191. }(VRExperienceHelperGazer));
  16192. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16193. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16194. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16195. var _this = _super.call(this, scene) || this;
  16196. _this.getCamera = getCamera;
  16197. return _this;
  16198. }
  16199. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16200. var camera = this.getCamera();
  16201. if (camera) {
  16202. return camera.getForwardRay(length);
  16203. }
  16204. else {
  16205. 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());
  16206. }
  16207. };
  16208. return VRExperienceHelperCameraGazer;
  16209. }(VRExperienceHelperGazer));
  16210. /**
  16211. * Event containing information after VR has been entered
  16212. */
  16213. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16214. function OnAfterEnteringVRObservableEvent() {
  16215. }
  16216. return OnAfterEnteringVRObservableEvent;
  16217. }());
  16218. /**
  16219. * Helps to quickly add VR support to an existing scene.
  16220. * See http://doc.babylonjs.com/how_to/webvr_helper
  16221. */
  16222. var VRExperienceHelper = /** @class */ (function () {
  16223. /**
  16224. * Instantiates a VRExperienceHelper.
  16225. * Helps to quickly add VR support to an existing scene.
  16226. * @param scene The scene the VRExperienceHelper belongs to.
  16227. * @param webVROptions Options to modify the vr experience helper's behavior.
  16228. */
  16229. function VRExperienceHelper(scene,
  16230. /** Options to modify the vr experience helper's behavior. */
  16231. webVROptions) {
  16232. if (webVROptions === void 0) { webVROptions = {}; }
  16233. var _this = this;
  16234. this.webVROptions = webVROptions;
  16235. // Can the system support WebVR, even if a headset isn't plugged in?
  16236. this._webVRsupported = false;
  16237. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16238. this._webVRready = false;
  16239. // Are we waiting for the requestPresent callback to complete?
  16240. this._webVRrequesting = false;
  16241. // Are we presenting to the headset right now? (this is the vrDevice state)
  16242. this._webVRpresenting = false;
  16243. // Are we presenting in the fullscreen fallback?
  16244. this._fullscreenVRpresenting = false;
  16245. /**
  16246. * Observable raised right before entering VR.
  16247. */
  16248. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16249. /**
  16250. * Observable raised when entering VR has completed.
  16251. */
  16252. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16253. /**
  16254. * Observable raised when exiting VR.
  16255. */
  16256. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16257. /**
  16258. * Observable raised when controller mesh is loaded.
  16259. */
  16260. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16261. this._useCustomVRButton = false;
  16262. this._teleportationRequested = false;
  16263. this._teleportActive = false;
  16264. this._floorMeshesCollection = [];
  16265. this._rotationAllowed = true;
  16266. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16267. this._isDefaultTeleportationTarget = true;
  16268. this._teleportationFillColor = "#444444";
  16269. this._teleportationBorderColor = "#FFFFFF";
  16270. this._rotationAngle = 0;
  16271. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16272. this._padSensibilityUp = 0.65;
  16273. this._padSensibilityDown = 0.35;
  16274. this._leftController = null;
  16275. this._rightController = null;
  16276. /**
  16277. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16278. */
  16279. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16280. /**
  16281. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16282. */
  16283. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16284. /**
  16285. * Observable raised before camera teleportation
  16286. */
  16287. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16288. /**
  16289. * Observable raised after camera teleportation
  16290. */
  16291. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16292. /**
  16293. * Observable raised when current selected mesh gets unselected
  16294. */
  16295. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16296. /**
  16297. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16298. */
  16299. this.teleportationEnabled = true;
  16300. this._teleportationInitialized = false;
  16301. this._interactionsEnabled = false;
  16302. this._interactionsRequested = false;
  16303. this._displayGaze = true;
  16304. this._displayLaserPointer = true;
  16305. /**
  16306. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16307. */
  16308. this.updateGazeTrackerScale = true;
  16309. /**
  16310. * If the gaze trackers color should be updated when selecting meshes
  16311. */
  16312. this.updateGazeTrackerColor = true;
  16313. /**
  16314. * Defines wether or not Pointer lock should be requested when switching to
  16315. * full screen.
  16316. */
  16317. this.requestPointerLockOnFullScreen = true;
  16318. this._onResize = function () {
  16319. _this.moveButtonToBottomRight();
  16320. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16321. _this.exitVR();
  16322. }
  16323. };
  16324. this._onFullscreenChange = function () {
  16325. var anyDoc = document;
  16326. if (anyDoc.fullscreen !== undefined) {
  16327. _this._fullscreenVRpresenting = document.fullscreen;
  16328. }
  16329. else if (anyDoc.mozFullScreen !== undefined) {
  16330. _this._fullscreenVRpresenting = anyDoc.mozFullScreen;
  16331. }
  16332. else if (anyDoc.webkitIsFullScreen !== undefined) {
  16333. _this._fullscreenVRpresenting = anyDoc.webkitIsFullScreen;
  16334. }
  16335. else if (anyDoc.msIsFullScreen !== undefined) {
  16336. _this._fullscreenVRpresenting = anyDoc.msIsFullScreen;
  16337. }
  16338. else if (document.msFullscreenElement !== undefined) {
  16339. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16340. }
  16341. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16342. _this.exitVR();
  16343. if (!_this._useCustomVRButton) {
  16344. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16345. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16346. }
  16347. }
  16348. };
  16349. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16350. this.beforeRender = function () {
  16351. if (_this._leftController && _this._leftController._activePointer) {
  16352. _this._castRayAndSelectObject(_this._leftController);
  16353. }
  16354. if (_this._rightController && _this._rightController._activePointer) {
  16355. _this._castRayAndSelectObject(_this._rightController);
  16356. }
  16357. if (_this._noControllerIsActive) {
  16358. _this._castRayAndSelectObject(_this._cameraGazer);
  16359. }
  16360. else {
  16361. _this._cameraGazer._gazeTracker.isVisible = false;
  16362. }
  16363. };
  16364. this._onNewGamepadConnected = function (gamepad) {
  16365. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  16366. if (gamepad.leftStick) {
  16367. gamepad.onleftstickchanged(function (stickValues) {
  16368. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16369. // Listening to classic/xbox gamepad only if no VR controller is active
  16370. if ((!_this._leftController && !_this._rightController) ||
  16371. ((_this._leftController && !_this._leftController._activePointer) &&
  16372. (_this._rightController && !_this._rightController._activePointer))) {
  16373. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16374. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16375. }
  16376. }
  16377. });
  16378. }
  16379. if (gamepad.rightStick) {
  16380. gamepad.onrightstickchanged(function (stickValues) {
  16381. if (_this._teleportationInitialized) {
  16382. _this._checkRotate(stickValues, _this._cameraGazer);
  16383. }
  16384. });
  16385. }
  16386. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  16387. gamepad.onbuttondown(function (buttonPressed) {
  16388. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16389. _this._cameraGazer._selectionPointerDown();
  16390. }
  16391. });
  16392. gamepad.onbuttonup(function (buttonPressed) {
  16393. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16394. _this._cameraGazer._selectionPointerUp();
  16395. }
  16396. });
  16397. }
  16398. }
  16399. else {
  16400. var webVRController = gamepad;
  16401. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16402. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16403. _this._rightController = controller;
  16404. }
  16405. else {
  16406. _this._leftController = controller;
  16407. }
  16408. _this._tryEnableInteractionOnController(controller);
  16409. }
  16410. };
  16411. // 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
  16412. this._tryEnableInteractionOnController = function (controller) {
  16413. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16414. _this._enableInteractionOnController(controller);
  16415. }
  16416. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16417. _this._enableTeleportationOnController(controller);
  16418. }
  16419. };
  16420. this._onNewGamepadDisconnected = function (gamepad) {
  16421. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  16422. if (gamepad.hand === "left" && _this._leftController != null) {
  16423. _this._leftController.dispose();
  16424. _this._leftController = null;
  16425. }
  16426. if (gamepad.hand === "right" && _this._rightController != null) {
  16427. _this._rightController.dispose();
  16428. _this._rightController = null;
  16429. }
  16430. }
  16431. };
  16432. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16433. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16434. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16435. this._scene = scene;
  16436. this._canvas = scene.getEngine().getRenderingCanvas();
  16437. // Parse options
  16438. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16439. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16440. }
  16441. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16442. webVROptions.createDeviceOrientationCamera = true;
  16443. }
  16444. if (webVROptions.laserToggle === undefined) {
  16445. webVROptions.laserToggle = true;
  16446. }
  16447. if (webVROptions.defaultHeight === undefined) {
  16448. webVROptions.defaultHeight = 1.7;
  16449. }
  16450. if (webVROptions.useCustomVRButton) {
  16451. this._useCustomVRButton = true;
  16452. if (webVROptions.customVRButton) {
  16453. this._btnVR = webVROptions.customVRButton;
  16454. }
  16455. }
  16456. if (webVROptions.rayLength) {
  16457. this._rayLength = webVROptions.rayLength;
  16458. }
  16459. this._defaultHeight = webVROptions.defaultHeight;
  16460. if (webVROptions.positionScale) {
  16461. this._rayLength *= webVROptions.positionScale;
  16462. this._defaultHeight *= webVROptions.positionScale;
  16463. }
  16464. this._hasEnteredVR = false;
  16465. // Set position
  16466. if (this._scene.activeCamera) {
  16467. this._position = this._scene.activeCamera.position.clone();
  16468. }
  16469. else {
  16470. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16471. }
  16472. // Set non-vr camera
  16473. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16474. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16475. // Copy data from existing camera
  16476. if (this._scene.activeCamera) {
  16477. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16478. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16479. // Set rotation from previous camera
  16480. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16481. var targetCamera = this._scene.activeCamera;
  16482. if (targetCamera.rotationQuaternion) {
  16483. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16484. }
  16485. else {
  16486. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16487. }
  16488. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16489. }
  16490. }
  16491. this._scene.activeCamera = this._deviceOrientationCamera;
  16492. if (this._canvas) {
  16493. this._scene.activeCamera.attachControl(this._canvas);
  16494. }
  16495. }
  16496. else {
  16497. this._existingCamera = this._scene.activeCamera;
  16498. }
  16499. // Create VR cameras
  16500. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16501. if (webVROptions.useMultiview) {
  16502. if (!webVROptions.vrDeviceOrientationCameraMetrics) {
  16503. webVROptions.vrDeviceOrientationCameraMetrics = _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__["VRCameraMetrics"].GetDefault();
  16504. }
  16505. webVROptions.vrDeviceOrientationCameraMetrics.multiviewEnabled = true;
  16506. }
  16507. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16508. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16509. }
  16510. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16511. this._webVRCamera.useStandingMatrix();
  16512. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16513. // Create default button
  16514. if (!this._useCustomVRButton) {
  16515. this._btnVR = document.createElement("BUTTON");
  16516. this._btnVR.className = "babylonVRicon";
  16517. this._btnVR.id = "babylonVRiconbtn";
  16518. this._btnVR.title = "Click to switch to VR";
  16519. 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) }";
  16520. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16521. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16522. // css += ".babylonVRicon.vrdisplaysupported { }";
  16523. // css += ".babylonVRicon.vrdisplayready { }";
  16524. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16525. var style = document.createElement('style');
  16526. style.appendChild(document.createTextNode(css));
  16527. document.getElementsByTagName('head')[0].appendChild(style);
  16528. this.moveButtonToBottomRight();
  16529. }
  16530. // VR button click event
  16531. if (this._btnVR) {
  16532. this._btnVR.addEventListener("click", function () {
  16533. if (!_this.isInVRMode) {
  16534. _this.enterVR();
  16535. }
  16536. else {
  16537. _this.exitVR();
  16538. }
  16539. });
  16540. }
  16541. // Window events
  16542. window.addEventListener("resize", this._onResize);
  16543. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16544. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16545. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16546. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16547. document.onmsfullscreenchange = this._onFullscreenChange;
  16548. // Display vr button when headset is connected
  16549. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16550. this.displayVRButton();
  16551. }
  16552. else {
  16553. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16554. if (e.vrDisplay) {
  16555. _this.displayVRButton();
  16556. }
  16557. });
  16558. }
  16559. // Exiting VR mode using 'ESC' key on desktop
  16560. this._onKeyDown = function (event) {
  16561. if (event.keyCode === 27 && _this.isInVRMode) {
  16562. _this.exitVR();
  16563. }
  16564. };
  16565. document.addEventListener("keydown", this._onKeyDown);
  16566. // Exiting VR mode double tapping the touch screen
  16567. this._scene.onPrePointerObservable.add(function () {
  16568. if (_this.isInVRMode) {
  16569. _this.exitVR();
  16570. if (_this._fullscreenVRpresenting) {
  16571. _this._scene.getEngine().exitFullscreen();
  16572. }
  16573. }
  16574. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16575. // Listen for WebVR display changes
  16576. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16577. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16578. this._onVRRequestPresentStart = function () {
  16579. _this._webVRrequesting = true;
  16580. _this.updateButtonVisibility();
  16581. };
  16582. this._onVRRequestPresentComplete = function () {
  16583. _this._webVRrequesting = false;
  16584. _this.updateButtonVisibility();
  16585. };
  16586. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16587. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16588. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16589. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16590. scene.onDisposeObservable.add(function () {
  16591. _this.dispose();
  16592. });
  16593. // Gamepad connection events
  16594. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16595. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16596. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16597. this.updateButtonVisibility();
  16598. //create easing functions
  16599. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16600. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16601. if (this.webVROptions.floorMeshes) {
  16602. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16603. }
  16604. }
  16605. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16606. /** Return this.onEnteringVRObservable
  16607. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16608. */
  16609. get: function () {
  16610. return this.onEnteringVRObservable;
  16611. },
  16612. enumerable: true,
  16613. configurable: true
  16614. });
  16615. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16616. /** Return this.onExitingVRObservable
  16617. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16618. */
  16619. get: function () {
  16620. return this.onExitingVRObservable;
  16621. },
  16622. enumerable: true,
  16623. configurable: true
  16624. });
  16625. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16626. /** Return this.onControllerMeshLoadedObservable
  16627. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16628. */
  16629. get: function () {
  16630. return this.onControllerMeshLoadedObservable;
  16631. },
  16632. enumerable: true,
  16633. configurable: true
  16634. });
  16635. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16636. /**
  16637. * The mesh used to display where the user is going to teleport.
  16638. */
  16639. get: function () {
  16640. return this._teleportationTarget;
  16641. },
  16642. /**
  16643. * Sets the mesh to be used to display where the user is going to teleport.
  16644. */
  16645. set: function (value) {
  16646. if (value) {
  16647. value.name = "teleportationTarget";
  16648. this._isDefaultTeleportationTarget = false;
  16649. this._teleportationTarget = value;
  16650. }
  16651. },
  16652. enumerable: true,
  16653. configurable: true
  16654. });
  16655. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16656. /**
  16657. * 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
  16658. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16659. * See http://doc.babylonjs.com/resources/baking_transformations
  16660. */
  16661. get: function () {
  16662. return this._cameraGazer._gazeTracker;
  16663. },
  16664. set: function (value) {
  16665. if (value) {
  16666. // Dispose of existing meshes
  16667. if (this._cameraGazer._gazeTracker) {
  16668. this._cameraGazer._gazeTracker.dispose();
  16669. }
  16670. if (this._leftController && this._leftController._gazeTracker) {
  16671. this._leftController._gazeTracker.dispose();
  16672. }
  16673. if (this._rightController && this._rightController._gazeTracker) {
  16674. this._rightController._gazeTracker.dispose();
  16675. }
  16676. // Set and create gaze trackers on head and controllers
  16677. this._cameraGazer._gazeTracker = value;
  16678. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16679. this._cameraGazer._gazeTracker.isPickable = false;
  16680. this._cameraGazer._gazeTracker.isVisible = false;
  16681. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16682. if (this._leftController) {
  16683. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16684. }
  16685. if (this._rightController) {
  16686. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16687. }
  16688. }
  16689. },
  16690. enumerable: true,
  16691. configurable: true
  16692. });
  16693. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16694. /**
  16695. * The gaze tracking mesh corresponding to the left controller
  16696. */
  16697. get: function () {
  16698. if (this._leftController) {
  16699. return this._leftController._gazeTracker;
  16700. }
  16701. return null;
  16702. },
  16703. enumerable: true,
  16704. configurable: true
  16705. });
  16706. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16707. /**
  16708. * The gaze tracking mesh corresponding to the right controller
  16709. */
  16710. get: function () {
  16711. if (this._rightController) {
  16712. return this._rightController._gazeTracker;
  16713. }
  16714. return null;
  16715. },
  16716. enumerable: true,
  16717. configurable: true
  16718. });
  16719. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16720. /**
  16721. * If the ray of the gaze should be displayed.
  16722. */
  16723. get: function () {
  16724. return this._displayGaze;
  16725. },
  16726. /**
  16727. * Sets if the ray of the gaze should be displayed.
  16728. */
  16729. set: function (value) {
  16730. this._displayGaze = value;
  16731. if (!value) {
  16732. this._cameraGazer._gazeTracker.isVisible = false;
  16733. if (this._leftController) {
  16734. this._leftController._gazeTracker.isVisible = false;
  16735. }
  16736. if (this._rightController) {
  16737. this._rightController._gazeTracker.isVisible = false;
  16738. }
  16739. }
  16740. },
  16741. enumerable: true,
  16742. configurable: true
  16743. });
  16744. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16745. /**
  16746. * If the ray of the LaserPointer should be displayed.
  16747. */
  16748. get: function () {
  16749. return this._displayLaserPointer;
  16750. },
  16751. /**
  16752. * Sets if the ray of the LaserPointer should be displayed.
  16753. */
  16754. set: function (value) {
  16755. this._displayLaserPointer = value;
  16756. if (!value) {
  16757. if (this._rightController) {
  16758. this._rightController._deactivatePointer();
  16759. this._rightController._gazeTracker.isVisible = false;
  16760. }
  16761. if (this._leftController) {
  16762. this._leftController._deactivatePointer();
  16763. this._leftController._gazeTracker.isVisible = false;
  16764. }
  16765. }
  16766. else {
  16767. if (this._rightController) {
  16768. this._rightController._activatePointer();
  16769. }
  16770. if (this._leftController) {
  16771. this._leftController._activatePointer();
  16772. }
  16773. }
  16774. },
  16775. enumerable: true,
  16776. configurable: true
  16777. });
  16778. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16779. /**
  16780. * The deviceOrientationCamera used as the camera when not in VR.
  16781. */
  16782. get: function () {
  16783. return this._deviceOrientationCamera;
  16784. },
  16785. enumerable: true,
  16786. configurable: true
  16787. });
  16788. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16789. /**
  16790. * Based on the current WebVR support, returns the current VR camera used.
  16791. */
  16792. get: function () {
  16793. if (this._webVRready) {
  16794. return this._webVRCamera;
  16795. }
  16796. else {
  16797. return this._scene.activeCamera;
  16798. }
  16799. },
  16800. enumerable: true,
  16801. configurable: true
  16802. });
  16803. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16804. /**
  16805. * The webVRCamera which is used when in VR.
  16806. */
  16807. get: function () {
  16808. return this._webVRCamera;
  16809. },
  16810. enumerable: true,
  16811. configurable: true
  16812. });
  16813. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16814. /**
  16815. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16816. */
  16817. get: function () {
  16818. return this._vrDeviceOrientationCamera;
  16819. },
  16820. enumerable: true,
  16821. configurable: true
  16822. });
  16823. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16824. get: function () {
  16825. var result = this._cameraGazer._teleportationRequestInitiated
  16826. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16827. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16828. return result;
  16829. },
  16830. enumerable: true,
  16831. configurable: true
  16832. });
  16833. // Raised when one of the controller has loaded successfully its associated default mesh
  16834. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16835. if (this._leftController && this._leftController.webVRController == webVRController) {
  16836. if (webVRController.mesh) {
  16837. this._leftController._setLaserPointerParent(webVRController.mesh);
  16838. }
  16839. }
  16840. if (this._rightController && this._rightController.webVRController == webVRController) {
  16841. if (webVRController.mesh) {
  16842. this._rightController._setLaserPointerParent(webVRController.mesh);
  16843. }
  16844. }
  16845. try {
  16846. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16847. }
  16848. catch (err) {
  16849. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16850. }
  16851. };
  16852. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16853. /**
  16854. * Gets a value indicating if we are currently in VR mode.
  16855. */
  16856. get: function () {
  16857. return this._webVRpresenting || this._fullscreenVRpresenting;
  16858. },
  16859. enumerable: true,
  16860. configurable: true
  16861. });
  16862. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16863. var vrDisplay = this._scene.getEngine().getVRDevice();
  16864. if (vrDisplay) {
  16865. var wasPresenting = this._webVRpresenting;
  16866. this._webVRpresenting = vrDisplay.isPresenting;
  16867. if (wasPresenting && !this._webVRpresenting) {
  16868. this.exitVR();
  16869. }
  16870. }
  16871. else {
  16872. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16873. }
  16874. this.updateButtonVisibility();
  16875. };
  16876. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16877. this._webVRsupported = eventArgs.vrSupported;
  16878. this._webVRready = !!eventArgs.vrDisplay;
  16879. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16880. this.updateButtonVisibility();
  16881. };
  16882. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16883. if (this._canvas && !this._useCustomVRButton) {
  16884. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16885. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16886. }
  16887. };
  16888. VRExperienceHelper.prototype.displayVRButton = function () {
  16889. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16890. document.body.appendChild(this._btnVR);
  16891. this._btnVRDisplayed = true;
  16892. }
  16893. };
  16894. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16895. if (!this._btnVR || this._useCustomVRButton) {
  16896. return;
  16897. }
  16898. this._btnVR.className = "babylonVRicon";
  16899. if (this.isInVRMode) {
  16900. this._btnVR.className += " vrdisplaypresenting";
  16901. }
  16902. else {
  16903. if (this._webVRready) {
  16904. this._btnVR.className += " vrdisplayready";
  16905. }
  16906. if (this._webVRsupported) {
  16907. this._btnVR.className += " vrdisplaysupported";
  16908. }
  16909. if (this._webVRrequesting) {
  16910. this._btnVR.className += " vrdisplayrequesting";
  16911. }
  16912. }
  16913. };
  16914. /**
  16915. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16916. * Otherwise, will use the fullscreen API.
  16917. */
  16918. VRExperienceHelper.prototype.enterVR = function () {
  16919. var _this = this;
  16920. if (this.onEnteringVRObservable) {
  16921. try {
  16922. this.onEnteringVRObservable.notifyObservers(this);
  16923. }
  16924. catch (err) {
  16925. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16926. }
  16927. }
  16928. if (this._scene.activeCamera) {
  16929. this._position = this._scene.activeCamera.position.clone();
  16930. if (this.vrDeviceOrientationCamera) {
  16931. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16932. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16933. }
  16934. if (this.webVRCamera) {
  16935. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16936. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16937. var delta = desiredYRotation - currentYRotation;
  16938. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16939. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16940. }
  16941. // make sure that we return to the last active camera
  16942. this._existingCamera = this._scene.activeCamera;
  16943. // Remove and cache angular sensability to avoid camera rotation when in VR
  16944. if (this._existingCamera.angularSensibilityX) {
  16945. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16946. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16947. }
  16948. if (this._existingCamera.angularSensibilityY) {
  16949. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16950. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16951. }
  16952. if (this._existingCamera.angularSensibility) {
  16953. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16954. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16955. }
  16956. }
  16957. if (this._webVRrequesting) {
  16958. return;
  16959. }
  16960. // If WebVR is supported and a headset is connected
  16961. if (this._webVRready) {
  16962. if (!this._webVRpresenting) {
  16963. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  16964. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  16965. });
  16966. this._webVRCamera.position = this._position;
  16967. this._scene.activeCamera = this._webVRCamera;
  16968. }
  16969. }
  16970. else if (this._vrDeviceOrientationCamera) {
  16971. this._vrDeviceOrientationCamera.position = this._position;
  16972. if (this._scene.activeCamera) {
  16973. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16974. }
  16975. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16976. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  16977. this.updateButtonVisibility();
  16978. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  16979. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  16980. });
  16981. }
  16982. if (this._scene.activeCamera && this._canvas) {
  16983. this._scene.activeCamera.attachControl(this._canvas);
  16984. }
  16985. if (this._interactionsEnabled) {
  16986. this._scene.registerBeforeRender(this.beforeRender);
  16987. }
  16988. if (this._displayLaserPointer) {
  16989. [this._leftController, this._rightController].forEach(function (controller) {
  16990. if (controller) {
  16991. controller._activatePointer();
  16992. }
  16993. });
  16994. }
  16995. this._hasEnteredVR = true;
  16996. };
  16997. /**
  16998. * Attempt to exit VR, or fullscreen.
  16999. */
  17000. VRExperienceHelper.prototype.exitVR = function () {
  17001. if (this._hasEnteredVR) {
  17002. if (this.onExitingVRObservable) {
  17003. try {
  17004. this.onExitingVRObservable.notifyObservers(this);
  17005. }
  17006. catch (err) {
  17007. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  17008. }
  17009. }
  17010. if (this._webVRpresenting) {
  17011. this._scene.getEngine().disableVR();
  17012. }
  17013. if (this._scene.activeCamera) {
  17014. this._position = this._scene.activeCamera.position.clone();
  17015. }
  17016. if (this.vrDeviceOrientationCamera) {
  17017. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  17018. }
  17019. if (this._deviceOrientationCamera) {
  17020. this._deviceOrientationCamera.position = this._position;
  17021. this._scene.activeCamera = this._deviceOrientationCamera;
  17022. if (this._canvas) {
  17023. this._scene.activeCamera.attachControl(this._canvas);
  17024. }
  17025. // Restore angular sensibility
  17026. if (this._cachedAngularSensibility.angularSensibilityX) {
  17027. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17028. this._cachedAngularSensibility.angularSensibilityX = null;
  17029. }
  17030. if (this._cachedAngularSensibility.angularSensibilityY) {
  17031. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17032. this._cachedAngularSensibility.angularSensibilityY = null;
  17033. }
  17034. if (this._cachedAngularSensibility.angularSensibility) {
  17035. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17036. this._cachedAngularSensibility.angularSensibility = null;
  17037. }
  17038. }
  17039. else if (this._existingCamera) {
  17040. this._existingCamera.position = this._position;
  17041. this._scene.activeCamera = this._existingCamera;
  17042. // Restore angular sensibility
  17043. if (this._cachedAngularSensibility.angularSensibilityX) {
  17044. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17045. this._cachedAngularSensibility.angularSensibilityX = null;
  17046. }
  17047. if (this._cachedAngularSensibility.angularSensibilityY) {
  17048. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17049. this._cachedAngularSensibility.angularSensibilityY = null;
  17050. }
  17051. if (this._cachedAngularSensibility.angularSensibility) {
  17052. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17053. this._cachedAngularSensibility.angularSensibility = null;
  17054. }
  17055. }
  17056. this.updateButtonVisibility();
  17057. if (this._interactionsEnabled) {
  17058. this._scene.unregisterBeforeRender(this.beforeRender);
  17059. this._cameraGazer._gazeTracker.isVisible = false;
  17060. if (this._leftController) {
  17061. this._leftController._gazeTracker.isVisible = false;
  17062. }
  17063. if (this._rightController) {
  17064. this._rightController._gazeTracker.isVisible = false;
  17065. }
  17066. }
  17067. // resize to update width and height when exiting vr exits fullscreen
  17068. this._scene.getEngine().resize();
  17069. [this._leftController, this._rightController].forEach(function (controller) {
  17070. if (controller) {
  17071. controller._deactivatePointer();
  17072. }
  17073. });
  17074. this._hasEnteredVR = false;
  17075. }
  17076. };
  17077. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17078. /**
  17079. * The position of the vr experience helper.
  17080. */
  17081. get: function () {
  17082. return this._position;
  17083. },
  17084. /**
  17085. * Sets the position of the vr experience helper.
  17086. */
  17087. set: function (value) {
  17088. this._position = value;
  17089. if (this._scene.activeCamera) {
  17090. this._scene.activeCamera.position = value;
  17091. }
  17092. },
  17093. enumerable: true,
  17094. configurable: true
  17095. });
  17096. /**
  17097. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17098. */
  17099. VRExperienceHelper.prototype.enableInteractions = function () {
  17100. var _this = this;
  17101. if (!this._interactionsEnabled) {
  17102. this._interactionsRequested = true;
  17103. if (this._leftController) {
  17104. this._enableInteractionOnController(this._leftController);
  17105. }
  17106. if (this._rightController) {
  17107. this._enableInteractionOnController(this._rightController);
  17108. }
  17109. this.raySelectionPredicate = function (mesh) {
  17110. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17111. };
  17112. this.meshSelectionPredicate = function () {
  17113. return true;
  17114. };
  17115. this._raySelectionPredicate = function (mesh) {
  17116. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17117. && mesh.name.indexOf("teleportationTarget") === -1
  17118. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17119. return _this.raySelectionPredicate(mesh);
  17120. }
  17121. return false;
  17122. };
  17123. this._interactionsEnabled = true;
  17124. }
  17125. };
  17126. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17127. get: function () {
  17128. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17129. },
  17130. enumerable: true,
  17131. configurable: true
  17132. });
  17133. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17134. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17135. if (this._floorMeshesCollection[i].id === mesh.id) {
  17136. return true;
  17137. }
  17138. }
  17139. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17140. return true;
  17141. }
  17142. return false;
  17143. };
  17144. /**
  17145. * Adds a floor mesh to be used for teleportation.
  17146. * @param floorMesh the mesh to be used for teleportation.
  17147. */
  17148. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17149. if (!this._floorMeshesCollection) {
  17150. return;
  17151. }
  17152. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17153. return;
  17154. }
  17155. this._floorMeshesCollection.push(floorMesh);
  17156. };
  17157. /**
  17158. * Removes a floor mesh from being used for teleportation.
  17159. * @param floorMesh the mesh to be removed.
  17160. */
  17161. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17162. if (!this._floorMeshesCollection) {
  17163. return;
  17164. }
  17165. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17166. if (meshIndex !== -1) {
  17167. this._floorMeshesCollection.splice(meshIndex, 1);
  17168. }
  17169. };
  17170. /**
  17171. * Enables interactions and teleportation using the VR controllers and gaze.
  17172. * @param vrTeleportationOptions options to modify teleportation behavior.
  17173. */
  17174. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17175. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17176. if (!this._teleportationInitialized) {
  17177. this._teleportationRequested = true;
  17178. this.enableInteractions();
  17179. if (vrTeleportationOptions.floorMeshName) {
  17180. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17181. }
  17182. if (vrTeleportationOptions.floorMeshes) {
  17183. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17184. }
  17185. if (this._leftController != null) {
  17186. this._enableTeleportationOnController(this._leftController);
  17187. }
  17188. if (this._rightController != null) {
  17189. this._enableTeleportationOnController(this._rightController);
  17190. }
  17191. // Creates an image processing post process for the vignette not relying
  17192. // on the main scene configuration for image processing to reduce setup and spaces
  17193. // (gamma/linear) conflicts.
  17194. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  17195. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  17196. imageProcessingConfiguration.vignetteEnabled = true;
  17197. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17198. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17199. this._teleportationInitialized = true;
  17200. if (this._isDefaultTeleportationTarget) {
  17201. this._createTeleportationCircles();
  17202. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17203. }
  17204. }
  17205. };
  17206. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17207. var _this = this;
  17208. var controllerMesh = controller.webVRController.mesh;
  17209. if (controllerMesh) {
  17210. controller._interactionsEnabled = true;
  17211. if (this.isInVRMode && this._displayLaserPointer) {
  17212. controller._activatePointer();
  17213. }
  17214. if (this.webVROptions.laserToggle) {
  17215. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17216. // Enabling / disabling laserPointer
  17217. if (_this._displayLaserPointer && stateObject.value === 1) {
  17218. if (controller._activePointer) {
  17219. controller._deactivatePointer();
  17220. }
  17221. else {
  17222. controller._activatePointer();
  17223. }
  17224. if (_this.displayGaze) {
  17225. controller._gazeTracker.isVisible = controller._activePointer;
  17226. }
  17227. }
  17228. });
  17229. }
  17230. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17231. var gazer = controller;
  17232. if (_this._noControllerIsActive) {
  17233. gazer = _this._cameraGazer;
  17234. }
  17235. if (!gazer._pointerDownOnMeshAsked) {
  17236. if (stateObject.value > _this._padSensibilityUp) {
  17237. gazer._selectionPointerDown();
  17238. }
  17239. }
  17240. else if (stateObject.value < _this._padSensibilityDown) {
  17241. gazer._selectionPointerUp();
  17242. }
  17243. });
  17244. }
  17245. };
  17246. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17247. // Dont teleport if another gaze already requested teleportation
  17248. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17249. return;
  17250. }
  17251. if (!gazer._teleportationRequestInitiated) {
  17252. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17253. gazer._activatePointer();
  17254. gazer._teleportationRequestInitiated = true;
  17255. }
  17256. }
  17257. else {
  17258. // Listening to the proper controller values changes to confirm teleportation
  17259. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17260. if (this._teleportActive) {
  17261. this.teleportCamera(this._haloCenter);
  17262. }
  17263. gazer._teleportationRequestInitiated = false;
  17264. }
  17265. }
  17266. };
  17267. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17268. // Only rotate when user is not currently selecting a teleportation location
  17269. if (gazer._teleportationRequestInitiated) {
  17270. return;
  17271. }
  17272. if (!gazer._rotationLeftAsked) {
  17273. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17274. gazer._rotationLeftAsked = true;
  17275. if (this._rotationAllowed) {
  17276. this._rotateCamera(false);
  17277. }
  17278. }
  17279. }
  17280. else {
  17281. if (stateObject.x > -this._padSensibilityDown) {
  17282. gazer._rotationLeftAsked = false;
  17283. }
  17284. }
  17285. if (!gazer._rotationRightAsked) {
  17286. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17287. gazer._rotationRightAsked = true;
  17288. if (this._rotationAllowed) {
  17289. this._rotateCamera(true);
  17290. }
  17291. }
  17292. }
  17293. else {
  17294. if (stateObject.x < this._padSensibilityDown) {
  17295. gazer._rotationRightAsked = false;
  17296. }
  17297. }
  17298. };
  17299. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17300. // Only teleport backwards when user is not currently selecting a teleportation location
  17301. if (gazer._teleportationRequestInitiated) {
  17302. return;
  17303. }
  17304. // Teleport backwards
  17305. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17306. if (!gazer._teleportationBackRequestInitiated) {
  17307. if (!this.currentVRCamera) {
  17308. return;
  17309. }
  17310. // Get rotation and position of the current camera
  17311. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17312. var position = this.currentVRCamera.position;
  17313. // If the camera has device position, use that instead
  17314. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17315. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17316. position = this.currentVRCamera.devicePosition;
  17317. }
  17318. // Get matrix with only the y rotation of the device rotation
  17319. rotation.toEulerAnglesToRef(this._workingVector);
  17320. this._workingVector.z = 0;
  17321. this._workingVector.x = 0;
  17322. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17323. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17324. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17325. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17326. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17327. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  17328. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17329. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17330. this.teleportCamera(hit.pickedPoint);
  17331. }
  17332. gazer._teleportationBackRequestInitiated = true;
  17333. }
  17334. }
  17335. else {
  17336. gazer._teleportationBackRequestInitiated = false;
  17337. }
  17338. };
  17339. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17340. var _this = this;
  17341. var controllerMesh = controller.webVRController.mesh;
  17342. if (controllerMesh) {
  17343. if (!controller._interactionsEnabled) {
  17344. this._enableInteractionOnController(controller);
  17345. }
  17346. controller._interactionsEnabled = true;
  17347. controller._teleportationEnabled = true;
  17348. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  17349. controller._dpadPressed = false;
  17350. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17351. controller._dpadPressed = stateObject.pressed;
  17352. if (!controller._dpadPressed) {
  17353. controller._rotationLeftAsked = false;
  17354. controller._rotationRightAsked = false;
  17355. controller._teleportationBackRequestInitiated = false;
  17356. }
  17357. });
  17358. }
  17359. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17360. if (_this.teleportationEnabled) {
  17361. _this._checkTeleportBackwards(stateObject, controller);
  17362. _this._checkTeleportWithRay(stateObject, controller);
  17363. }
  17364. _this._checkRotate(stateObject, controller);
  17365. });
  17366. }
  17367. };
  17368. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17369. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17370. this._teleportationTarget.isPickable = false;
  17371. var length = 512;
  17372. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17373. dynamicTexture.hasAlpha = true;
  17374. var context = dynamicTexture.getContext();
  17375. var centerX = length / 2;
  17376. var centerY = length / 2;
  17377. var radius = 200;
  17378. context.beginPath();
  17379. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17380. context.fillStyle = this._teleportationFillColor;
  17381. context.fill();
  17382. context.lineWidth = 10;
  17383. context.strokeStyle = this._teleportationBorderColor;
  17384. context.stroke();
  17385. context.closePath();
  17386. dynamicTexture.update();
  17387. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17388. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17389. this._teleportationTarget.material = teleportationCircleMaterial;
  17390. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17391. torus.isPickable = false;
  17392. torus.parent = this._teleportationTarget;
  17393. 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);
  17394. var keys = [];
  17395. keys.push({
  17396. frame: 0,
  17397. value: 0
  17398. });
  17399. keys.push({
  17400. frame: 30,
  17401. value: 0.4
  17402. });
  17403. keys.push({
  17404. frame: 60,
  17405. value: 0
  17406. });
  17407. animationInnerCircle.setKeys(keys);
  17408. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  17409. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  17410. animationInnerCircle.setEasingFunction(easingFunction);
  17411. torus.animations = [];
  17412. torus.animations.push(animationInnerCircle);
  17413. this._scene.beginAnimation(torus, 0, 60, true);
  17414. this._hideTeleportationTarget();
  17415. };
  17416. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17417. this._teleportActive = true;
  17418. if (this._teleportationInitialized) {
  17419. this._teleportationTarget.isVisible = true;
  17420. if (this._isDefaultTeleportationTarget) {
  17421. this._teleportationTarget.getChildren()[0].isVisible = true;
  17422. }
  17423. }
  17424. };
  17425. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17426. this._teleportActive = false;
  17427. if (this._teleportationInitialized) {
  17428. this._teleportationTarget.isVisible = false;
  17429. if (this._isDefaultTeleportationTarget) {
  17430. this._teleportationTarget.getChildren()[0].isVisible = false;
  17431. }
  17432. }
  17433. };
  17434. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17435. var _this = this;
  17436. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17437. return;
  17438. }
  17439. if (right) {
  17440. this._rotationAngle++;
  17441. }
  17442. else {
  17443. this._rotationAngle--;
  17444. }
  17445. this.currentVRCamera.animations = [];
  17446. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17447. 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);
  17448. var animationRotationKeys = [];
  17449. animationRotationKeys.push({
  17450. frame: 0,
  17451. value: this.currentVRCamera.rotationQuaternion
  17452. });
  17453. animationRotationKeys.push({
  17454. frame: 6,
  17455. value: target
  17456. });
  17457. animationRotation.setKeys(animationRotationKeys);
  17458. animationRotation.setEasingFunction(this._circleEase);
  17459. this.currentVRCamera.animations.push(animationRotation);
  17460. this._postProcessMove.animations = [];
  17461. 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);
  17462. var vignetteWeightKeys = [];
  17463. vignetteWeightKeys.push({
  17464. frame: 0,
  17465. value: 0
  17466. });
  17467. vignetteWeightKeys.push({
  17468. frame: 3,
  17469. value: 4
  17470. });
  17471. vignetteWeightKeys.push({
  17472. frame: 6,
  17473. value: 0
  17474. });
  17475. animationPP.setKeys(vignetteWeightKeys);
  17476. animationPP.setEasingFunction(this._circleEase);
  17477. this._postProcessMove.animations.push(animationPP);
  17478. 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);
  17479. var vignetteStretchKeys = [];
  17480. vignetteStretchKeys.push({
  17481. frame: 0,
  17482. value: 0
  17483. });
  17484. vignetteStretchKeys.push({
  17485. frame: 3,
  17486. value: 10
  17487. });
  17488. vignetteStretchKeys.push({
  17489. frame: 6,
  17490. value: 0
  17491. });
  17492. animationPP2.setKeys(vignetteStretchKeys);
  17493. animationPP2.setEasingFunction(this._circleEase);
  17494. this._postProcessMove.animations.push(animationPP2);
  17495. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17496. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17497. this._postProcessMove.samples = 4;
  17498. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17499. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17500. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17501. });
  17502. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17503. };
  17504. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17505. if (hit.pickedPoint) {
  17506. if (gazer._teleportationRequestInitiated) {
  17507. this._displayTeleportationTarget();
  17508. this._haloCenter.copyFrom(hit.pickedPoint);
  17509. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17510. }
  17511. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17512. if (pickNormal) {
  17513. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17514. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17515. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17516. }
  17517. this._teleportationTarget.position.y += 0.1;
  17518. }
  17519. };
  17520. /**
  17521. * Teleports the users feet to the desired location
  17522. * @param location The location where the user's feet should be placed
  17523. */
  17524. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17525. var _this = this;
  17526. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17527. return;
  17528. }
  17529. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17530. // offset of the headset from the anchor.
  17531. if (this.webVRCamera.leftCamera) {
  17532. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17533. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17534. location.subtractToRef(this._workingVector, this._workingVector);
  17535. }
  17536. else {
  17537. this._workingVector.copyFrom(location);
  17538. }
  17539. // Add height to account for user's height offset
  17540. if (this.isInVRMode) {
  17541. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17542. }
  17543. else {
  17544. this._workingVector.y += this._defaultHeight;
  17545. }
  17546. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17547. // Create animation from the camera's position to the new location
  17548. this.currentVRCamera.animations = [];
  17549. 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);
  17550. var animationCameraTeleportationKeys = [{
  17551. frame: 0,
  17552. value: this.currentVRCamera.position
  17553. },
  17554. {
  17555. frame: 11,
  17556. value: this._workingVector
  17557. }
  17558. ];
  17559. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17560. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17561. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17562. this._postProcessMove.animations = [];
  17563. 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);
  17564. var vignetteWeightKeys = [];
  17565. vignetteWeightKeys.push({
  17566. frame: 0,
  17567. value: 0
  17568. });
  17569. vignetteWeightKeys.push({
  17570. frame: 5,
  17571. value: 8
  17572. });
  17573. vignetteWeightKeys.push({
  17574. frame: 11,
  17575. value: 0
  17576. });
  17577. animationPP.setKeys(vignetteWeightKeys);
  17578. this._postProcessMove.animations.push(animationPP);
  17579. 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);
  17580. var vignetteStretchKeys = [];
  17581. vignetteStretchKeys.push({
  17582. frame: 0,
  17583. value: 0
  17584. });
  17585. vignetteStretchKeys.push({
  17586. frame: 5,
  17587. value: 10
  17588. });
  17589. vignetteStretchKeys.push({
  17590. frame: 11,
  17591. value: 0
  17592. });
  17593. animationPP2.setKeys(vignetteStretchKeys);
  17594. this._postProcessMove.animations.push(animationPP2);
  17595. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17596. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17597. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17598. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17599. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17600. });
  17601. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17602. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17603. });
  17604. this._hideTeleportationTarget();
  17605. };
  17606. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17607. if (normal) {
  17608. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17609. if (angle < Math.PI / 2) {
  17610. normal.scaleInPlace(-1);
  17611. }
  17612. }
  17613. return normal;
  17614. };
  17615. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17616. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17617. return;
  17618. }
  17619. var ray = gazer._getForwardRay(this._rayLength);
  17620. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17621. if (hit) {
  17622. // Populate the contrllers mesh that can be used for drag/drop
  17623. if (gazer._laserPointer) {
  17624. hit.originMesh = gazer._laserPointer.parent;
  17625. }
  17626. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17627. }
  17628. gazer._currentHit = hit;
  17629. // Moving the gazeTracker on the mesh face targetted
  17630. if (hit && hit.pickedPoint) {
  17631. if (this._displayGaze) {
  17632. var multiplier = 1;
  17633. gazer._gazeTracker.isVisible = true;
  17634. if (gazer._isActionableMesh) {
  17635. multiplier = 3;
  17636. }
  17637. if (this.updateGazeTrackerScale) {
  17638. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17639. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17640. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17641. }
  17642. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17643. // To avoid z-fighting
  17644. var deltaFighting = 0.002;
  17645. if (pickNormal) {
  17646. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17647. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17648. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17649. }
  17650. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17651. if (gazer._gazeTracker.position.x < 0) {
  17652. gazer._gazeTracker.position.x += deltaFighting;
  17653. }
  17654. else {
  17655. gazer._gazeTracker.position.x -= deltaFighting;
  17656. }
  17657. if (gazer._gazeTracker.position.y < 0) {
  17658. gazer._gazeTracker.position.y += deltaFighting;
  17659. }
  17660. else {
  17661. gazer._gazeTracker.position.y -= deltaFighting;
  17662. }
  17663. if (gazer._gazeTracker.position.z < 0) {
  17664. gazer._gazeTracker.position.z += deltaFighting;
  17665. }
  17666. else {
  17667. gazer._gazeTracker.position.z -= deltaFighting;
  17668. }
  17669. }
  17670. // Changing the size of the laser pointer based on the distance from the targetted point
  17671. gazer._updatePointerDistance(hit.distance);
  17672. }
  17673. else {
  17674. gazer._updatePointerDistance();
  17675. gazer._gazeTracker.isVisible = false;
  17676. }
  17677. if (hit && hit.pickedMesh) {
  17678. // The object selected is the floor, we're in a teleportation scenario
  17679. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17680. // Moving the teleportation area to this targetted point
  17681. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17682. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17683. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17684. }
  17685. gazer._currentMeshSelected = null;
  17686. if (gazer._teleportationRequestInitiated) {
  17687. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17688. }
  17689. return;
  17690. }
  17691. // If not, we're in a selection scenario
  17692. //this._teleportationAllowed = false;
  17693. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17694. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17695. this.onNewMeshPicked.notifyObservers(hit);
  17696. gazer._currentMeshSelected = hit.pickedMesh;
  17697. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17698. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17699. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17700. gazer._isActionableMesh = true;
  17701. }
  17702. else {
  17703. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17704. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17705. gazer._isActionableMesh = false;
  17706. }
  17707. try {
  17708. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17709. }
  17710. catch (err) {
  17711. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17712. }
  17713. }
  17714. else {
  17715. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17716. gazer._currentMeshSelected = null;
  17717. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17718. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17719. }
  17720. }
  17721. }
  17722. else {
  17723. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17724. gazer._currentMeshSelected = null;
  17725. //this._teleportationAllowed = false;
  17726. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17727. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17728. }
  17729. };
  17730. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17731. if (mesh) {
  17732. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17733. }
  17734. };
  17735. /**
  17736. * Sets the color of the laser ray from the vr controllers.
  17737. * @param color new color for the ray.
  17738. */
  17739. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17740. if (this._leftController) {
  17741. this._leftController._setLaserPointerColor(color);
  17742. }
  17743. if (this._rightController) {
  17744. this._rightController._setLaserPointerColor(color);
  17745. }
  17746. };
  17747. /**
  17748. * Sets the color of the ray from the vr headsets gaze.
  17749. * @param color new color for the ray.
  17750. */
  17751. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17752. if (!this.updateGazeTrackerColor) {
  17753. return;
  17754. }
  17755. if (!this._cameraGazer._gazeTracker.material) {
  17756. return;
  17757. }
  17758. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17759. if (this._leftController) {
  17760. this._leftController._gazeTracker.material.emissiveColor = color;
  17761. }
  17762. if (this._rightController) {
  17763. this._rightController._gazeTracker.material.emissiveColor = color;
  17764. }
  17765. };
  17766. /**
  17767. * Exits VR and disposes of the vr experience helper
  17768. */
  17769. VRExperienceHelper.prototype.dispose = function () {
  17770. if (this.isInVRMode) {
  17771. this.exitVR();
  17772. }
  17773. if (this._postProcessMove) {
  17774. this._postProcessMove.dispose();
  17775. }
  17776. if (this._webVRCamera) {
  17777. this._webVRCamera.dispose();
  17778. }
  17779. if (this._vrDeviceOrientationCamera) {
  17780. this._vrDeviceOrientationCamera.dispose();
  17781. }
  17782. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17783. document.body.removeChild(this._btnVR);
  17784. }
  17785. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17786. this._deviceOrientationCamera.dispose();
  17787. }
  17788. if (this._cameraGazer) {
  17789. this._cameraGazer.dispose();
  17790. }
  17791. if (this._leftController) {
  17792. this._leftController.dispose();
  17793. }
  17794. if (this._rightController) {
  17795. this._rightController.dispose();
  17796. }
  17797. if (this._teleportationTarget) {
  17798. this._teleportationTarget.dispose();
  17799. }
  17800. this._floorMeshesCollection = [];
  17801. document.removeEventListener("keydown", this._onKeyDown);
  17802. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17803. window.removeEventListener("resize", this._onResize);
  17804. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17805. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17806. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17807. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17808. document.onmsfullscreenchange = null;
  17809. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17810. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17811. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17812. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17813. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17814. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17815. this._scene.unregisterBeforeRender(this.beforeRender);
  17816. };
  17817. /**
  17818. * Gets the name of the VRExperienceHelper class
  17819. * @returns "VRExperienceHelper"
  17820. */
  17821. VRExperienceHelper.prototype.getClassName = function () {
  17822. return "VRExperienceHelper";
  17823. };
  17824. return VRExperienceHelper;
  17825. }());
  17826. /***/ }),
  17827. /***/ "./Cameras/VR/webVRCamera.ts":
  17828. /*!***********************************!*\
  17829. !*** ./Cameras/VR/webVRCamera.ts ***!
  17830. \***********************************/
  17831. /*! exports provided: WebVRFreeCamera */
  17832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17833. "use strict";
  17834. __webpack_require__.r(__webpack_exports__);
  17835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17836. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17837. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17838. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17839. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17840. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17841. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17842. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17843. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17844. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17845. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  17846. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  17847. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17848. // Side effect import to define the stereoscopic mode.
  17849. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17850. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17851. });
  17852. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17853. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17854. });
  17855. /**
  17856. * This represents a WebVR camera.
  17857. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17858. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17859. */
  17860. var WebVRFreeCamera = /** @class */ (function (_super) {
  17861. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17862. /**
  17863. * Instantiates a WebVRFreeCamera.
  17864. * @param name The name of the WebVRFreeCamera
  17865. * @param position The starting anchor position for the camera
  17866. * @param scene The scene the camera belongs to
  17867. * @param webVROptions a set of customizable options for the webVRCamera
  17868. */
  17869. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17870. if (webVROptions === void 0) { webVROptions = {}; }
  17871. var _this = _super.call(this, name, position, scene) || this;
  17872. _this.webVROptions = webVROptions;
  17873. /**
  17874. * @hidden
  17875. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17876. */
  17877. _this._vrDevice = null;
  17878. /**
  17879. * The rawPose of the vrDevice.
  17880. */
  17881. _this.rawPose = null;
  17882. _this._specsVersion = "1.1";
  17883. _this._attached = false;
  17884. _this._descendants = [];
  17885. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17886. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17887. /** @hidden */
  17888. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17889. _this._standingMatrix = null;
  17890. /**
  17891. * Represents device position in babylon space.
  17892. */
  17893. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17894. /**
  17895. * Represents device rotation in babylon space.
  17896. */
  17897. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17898. /**
  17899. * The scale of the device to be used when translating from device space to babylon space.
  17900. */
  17901. _this.deviceScaleFactor = 1;
  17902. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17903. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17904. /**
  17905. * References to the webVR controllers for the vrDevice.
  17906. */
  17907. _this.controllers = [];
  17908. /**
  17909. * Emits an event when a controller is attached.
  17910. */
  17911. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17912. /**
  17913. * Emits an event when a controller's mesh has been loaded;
  17914. */
  17915. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17916. /**
  17917. * Emits an event when the HMD's pose has been updated.
  17918. */
  17919. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17920. _this._poseSet = false;
  17921. /**
  17922. * If the rig cameras be used as parent instead of this camera.
  17923. */
  17924. _this.rigParenting = true;
  17925. _this._defaultHeight = undefined;
  17926. _this._htmlElementAttached = null;
  17927. _this._detachIfAttached = function () {
  17928. var vrDisplay = _this.getEngine().getVRDevice();
  17929. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17930. _this.detachControl(_this._htmlElementAttached);
  17931. }
  17932. };
  17933. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17934. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17935. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17936. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17937. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17938. if (webVROptions.defaultHeight) {
  17939. _this._defaultHeight = webVROptions.defaultHeight;
  17940. _this.position.y = _this._defaultHeight;
  17941. }
  17942. _this.minZ = 0.1;
  17943. //legacy support - the compensation boolean was removed.
  17944. if (arguments.length === 5) {
  17945. _this.webVROptions = arguments[4];
  17946. }
  17947. // default webVR options
  17948. if (_this.webVROptions.trackPosition == undefined) {
  17949. _this.webVROptions.trackPosition = true;
  17950. }
  17951. if (_this.webVROptions.controllerMeshes == undefined) {
  17952. _this.webVROptions.controllerMeshes = true;
  17953. }
  17954. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17955. _this.webVROptions.defaultLightingOnControllers = true;
  17956. }
  17957. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17958. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17959. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17960. }
  17961. //enable VR
  17962. var engine = _this.getEngine();
  17963. _this._onVREnabled = function (success) { if (success) {
  17964. _this.initControllers();
  17965. } };
  17966. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17967. engine.initWebVR().add(function (event) {
  17968. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17969. return;
  17970. }
  17971. _this._vrDevice = event.vrDisplay;
  17972. //reset the rig parameters.
  17973. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17974. if (_this._attached) {
  17975. _this.getEngine().enableVR();
  17976. }
  17977. });
  17978. if (typeof (VRFrameData) !== "undefined") {
  17979. _this._frameData = new VRFrameData();
  17980. }
  17981. if (webVROptions.useMultiview) {
  17982. if (!_this.getScene().getEngine().getCaps().multiview) {
  17983. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  17984. _this._useMultiviewToSingleView = false;
  17985. }
  17986. else {
  17987. _this._useMultiviewToSingleView = true;
  17988. _this._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_10__["VRMultiviewToSingleview"]("VRMultiviewToSingleview", _this, 1.0);
  17989. }
  17990. }
  17991. /**
  17992. * The idea behind the following lines:
  17993. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17994. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17995. * the second will not show it correctly.
  17996. *
  17997. * To solve this - each object that has the camera as parent will be added to a protected array.
  17998. * When the rig camera renders, it will take this array and set all of those to be its children.
  17999. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  18000. * Amazing!
  18001. */
  18002. scene.onBeforeCameraRenderObservable.add(function (camera) {
  18003. if (camera.parent === _this && _this.rigParenting) {
  18004. _this._descendants = _this.getDescendants(true, function (n) {
  18005. // don't take the cameras or the controllers!
  18006. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  18007. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  18008. return !isController && !isRigCamera;
  18009. });
  18010. _this._descendants.forEach(function (node) {
  18011. node.parent = camera;
  18012. });
  18013. }
  18014. });
  18015. scene.onAfterCameraRenderObservable.add(function (camera) {
  18016. if (camera.parent === _this && _this.rigParenting) {
  18017. _this._descendants.forEach(function (node) {
  18018. node.parent = _this;
  18019. });
  18020. }
  18021. });
  18022. return _this;
  18023. }
  18024. /**
  18025. * Gets the device distance from the ground in meters.
  18026. * @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.
  18027. */
  18028. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  18029. if (this._standingMatrix) {
  18030. // Add standing matrix offset to get real offset from ground in room
  18031. this._standingMatrix.getTranslationToRef(this._workingVector);
  18032. return this._deviceRoomPosition.y + this._workingVector.y;
  18033. }
  18034. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  18035. return this._defaultHeight || 0;
  18036. };
  18037. /**
  18038. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18039. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18040. */
  18041. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  18042. var _this = this;
  18043. if (callback === void 0) { callback = function (bool) { }; }
  18044. // Use standing matrix if available
  18045. this.getEngine().initWebVRAsync().then(function (result) {
  18046. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  18047. callback(false);
  18048. }
  18049. else {
  18050. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18051. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  18052. if (!_this.getScene().useRightHandedSystem) {
  18053. if (_this._standingMatrix) {
  18054. _this._standingMatrix.toggleModelMatrixHandInPlace();
  18055. }
  18056. }
  18057. callback(true);
  18058. }
  18059. });
  18060. };
  18061. /**
  18062. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18063. * @returns A promise with a boolean set to if the standing matrix is supported.
  18064. */
  18065. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  18066. var _this = this;
  18067. return new Promise(function (res) {
  18068. _this.useStandingMatrix(function (supported) {
  18069. res(supported);
  18070. });
  18071. });
  18072. };
  18073. /**
  18074. * Disposes the camera
  18075. */
  18076. WebVRFreeCamera.prototype.dispose = function () {
  18077. this._detachIfAttached();
  18078. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18079. if (this._updateCacheWhenTrackingDisabledObserver) {
  18080. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18081. }
  18082. _super.prototype.dispose.call(this);
  18083. };
  18084. /**
  18085. * Gets a vrController by name.
  18086. * @param name The name of the controller to retreive
  18087. * @returns the controller matching the name specified or null if not found
  18088. */
  18089. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18090. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18091. var gp = _a[_i];
  18092. if (gp.hand === name) {
  18093. return gp;
  18094. }
  18095. }
  18096. return null;
  18097. };
  18098. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18099. /**
  18100. * The controller corrisponding to the users left hand.
  18101. */
  18102. get: function () {
  18103. if (!this._leftController) {
  18104. this._leftController = this.getControllerByName("left");
  18105. }
  18106. return this._leftController;
  18107. },
  18108. enumerable: true,
  18109. configurable: true
  18110. });
  18111. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18112. /**
  18113. * The controller corrisponding to the users right hand.
  18114. */
  18115. get: function () {
  18116. if (!this._rightController) {
  18117. this._rightController = this.getControllerByName("right");
  18118. }
  18119. return this._rightController;
  18120. },
  18121. enumerable: true,
  18122. configurable: true
  18123. });
  18124. /**
  18125. * Casts a ray forward from the vrCamera's gaze.
  18126. * @param length Length of the ray (default: 100)
  18127. * @returns the ray corrisponding to the gaze
  18128. */
  18129. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18130. if (length === void 0) { length = 100; }
  18131. if (this.leftCamera) {
  18132. // Use left eye to avoid computation to compute center on every call
  18133. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18134. }
  18135. else {
  18136. return _super.prototype.getForwardRay.call(this, length);
  18137. }
  18138. };
  18139. /**
  18140. * @hidden
  18141. * Updates the camera based on device's frame data
  18142. */
  18143. WebVRFreeCamera.prototype._checkInputs = function () {
  18144. if (this._vrDevice && this._vrDevice.isPresenting) {
  18145. this._vrDevice.getFrameData(this._frameData);
  18146. this.updateFromDevice(this._frameData.pose);
  18147. }
  18148. _super.prototype._checkInputs.call(this);
  18149. };
  18150. /**
  18151. * Updates the poseControlled values based on the input device pose.
  18152. * @param poseData Pose coming from the device
  18153. */
  18154. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18155. if (poseData && poseData.orientation) {
  18156. this.rawPose = poseData;
  18157. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18158. if (this.getScene().useRightHandedSystem) {
  18159. this._deviceRoomRotationQuaternion.z *= -1;
  18160. this._deviceRoomRotationQuaternion.w *= -1;
  18161. }
  18162. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18163. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18164. if (this.getScene().useRightHandedSystem) {
  18165. this._deviceRoomPosition.z *= -1;
  18166. }
  18167. }
  18168. this._poseSet = true;
  18169. }
  18170. };
  18171. /**
  18172. * WebVR's attach control will start broadcasting frames to the device.
  18173. * Note that in certain browsers (chrome for example) this function must be called
  18174. * within a user-interaction callback. Example:
  18175. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18176. *
  18177. * @param element html element to attach the vrDevice to
  18178. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18179. */
  18180. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18181. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18182. this._attached = true;
  18183. this._htmlElementAttached = element;
  18184. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18185. if (this._vrDevice) {
  18186. this.getEngine().enableVR();
  18187. }
  18188. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18189. };
  18190. /**
  18191. * Detaches the camera from the html element and disables VR
  18192. *
  18193. * @param element html element to detach from
  18194. */
  18195. WebVRFreeCamera.prototype.detachControl = function (element) {
  18196. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18197. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18198. _super.prototype.detachControl.call(this, element);
  18199. this._attached = false;
  18200. this.getEngine().disableVR();
  18201. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18202. };
  18203. /**
  18204. * @returns the name of this class
  18205. */
  18206. WebVRFreeCamera.prototype.getClassName = function () {
  18207. return "WebVRFreeCamera";
  18208. };
  18209. /**
  18210. * Calls resetPose on the vrDisplay
  18211. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18212. */
  18213. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18214. //uses the vrDisplay's "resetPose()".
  18215. //pitch and roll won't be affected.
  18216. this._vrDevice.resetPose();
  18217. };
  18218. /**
  18219. * @hidden
  18220. * Updates the rig cameras (left and right eye)
  18221. */
  18222. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18223. var camLeft = this._rigCameras[0];
  18224. var camRight = this._rigCameras[1];
  18225. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18226. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18227. camLeft.position.copyFrom(this._deviceRoomPosition);
  18228. camRight.position.copyFrom(this._deviceRoomPosition);
  18229. };
  18230. // Remove translation from 6dof headset if trackposition is set to false
  18231. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18232. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18233. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18234. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18235. if (!isViewMatrix) {
  18236. this._tmpMatrix.invert();
  18237. }
  18238. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18239. }
  18240. };
  18241. /**
  18242. * @hidden
  18243. * Updates the cached values of the camera
  18244. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18245. */
  18246. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18247. var _this = this;
  18248. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18249. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18250. if (!this.updateCacheCalled) {
  18251. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18252. this.updateCacheCalled = true;
  18253. this.update();
  18254. }
  18255. // Set working vector to the device position in room space rotated by the new rotation
  18256. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18257. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18258. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18259. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18260. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18261. // Add translation from anchor position
  18262. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18263. this._workingVector.addInPlace(this.position);
  18264. this._workingVector.subtractInPlace(this._cache.position);
  18265. this._deviceToWorld.setTranslation(this._workingVector);
  18266. // Set an inverted matrix to be used when updating the camera
  18267. this._deviceToWorld.invertToRef(this._worldToDevice);
  18268. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18269. this.controllers.forEach(function (controller) {
  18270. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18271. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18272. controller.update();
  18273. });
  18274. }
  18275. if (!ignoreParentClass) {
  18276. _super.prototype._updateCache.call(this);
  18277. }
  18278. this.updateCacheCalled = false;
  18279. };
  18280. /**
  18281. * @hidden
  18282. * Get current device position in babylon world
  18283. */
  18284. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18285. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18286. };
  18287. /**
  18288. * Updates the current device position and rotation in the babylon world
  18289. */
  18290. WebVRFreeCamera.prototype.update = function () {
  18291. this._computeDevicePosition();
  18292. // Get current device rotation in babylon world
  18293. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18294. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18295. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18296. if (this._poseSet) {
  18297. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18298. }
  18299. _super.prototype.update.call(this);
  18300. };
  18301. /**
  18302. * @hidden
  18303. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18304. * @returns an identity matrix
  18305. */
  18306. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18307. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18308. };
  18309. /**
  18310. * This function is called by the two RIG cameras.
  18311. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18312. * @hidden
  18313. */
  18314. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18315. // Update the parent camera prior to using a child camera to avoid desynchronization
  18316. var parentCamera = this._cameraRigParams["parentCamera"];
  18317. parentCamera._updateCache();
  18318. //WebVR 1.1
  18319. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18320. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18321. if (!this.getScene().useRightHandedSystem) {
  18322. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18323. }
  18324. // update the camera rotation matrix
  18325. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18326. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18327. // Computing target and final matrix
  18328. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18329. // should the view matrix be updated with scale and position offset?
  18330. if (parentCamera.deviceScaleFactor !== 1) {
  18331. this._webvrViewMatrix.invert();
  18332. // scale the position, if set
  18333. if (parentCamera.deviceScaleFactor) {
  18334. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18335. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18336. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18337. }
  18338. this._webvrViewMatrix.invert();
  18339. }
  18340. // Remove translation from 6dof headset if trackposition is set to false
  18341. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18342. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18343. // Compute global position
  18344. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18345. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18346. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18347. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18348. this._markSyncedWithParent();
  18349. return this._webvrViewMatrix;
  18350. };
  18351. /** @hidden */
  18352. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18353. var parentCamera = this.parent;
  18354. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18355. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18356. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18357. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18358. //babylon compatible matrix
  18359. if (!this.getScene().useRightHandedSystem) {
  18360. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18361. }
  18362. return this._projectionMatrix;
  18363. };
  18364. /**
  18365. * Initializes the controllers and their meshes
  18366. */
  18367. WebVRFreeCamera.prototype.initControllers = function () {
  18368. var _this = this;
  18369. this.controllers = [];
  18370. var manager = this.getScene().gamepadManager;
  18371. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18372. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18373. var webVrController = gamepad;
  18374. if (webVrController.defaultModel) {
  18375. webVrController.defaultModel.setEnabled(false);
  18376. }
  18377. if (webVrController.hand === "right") {
  18378. _this._rightController = null;
  18379. }
  18380. if (webVrController.hand === "left") {
  18381. _this._leftController = null;
  18382. }
  18383. var controllerIndex = _this.controllers.indexOf(webVrController);
  18384. if (controllerIndex !== -1) {
  18385. _this.controllers.splice(controllerIndex, 1);
  18386. }
  18387. }
  18388. });
  18389. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18390. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18391. var webVrController_1 = gamepad;
  18392. if (!_this.webVROptions.trackPosition) {
  18393. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18394. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18395. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18396. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18397. _this._updateCache();
  18398. });
  18399. }
  18400. }
  18401. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18402. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18403. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18404. if (_this.webVROptions.controllerMeshes) {
  18405. if (webVrController_1.defaultModel) {
  18406. webVrController_1.defaultModel.setEnabled(true);
  18407. }
  18408. else {
  18409. // Load the meshes
  18410. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18411. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18412. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18413. if (_this.webVROptions.defaultLightingOnControllers) {
  18414. if (!_this._lightOnControllers) {
  18415. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18416. }
  18417. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18418. var children = mesh.getChildren();
  18419. if (children && children.length !== 0) {
  18420. children.forEach(function (mesh) {
  18421. light.includedOnlyMeshes.push(mesh);
  18422. activateLightOnSubMeshes_1(mesh, light);
  18423. });
  18424. }
  18425. };
  18426. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18427. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18428. }
  18429. });
  18430. }
  18431. }
  18432. webVrController_1.attachToPoseControlledCamera(_this);
  18433. // since this is async - sanity check. Is the controller already stored?
  18434. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18435. //add to the controllers array
  18436. _this.controllers.push(webVrController_1);
  18437. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18438. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18439. // So we're overriding setting left & right manually to be sure
  18440. var firstViveWandDetected = false;
  18441. for (var i = 0; i < _this.controllers.length; i++) {
  18442. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18443. if (!firstViveWandDetected) {
  18444. firstViveWandDetected = true;
  18445. _this.controllers[i].hand = "left";
  18446. }
  18447. else {
  18448. _this.controllers[i].hand = "right";
  18449. }
  18450. }
  18451. }
  18452. //did we find enough controllers? Great! let the developer know.
  18453. if (_this.controllers.length >= 2) {
  18454. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18455. }
  18456. }
  18457. }
  18458. });
  18459. };
  18460. return WebVRFreeCamera;
  18461. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18462. /***/ }),
  18463. /***/ "./Cameras/XR/index.ts":
  18464. /*!*****************************!*\
  18465. !*** ./Cameras/XR/index.ts ***!
  18466. \*****************************/
  18467. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18469. "use strict";
  18470. __webpack_require__.r(__webpack_exports__);
  18471. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18473. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18477. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18480. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18483. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18485. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18487. /***/ }),
  18488. /***/ "./Cameras/XR/webXRCamera.ts":
  18489. /*!***********************************!*\
  18490. !*** ./Cameras/XR/webXRCamera.ts ***!
  18491. \***********************************/
  18492. /*! exports provided: WebXRCamera */
  18493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18494. "use strict";
  18495. __webpack_require__.r(__webpack_exports__);
  18496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18497. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18498. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18499. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18500. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18501. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18502. /**
  18503. * WebXR Camera which holds the views for the xrSession
  18504. * @see https://doc.babylonjs.com/how_to/webxr
  18505. */
  18506. var WebXRCamera = /** @class */ (function (_super) {
  18507. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18508. /**
  18509. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18510. * @param name the name of the camera
  18511. * @param scene the scene to add the camera to
  18512. */
  18513. function WebXRCamera(name, scene) {
  18514. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18515. // Initial camera configuration
  18516. _this.minZ = 0;
  18517. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18518. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18519. _this.updateUpVectorFromRotation = true;
  18520. _this._updateNumberOfRigCameras(1);
  18521. return _this;
  18522. }
  18523. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18524. if (viewCount === void 0) { viewCount = 1; }
  18525. while (this.rigCameras.length < viewCount) {
  18526. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18527. newCamera.minZ = 0;
  18528. newCamera.parent = this;
  18529. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18530. newCamera.updateUpVectorFromRotation = true;
  18531. this.rigCameras.push(newCamera);
  18532. }
  18533. while (this.rigCameras.length > viewCount) {
  18534. var removedCamera = this.rigCameras.pop();
  18535. if (removedCamera) {
  18536. removedCamera.dispose();
  18537. }
  18538. }
  18539. };
  18540. /** @hidden */
  18541. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18542. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18543. // Create initial camera rigs
  18544. this._updateNumberOfRigCameras(2);
  18545. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18546. this.rigCameras[0].position.x = -pupilDistance / 2;
  18547. this.rigCameras[0].outputRenderTarget = null;
  18548. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18549. this.rigCameras[1].position.x = pupilDistance / 2;
  18550. this.rigCameras[1].outputRenderTarget = null;
  18551. };
  18552. /**
  18553. * Updates the cameras position from the current pose information of the XR session
  18554. * @param xrSessionManager the session containing pose information
  18555. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18556. */
  18557. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18558. var _this = this;
  18559. // Ensure all frame data is available
  18560. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18561. return false;
  18562. }
  18563. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18564. if (!pose || !pose.poseModelMatrix) {
  18565. return false;
  18566. }
  18567. // Update the parent cameras matrix
  18568. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18569. if (!this._scene.useRightHandedSystem) {
  18570. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18571. }
  18572. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18573. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18574. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18575. this.computeWorldMatrix();
  18576. // Update camera rigs
  18577. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18578. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18579. // Update view/projection matrix
  18580. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18581. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18582. if (!_this._scene.useRightHandedSystem) {
  18583. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18584. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18585. }
  18586. // Update viewport
  18587. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18588. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18589. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18590. _this.rigCameras[i].viewport.width = viewport.width / width;
  18591. _this.rigCameras[i].viewport.height = viewport.height / height;
  18592. _this.rigCameras[i].viewport.x = viewport.x / width;
  18593. _this.rigCameras[i].viewport.y = viewport.y / height;
  18594. // Set cameras to render to the session's render target
  18595. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18596. });
  18597. return true;
  18598. };
  18599. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18600. return WebXRCamera;
  18601. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18602. /***/ }),
  18603. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18604. /*!****************************************!*\
  18605. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18606. \****************************************/
  18607. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18609. "use strict";
  18610. __webpack_require__.r(__webpack_exports__);
  18611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18615. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18616. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18617. /**
  18618. * Button which can be used to enter a different mode of XR
  18619. */
  18620. var WebXREnterExitUIButton = /** @class */ (function () {
  18621. /**
  18622. * Creates a WebXREnterExitUIButton
  18623. * @param element button element
  18624. * @param initializationOptions XR initialization options for the button
  18625. */
  18626. function WebXREnterExitUIButton(
  18627. /** button element */
  18628. element,
  18629. /** XR initialization options for the button */
  18630. initializationOptions) {
  18631. this.element = element;
  18632. this.initializationOptions = initializationOptions;
  18633. }
  18634. /**
  18635. * Overwritable function which can be used to update the button's visuals when the state changes
  18636. * @param activeButton the current active button in the UI
  18637. */
  18638. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18639. };
  18640. return WebXREnterExitUIButton;
  18641. }());
  18642. /**
  18643. * Options to create the webXR UI
  18644. */
  18645. var WebXREnterExitUIOptions = /** @class */ (function () {
  18646. function WebXREnterExitUIOptions() {
  18647. }
  18648. return WebXREnterExitUIOptions;
  18649. }());
  18650. /**
  18651. * UI to allow the user to enter/exit XR mode
  18652. */
  18653. var WebXREnterExitUI = /** @class */ (function () {
  18654. function WebXREnterExitUI(scene, options) {
  18655. var _this = this;
  18656. this.scene = scene;
  18657. this._buttons = [];
  18658. this._activeButton = null;
  18659. /**
  18660. * Fired every time the active button is changed.
  18661. *
  18662. * When xr is entered via a button that launches xr that button will be the callback parameter
  18663. *
  18664. * When exiting xr the callback parameter will be null)
  18665. */
  18666. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18667. this._overlay = document.createElement("div");
  18668. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18669. if (options.customButtons) {
  18670. this._buttons = options.customButtons;
  18671. }
  18672. else {
  18673. var hmdBtn = document.createElement("button");
  18674. 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;";
  18675. hmdBtn.innerText = "HMD";
  18676. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18677. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18678. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18679. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18680. };
  18681. var windowBtn = document.createElement("button");
  18682. windowBtn.style.cssText = hmdBtn.style.cssText;
  18683. windowBtn.innerText = "Window";
  18684. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18685. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18686. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18687. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18688. };
  18689. this._updateButtons(null);
  18690. }
  18691. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18692. if (renderCanvas && renderCanvas.parentNode) {
  18693. renderCanvas.parentNode.appendChild(this._overlay);
  18694. scene.onDisposeObservable.addOnce(function () {
  18695. _this.dispose();
  18696. });
  18697. }
  18698. }
  18699. /**
  18700. * Creates UI to allow the user to enter/exit XR mode
  18701. * @param scene the scene to add the ui to
  18702. * @param helper the xr experience helper to enter/exit xr with
  18703. * @param options options to configure the UI
  18704. * @returns the created ui
  18705. */
  18706. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18707. var _this = this;
  18708. var ui = new WebXREnterExitUI(scene, options);
  18709. var supportedPromises = ui._buttons.map(function (btn) {
  18710. return helper.supportsSessionAsync(btn.initializationOptions);
  18711. });
  18712. helper.onStateChangedObservable.add(function (state) {
  18713. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18714. ui._updateButtons(null);
  18715. }
  18716. });
  18717. return Promise.all(supportedPromises).then(function (results) {
  18718. results.forEach(function (supported, i) {
  18719. if (supported) {
  18720. ui._overlay.appendChild(ui._buttons[i].element);
  18721. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18722. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18723. switch (_a.label) {
  18724. case 0:
  18725. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18726. ui._updateButtons(null);
  18727. return [4 /*yield*/, helper.exitXRAsync()];
  18728. case 1:
  18729. _a.sent();
  18730. return [2 /*return*/];
  18731. case 2:
  18732. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18733. ui._updateButtons(ui._buttons[i]);
  18734. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18735. case 3:
  18736. _a.sent();
  18737. _a.label = 4;
  18738. case 4: return [2 /*return*/];
  18739. }
  18740. });
  18741. }); };
  18742. }
  18743. });
  18744. return ui;
  18745. });
  18746. };
  18747. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18748. var _this = this;
  18749. this._activeButton = activeButton;
  18750. this._buttons.forEach(function (b) {
  18751. b.update(_this._activeButton);
  18752. });
  18753. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18754. };
  18755. /**
  18756. * Disposes of the object
  18757. */
  18758. WebXREnterExitUI.prototype.dispose = function () {
  18759. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18760. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18761. renderCanvas.parentNode.removeChild(this._overlay);
  18762. }
  18763. this.activeButtonChangedObservable.clear();
  18764. };
  18765. return WebXREnterExitUI;
  18766. }());
  18767. /***/ }),
  18768. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18769. /*!*********************************************!*\
  18770. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18771. \*********************************************/
  18772. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18774. "use strict";
  18775. __webpack_require__.r(__webpack_exports__);
  18776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18778. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18779. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18780. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18781. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18782. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18783. /**
  18784. * States of the webXR experience
  18785. */
  18786. var WebXRState;
  18787. (function (WebXRState) {
  18788. /**
  18789. * Transitioning to being in XR mode
  18790. */
  18791. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18792. /**
  18793. * Transitioning to non XR mode
  18794. */
  18795. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18796. /**
  18797. * In XR mode and presenting
  18798. */
  18799. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18800. /**
  18801. * Not entered XR mode
  18802. */
  18803. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18804. })(WebXRState || (WebXRState = {}));
  18805. /**
  18806. * Helper class used to enable XR
  18807. * @see https://doc.babylonjs.com/how_to/webxr
  18808. */
  18809. var WebXRExperienceHelper = /** @class */ (function () {
  18810. /**
  18811. * Creates a WebXRExperienceHelper
  18812. * @param scene The scene the helper should be created in
  18813. */
  18814. function WebXRExperienceHelper(scene) {
  18815. this.scene = scene;
  18816. /**
  18817. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18818. */
  18819. this.state = WebXRState.NOT_IN_XR;
  18820. /**
  18821. * Fires when the state of the experience helper has changed
  18822. */
  18823. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18824. this._nonVRCamera = null;
  18825. this._originalSceneAutoClear = true;
  18826. this._supported = false;
  18827. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18828. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18829. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18830. this.camera.parent = this.container;
  18831. }
  18832. WebXRExperienceHelper.prototype._setState = function (val) {
  18833. this.state = val;
  18834. this.onStateChangedObservable.notifyObservers(this.state);
  18835. };
  18836. /**
  18837. * Creates the experience helper
  18838. * @param scene the scene to attach the experience helper to
  18839. * @returns a promise for the experience helper
  18840. */
  18841. WebXRExperienceHelper.CreateAsync = function (scene) {
  18842. var helper = new WebXRExperienceHelper(scene);
  18843. return helper._sessionManager.initializeAsync().then(function () {
  18844. helper._supported = true;
  18845. return helper;
  18846. }).catch(function () {
  18847. return helper;
  18848. });
  18849. };
  18850. /**
  18851. * Exits XR mode and returns the scene to its original state
  18852. * @returns promise that resolves after xr mode has exited
  18853. */
  18854. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18855. this._setState(WebXRState.EXITING_XR);
  18856. return this._sessionManager.exitXRAsync();
  18857. };
  18858. /**
  18859. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18860. * @param sessionCreationOptions options for the XR session
  18861. * @param frameOfReference frame of reference of the XR session
  18862. * @returns promise that resolves after xr mode has entered
  18863. */
  18864. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18865. var _this = this;
  18866. if (!this._supported) {
  18867. throw "XR session not supported by this browser";
  18868. }
  18869. this._setState(WebXRState.ENTERING_XR);
  18870. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18871. // Cache pre xr scene settings
  18872. _this._originalSceneAutoClear = _this.scene.autoClear;
  18873. _this._nonVRCamera = _this.scene.activeCamera;
  18874. // Overwrite current scene settings
  18875. _this.scene.autoClear = false;
  18876. _this.scene.activeCamera = _this.camera;
  18877. _this._sessionManager.onXRFrameObservable.add(function () {
  18878. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18879. });
  18880. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18881. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18882. _this.camera.rigCameras.forEach(function (c) {
  18883. c.outputRenderTarget = null;
  18884. });
  18885. // Restore scene settings
  18886. _this.scene.autoClear = _this._originalSceneAutoClear;
  18887. _this.scene.activeCamera = _this._nonVRCamera;
  18888. _this._sessionManager.onXRFrameObservable.clear();
  18889. _this._setState(WebXRState.NOT_IN_XR);
  18890. });
  18891. _this._setState(WebXRState.IN_XR);
  18892. });
  18893. };
  18894. /**
  18895. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18896. * @param ray ray to cast into the environment
  18897. * @returns Promise which resolves with a collision point in the environment if it exists
  18898. */
  18899. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18900. return this._sessionManager.environmentPointHitTestAsync(ray);
  18901. };
  18902. /**
  18903. * Updates the global position of the camera by moving the camera's container
  18904. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18905. * @param position The desired global position of the camera
  18906. */
  18907. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18908. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18909. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18910. };
  18911. /**
  18912. * Rotates the xr camera by rotating the camera's container around the camera's position
  18913. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18914. * @param rotation the desired quaternion rotation to apply to the camera
  18915. */
  18916. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18917. if (!this.container.rotationQuaternion) {
  18918. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18919. }
  18920. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18921. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18922. };
  18923. /**
  18924. * Checks if the creation options are supported by the xr session
  18925. * @param options creation options
  18926. * @returns true if supported
  18927. */
  18928. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18929. if (!this._supported) {
  18930. return Promise.resolve(false);
  18931. }
  18932. return this._sessionManager.supportsSessionAsync(options);
  18933. };
  18934. /**
  18935. * Disposes of the experience helper
  18936. */
  18937. WebXRExperienceHelper.prototype.dispose = function () {
  18938. this.camera.dispose();
  18939. this.container.dispose();
  18940. this.onStateChangedObservable.clear();
  18941. this._sessionManager.dispose();
  18942. };
  18943. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18944. return WebXRExperienceHelper;
  18945. }());
  18946. /***/ }),
  18947. /***/ "./Cameras/XR/webXRInput.ts":
  18948. /*!**********************************!*\
  18949. !*** ./Cameras/XR/webXRInput.ts ***!
  18950. \**********************************/
  18951. /*! exports provided: WebXRController, WebXRInput */
  18952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18953. "use strict";
  18954. __webpack_require__.r(__webpack_exports__);
  18955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18957. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18958. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18959. /**
  18960. * Represents an XR input
  18961. */
  18962. var WebXRController = /** @class */ (function () {
  18963. /**
  18964. * Creates the controller
  18965. * @see https://doc.babylonjs.com/how_to/webxr
  18966. * @param scene the scene which the controller should be associated to
  18967. */
  18968. function WebXRController(scene) {
  18969. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18970. }
  18971. /**
  18972. * Disposes of the object
  18973. */
  18974. WebXRController.prototype.dispose = function () {
  18975. if (this.grip) {
  18976. this.grip.dispose();
  18977. }
  18978. this.pointer.dispose();
  18979. };
  18980. return WebXRController;
  18981. }());
  18982. /**
  18983. * XR input used to track XR inputs such as controllers/rays
  18984. */
  18985. var WebXRInput = /** @class */ (function () {
  18986. /**
  18987. * Initializes the WebXRInput
  18988. * @param helper experience helper which the input should be created for
  18989. */
  18990. function WebXRInput(helper) {
  18991. var _this = this;
  18992. this.helper = helper;
  18993. /**
  18994. * XR controllers being tracked
  18995. */
  18996. this.controllers = [];
  18997. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18998. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18999. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  19000. return;
  19001. }
  19002. var xrFrame = helper._sessionManager._currentXRFrame;
  19003. var inputSources = helper._sessionManager._xrSession.getInputSources();
  19004. inputSources.forEach(function (input, i) {
  19005. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  19006. if (inputPose) {
  19007. if (_this.controllers.length <= i) {
  19008. _this.controllers.push(new WebXRController(helper.container.getScene()));
  19009. }
  19010. var controller = _this.controllers[i];
  19011. // Manage the grip if it exists
  19012. if (inputPose.gripMatrix) {
  19013. if (!controller.grip) {
  19014. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  19015. }
  19016. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  19017. if (!controller.grip.getScene().useRightHandedSystem) {
  19018. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19019. }
  19020. if (!controller.grip.rotationQuaternion) {
  19021. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19022. }
  19023. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  19024. }
  19025. // Manager pointer of controller
  19026. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  19027. if (!controller.pointer.getScene().useRightHandedSystem) {
  19028. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19029. }
  19030. if (!controller.pointer.rotationQuaternion) {
  19031. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19032. }
  19033. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  19034. }
  19035. });
  19036. });
  19037. }
  19038. /**
  19039. * Disposes of the object
  19040. */
  19041. WebXRInput.prototype.dispose = function () {
  19042. this.controllers.forEach(function (c) {
  19043. c.dispose();
  19044. });
  19045. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  19046. };
  19047. return WebXRInput;
  19048. }());
  19049. /***/ }),
  19050. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  19051. /*!************************************************!*\
  19052. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  19053. \************************************************/
  19054. /*! exports provided: WebXRManagedOutputCanvas */
  19055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19056. "use strict";
  19057. __webpack_require__.r(__webpack_exports__);
  19058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  19059. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19060. /**
  19061. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  19062. */
  19063. var WebXRManagedOutputCanvas = /** @class */ (function () {
  19064. /**
  19065. * Initializes the canvas to be added/removed upon entering/exiting xr
  19066. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  19067. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  19068. */
  19069. function WebXRManagedOutputCanvas(helper, canvas) {
  19070. var _this = this;
  19071. this._canvas = null;
  19072. /**
  19073. * xrpresent context of the canvas which can be used to display/mirror xr content
  19074. */
  19075. this.canvasContext = null;
  19076. if (!canvas) {
  19077. canvas = document.createElement('canvas');
  19078. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  19079. }
  19080. this._setManagedOutputCanvas(canvas);
  19081. helper.onStateChangedObservable.add(function (stateInfo) {
  19082. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19083. // 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
  19084. _this._addCanvas();
  19085. }
  19086. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19087. _this._removeCanvas();
  19088. }
  19089. });
  19090. }
  19091. /**
  19092. * Disposes of the object
  19093. */
  19094. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19095. this._removeCanvas();
  19096. this._setManagedOutputCanvas(null);
  19097. };
  19098. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19099. this._removeCanvas();
  19100. if (!canvas) {
  19101. this._canvas = null;
  19102. this.canvasContext = null;
  19103. }
  19104. else {
  19105. this._canvas = canvas;
  19106. this.canvasContext = this._canvas.getContext('xrpresent');
  19107. }
  19108. };
  19109. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  19110. if (this._canvas) {
  19111. document.body.appendChild(this._canvas);
  19112. }
  19113. };
  19114. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  19115. if (this._canvas && document.body.contains(this._canvas)) {
  19116. document.body.removeChild(this._canvas);
  19117. }
  19118. };
  19119. return WebXRManagedOutputCanvas;
  19120. }());
  19121. /***/ }),
  19122. /***/ "./Cameras/XR/webXRSessionManager.ts":
  19123. /*!*******************************************!*\
  19124. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  19125. \*******************************************/
  19126. /*! exports provided: WebXRSessionManager */
  19127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19128. "use strict";
  19129. __webpack_require__.r(__webpack_exports__);
  19130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  19131. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  19132. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19133. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19134. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  19135. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  19136. /**
  19137. * Manages an XRSession
  19138. * @see https://doc.babylonjs.com/how_to/webxr
  19139. */
  19140. var WebXRSessionManager = /** @class */ (function () {
  19141. /**
  19142. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  19143. * @param scene The scene which the session should be created for
  19144. */
  19145. function WebXRSessionManager(scene) {
  19146. this.scene = scene;
  19147. /**
  19148. * Fires every time a new xrFrame arrives which can be used to update the camera
  19149. */
  19150. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19151. /**
  19152. * Fires when the xr session is ended either by the device or manually done
  19153. */
  19154. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19155. /** @hidden */
  19156. this._sessionRenderTargetTexture = null;
  19157. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  19158. }
  19159. /**
  19160. * Initializes the manager
  19161. * After initialization enterXR can be called to start an XR session
  19162. * @returns Promise which resolves after it is initialized
  19163. */
  19164. WebXRSessionManager.prototype.initializeAsync = function () {
  19165. var _this = this;
  19166. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  19167. // Check if the browser supports webXR
  19168. this._xrNavigator = navigator;
  19169. if (!this._xrNavigator.xr) {
  19170. return Promise.reject("webXR not supported by this browser");
  19171. }
  19172. // Request the webXR device
  19173. return this._xrNavigator.xr.requestDevice().then(function (device) {
  19174. _this._xrDevice = device;
  19175. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  19176. });
  19177. };
  19178. /**
  19179. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  19180. * @param sessionCreationOptions xr options to create the session with
  19181. * @param frameOfReferenceType option to configure how the xr pose is expressed
  19182. * @returns Promise which resolves after it enters XR
  19183. */
  19184. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  19185. var _this = this;
  19186. // initialize session
  19187. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  19188. _this._xrSession = session;
  19189. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  19190. _this._xrSession.addEventListener("end", function () {
  19191. // Remove render target texture and notify frame obervers
  19192. _this._sessionRenderTargetTexture = null;
  19193. // Restore frame buffer to avoid clear on xr framebuffer after session end
  19194. _this.scene.getEngine().restoreDefaultFramebuffer();
  19195. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  19196. _this.scene.getEngine().customAnimationFrameRequester = null;
  19197. _this.onXRSessionEnded.notifyObservers(null);
  19198. _this.scene.getEngine()._renderLoop();
  19199. }, { once: true });
  19200. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  19201. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  19202. }).then(function (frameOfRef) {
  19203. _this._frameOfReference = frameOfRef;
  19204. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  19205. _this.scene.getEngine().customAnimationFrameRequester = {
  19206. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  19207. renderFunction: function (timestamp, xrFrame) {
  19208. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  19209. _this._currentXRFrame = xrFrame;
  19210. _this.onXRFrameObservable.notifyObservers(null);
  19211. _this.scene.getEngine()._renderLoop();
  19212. }
  19213. };
  19214. // Create render target texture from xr's webgl render target
  19215. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  19216. // Stop window's animation frame and trigger sessions animation frame
  19217. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  19218. _this.scene.getEngine()._renderLoop();
  19219. });
  19220. };
  19221. /**
  19222. * Stops the xrSession and restores the renderloop
  19223. * @returns Promise which resolves after it exits XR
  19224. */
  19225. WebXRSessionManager.prototype.exitXRAsync = function () {
  19226. return this._xrSession.end();
  19227. };
  19228. /**
  19229. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19230. * @param ray ray to cast into the environment
  19231. * @returns Promise which resolves with a collision point in the environment if it exists
  19232. */
  19233. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  19234. var _this = this;
  19235. return new Promise(function (res) {
  19236. // Compute left handed inputs to request hit test
  19237. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  19238. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  19239. if (!_this.scene.useRightHandedSystem) {
  19240. origin[2] *= -1;
  19241. direction[2] *= -1;
  19242. }
  19243. // Fire hittest
  19244. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  19245. .then(function (hits) {
  19246. if (hits.length > 0) {
  19247. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  19248. var hitPoint = _this._tmpMatrix.getTranslation();
  19249. if (!_this.scene.useRightHandedSystem) {
  19250. hitPoint.z *= -1;
  19251. }
  19252. res(hitPoint);
  19253. }
  19254. else {
  19255. res(null);
  19256. }
  19257. }).catch(function () {
  19258. res(null);
  19259. });
  19260. });
  19261. };
  19262. /**
  19263. * Checks if a session would be supported for the creation options specified
  19264. * @param options creation options to check if they are supported
  19265. * @returns true if supported
  19266. */
  19267. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  19268. return this._xrDevice.supportsSession(options).then(function () {
  19269. return true;
  19270. }).catch(function () {
  19271. return false;
  19272. });
  19273. };
  19274. /**
  19275. * @hidden
  19276. * Converts the render layer of xrSession to a render target
  19277. * @param session session to create render target for
  19278. * @param scene scene the new render target should be created for
  19279. */
  19280. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  19281. // Create internal texture
  19282. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  19283. internalTexture.width = session.baseLayer.framebufferWidth;
  19284. internalTexture.height = session.baseLayer.framebufferHeight;
  19285. internalTexture._framebuffer = session.baseLayer.framebuffer;
  19286. // Create render target texture from the internal texture
  19287. 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);
  19288. renderTargetTexture._texture = internalTexture;
  19289. return renderTargetTexture;
  19290. };
  19291. /**
  19292. * Disposes of the session manager
  19293. */
  19294. WebXRSessionManager.prototype.dispose = function () {
  19295. this.onXRFrameObservable.clear();
  19296. this.onXRSessionEnded.clear();
  19297. };
  19298. return WebXRSessionManager;
  19299. }());
  19300. /***/ }),
  19301. /***/ "./Cameras/arcRotateCamera.ts":
  19302. /*!************************************!*\
  19303. !*** ./Cameras/arcRotateCamera.ts ***!
  19304. \************************************/
  19305. /*! exports provided: ArcRotateCamera */
  19306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19307. "use strict";
  19308. __webpack_require__.r(__webpack_exports__);
  19309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  19310. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19311. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19312. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19313. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19314. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  19315. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  19316. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  19317. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  19318. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  19319. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  19320. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  19321. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  19322. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  19323. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  19324. });
  19325. /**
  19326. * This represents an orbital type of camera.
  19327. *
  19328. * 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.
  19329. * 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.
  19330. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  19331. */
  19332. var ArcRotateCamera = /** @class */ (function (_super) {
  19333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  19334. /**
  19335. * Instantiates a new ArcRotateCamera in a given scene
  19336. * @param name Defines the name of the camera
  19337. * @param alpha Defines the camera rotation along the logitudinal axis
  19338. * @param beta Defines the camera rotation along the latitudinal axis
  19339. * @param radius Defines the camera distance from its target
  19340. * @param target Defines the camera target
  19341. * @param scene Defines the scene the camera belongs to
  19342. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19343. */
  19344. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  19345. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19346. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  19347. /**
  19348. * Current inertia value on the longitudinal axis.
  19349. * The bigger this number the longer it will take for the camera to stop.
  19350. */
  19351. _this.inertialAlphaOffset = 0;
  19352. /**
  19353. * Current inertia value on the latitudinal axis.
  19354. * The bigger this number the longer it will take for the camera to stop.
  19355. */
  19356. _this.inertialBetaOffset = 0;
  19357. /**
  19358. * Current inertia value on the radius axis.
  19359. * The bigger this number the longer it will take for the camera to stop.
  19360. */
  19361. _this.inertialRadiusOffset = 0;
  19362. /**
  19363. * Minimum allowed angle on the longitudinal axis.
  19364. * This can help limiting how the Camera is able to move in the scene.
  19365. */
  19366. _this.lowerAlphaLimit = null;
  19367. /**
  19368. * Maximum allowed angle on the longitudinal axis.
  19369. * This can help limiting how the Camera is able to move in the scene.
  19370. */
  19371. _this.upperAlphaLimit = null;
  19372. /**
  19373. * Minimum allowed angle on the latitudinal axis.
  19374. * This can help limiting how the Camera is able to move in the scene.
  19375. */
  19376. _this.lowerBetaLimit = 0.01;
  19377. /**
  19378. * Maximum allowed angle on the latitudinal axis.
  19379. * This can help limiting how the Camera is able to move in the scene.
  19380. */
  19381. _this.upperBetaLimit = Math.PI - 0.01;
  19382. /**
  19383. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  19384. * This can help limiting how the Camera is able to move in the scene.
  19385. */
  19386. _this.lowerRadiusLimit = null;
  19387. /**
  19388. * Maximum allowed distance of the camera to the target (The camera can not get further).
  19389. * This can help limiting how the Camera is able to move in the scene.
  19390. */
  19391. _this.upperRadiusLimit = null;
  19392. /**
  19393. * Defines the current inertia value used during panning of the camera along the X axis.
  19394. */
  19395. _this.inertialPanningX = 0;
  19396. /**
  19397. * Defines the current inertia value used during panning of the camera along the Y axis.
  19398. */
  19399. _this.inertialPanningY = 0;
  19400. /**
  19401. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  19402. * Basically if your fingers moves away from more than this distance you will be considered
  19403. * in pinch mode.
  19404. */
  19405. _this.pinchToPanMaxDistance = 20;
  19406. /**
  19407. * Defines the maximum distance the camera can pan.
  19408. * This could help keeping the cammera always in your scene.
  19409. */
  19410. _this.panningDistanceLimit = null;
  19411. /**
  19412. * Defines the target of the camera before paning.
  19413. */
  19414. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19415. /**
  19416. * Defines the value of the inertia used during panning.
  19417. * 0 would mean stop inertia and one would mean no decelleration at all.
  19418. */
  19419. _this.panningInertia = 0.9;
  19420. //-- end properties for backward compatibility for inputs
  19421. /**
  19422. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  19423. */
  19424. _this.zoomOnFactor = 1;
  19425. /**
  19426. * Defines a screen offset for the camera position.
  19427. */
  19428. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19429. /**
  19430. * Allows the camera to be completely reversed.
  19431. * If false the camera can not arrive upside down.
  19432. */
  19433. _this.allowUpsideDown = true;
  19434. /**
  19435. * Define if double tap/click is used to restore the previously saved state of the camera.
  19436. */
  19437. _this.useInputToRestoreState = true;
  19438. /** @hidden */
  19439. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19440. /**
  19441. * Defines the allowed panning axis.
  19442. */
  19443. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  19444. /**
  19445. * Observable triggered when the mesh target has been changed on the camera.
  19446. */
  19447. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  19448. /**
  19449. * Defines whether the camera should check collision with the objects oh the scene.
  19450. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  19451. */
  19452. _this.checkCollisions = false;
  19453. /**
  19454. * Defines the collision radius of the camera.
  19455. * This simulates a sphere around the camera.
  19456. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19457. */
  19458. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  19459. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19460. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19461. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19462. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19463. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  19464. if (collidedMesh === void 0) { collidedMesh = null; }
  19465. if (!collidedMesh) {
  19466. _this._previousPosition.copyFrom(_this._position);
  19467. }
  19468. else {
  19469. _this.setPosition(newPosition);
  19470. if (_this.onCollide) {
  19471. _this.onCollide(collidedMesh);
  19472. }
  19473. }
  19474. // Recompute because of constraints
  19475. var cosa = Math.cos(_this.alpha);
  19476. var sina = Math.sin(_this.alpha);
  19477. var cosb = Math.cos(_this.beta);
  19478. var sinb = Math.sin(_this.beta);
  19479. if (sinb === 0) {
  19480. sinb = 0.0001;
  19481. }
  19482. var target = _this._getTargetPosition();
  19483. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19484. target.addToRef(_this._computationVector, _this._newPosition);
  19485. _this._position.copyFrom(_this._newPosition);
  19486. var up = _this.upVector;
  19487. if (_this.allowUpsideDown && _this.beta < 0) {
  19488. up = up.clone();
  19489. up = up.negate();
  19490. }
  19491. _this._computeViewMatrix(_this._position, target, up);
  19492. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19493. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19494. _this._collisionTriggered = false;
  19495. };
  19496. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19497. if (target) {
  19498. _this.setTarget(target);
  19499. }
  19500. _this.alpha = alpha;
  19501. _this.beta = beta;
  19502. _this.radius = radius;
  19503. _this.getViewMatrix();
  19504. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19505. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19506. return _this;
  19507. }
  19508. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19509. /**
  19510. * Defines the target point of the camera.
  19511. * The camera looks towards it form the radius distance.
  19512. */
  19513. get: function () {
  19514. return this._target;
  19515. },
  19516. set: function (value) {
  19517. this.setTarget(value);
  19518. },
  19519. enumerable: true,
  19520. configurable: true
  19521. });
  19522. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  19523. /**
  19524. * Define the current local position of the camera in the scene
  19525. */
  19526. get: function () {
  19527. return this._position;
  19528. },
  19529. set: function (newPosition) {
  19530. this.setPosition(newPosition);
  19531. },
  19532. enumerable: true,
  19533. configurable: true
  19534. });
  19535. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19536. //-- begin properties for backward compatibility for inputs
  19537. /**
  19538. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19539. */
  19540. get: function () {
  19541. var pointers = this.inputs.attached["pointers"];
  19542. if (pointers) {
  19543. return pointers.angularSensibilityX;
  19544. }
  19545. return 0;
  19546. },
  19547. set: function (value) {
  19548. var pointers = this.inputs.attached["pointers"];
  19549. if (pointers) {
  19550. pointers.angularSensibilityX = value;
  19551. }
  19552. },
  19553. enumerable: true,
  19554. configurable: true
  19555. });
  19556. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19557. /**
  19558. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19559. */
  19560. get: function () {
  19561. var pointers = this.inputs.attached["pointers"];
  19562. if (pointers) {
  19563. return pointers.angularSensibilityY;
  19564. }
  19565. return 0;
  19566. },
  19567. set: function (value) {
  19568. var pointers = this.inputs.attached["pointers"];
  19569. if (pointers) {
  19570. pointers.angularSensibilityY = value;
  19571. }
  19572. },
  19573. enumerable: true,
  19574. configurable: true
  19575. });
  19576. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19577. /**
  19578. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19579. */
  19580. get: function () {
  19581. var pointers = this.inputs.attached["pointers"];
  19582. if (pointers) {
  19583. return pointers.pinchPrecision;
  19584. }
  19585. return 0;
  19586. },
  19587. set: function (value) {
  19588. var pointers = this.inputs.attached["pointers"];
  19589. if (pointers) {
  19590. pointers.pinchPrecision = value;
  19591. }
  19592. },
  19593. enumerable: true,
  19594. configurable: true
  19595. });
  19596. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19597. /**
  19598. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19599. * It will be used instead of pinchDeltaPrecision if different from 0.
  19600. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19601. */
  19602. get: function () {
  19603. var pointers = this.inputs.attached["pointers"];
  19604. if (pointers) {
  19605. return pointers.pinchDeltaPercentage;
  19606. }
  19607. return 0;
  19608. },
  19609. set: function (value) {
  19610. var pointers = this.inputs.attached["pointers"];
  19611. if (pointers) {
  19612. pointers.pinchDeltaPercentage = value;
  19613. }
  19614. },
  19615. enumerable: true,
  19616. configurable: true
  19617. });
  19618. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19619. /**
  19620. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19621. */
  19622. get: function () {
  19623. var pointers = this.inputs.attached["pointers"];
  19624. if (pointers) {
  19625. return pointers.panningSensibility;
  19626. }
  19627. return 0;
  19628. },
  19629. set: function (value) {
  19630. var pointers = this.inputs.attached["pointers"];
  19631. if (pointers) {
  19632. pointers.panningSensibility = value;
  19633. }
  19634. },
  19635. enumerable: true,
  19636. configurable: true
  19637. });
  19638. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19639. /**
  19640. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19641. */
  19642. get: function () {
  19643. var keyboard = this.inputs.attached["keyboard"];
  19644. if (keyboard) {
  19645. return keyboard.keysUp;
  19646. }
  19647. return [];
  19648. },
  19649. set: function (value) {
  19650. var keyboard = this.inputs.attached["keyboard"];
  19651. if (keyboard) {
  19652. keyboard.keysUp = value;
  19653. }
  19654. },
  19655. enumerable: true,
  19656. configurable: true
  19657. });
  19658. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19659. /**
  19660. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19661. */
  19662. get: function () {
  19663. var keyboard = this.inputs.attached["keyboard"];
  19664. if (keyboard) {
  19665. return keyboard.keysDown;
  19666. }
  19667. return [];
  19668. },
  19669. set: function (value) {
  19670. var keyboard = this.inputs.attached["keyboard"];
  19671. if (keyboard) {
  19672. keyboard.keysDown = value;
  19673. }
  19674. },
  19675. enumerable: true,
  19676. configurable: true
  19677. });
  19678. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19679. /**
  19680. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19681. */
  19682. get: function () {
  19683. var keyboard = this.inputs.attached["keyboard"];
  19684. if (keyboard) {
  19685. return keyboard.keysLeft;
  19686. }
  19687. return [];
  19688. },
  19689. set: function (value) {
  19690. var keyboard = this.inputs.attached["keyboard"];
  19691. if (keyboard) {
  19692. keyboard.keysLeft = value;
  19693. }
  19694. },
  19695. enumerable: true,
  19696. configurable: true
  19697. });
  19698. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19699. /**
  19700. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19701. */
  19702. get: function () {
  19703. var keyboard = this.inputs.attached["keyboard"];
  19704. if (keyboard) {
  19705. return keyboard.keysRight;
  19706. }
  19707. return [];
  19708. },
  19709. set: function (value) {
  19710. var keyboard = this.inputs.attached["keyboard"];
  19711. if (keyboard) {
  19712. keyboard.keysRight = value;
  19713. }
  19714. },
  19715. enumerable: true,
  19716. configurable: true
  19717. });
  19718. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19719. /**
  19720. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19721. */
  19722. get: function () {
  19723. var mousewheel = this.inputs.attached["mousewheel"];
  19724. if (mousewheel) {
  19725. return mousewheel.wheelPrecision;
  19726. }
  19727. return 0;
  19728. },
  19729. set: function (value) {
  19730. var mousewheel = this.inputs.attached["mousewheel"];
  19731. if (mousewheel) {
  19732. mousewheel.wheelPrecision = value;
  19733. }
  19734. },
  19735. enumerable: true,
  19736. configurable: true
  19737. });
  19738. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19739. /**
  19740. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19741. * It will be used instead of pinchDeltaPrecision if different from 0.
  19742. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19743. */
  19744. get: function () {
  19745. var mousewheel = this.inputs.attached["mousewheel"];
  19746. if (mousewheel) {
  19747. return mousewheel.wheelDeltaPercentage;
  19748. }
  19749. return 0;
  19750. },
  19751. set: function (value) {
  19752. var mousewheel = this.inputs.attached["mousewheel"];
  19753. if (mousewheel) {
  19754. mousewheel.wheelDeltaPercentage = value;
  19755. }
  19756. },
  19757. enumerable: true,
  19758. configurable: true
  19759. });
  19760. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19761. /**
  19762. * Gets the bouncing behavior of the camera if it has been enabled.
  19763. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19764. */
  19765. get: function () {
  19766. return this._bouncingBehavior;
  19767. },
  19768. enumerable: true,
  19769. configurable: true
  19770. });
  19771. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19772. /**
  19773. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19774. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19775. */
  19776. get: function () {
  19777. return this._bouncingBehavior != null;
  19778. },
  19779. set: function (value) {
  19780. if (value === this.useBouncingBehavior) {
  19781. return;
  19782. }
  19783. if (value) {
  19784. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19785. this.addBehavior(this._bouncingBehavior);
  19786. }
  19787. else if (this._bouncingBehavior) {
  19788. this.removeBehavior(this._bouncingBehavior);
  19789. this._bouncingBehavior = null;
  19790. }
  19791. },
  19792. enumerable: true,
  19793. configurable: true
  19794. });
  19795. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19796. /**
  19797. * Gets the framing behavior of the camera if it has been enabled.
  19798. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19799. */
  19800. get: function () {
  19801. return this._framingBehavior;
  19802. },
  19803. enumerable: true,
  19804. configurable: true
  19805. });
  19806. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19807. /**
  19808. * Defines if the framing behavior of the camera is enabled on the camera.
  19809. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19810. */
  19811. get: function () {
  19812. return this._framingBehavior != null;
  19813. },
  19814. set: function (value) {
  19815. if (value === this.useFramingBehavior) {
  19816. return;
  19817. }
  19818. if (value) {
  19819. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19820. this.addBehavior(this._framingBehavior);
  19821. }
  19822. else if (this._framingBehavior) {
  19823. this.removeBehavior(this._framingBehavior);
  19824. this._framingBehavior = null;
  19825. }
  19826. },
  19827. enumerable: true,
  19828. configurable: true
  19829. });
  19830. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19831. /**
  19832. * Gets the auto rotation behavior of the camera if it has been enabled.
  19833. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19834. */
  19835. get: function () {
  19836. return this._autoRotationBehavior;
  19837. },
  19838. enumerable: true,
  19839. configurable: true
  19840. });
  19841. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19842. /**
  19843. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19844. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19845. */
  19846. get: function () {
  19847. return this._autoRotationBehavior != null;
  19848. },
  19849. set: function (value) {
  19850. if (value === this.useAutoRotationBehavior) {
  19851. return;
  19852. }
  19853. if (value) {
  19854. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19855. this.addBehavior(this._autoRotationBehavior);
  19856. }
  19857. else if (this._autoRotationBehavior) {
  19858. this.removeBehavior(this._autoRotationBehavior);
  19859. this._autoRotationBehavior = null;
  19860. }
  19861. },
  19862. enumerable: true,
  19863. configurable: true
  19864. });
  19865. // Cache
  19866. /** @hidden */
  19867. ArcRotateCamera.prototype._initCache = function () {
  19868. _super.prototype._initCache.call(this);
  19869. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19870. this._cache.alpha = undefined;
  19871. this._cache.beta = undefined;
  19872. this._cache.radius = undefined;
  19873. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19874. };
  19875. /** @hidden */
  19876. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19877. if (!ignoreParentClass) {
  19878. _super.prototype._updateCache.call(this);
  19879. }
  19880. this._cache._target.copyFrom(this._getTargetPosition());
  19881. this._cache.alpha = this.alpha;
  19882. this._cache.beta = this.beta;
  19883. this._cache.radius = this.radius;
  19884. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19885. };
  19886. ArcRotateCamera.prototype._getTargetPosition = function () {
  19887. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19888. var pos = this._targetHost.absolutePosition;
  19889. if (this._targetBoundingCenter) {
  19890. pos.addToRef(this._targetBoundingCenter, this._target);
  19891. }
  19892. else {
  19893. this._target.copyFrom(pos);
  19894. }
  19895. }
  19896. var lockedTargetPosition = this._getLockedTargetPosition();
  19897. if (lockedTargetPosition) {
  19898. return lockedTargetPosition;
  19899. }
  19900. return this._target;
  19901. };
  19902. /**
  19903. * Stores the current state of the camera (alpha, beta, radius and target)
  19904. * @returns the camera itself
  19905. */
  19906. ArcRotateCamera.prototype.storeState = function () {
  19907. this._storedAlpha = this.alpha;
  19908. this._storedBeta = this.beta;
  19909. this._storedRadius = this.radius;
  19910. this._storedTarget = this._getTargetPosition().clone();
  19911. return _super.prototype.storeState.call(this);
  19912. };
  19913. /**
  19914. * @hidden
  19915. * Restored camera state. You must call storeState() first
  19916. */
  19917. ArcRotateCamera.prototype._restoreStateValues = function () {
  19918. if (!_super.prototype._restoreStateValues.call(this)) {
  19919. return false;
  19920. }
  19921. this.alpha = this._storedAlpha;
  19922. this.beta = this._storedBeta;
  19923. this.radius = this._storedRadius;
  19924. this.setTarget(this._storedTarget.clone());
  19925. this.inertialAlphaOffset = 0;
  19926. this.inertialBetaOffset = 0;
  19927. this.inertialRadiusOffset = 0;
  19928. this.inertialPanningX = 0;
  19929. this.inertialPanningY = 0;
  19930. return true;
  19931. };
  19932. // Synchronized
  19933. /** @hidden */
  19934. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19935. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19936. return false;
  19937. }
  19938. return this._cache._target.equals(this._getTargetPosition())
  19939. && this._cache.alpha === this.alpha
  19940. && this._cache.beta === this.beta
  19941. && this._cache.radius === this.radius
  19942. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19943. };
  19944. /**
  19945. * Attached controls to the current camera.
  19946. * @param element Defines the element the controls should be listened from
  19947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19948. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19949. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19950. */
  19951. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19952. var _this = this;
  19953. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19954. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19955. this._useCtrlForPanning = useCtrlForPanning;
  19956. this._panningMouseButton = panningMouseButton;
  19957. this.inputs.attachElement(element, noPreventDefault);
  19958. this._reset = function () {
  19959. _this.inertialAlphaOffset = 0;
  19960. _this.inertialBetaOffset = 0;
  19961. _this.inertialRadiusOffset = 0;
  19962. _this.inertialPanningX = 0;
  19963. _this.inertialPanningY = 0;
  19964. };
  19965. };
  19966. /**
  19967. * Detach the current controls from the camera.
  19968. * The camera will stop reacting to inputs.
  19969. * @param element Defines the element to stop listening the inputs from
  19970. */
  19971. ArcRotateCamera.prototype.detachControl = function (element) {
  19972. this.inputs.detachElement(element);
  19973. if (this._reset) {
  19974. this._reset();
  19975. }
  19976. };
  19977. /** @hidden */
  19978. ArcRotateCamera.prototype._checkInputs = function () {
  19979. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19980. if (this._collisionTriggered) {
  19981. return;
  19982. }
  19983. this.inputs.checkInputs();
  19984. // Inertia
  19985. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19986. var inertialAlphaOffset = this.inertialAlphaOffset;
  19987. if (this.beta <= 0) {
  19988. inertialAlphaOffset *= -1;
  19989. }
  19990. if (this.getScene().useRightHandedSystem) {
  19991. inertialAlphaOffset *= -1;
  19992. }
  19993. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19994. inertialAlphaOffset *= -1;
  19995. }
  19996. this.alpha += inertialAlphaOffset;
  19997. this.beta += this.inertialBetaOffset;
  19998. this.radius -= this.inertialRadiusOffset;
  19999. this.inertialAlphaOffset *= this.inertia;
  20000. this.inertialBetaOffset *= this.inertia;
  20001. this.inertialRadiusOffset *= this.inertia;
  20002. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20003. this.inertialAlphaOffset = 0;
  20004. }
  20005. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20006. this.inertialBetaOffset = 0;
  20007. }
  20008. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20009. this.inertialRadiusOffset = 0;
  20010. }
  20011. }
  20012. // Panning inertia
  20013. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  20014. if (!this._localDirection) {
  20015. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20016. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20017. }
  20018. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  20019. this._localDirection.multiplyInPlace(this.panningAxis);
  20020. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  20021. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  20022. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  20023. if (!this.panningAxis.y) {
  20024. this._transformedDirection.y = 0;
  20025. }
  20026. if (!this._targetHost) {
  20027. if (this.panningDistanceLimit) {
  20028. this._transformedDirection.addInPlace(this._target);
  20029. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  20030. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  20031. this._target.copyFrom(this._transformedDirection);
  20032. }
  20033. }
  20034. else {
  20035. this._target.addInPlace(this._transformedDirection);
  20036. }
  20037. }
  20038. this.inertialPanningX *= this.panningInertia;
  20039. this.inertialPanningY *= this.panningInertia;
  20040. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20041. this.inertialPanningX = 0;
  20042. }
  20043. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20044. this.inertialPanningY = 0;
  20045. }
  20046. }
  20047. // Limits
  20048. this._checkLimits();
  20049. _super.prototype._checkInputs.call(this);
  20050. };
  20051. ArcRotateCamera.prototype._checkLimits = function () {
  20052. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  20053. if (this.allowUpsideDown && this.beta > Math.PI) {
  20054. this.beta = this.beta - (2 * Math.PI);
  20055. }
  20056. }
  20057. else {
  20058. if (this.beta < this.lowerBetaLimit) {
  20059. this.beta = this.lowerBetaLimit;
  20060. }
  20061. }
  20062. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  20063. if (this.allowUpsideDown && this.beta < -Math.PI) {
  20064. this.beta = this.beta + (2 * Math.PI);
  20065. }
  20066. }
  20067. else {
  20068. if (this.beta > this.upperBetaLimit) {
  20069. this.beta = this.upperBetaLimit;
  20070. }
  20071. }
  20072. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  20073. this.alpha = this.lowerAlphaLimit;
  20074. }
  20075. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  20076. this.alpha = this.upperAlphaLimit;
  20077. }
  20078. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  20079. this.radius = this.lowerRadiusLimit;
  20080. this.inertialRadiusOffset = 0;
  20081. }
  20082. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  20083. this.radius = this.upperRadiusLimit;
  20084. this.inertialRadiusOffset = 0;
  20085. }
  20086. };
  20087. /**
  20088. * Rebuilds angles (alpha, beta) and radius from the give position and target
  20089. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  20090. */
  20091. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function (updateView) {
  20092. if (updateView === void 0) { updateView = true; }
  20093. if (updateView) {
  20094. this.getViewMatrix(); // Force position update
  20095. }
  20096. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  20097. this.radius = this._computationVector.length();
  20098. if (this.radius === 0) {
  20099. this.radius = 0.0001; // Just to avoid division by zero
  20100. }
  20101. // Alpha
  20102. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  20103. if (this._computationVector.z < 0) {
  20104. this.alpha = 2 * Math.PI - this.alpha;
  20105. }
  20106. // Beta
  20107. this.beta = Math.acos(this._computationVector.y / this.radius);
  20108. this._checkLimits();
  20109. };
  20110. /**
  20111. * Use a position to define the current camera related information like aplha, beta and radius
  20112. * @param position Defines the position to set the camera at
  20113. */
  20114. ArcRotateCamera.prototype.setPosition = function (position) {
  20115. if (this._position.equals(position)) {
  20116. return;
  20117. }
  20118. this._position.copyFrom(position);
  20119. this.rebuildAnglesAndRadius(false);
  20120. };
  20121. /**
  20122. * Defines the target the camera should look at.
  20123. * This will automatically adapt alpha beta and radius to fit within the new target.
  20124. * @param target Defines the new target as a Vector or a mesh
  20125. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  20126. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  20127. */
  20128. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  20129. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  20130. if (allowSamePosition === void 0) { allowSamePosition = false; }
  20131. if (target.getBoundingInfo) {
  20132. if (toBoundingCenter) {
  20133. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  20134. }
  20135. else {
  20136. this._targetBoundingCenter = null;
  20137. }
  20138. target.computeWorldMatrix();
  20139. this._targetHost = target;
  20140. this._target = this._getTargetPosition();
  20141. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  20142. }
  20143. else {
  20144. var newTarget = target;
  20145. var currentTarget = this._getTargetPosition();
  20146. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  20147. return;
  20148. }
  20149. this._targetHost = null;
  20150. this._target = newTarget;
  20151. this._targetBoundingCenter = null;
  20152. this.onMeshTargetChangedObservable.notifyObservers(null);
  20153. }
  20154. this.rebuildAnglesAndRadius();
  20155. };
  20156. /** @hidden */
  20157. ArcRotateCamera.prototype._getViewMatrix = function () {
  20158. // Compute
  20159. var cosa = Math.cos(this.alpha);
  20160. var sina = Math.sin(this.alpha);
  20161. var cosb = Math.cos(this.beta);
  20162. var sinb = Math.sin(this.beta);
  20163. if (sinb === 0) {
  20164. sinb = 0.0001;
  20165. }
  20166. var target = this._getTargetPosition();
  20167. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  20168. // Rotate according to up vector
  20169. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  20170. if (!this._tempAxisVector) {
  20171. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  20172. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  20173. }
  20174. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  20175. this._tempAxisVector.normalize();
  20176. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  20177. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  20178. this._tempAxisVector.copyFrom(this._computationVector);
  20179. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  20180. }
  20181. target.addToRef(this._computationVector, this._newPosition);
  20182. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  20183. var coordinator = this.getScene().collisionCoordinator;
  20184. if (!this._collider) {
  20185. this._collider = coordinator.createCollider();
  20186. }
  20187. this._collider._radius = this.collisionRadius;
  20188. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  20189. this._collisionTriggered = true;
  20190. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20191. }
  20192. else {
  20193. this._position.copyFrom(this._newPosition);
  20194. var up = this.upVector;
  20195. if (this.allowUpsideDown && sinb < 0) {
  20196. up = up.clone();
  20197. up = up.negate();
  20198. }
  20199. this._computeViewMatrix(this._position, target, up);
  20200. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  20201. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  20202. }
  20203. this._currentTarget = target;
  20204. return this._viewMatrix;
  20205. };
  20206. /**
  20207. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  20208. * @param meshes Defines the mesh to zoom on
  20209. * @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)
  20210. */
  20211. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  20212. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20213. meshes = meshes || this.getScene().meshes;
  20214. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20215. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  20216. this.radius = distance * this.zoomOnFactor;
  20217. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  20218. };
  20219. /**
  20220. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  20221. * The target will be changed but the radius
  20222. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  20223. * @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)
  20224. */
  20225. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  20226. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20227. var meshesOrMinMaxVector;
  20228. var distance;
  20229. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  20230. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  20231. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20232. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  20233. }
  20234. else { //minMaxVector and distance
  20235. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  20236. meshesOrMinMaxVector = minMaxVectorAndDistance;
  20237. distance = minMaxVectorAndDistance.distance;
  20238. }
  20239. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  20240. if (!doNotUpdateMaxZ) {
  20241. this.maxZ = distance * 2;
  20242. }
  20243. };
  20244. /**
  20245. * @override
  20246. * Override Camera.createRigCamera
  20247. */
  20248. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  20249. var alphaShift = 0;
  20250. switch (this.cameraRigMode) {
  20251. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20252. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20253. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20254. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20255. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  20256. break;
  20257. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20258. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  20259. break;
  20260. }
  20261. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  20262. rigCam._cameraRigParams = {};
  20263. return rigCam;
  20264. };
  20265. /**
  20266. * @hidden
  20267. * @override
  20268. * Override Camera._updateRigCameras
  20269. */
  20270. ArcRotateCamera.prototype._updateRigCameras = function () {
  20271. var camLeft = this._rigCameras[0];
  20272. var camRight = this._rigCameras[1];
  20273. camLeft.beta = camRight.beta = this.beta;
  20274. switch (this.cameraRigMode) {
  20275. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20276. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20277. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20278. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20279. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20280. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20281. break;
  20282. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20283. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20284. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20285. break;
  20286. }
  20287. _super.prototype._updateRigCameras.call(this);
  20288. };
  20289. /**
  20290. * Destroy the camera and release the current resources hold by it.
  20291. */
  20292. ArcRotateCamera.prototype.dispose = function () {
  20293. this.inputs.clear();
  20294. _super.prototype.dispose.call(this);
  20295. };
  20296. /**
  20297. * Gets the current object class name.
  20298. * @return the class name
  20299. */
  20300. ArcRotateCamera.prototype.getClassName = function () {
  20301. return "ArcRotateCamera";
  20302. };
  20303. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20304. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20305. ], ArcRotateCamera.prototype, "alpha", void 0);
  20306. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20308. ], ArcRotateCamera.prototype, "beta", void 0);
  20309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20311. ], ArcRotateCamera.prototype, "radius", void 0);
  20312. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20313. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  20314. ], ArcRotateCamera.prototype, "_target", void 0);
  20315. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20316. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20317. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  20318. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20319. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20320. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  20321. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20323. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  20324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20326. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  20327. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20328. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20329. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  20330. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20332. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  20333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20335. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  20336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20338. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  20339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20341. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  20342. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20344. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  20345. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20347. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  20348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20350. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  20351. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20352. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20353. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  20354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20356. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  20357. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20359. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  20360. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20362. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  20363. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20364. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20365. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  20366. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20368. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  20369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20371. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  20372. return ArcRotateCamera;
  20373. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  20374. /***/ }),
  20375. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  20376. /*!*************************************************!*\
  20377. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  20378. \*************************************************/
  20379. /*! exports provided: ArcRotateCameraInputsManager */
  20380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20381. "use strict";
  20382. __webpack_require__.r(__webpack_exports__);
  20383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  20384. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20385. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  20386. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  20387. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  20388. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  20389. /**
  20390. * Default Inputs manager for the ArcRotateCamera.
  20391. * It groups all the default supported inputs for ease of use.
  20392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20393. */
  20394. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  20395. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  20396. /**
  20397. * Instantiates a new ArcRotateCameraInputsManager.
  20398. * @param camera Defines the camera the inputs belong to
  20399. */
  20400. function ArcRotateCameraInputsManager(camera) {
  20401. return _super.call(this, camera) || this;
  20402. }
  20403. /**
  20404. * Add mouse wheel input support to the input manager.
  20405. * @returns the current input manager
  20406. */
  20407. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  20408. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  20409. return this;
  20410. };
  20411. /**
  20412. * Add pointers input support to the input manager.
  20413. * @returns the current input manager
  20414. */
  20415. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  20416. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  20417. return this;
  20418. };
  20419. /**
  20420. * Add keyboard input support to the input manager.
  20421. * @returns the current input manager
  20422. */
  20423. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  20424. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  20425. return this;
  20426. };
  20427. return ArcRotateCameraInputsManager;
  20428. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  20429. /***/ }),
  20430. /***/ "./Cameras/camera.ts":
  20431. /*!***************************!*\
  20432. !*** ./Cameras/camera.ts ***!
  20433. \***************************/
  20434. /*! exports provided: Camera */
  20435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20436. "use strict";
  20437. __webpack_require__.r(__webpack_exports__);
  20438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  20439. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20440. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20441. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  20442. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  20443. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20444. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20445. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  20446. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20447. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  20448. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  20449. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  20450. /**
  20451. * This is the base class of all the camera used in the application.
  20452. * @see http://doc.babylonjs.com/features/cameras
  20453. */
  20454. var Camera = /** @class */ (function (_super) {
  20455. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  20456. /**
  20457. * Instantiates a new camera object.
  20458. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  20459. * @see http://doc.babylonjs.com/features/cameras
  20460. * @param name Defines the name of the camera in the scene
  20461. * @param position Defines the position of the camera
  20462. * @param scene Defines the scene the camera belongs too
  20463. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  20464. */
  20465. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20466. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20467. var _this = _super.call(this, name, scene) || this;
  20468. /** @hidden */
  20469. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20470. /**
  20471. * The vector the camera should consider as up.
  20472. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  20473. */
  20474. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  20475. /**
  20476. * Define the current limit on the left side for an orthographic camera
  20477. * In scene unit
  20478. */
  20479. _this.orthoLeft = null;
  20480. /**
  20481. * Define the current limit on the right side for an orthographic camera
  20482. * In scene unit
  20483. */
  20484. _this.orthoRight = null;
  20485. /**
  20486. * Define the current limit on the bottom side for an orthographic camera
  20487. * In scene unit
  20488. */
  20489. _this.orthoBottom = null;
  20490. /**
  20491. * Define the current limit on the top side for an orthographic camera
  20492. * In scene unit
  20493. */
  20494. _this.orthoTop = null;
  20495. /**
  20496. * Field Of View is set in Radians. (default is 0.8)
  20497. */
  20498. _this.fov = 0.8;
  20499. /**
  20500. * Define the minimum distance the camera can see from.
  20501. * This is important to note that the depth buffer are not infinite and the closer it starts
  20502. * the more your scene might encounter depth fighting issue.
  20503. */
  20504. _this.minZ = 1;
  20505. /**
  20506. * Define the maximum distance the camera can see to.
  20507. * This is important to note that the depth buffer are not infinite and the further it end
  20508. * the more your scene might encounter depth fighting issue.
  20509. */
  20510. _this.maxZ = 10000.0;
  20511. /**
  20512. * Define the default inertia of the camera.
  20513. * This helps giving a smooth feeling to the camera movement.
  20514. */
  20515. _this.inertia = 0.9;
  20516. /**
  20517. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20518. */
  20519. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20520. /**
  20521. * Define wether the camera is intermediate.
  20522. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20523. */
  20524. _this.isIntermediate = false;
  20525. /**
  20526. * Define the viewport of the camera.
  20527. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20528. */
  20529. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20530. /**
  20531. * Restricts the camera to viewing objects with the same layerMask.
  20532. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20533. */
  20534. _this.layerMask = 0x0FFFFFFF;
  20535. /**
  20536. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20537. */
  20538. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20539. /**
  20540. * Rig mode of the camera.
  20541. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20542. * This is normally controlled byt the camera themselves as internal use.
  20543. */
  20544. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20545. /**
  20546. * 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
  20547. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20548. * else in the scene.
  20549. */
  20550. _this.customRenderTargets = new Array();
  20551. /**
  20552. * When set, the camera will render to this render target instead of the default canvas
  20553. */
  20554. _this.outputRenderTarget = null;
  20555. /**
  20556. * @hidden
  20557. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20558. */
  20559. _this._useMultiviewToSingleView = false;
  20560. /**
  20561. * @hidden
  20562. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20563. */
  20564. _this._multiviewTexture = null;
  20565. /**
  20566. * Observable triggered when the camera view matrix has changed.
  20567. */
  20568. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20569. /**
  20570. * Observable triggered when the camera Projection matrix has changed.
  20571. */
  20572. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20573. /**
  20574. * Observable triggered when the inputs have been processed.
  20575. */
  20576. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20577. /**
  20578. * Observable triggered when reset has been called and applied to the camera.
  20579. */
  20580. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20581. /** @hidden */
  20582. _this._rigCameras = new Array();
  20583. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20584. /** @hidden */
  20585. _this._skipRendering = false;
  20586. /** @hidden */
  20587. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20588. /** @hidden */
  20589. _this._postProcesses = new Array();
  20590. /** @hidden */
  20591. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20592. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20593. /** hidden */
  20594. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20595. _this._doNotComputeProjectionMatrix = false;
  20596. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20597. _this._refreshFrustumPlanes = true;
  20598. /** @hidden */
  20599. _this._isCamera = true;
  20600. /** @hidden */
  20601. _this._isLeftCamera = false;
  20602. /** @hidden */
  20603. _this._isRightCamera = true;
  20604. _this.getScene().addCamera(_this);
  20605. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20606. _this.getScene().activeCamera = _this;
  20607. }
  20608. _this.position = position;
  20609. return _this;
  20610. }
  20611. Object.defineProperty(Camera.prototype, "position", {
  20612. /**
  20613. * Define the current local position of the camera in the scene
  20614. */
  20615. get: function () {
  20616. return this._position;
  20617. },
  20618. set: function (newPosition) {
  20619. this._position = newPosition;
  20620. },
  20621. enumerable: true,
  20622. configurable: true
  20623. });
  20624. /**
  20625. * @hidden
  20626. * ensures the multiview texture of the camera exists and has the specified width/height
  20627. * @param width height to set on the multiview texture
  20628. * @param height width to set on the multiview texture
  20629. */
  20630. Camera.prototype._resizeOrCreateMultiviewTexture = function (width, height) {
  20631. if (!this._multiviewTexture) {
  20632. this._multiviewTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  20633. }
  20634. else if (this._multiviewTexture.getRenderWidth() != width || this._multiviewTexture.getRenderHeight() != height) {
  20635. this._multiviewTexture.dispose();
  20636. this._multiviewTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  20637. }
  20638. };
  20639. /**
  20640. * Store current camera state (fov, position, etc..)
  20641. * @returns the camera
  20642. */
  20643. Camera.prototype.storeState = function () {
  20644. this._stateStored = true;
  20645. this._storedFov = this.fov;
  20646. return this;
  20647. };
  20648. /**
  20649. * Restores the camera state values if it has been stored. You must call storeState() first
  20650. */
  20651. Camera.prototype._restoreStateValues = function () {
  20652. if (!this._stateStored) {
  20653. return false;
  20654. }
  20655. this.fov = this._storedFov;
  20656. return true;
  20657. };
  20658. /**
  20659. * Restored camera state. You must call storeState() first.
  20660. * @returns true if restored and false otherwise
  20661. */
  20662. Camera.prototype.restoreState = function () {
  20663. if (this._restoreStateValues()) {
  20664. this.onRestoreStateObservable.notifyObservers(this);
  20665. return true;
  20666. }
  20667. return false;
  20668. };
  20669. /**
  20670. * Gets the class name of the camera.
  20671. * @returns the class name
  20672. */
  20673. Camera.prototype.getClassName = function () {
  20674. return "Camera";
  20675. };
  20676. /**
  20677. * Gets a string representation of the camera useful for debug purpose.
  20678. * @param fullDetails Defines that a more verboe level of logging is required
  20679. * @returns the string representation
  20680. */
  20681. Camera.prototype.toString = function (fullDetails) {
  20682. var ret = "Name: " + this.name;
  20683. ret += ", type: " + this.getClassName();
  20684. if (this.animations) {
  20685. for (var i = 0; i < this.animations.length; i++) {
  20686. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20687. }
  20688. }
  20689. if (fullDetails) {
  20690. }
  20691. return ret;
  20692. };
  20693. Object.defineProperty(Camera.prototype, "globalPosition", {
  20694. /**
  20695. * Gets the current world space position of the camera.
  20696. */
  20697. get: function () {
  20698. return this._globalPosition;
  20699. },
  20700. enumerable: true,
  20701. configurable: true
  20702. });
  20703. /**
  20704. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20705. * @returns the active meshe list
  20706. */
  20707. Camera.prototype.getActiveMeshes = function () {
  20708. return this._activeMeshes;
  20709. };
  20710. /**
  20711. * Check wether a mesh is part of the current active mesh list of the camera
  20712. * @param mesh Defines the mesh to check
  20713. * @returns true if active, false otherwise
  20714. */
  20715. Camera.prototype.isActiveMesh = function (mesh) {
  20716. return (this._activeMeshes.indexOf(mesh) !== -1);
  20717. };
  20718. /**
  20719. * Is this camera ready to be used/rendered
  20720. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20721. * @return true if the camera is ready
  20722. */
  20723. Camera.prototype.isReady = function (completeCheck) {
  20724. if (completeCheck === void 0) { completeCheck = false; }
  20725. if (completeCheck) {
  20726. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20727. var pp = _a[_i];
  20728. if (pp && !pp.isReady()) {
  20729. return false;
  20730. }
  20731. }
  20732. }
  20733. return _super.prototype.isReady.call(this, completeCheck);
  20734. };
  20735. /** @hidden */
  20736. Camera.prototype._initCache = function () {
  20737. _super.prototype._initCache.call(this);
  20738. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20739. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20740. this._cache.mode = undefined;
  20741. this._cache.minZ = undefined;
  20742. this._cache.maxZ = undefined;
  20743. this._cache.fov = undefined;
  20744. this._cache.fovMode = undefined;
  20745. this._cache.aspectRatio = undefined;
  20746. this._cache.orthoLeft = undefined;
  20747. this._cache.orthoRight = undefined;
  20748. this._cache.orthoBottom = undefined;
  20749. this._cache.orthoTop = undefined;
  20750. this._cache.renderWidth = undefined;
  20751. this._cache.renderHeight = undefined;
  20752. };
  20753. /** @hidden */
  20754. Camera.prototype._updateCache = function (ignoreParentClass) {
  20755. if (!ignoreParentClass) {
  20756. _super.prototype._updateCache.call(this);
  20757. }
  20758. this._cache.position.copyFrom(this.position);
  20759. this._cache.upVector.copyFrom(this.upVector);
  20760. };
  20761. /** @hidden */
  20762. Camera.prototype._isSynchronized = function () {
  20763. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20764. };
  20765. /** @hidden */
  20766. Camera.prototype._isSynchronizedViewMatrix = function () {
  20767. if (!_super.prototype._isSynchronized.call(this)) {
  20768. return false;
  20769. }
  20770. return this._cache.position.equals(this.position)
  20771. && this._cache.upVector.equals(this.upVector)
  20772. && this.isSynchronizedWithParent();
  20773. };
  20774. /** @hidden */
  20775. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20776. var check = this._cache.mode === this.mode
  20777. && this._cache.minZ === this.minZ
  20778. && this._cache.maxZ === this.maxZ;
  20779. if (!check) {
  20780. return false;
  20781. }
  20782. var engine = this.getEngine();
  20783. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20784. check = this._cache.fov === this.fov
  20785. && this._cache.fovMode === this.fovMode
  20786. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20787. }
  20788. else {
  20789. check = this._cache.orthoLeft === this.orthoLeft
  20790. && this._cache.orthoRight === this.orthoRight
  20791. && this._cache.orthoBottom === this.orthoBottom
  20792. && this._cache.orthoTop === this.orthoTop
  20793. && this._cache.renderWidth === engine.getRenderWidth()
  20794. && this._cache.renderHeight === engine.getRenderHeight();
  20795. }
  20796. return check;
  20797. };
  20798. /**
  20799. * Attach the input controls to a specific dom element to get the input from.
  20800. * @param element Defines the element the controls should be listened from
  20801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20802. */
  20803. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20804. };
  20805. /**
  20806. * Detach the current controls from the specified dom element.
  20807. * @param element Defines the element to stop listening the inputs from
  20808. */
  20809. Camera.prototype.detachControl = function (element) {
  20810. };
  20811. /**
  20812. * Update the camera state according to the different inputs gathered during the frame.
  20813. */
  20814. Camera.prototype.update = function () {
  20815. this._checkInputs();
  20816. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20817. this._updateRigCameras();
  20818. }
  20819. };
  20820. /** @hidden */
  20821. Camera.prototype._checkInputs = function () {
  20822. this.onAfterCheckInputsObservable.notifyObservers(this);
  20823. };
  20824. Object.defineProperty(Camera.prototype, "rigCameras", {
  20825. /** @hidden */
  20826. get: function () {
  20827. return this._rigCameras;
  20828. },
  20829. enumerable: true,
  20830. configurable: true
  20831. });
  20832. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20833. /**
  20834. * Gets the post process used by the rig cameras
  20835. */
  20836. get: function () {
  20837. return this._rigPostProcess;
  20838. },
  20839. enumerable: true,
  20840. configurable: true
  20841. });
  20842. /**
  20843. * Internal, gets the first post proces.
  20844. * @returns the first post process to be run on this camera.
  20845. */
  20846. Camera.prototype._getFirstPostProcess = function () {
  20847. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20848. if (this._postProcesses[ppIndex] !== null) {
  20849. return this._postProcesses[ppIndex];
  20850. }
  20851. }
  20852. return null;
  20853. };
  20854. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20855. // invalidate framebuffer
  20856. var firstPostProcess = this._getFirstPostProcess();
  20857. if (firstPostProcess) {
  20858. firstPostProcess.markTextureDirty();
  20859. }
  20860. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20861. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20862. var cam = this._rigCameras[i];
  20863. var rigPostProcess = cam._rigPostProcess;
  20864. // for VR rig, there does not have to be a post process
  20865. if (rigPostProcess) {
  20866. var isPass = rigPostProcess.getEffectName() === "pass";
  20867. if (isPass) {
  20868. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20869. cam.isIntermediate = this._postProcesses.length === 0;
  20870. }
  20871. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20872. rigPostProcess.markTextureDirty();
  20873. }
  20874. else {
  20875. cam._postProcesses = this._postProcesses.slice(0);
  20876. }
  20877. }
  20878. };
  20879. /**
  20880. * Attach a post process to the camera.
  20881. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20882. * @param postProcess The post process to attach to the camera
  20883. * @param insertAt The position of the post process in case several of them are in use in the scene
  20884. * @returns the position the post process has been inserted at
  20885. */
  20886. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20887. if (insertAt === void 0) { insertAt = null; }
  20888. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20889. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20890. return 0;
  20891. }
  20892. if (insertAt == null || insertAt < 0) {
  20893. this._postProcesses.push(postProcess);
  20894. }
  20895. else if (this._postProcesses[insertAt] === null) {
  20896. this._postProcesses[insertAt] = postProcess;
  20897. }
  20898. else {
  20899. this._postProcesses.splice(insertAt, 0, postProcess);
  20900. }
  20901. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20902. return this._postProcesses.indexOf(postProcess);
  20903. };
  20904. /**
  20905. * Detach a post process to the camera.
  20906. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20907. * @param postProcess The post process to detach from the camera
  20908. */
  20909. Camera.prototype.detachPostProcess = function (postProcess) {
  20910. var idx = this._postProcesses.indexOf(postProcess);
  20911. if (idx !== -1) {
  20912. this._postProcesses[idx] = null;
  20913. }
  20914. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20915. };
  20916. /**
  20917. * Gets the current world matrix of the camera
  20918. */
  20919. Camera.prototype.getWorldMatrix = function () {
  20920. if (this._isSynchronizedViewMatrix()) {
  20921. return this._worldMatrix;
  20922. }
  20923. // Getting the the view matrix will also compute the world matrix.
  20924. this.getViewMatrix();
  20925. return this._worldMatrix;
  20926. };
  20927. /** @hidden */
  20928. Camera.prototype._getViewMatrix = function () {
  20929. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20930. };
  20931. /**
  20932. * Gets the current view matrix of the camera.
  20933. * @param force forces the camera to recompute the matrix without looking at the cached state
  20934. * @returns the view matrix
  20935. */
  20936. Camera.prototype.getViewMatrix = function (force) {
  20937. if (!force && this._isSynchronizedViewMatrix()) {
  20938. return this._computedViewMatrix;
  20939. }
  20940. this.updateCache();
  20941. this._computedViewMatrix = this._getViewMatrix();
  20942. this._currentRenderId = this.getScene().getRenderId();
  20943. this._childRenderId = this._currentRenderId;
  20944. this._refreshFrustumPlanes = true;
  20945. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20946. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20947. }
  20948. this.onViewMatrixChangedObservable.notifyObservers(this);
  20949. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20950. return this._computedViewMatrix;
  20951. };
  20952. /**
  20953. * Freeze the projection matrix.
  20954. * It will prevent the cache check of the camera projection compute and can speed up perf
  20955. * if no parameter of the camera are meant to change
  20956. * @param projection Defines manually a projection if necessary
  20957. */
  20958. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20959. this._doNotComputeProjectionMatrix = true;
  20960. if (projection !== undefined) {
  20961. this._projectionMatrix = projection;
  20962. }
  20963. };
  20964. /**
  20965. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20966. */
  20967. Camera.prototype.unfreezeProjectionMatrix = function () {
  20968. this._doNotComputeProjectionMatrix = false;
  20969. };
  20970. /**
  20971. * Gets the current projection matrix of the camera.
  20972. * @param force forces the camera to recompute the matrix without looking at the cached state
  20973. * @returns the projection matrix
  20974. */
  20975. Camera.prototype.getProjectionMatrix = function (force) {
  20976. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20977. return this._projectionMatrix;
  20978. }
  20979. // Cache
  20980. this._cache.mode = this.mode;
  20981. this._cache.minZ = this.minZ;
  20982. this._cache.maxZ = this.maxZ;
  20983. // Matrix
  20984. this._refreshFrustumPlanes = true;
  20985. var engine = this.getEngine();
  20986. var scene = this.getScene();
  20987. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20988. this._cache.fov = this.fov;
  20989. this._cache.fovMode = this.fovMode;
  20990. this._cache.aspectRatio = engine.getAspectRatio(this);
  20991. if (this.minZ <= 0) {
  20992. this.minZ = 0.1;
  20993. }
  20994. if (scene.useRightHandedSystem) {
  20995. _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);
  20996. }
  20997. else {
  20998. _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);
  20999. }
  21000. }
  21001. else {
  21002. var halfWidth = engine.getRenderWidth() / 2.0;
  21003. var halfHeight = engine.getRenderHeight() / 2.0;
  21004. if (scene.useRightHandedSystem) {
  21005. _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);
  21006. }
  21007. else {
  21008. _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);
  21009. }
  21010. this._cache.orthoLeft = this.orthoLeft;
  21011. this._cache.orthoRight = this.orthoRight;
  21012. this._cache.orthoBottom = this.orthoBottom;
  21013. this._cache.orthoTop = this.orthoTop;
  21014. this._cache.renderWidth = engine.getRenderWidth();
  21015. this._cache.renderHeight = engine.getRenderHeight();
  21016. }
  21017. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  21018. return this._projectionMatrix;
  21019. };
  21020. /**
  21021. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  21022. * @returns a Matrix
  21023. */
  21024. Camera.prototype.getTransformationMatrix = function () {
  21025. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  21026. return this._transformMatrix;
  21027. };
  21028. Camera.prototype._updateFrustumPlanes = function () {
  21029. if (!this._refreshFrustumPlanes) {
  21030. return;
  21031. }
  21032. this.getTransformationMatrix();
  21033. if (!this._frustumPlanes) {
  21034. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  21035. }
  21036. else {
  21037. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  21038. }
  21039. this._refreshFrustumPlanes = false;
  21040. };
  21041. /**
  21042. * Checks if a cullable object (mesh...) is in the camera frustum
  21043. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  21044. * @param target The object to check
  21045. * @returns true if the object is in frustum otherwise false
  21046. */
  21047. Camera.prototype.isInFrustum = function (target) {
  21048. this._updateFrustumPlanes();
  21049. return target.isInFrustum(this._frustumPlanes);
  21050. };
  21051. /**
  21052. * Checks if a cullable object (mesh...) is in the camera frustum
  21053. * Unlike isInFrustum this cheks the full bounding box
  21054. * @param target The object to check
  21055. * @returns true if the object is in frustum otherwise false
  21056. */
  21057. Camera.prototype.isCompletelyInFrustum = function (target) {
  21058. this._updateFrustumPlanes();
  21059. return target.isCompletelyInFrustum(this._frustumPlanes);
  21060. };
  21061. /**
  21062. * Gets a ray in the forward direction from the camera.
  21063. * @param length Defines the length of the ray to create
  21064. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  21065. * @param origin Defines the start point of the ray which defaults to the camera position
  21066. * @returns the forward ray
  21067. */
  21068. Camera.prototype.getForwardRay = function (length, transform, origin) {
  21069. if (length === void 0) { length = 100; }
  21070. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  21071. };
  21072. /**
  21073. * Releases resources associated with this node.
  21074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21076. */
  21077. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  21078. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  21079. // Observables
  21080. this.onViewMatrixChangedObservable.clear();
  21081. this.onProjectionMatrixChangedObservable.clear();
  21082. this.onAfterCheckInputsObservable.clear();
  21083. this.onRestoreStateObservable.clear();
  21084. // Inputs
  21085. if (this.inputs) {
  21086. this.inputs.clear();
  21087. }
  21088. // Animations
  21089. this.getScene().stopAnimation(this);
  21090. // Remove from scene
  21091. this.getScene().removeCamera(this);
  21092. while (this._rigCameras.length > 0) {
  21093. var camera = this._rigCameras.pop();
  21094. if (camera) {
  21095. camera.dispose();
  21096. }
  21097. }
  21098. // Postprocesses
  21099. if (this._rigPostProcess) {
  21100. this._rigPostProcess.dispose(this);
  21101. this._rigPostProcess = null;
  21102. this._postProcesses = [];
  21103. }
  21104. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21105. this._rigPostProcess = null;
  21106. this._postProcesses = [];
  21107. }
  21108. else {
  21109. var i = this._postProcesses.length;
  21110. while (--i >= 0) {
  21111. var postProcess = this._postProcesses[i];
  21112. if (postProcess) {
  21113. postProcess.dispose(this);
  21114. }
  21115. }
  21116. }
  21117. // Render targets
  21118. var i = this.customRenderTargets.length;
  21119. while (--i >= 0) {
  21120. this.customRenderTargets[i].dispose();
  21121. }
  21122. this.customRenderTargets = [];
  21123. // Active Meshes
  21124. this._activeMeshes.dispose();
  21125. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  21126. };
  21127. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  21128. /**
  21129. * Gets the left camera of a rig setup in case of Rigged Camera
  21130. */
  21131. get: function () {
  21132. return this._isLeftCamera;
  21133. },
  21134. enumerable: true,
  21135. configurable: true
  21136. });
  21137. Object.defineProperty(Camera.prototype, "isRightCamera", {
  21138. /**
  21139. * Gets the right camera of a rig setup in case of Rigged Camera
  21140. */
  21141. get: function () {
  21142. return this._isRightCamera;
  21143. },
  21144. enumerable: true,
  21145. configurable: true
  21146. });
  21147. Object.defineProperty(Camera.prototype, "leftCamera", {
  21148. /**
  21149. * Gets the left camera of a rig setup in case of Rigged Camera
  21150. */
  21151. get: function () {
  21152. if (this._rigCameras.length < 1) {
  21153. return null;
  21154. }
  21155. return this._rigCameras[0];
  21156. },
  21157. enumerable: true,
  21158. configurable: true
  21159. });
  21160. Object.defineProperty(Camera.prototype, "rightCamera", {
  21161. /**
  21162. * Gets the right camera of a rig setup in case of Rigged Camera
  21163. */
  21164. get: function () {
  21165. if (this._rigCameras.length < 2) {
  21166. return null;
  21167. }
  21168. return this._rigCameras[1];
  21169. },
  21170. enumerable: true,
  21171. configurable: true
  21172. });
  21173. /**
  21174. * Gets the left camera target of a rig setup in case of Rigged Camera
  21175. * @returns the target position
  21176. */
  21177. Camera.prototype.getLeftTarget = function () {
  21178. if (this._rigCameras.length < 1) {
  21179. return null;
  21180. }
  21181. return this._rigCameras[0].getTarget();
  21182. };
  21183. /**
  21184. * Gets the right camera target of a rig setup in case of Rigged Camera
  21185. * @returns the target position
  21186. */
  21187. Camera.prototype.getRightTarget = function () {
  21188. if (this._rigCameras.length < 2) {
  21189. return null;
  21190. }
  21191. return this._rigCameras[1].getTarget();
  21192. };
  21193. /**
  21194. * @hidden
  21195. */
  21196. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  21197. if (this.cameraRigMode === mode) {
  21198. return;
  21199. }
  21200. while (this._rigCameras.length > 0) {
  21201. var camera = this._rigCameras.pop();
  21202. if (camera) {
  21203. camera.dispose();
  21204. }
  21205. }
  21206. this.cameraRigMode = mode;
  21207. this._cameraRigParams = {};
  21208. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  21209. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  21210. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  21211. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  21212. // create the rig cameras, unless none
  21213. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21214. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  21215. if (leftCamera) {
  21216. leftCamera._isLeftCamera = true;
  21217. }
  21218. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  21219. if (rightCamera) {
  21220. rightCamera._isRightCamera = true;
  21221. }
  21222. if (leftCamera && rightCamera) {
  21223. this._rigCameras.push(leftCamera);
  21224. this._rigCameras.push(rightCamera);
  21225. }
  21226. }
  21227. switch (this.cameraRigMode) {
  21228. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21229. Camera._setStereoscopicAnaglyphRigMode(this);
  21230. break;
  21231. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21232. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21233. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21234. Camera._setStereoscopicRigMode(this);
  21235. break;
  21236. case Camera.RIG_MODE_VR:
  21237. Camera._setVRRigMode(this, rigParams);
  21238. break;
  21239. case Camera.RIG_MODE_WEBVR:
  21240. Camera._setWebVRRigMode(this, rigParams);
  21241. break;
  21242. }
  21243. this._cascadePostProcessesToRigCams();
  21244. this.update();
  21245. };
  21246. /** @hidden */
  21247. Camera._setStereoscopicRigMode = function (camera) {
  21248. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  21249. };
  21250. /** @hidden */
  21251. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  21252. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  21253. };
  21254. /** @hidden */
  21255. Camera._setVRRigMode = function (camera, rigParams) {
  21256. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  21257. };
  21258. /** @hidden */
  21259. Camera._setWebVRRigMode = function (camera, rigParams) {
  21260. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  21261. };
  21262. /** @hidden */
  21263. Camera.prototype._getVRProjectionMatrix = function () {
  21264. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  21265. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  21266. return this._projectionMatrix;
  21267. };
  21268. Camera.prototype._updateCameraRotationMatrix = function () {
  21269. //Here for WebVR
  21270. };
  21271. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  21272. //Here for WebVR
  21273. };
  21274. /**
  21275. * This function MUST be overwritten by the different WebVR cameras available.
  21276. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21277. * @hidden
  21278. */
  21279. Camera.prototype._getWebVRProjectionMatrix = function () {
  21280. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21281. };
  21282. /**
  21283. * This function MUST be overwritten by the different WebVR cameras available.
  21284. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21285. * @hidden
  21286. */
  21287. Camera.prototype._getWebVRViewMatrix = function () {
  21288. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21289. };
  21290. /** @hidden */
  21291. Camera.prototype.setCameraRigParameter = function (name, value) {
  21292. if (!this._cameraRigParams) {
  21293. this._cameraRigParams = {};
  21294. }
  21295. this._cameraRigParams[name] = value;
  21296. //provisionnally:
  21297. if (name === "interaxialDistance") {
  21298. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  21299. }
  21300. };
  21301. /**
  21302. * needs to be overridden by children so sub has required properties to be copied
  21303. * @hidden
  21304. */
  21305. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  21306. return null;
  21307. };
  21308. /**
  21309. * May need to be overridden by children
  21310. * @hidden
  21311. */
  21312. Camera.prototype._updateRigCameras = function () {
  21313. for (var i = 0; i < this._rigCameras.length; i++) {
  21314. this._rigCameras[i].minZ = this.minZ;
  21315. this._rigCameras[i].maxZ = this.maxZ;
  21316. this._rigCameras[i].fov = this.fov;
  21317. this._rigCameras[i].upVector.copyFrom(this.upVector);
  21318. }
  21319. // only update viewport when ANAGLYPH
  21320. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  21321. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  21322. }
  21323. };
  21324. /** @hidden */
  21325. Camera.prototype._setupInputs = function () {
  21326. };
  21327. /**
  21328. * Serialiaze the camera setup to a json represention
  21329. * @returns the JSON representation
  21330. */
  21331. Camera.prototype.serialize = function () {
  21332. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  21333. // Type
  21334. serializationObject.type = this.getClassName();
  21335. // Parent
  21336. if (this.parent) {
  21337. serializationObject.parentId = this.parent.id;
  21338. }
  21339. if (this.inputs) {
  21340. this.inputs.serialize(serializationObject);
  21341. }
  21342. // Animations
  21343. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  21344. serializationObject.ranges = this.serializeAnimationRanges();
  21345. return serializationObject;
  21346. };
  21347. /**
  21348. * Clones the current camera.
  21349. * @param name The cloned camera name
  21350. * @returns the cloned camera
  21351. */
  21352. Camera.prototype.clone = function (name) {
  21353. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  21354. };
  21355. /**
  21356. * Gets the direction of the camera relative to a given local axis.
  21357. * @param localAxis Defines the reference axis to provide a relative direction.
  21358. * @return the direction
  21359. */
  21360. Camera.prototype.getDirection = function (localAxis) {
  21361. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21362. this.getDirectionToRef(localAxis, result);
  21363. return result;
  21364. };
  21365. /**
  21366. * Gets the direction of the camera relative to a given local axis into a passed vector.
  21367. * @param localAxis Defines the reference axis to provide a relative direction.
  21368. * @param result Defines the vector to store the result in
  21369. */
  21370. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  21371. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  21372. };
  21373. /**
  21374. * Gets a camera constructor for a given camera type
  21375. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  21376. * @param name The name of the camera the result will be able to instantiate
  21377. * @param scene The scene the result will construct the camera in
  21378. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  21379. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  21380. * @returns a factory method to construc the camera
  21381. */
  21382. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  21383. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  21384. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  21385. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  21386. interaxial_distance: interaxial_distance,
  21387. isStereoscopicSideBySide: isStereoscopicSideBySide
  21388. });
  21389. if (constructorFunc) {
  21390. return constructorFunc;
  21391. }
  21392. // Default to universal camera
  21393. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  21394. };
  21395. /**
  21396. * Compute the world matrix of the camera.
  21397. * @returns the camera workd matrix
  21398. */
  21399. Camera.prototype.computeWorldMatrix = function () {
  21400. return this.getWorldMatrix();
  21401. };
  21402. /**
  21403. * Parse a JSON and creates the camera from the parsed information
  21404. * @param parsedCamera The JSON to parse
  21405. * @param scene The scene to instantiate the camera in
  21406. * @returns the newly constructed camera
  21407. */
  21408. Camera.Parse = function (parsedCamera, scene) {
  21409. var type = parsedCamera.type;
  21410. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  21411. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  21412. // Parent
  21413. if (parsedCamera.parentId) {
  21414. camera._waitingParentId = parsedCamera.parentId;
  21415. }
  21416. //If camera has an input manager, let it parse inputs settings
  21417. if (camera.inputs) {
  21418. camera.inputs.parse(parsedCamera);
  21419. camera._setupInputs();
  21420. }
  21421. if (camera.setPosition) { // need to force position
  21422. camera.position.copyFromFloats(0, 0, 0);
  21423. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  21424. }
  21425. // Target
  21426. if (parsedCamera.target) {
  21427. if (camera.setTarget) {
  21428. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  21429. }
  21430. }
  21431. // Apply 3d rig, when found
  21432. if (parsedCamera.cameraRigMode) {
  21433. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  21434. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  21435. }
  21436. // Animations
  21437. if (parsedCamera.animations) {
  21438. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  21439. var parsedAnimation = parsedCamera.animations[animationIndex];
  21440. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  21441. if (internalClass) {
  21442. camera.animations.push(internalClass.Parse(parsedAnimation));
  21443. }
  21444. }
  21445. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  21446. }
  21447. if (parsedCamera.autoAnimate) {
  21448. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  21449. }
  21450. return camera;
  21451. };
  21452. /** @hidden */
  21453. Camera._createDefaultParsedCamera = function (name, scene) {
  21454. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  21455. };
  21456. /**
  21457. * This is the default projection mode used by the cameras.
  21458. * It helps recreating a feeling of perspective and better appreciate depth.
  21459. * This is the best way to simulate real life cameras.
  21460. */
  21461. Camera.PERSPECTIVE_CAMERA = 0;
  21462. /**
  21463. * This helps creating camera with an orthographic mode.
  21464. * 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.
  21465. */
  21466. Camera.ORTHOGRAPHIC_CAMERA = 1;
  21467. /**
  21468. * This is the default FOV mode for perspective cameras.
  21469. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  21470. */
  21471. Camera.FOVMODE_VERTICAL_FIXED = 0;
  21472. /**
  21473. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  21474. */
  21475. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  21476. /**
  21477. * This specifies ther is no need for a camera rig.
  21478. * Basically only one eye is rendered corresponding to the camera.
  21479. */
  21480. Camera.RIG_MODE_NONE = 0;
  21481. /**
  21482. * Simulates a camera Rig with one blue eye and one red eye.
  21483. * This can be use with 3d blue and red glasses.
  21484. */
  21485. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  21486. /**
  21487. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  21488. */
  21489. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  21490. /**
  21491. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  21492. */
  21493. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  21494. /**
  21495. * Defines that both eyes of the camera will be rendered over under each other.
  21496. */
  21497. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  21498. /**
  21499. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  21500. */
  21501. Camera.RIG_MODE_VR = 20;
  21502. /**
  21503. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  21504. */
  21505. Camera.RIG_MODE_WEBVR = 21;
  21506. /**
  21507. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  21508. */
  21509. Camera.RIG_MODE_CUSTOM = 22;
  21510. /**
  21511. * Defines if by default attaching controls should prevent the default javascript event to continue.
  21512. */
  21513. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  21514. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21515. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  21516. ], Camera.prototype, "_position", void 0);
  21517. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21518. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21519. ], Camera.prototype, "upVector", void 0);
  21520. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21521. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21522. ], Camera.prototype, "orthoLeft", void 0);
  21523. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21524. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21525. ], Camera.prototype, "orthoRight", void 0);
  21526. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21527. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21528. ], Camera.prototype, "orthoBottom", void 0);
  21529. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21530. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21531. ], Camera.prototype, "orthoTop", void 0);
  21532. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21533. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21534. ], Camera.prototype, "fov", void 0);
  21535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21536. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21537. ], Camera.prototype, "minZ", void 0);
  21538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21540. ], Camera.prototype, "maxZ", void 0);
  21541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21543. ], Camera.prototype, "inertia", void 0);
  21544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21546. ], Camera.prototype, "mode", void 0);
  21547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21549. ], Camera.prototype, "layerMask", void 0);
  21550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21552. ], Camera.prototype, "fovMode", void 0);
  21553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21555. ], Camera.prototype, "cameraRigMode", void 0);
  21556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21558. ], Camera.prototype, "interaxialDistance", void 0);
  21559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21561. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21562. return Camera;
  21563. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21564. /***/ }),
  21565. /***/ "./Cameras/cameraInputsManager.ts":
  21566. /*!****************************************!*\
  21567. !*** ./Cameras/cameraInputsManager.ts ***!
  21568. \****************************************/
  21569. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21571. "use strict";
  21572. __webpack_require__.r(__webpack_exports__);
  21573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21575. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21576. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21577. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21578. /**
  21579. * @ignore
  21580. * This is a list of all the different input types that are available in the application.
  21581. * Fo instance: ArcRotateCameraGamepadInput...
  21582. */
  21583. var CameraInputTypes = {};
  21584. /**
  21585. * This represents the input manager used within a camera.
  21586. * It helps dealing with all the different kind of input attached to a camera.
  21587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21588. */
  21589. var CameraInputsManager = /** @class */ (function () {
  21590. /**
  21591. * Instantiate a new Camera Input Manager.
  21592. * @param camera Defines the camera the input manager blongs to
  21593. */
  21594. function CameraInputsManager(camera) {
  21595. this.attached = {};
  21596. this.camera = camera;
  21597. this.checkInputs = function () { };
  21598. }
  21599. /**
  21600. * Add an input method to a camera
  21601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21602. * @param input camera input method
  21603. */
  21604. CameraInputsManager.prototype.add = function (input) {
  21605. var type = input.getSimpleName();
  21606. if (this.attached[type]) {
  21607. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21608. return;
  21609. }
  21610. this.attached[type] = input;
  21611. input.camera = this.camera;
  21612. //for checkInputs, we are dynamically creating a function
  21613. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21614. if (input.checkInputs) {
  21615. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21616. }
  21617. if (this.attachedElement) {
  21618. input.attachControl(this.attachedElement);
  21619. }
  21620. };
  21621. /**
  21622. * Remove a specific input method from a camera
  21623. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21624. * @param inputToRemove camera input method
  21625. */
  21626. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21627. for (var cam in this.attached) {
  21628. var input = this.attached[cam];
  21629. if (input === inputToRemove) {
  21630. input.detachControl(this.attachedElement);
  21631. input.camera = null;
  21632. delete this.attached[cam];
  21633. this.rebuildInputCheck();
  21634. }
  21635. }
  21636. };
  21637. /**
  21638. * Remove a specific input type from a camera
  21639. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21640. * @param inputType the type of the input to remove
  21641. */
  21642. CameraInputsManager.prototype.removeByType = function (inputType) {
  21643. for (var cam in this.attached) {
  21644. var input = this.attached[cam];
  21645. if (input.getClassName() === inputType) {
  21646. input.detachControl(this.attachedElement);
  21647. input.camera = null;
  21648. delete this.attached[cam];
  21649. this.rebuildInputCheck();
  21650. }
  21651. }
  21652. };
  21653. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21654. var current = this.checkInputs;
  21655. return function () {
  21656. current();
  21657. fn();
  21658. };
  21659. };
  21660. /**
  21661. * Attach the input controls to the currently attached dom element to listen the events from.
  21662. * @param input Defines the input to attach
  21663. */
  21664. CameraInputsManager.prototype.attachInput = function (input) {
  21665. if (this.attachedElement) {
  21666. input.attachControl(this.attachedElement, this.noPreventDefault);
  21667. }
  21668. };
  21669. /**
  21670. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21671. * @param element Defines the dom element to collect the events from
  21672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21673. */
  21674. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21675. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21676. if (this.attachedElement) {
  21677. return;
  21678. }
  21679. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21680. this.attachedElement = element;
  21681. this.noPreventDefault = noPreventDefault;
  21682. for (var cam in this.attached) {
  21683. this.attached[cam].attachControl(element, noPreventDefault);
  21684. }
  21685. };
  21686. /**
  21687. * Detach the current manager inputs controls from a specific dom element.
  21688. * @param element Defines the dom element to collect the events from
  21689. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21690. */
  21691. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21692. if (disconnect === void 0) { disconnect = false; }
  21693. if (this.attachedElement !== element) {
  21694. return;
  21695. }
  21696. for (var cam in this.attached) {
  21697. this.attached[cam].detachControl(element);
  21698. if (disconnect) {
  21699. this.attached[cam].camera = null;
  21700. }
  21701. }
  21702. this.attachedElement = null;
  21703. };
  21704. /**
  21705. * Rebuild the dynamic inputCheck function from the current list of
  21706. * defined inputs in the manager.
  21707. */
  21708. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21709. this.checkInputs = function () { };
  21710. for (var cam in this.attached) {
  21711. var input = this.attached[cam];
  21712. if (input.checkInputs) {
  21713. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21714. }
  21715. }
  21716. };
  21717. /**
  21718. * Remove all attached input methods from a camera
  21719. */
  21720. CameraInputsManager.prototype.clear = function () {
  21721. if (this.attachedElement) {
  21722. this.detachElement(this.attachedElement, true);
  21723. }
  21724. this.attached = {};
  21725. this.attachedElement = null;
  21726. this.checkInputs = function () { };
  21727. };
  21728. /**
  21729. * Serialize the current input manager attached to a camera.
  21730. * This ensures than once parsed,
  21731. * the input associated to the camera will be identical to the current ones
  21732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21733. */
  21734. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21735. var inputs = {};
  21736. for (var cam in this.attached) {
  21737. var input = this.attached[cam];
  21738. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21739. inputs[input.getClassName()] = res;
  21740. }
  21741. serializedCamera.inputsmgr = inputs;
  21742. };
  21743. /**
  21744. * Parses an input manager serialized JSON to restore the previous list of inputs
  21745. * and states associated to a camera.
  21746. * @param parsedCamera Defines the JSON to parse
  21747. */
  21748. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21749. var parsedInputs = parsedCamera.inputsmgr;
  21750. if (parsedInputs) {
  21751. this.clear();
  21752. for (var n in parsedInputs) {
  21753. var construct = CameraInputTypes[n];
  21754. if (construct) {
  21755. var parsedinput = parsedInputs[n];
  21756. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21757. this.add(input);
  21758. }
  21759. }
  21760. }
  21761. else {
  21762. //2016-03-08 this part is for managing backward compatibility
  21763. for (var n in this.attached) {
  21764. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21765. if (construct) {
  21766. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21767. this.remove(this.attached[n]);
  21768. this.add(input);
  21769. }
  21770. }
  21771. }
  21772. };
  21773. return CameraInputsManager;
  21774. }());
  21775. /***/ }),
  21776. /***/ "./Cameras/deviceOrientationCamera.ts":
  21777. /*!********************************************!*\
  21778. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21779. \********************************************/
  21780. /*! exports provided: DeviceOrientationCamera */
  21781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21782. "use strict";
  21783. __webpack_require__.r(__webpack_exports__);
  21784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21785. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21786. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21787. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21788. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21789. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21790. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21791. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21792. });
  21793. // We're mainly based on the logic defined into the FreeCamera code
  21794. /**
  21795. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21796. * being tilted forward or back and left or right.
  21797. */
  21798. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21799. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21800. /**
  21801. * Creates a new device orientation camera
  21802. * @param name The name of the camera
  21803. * @param position The start position camera
  21804. * @param scene The scene the camera belongs to
  21805. */
  21806. function DeviceOrientationCamera(name, position, scene) {
  21807. var _this = _super.call(this, name, position, scene) || this;
  21808. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21809. _this.inputs.addDeviceOrientation();
  21810. return _this;
  21811. }
  21812. /**
  21813. * Gets the current instance class name ("DeviceOrientationCamera").
  21814. * This helps avoiding instanceof at run time.
  21815. * @returns the class name
  21816. */
  21817. DeviceOrientationCamera.prototype.getClassName = function () {
  21818. return "DeviceOrientationCamera";
  21819. };
  21820. /**
  21821. * @hidden
  21822. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21823. */
  21824. DeviceOrientationCamera.prototype._checkInputs = function () {
  21825. _super.prototype._checkInputs.call(this);
  21826. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21827. if (this._initialQuaternion) {
  21828. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21829. }
  21830. };
  21831. /**
  21832. * Reset the camera to its default orientation on the specified axis only.
  21833. * @param axis The axis to reset
  21834. */
  21835. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21836. var _this = this;
  21837. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21838. //can only work if this camera has a rotation quaternion already.
  21839. if (!this.rotationQuaternion) {
  21840. return;
  21841. }
  21842. if (!this._initialQuaternion) {
  21843. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21844. }
  21845. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21846. ['x', 'y', 'z'].forEach(function (axisName) {
  21847. if (!axis[axisName]) {
  21848. _this._initialQuaternion[axisName] = 0;
  21849. }
  21850. else {
  21851. _this._initialQuaternion[axisName] *= -1;
  21852. }
  21853. });
  21854. this._initialQuaternion.normalize();
  21855. //force rotation update
  21856. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21857. };
  21858. return DeviceOrientationCamera;
  21859. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21860. /***/ }),
  21861. /***/ "./Cameras/flyCamera.ts":
  21862. /*!******************************!*\
  21863. !*** ./Cameras/flyCamera.ts ***!
  21864. \******************************/
  21865. /*! exports provided: FlyCamera */
  21866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21867. "use strict";
  21868. __webpack_require__.r(__webpack_exports__);
  21869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21870. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21871. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21872. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21873. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21874. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21875. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21876. /**
  21877. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21878. * such as in a 3D Space Shooter or a Flight Simulator.
  21879. */
  21880. var FlyCamera = /** @class */ (function (_super) {
  21881. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21882. /**
  21883. * Instantiates a FlyCamera.
  21884. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21885. * such as in a 3D Space Shooter or a Flight Simulator.
  21886. * @param name Define the name of the camera in the scene.
  21887. * @param position Define the starting position of the camera in the scene.
  21888. * @param scene Define the scene the camera belongs to.
  21889. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21890. */
  21891. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21892. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21893. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21894. /**
  21895. * Define the collision ellipsoid of the camera.
  21896. * This is helpful for simulating a camera body, like a player's body.
  21897. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21898. */
  21899. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21900. /**
  21901. * Define an offset for the position of the ellipsoid around the camera.
  21902. * This can be helpful if the camera is attached away from the player's body center,
  21903. * such as at its head.
  21904. */
  21905. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21906. /**
  21907. * Enable or disable collisions of the camera with the rest of the scene objects.
  21908. */
  21909. _this.checkCollisions = false;
  21910. /**
  21911. * Enable or disable gravity on the camera.
  21912. */
  21913. _this.applyGravity = false;
  21914. /**
  21915. * Define the current direction the camera is moving to.
  21916. */
  21917. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21918. /**
  21919. * Track Roll to maintain the wanted Rolling when looking around.
  21920. */
  21921. _this._trackRoll = 0;
  21922. /**
  21923. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21924. */
  21925. _this.rollCorrect = 100;
  21926. /**
  21927. * Mimic a banked turn, Rolling the camera when Yawing.
  21928. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21929. */
  21930. _this.bankedTurn = false;
  21931. /**
  21932. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21933. */
  21934. _this.bankedTurnLimit = Math.PI / 2;
  21935. /**
  21936. * Value of 0 disables the banked Roll.
  21937. * Value of 1 is equal to the Yaw angle in radians.
  21938. */
  21939. _this.bankedTurnMultiplier = 1;
  21940. _this._needMoveForGravity = false;
  21941. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21942. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21943. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21944. // Collisions.
  21945. _this._collisionMask = -1;
  21946. /** @hidden */
  21947. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21948. if (collidedMesh === void 0) { collidedMesh = null; }
  21949. var updatePosition = function (newPos) {
  21950. _this._newPosition.copyFrom(newPos);
  21951. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21952. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21953. _this.position.addInPlace(_this._diffPosition);
  21954. if (_this.onCollide && collidedMesh) {
  21955. _this.onCollide(collidedMesh);
  21956. }
  21957. }
  21958. };
  21959. updatePosition(newPosition);
  21960. };
  21961. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21962. _this.inputs.addKeyboard().addMouse();
  21963. return _this;
  21964. }
  21965. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21966. /**
  21967. * Gets the input sensibility for mouse input.
  21968. * Higher values reduce sensitivity.
  21969. */
  21970. get: function () {
  21971. var mouse = this.inputs.attached["mouse"];
  21972. if (mouse) {
  21973. return mouse.angularSensibility;
  21974. }
  21975. return 0;
  21976. },
  21977. /**
  21978. * Sets the input sensibility for a mouse input.
  21979. * Higher values reduce sensitivity.
  21980. */
  21981. set: function (value) {
  21982. var mouse = this.inputs.attached["mouse"];
  21983. if (mouse) {
  21984. mouse.angularSensibility = value;
  21985. }
  21986. },
  21987. enumerable: true,
  21988. configurable: true
  21989. });
  21990. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21991. /**
  21992. * Get the keys for camera movement forward.
  21993. */
  21994. get: function () {
  21995. var keyboard = this.inputs.attached["keyboard"];
  21996. if (keyboard) {
  21997. return keyboard.keysForward;
  21998. }
  21999. return [];
  22000. },
  22001. /**
  22002. * Set the keys for camera movement forward.
  22003. */
  22004. set: function (value) {
  22005. var keyboard = this.inputs.attached["keyboard"];
  22006. if (keyboard) {
  22007. keyboard.keysForward = value;
  22008. }
  22009. },
  22010. enumerable: true,
  22011. configurable: true
  22012. });
  22013. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  22014. /**
  22015. * Get the keys for camera movement backward.
  22016. */
  22017. get: function () {
  22018. var keyboard = this.inputs.attached["keyboard"];
  22019. if (keyboard) {
  22020. return keyboard.keysBackward;
  22021. }
  22022. return [];
  22023. },
  22024. set: function (value) {
  22025. var keyboard = this.inputs.attached["keyboard"];
  22026. if (keyboard) {
  22027. keyboard.keysBackward = value;
  22028. }
  22029. },
  22030. enumerable: true,
  22031. configurable: true
  22032. });
  22033. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  22034. /**
  22035. * Get the keys for camera movement up.
  22036. */
  22037. get: function () {
  22038. var keyboard = this.inputs.attached["keyboard"];
  22039. if (keyboard) {
  22040. return keyboard.keysUp;
  22041. }
  22042. return [];
  22043. },
  22044. /**
  22045. * Set the keys for camera movement up.
  22046. */
  22047. set: function (value) {
  22048. var keyboard = this.inputs.attached["keyboard"];
  22049. if (keyboard) {
  22050. keyboard.keysUp = value;
  22051. }
  22052. },
  22053. enumerable: true,
  22054. configurable: true
  22055. });
  22056. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  22057. /**
  22058. * Get the keys for camera movement down.
  22059. */
  22060. get: function () {
  22061. var keyboard = this.inputs.attached["keyboard"];
  22062. if (keyboard) {
  22063. return keyboard.keysDown;
  22064. }
  22065. return [];
  22066. },
  22067. /**
  22068. * Set the keys for camera movement down.
  22069. */
  22070. set: function (value) {
  22071. var keyboard = this.inputs.attached["keyboard"];
  22072. if (keyboard) {
  22073. keyboard.keysDown = value;
  22074. }
  22075. },
  22076. enumerable: true,
  22077. configurable: true
  22078. });
  22079. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  22080. /**
  22081. * Get the keys for camera movement left.
  22082. */
  22083. get: function () {
  22084. var keyboard = this.inputs.attached["keyboard"];
  22085. if (keyboard) {
  22086. return keyboard.keysLeft;
  22087. }
  22088. return [];
  22089. },
  22090. /**
  22091. * Set the keys for camera movement left.
  22092. */
  22093. set: function (value) {
  22094. var keyboard = this.inputs.attached["keyboard"];
  22095. if (keyboard) {
  22096. keyboard.keysLeft = value;
  22097. }
  22098. },
  22099. enumerable: true,
  22100. configurable: true
  22101. });
  22102. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  22103. /**
  22104. * Set the keys for camera movement right.
  22105. */
  22106. get: function () {
  22107. var keyboard = this.inputs.attached["keyboard"];
  22108. if (keyboard) {
  22109. return keyboard.keysRight;
  22110. }
  22111. return [];
  22112. },
  22113. /**
  22114. * Set the keys for camera movement right.
  22115. */
  22116. set: function (value) {
  22117. var keyboard = this.inputs.attached["keyboard"];
  22118. if (keyboard) {
  22119. keyboard.keysRight = value;
  22120. }
  22121. },
  22122. enumerable: true,
  22123. configurable: true
  22124. });
  22125. /**
  22126. * Attach a control to the HTML DOM element.
  22127. * @param element Defines the element that listens to the input events.
  22128. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  22129. */
  22130. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  22131. this.inputs.attachElement(element, noPreventDefault);
  22132. };
  22133. /**
  22134. * Detach a control from the HTML DOM element.
  22135. * The camera will stop reacting to that input.
  22136. * @param element Defines the element that listens to the input events.
  22137. */
  22138. FlyCamera.prototype.detachControl = function (element) {
  22139. this.inputs.detachElement(element);
  22140. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22141. };
  22142. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  22143. /**
  22144. * Get the mask that the camera ignores in collision events.
  22145. */
  22146. get: function () {
  22147. return this._collisionMask;
  22148. },
  22149. /**
  22150. * Set the mask that the camera ignores in collision events.
  22151. */
  22152. set: function (mask) {
  22153. this._collisionMask = !isNaN(mask) ? mask : -1;
  22154. },
  22155. enumerable: true,
  22156. configurable: true
  22157. });
  22158. /** @hidden */
  22159. FlyCamera.prototype._collideWithWorld = function (displacement) {
  22160. var globalPosition;
  22161. if (this.parent) {
  22162. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22163. }
  22164. else {
  22165. globalPosition = this.position;
  22166. }
  22167. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22168. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22169. var coordinator = this.getScene().collisionCoordinator;
  22170. if (!this._collider) {
  22171. this._collider = coordinator.createCollider();
  22172. }
  22173. this._collider._radius = this.ellipsoid;
  22174. this._collider.collisionMask = this._collisionMask;
  22175. // No need for clone, as long as gravity is not on.
  22176. var actualDisplacement = displacement;
  22177. // Add gravity to direction to prevent dual-collision checking.
  22178. if (this.applyGravity) {
  22179. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  22180. actualDisplacement = displacement.add(this.getScene().gravity);
  22181. }
  22182. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22183. };
  22184. /** @hidden */
  22185. FlyCamera.prototype._checkInputs = function () {
  22186. if (!this._localDirection) {
  22187. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22188. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22189. }
  22190. this.inputs.checkInputs();
  22191. _super.prototype._checkInputs.call(this);
  22192. };
  22193. /** @hidden */
  22194. FlyCamera.prototype._decideIfNeedsToMove = function () {
  22195. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22196. };
  22197. /** @hidden */
  22198. FlyCamera.prototype._updatePosition = function () {
  22199. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22200. this._collideWithWorld(this.cameraDirection);
  22201. }
  22202. else {
  22203. _super.prototype._updatePosition.call(this);
  22204. }
  22205. };
  22206. /**
  22207. * Restore the Roll to its target value at the rate specified.
  22208. * @param rate - Higher means slower restoring.
  22209. * @hidden
  22210. */
  22211. FlyCamera.prototype.restoreRoll = function (rate) {
  22212. var limit = this._trackRoll; // Target Roll.
  22213. var z = this.rotation.z; // Current Roll.
  22214. var delta = limit - z; // Difference in Roll.
  22215. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  22216. // If the difference is noticable, restore the Roll.
  22217. if (Math.abs(delta) >= minRad) {
  22218. // Change Z rotation towards the target Roll.
  22219. this.rotation.z += delta / rate;
  22220. // Match when near enough.
  22221. if (Math.abs(limit - this.rotation.z) <= minRad) {
  22222. this.rotation.z = limit;
  22223. }
  22224. }
  22225. };
  22226. /**
  22227. * Destroy the camera and release the current resources held by it.
  22228. */
  22229. FlyCamera.prototype.dispose = function () {
  22230. this.inputs.clear();
  22231. _super.prototype.dispose.call(this);
  22232. };
  22233. /**
  22234. * Get the current object class name.
  22235. * @returns the class name.
  22236. */
  22237. FlyCamera.prototype.getClassName = function () {
  22238. return "FlyCamera";
  22239. };
  22240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22242. ], FlyCamera.prototype, "ellipsoid", void 0);
  22243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22245. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  22246. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22247. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22248. ], FlyCamera.prototype, "checkCollisions", void 0);
  22249. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22251. ], FlyCamera.prototype, "applyGravity", void 0);
  22252. return FlyCamera;
  22253. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22254. /***/ }),
  22255. /***/ "./Cameras/flyCameraInputsManager.ts":
  22256. /*!*******************************************!*\
  22257. !*** ./Cameras/flyCameraInputsManager.ts ***!
  22258. \*******************************************/
  22259. /*! exports provided: FlyCameraInputsManager */
  22260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22261. "use strict";
  22262. __webpack_require__.r(__webpack_exports__);
  22263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  22264. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22265. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22266. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  22267. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  22268. /**
  22269. * Default Inputs manager for the FlyCamera.
  22270. * It groups all the default supported inputs for ease of use.
  22271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22272. */
  22273. var FlyCameraInputsManager = /** @class */ (function (_super) {
  22274. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  22275. /**
  22276. * Instantiates a new FlyCameraInputsManager.
  22277. * @param camera Defines the camera the inputs belong to.
  22278. */
  22279. function FlyCameraInputsManager(camera) {
  22280. return _super.call(this, camera) || this;
  22281. }
  22282. /**
  22283. * Add keyboard input support to the input manager.
  22284. * @returns the new FlyCameraKeyboardMoveInput().
  22285. */
  22286. FlyCameraInputsManager.prototype.addKeyboard = function () {
  22287. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  22288. return this;
  22289. };
  22290. /**
  22291. * Add mouse input support to the input manager.
  22292. * @param touchEnabled Enable touch screen support.
  22293. * @returns the new FlyCameraMouseInput().
  22294. */
  22295. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22296. if (touchEnabled === void 0) { touchEnabled = true; }
  22297. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  22298. return this;
  22299. };
  22300. return FlyCameraInputsManager;
  22301. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22302. /***/ }),
  22303. /***/ "./Cameras/followCamera.ts":
  22304. /*!*********************************!*\
  22305. !*** ./Cameras/followCamera.ts ***!
  22306. \*********************************/
  22307. /*! exports provided: FollowCamera, ArcFollowCamera */
  22308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22309. "use strict";
  22310. __webpack_require__.r(__webpack_exports__);
  22311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  22312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  22313. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22314. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22315. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  22316. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22317. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22318. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  22319. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  22320. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  22321. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  22322. });
  22323. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  22324. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  22325. });
  22326. /**
  22327. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  22328. * an arc rotate version arcFollowCamera are available.
  22329. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22330. */
  22331. var FollowCamera = /** @class */ (function (_super) {
  22332. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  22333. /**
  22334. * Instantiates the follow camera.
  22335. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22336. * @param name Define the name of the camera in the scene
  22337. * @param position Define the position of the camera
  22338. * @param scene Define the scene the camera belong to
  22339. * @param lockedTarget Define the target of the camera
  22340. */
  22341. function FollowCamera(name, position, scene, lockedTarget) {
  22342. if (lockedTarget === void 0) { lockedTarget = null; }
  22343. var _this = _super.call(this, name, position, scene) || this;
  22344. /**
  22345. * Distance the follow camera should follow an object at
  22346. */
  22347. _this.radius = 12;
  22348. /**
  22349. * Minimum allowed distance of the camera to the axis of rotation
  22350. * (The camera can not get closer).
  22351. * This can help limiting how the Camera is able to move in the scene.
  22352. */
  22353. _this.lowerRadiusLimit = null;
  22354. /**
  22355. * Maximum allowed distance of the camera to the axis of rotation
  22356. * (The camera can not get further).
  22357. * This can help limiting how the Camera is able to move in the scene.
  22358. */
  22359. _this.upperRadiusLimit = null;
  22360. /**
  22361. * Define a rotation offset between the camera and the object it follows
  22362. */
  22363. _this.rotationOffset = 0;
  22364. /**
  22365. * Minimum allowed angle to camera position relative to target object.
  22366. * This can help limiting how the Camera is able to move in the scene.
  22367. */
  22368. _this.lowerRotationOffsetLimit = null;
  22369. /**
  22370. * Maximum allowed angle to camera position relative to target object.
  22371. * This can help limiting how the Camera is able to move in the scene.
  22372. */
  22373. _this.upperRotationOffsetLimit = null;
  22374. /**
  22375. * Define a height offset between the camera and the object it follows.
  22376. * It can help following an object from the top (like a car chaing a plane)
  22377. */
  22378. _this.heightOffset = 4;
  22379. /**
  22380. * Minimum allowed height of camera position relative to target object.
  22381. * This can help limiting how the Camera is able to move in the scene.
  22382. */
  22383. _this.lowerHeightOffsetLimit = null;
  22384. /**
  22385. * Maximum allowed height of camera position relative to target object.
  22386. * This can help limiting how the Camera is able to move in the scene.
  22387. */
  22388. _this.upperHeightOffsetLimit = null;
  22389. /**
  22390. * Define how fast the camera can accelerate to follow it s target.
  22391. */
  22392. _this.cameraAcceleration = 0.05;
  22393. /**
  22394. * Define the speed limit of the camera following an object.
  22395. */
  22396. _this.maxCameraSpeed = 20;
  22397. _this.lockedTarget = lockedTarget;
  22398. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  22399. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  22400. return _this;
  22401. // Uncomment the following line when the relevant handlers have been implemented.
  22402. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  22403. }
  22404. FollowCamera.prototype._follow = function (cameraTarget) {
  22405. if (!cameraTarget) {
  22406. return;
  22407. }
  22408. var yRotation;
  22409. if (cameraTarget.rotationQuaternion) {
  22410. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  22411. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  22412. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  22413. }
  22414. else {
  22415. yRotation = cameraTarget.rotation.y;
  22416. }
  22417. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  22418. var targetPosition = cameraTarget.getAbsolutePosition();
  22419. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  22420. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  22421. var dx = targetX - this.position.x;
  22422. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  22423. var dz = (targetZ) - this.position.z;
  22424. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  22425. var vy = dy * this.cameraAcceleration;
  22426. var vz = dz * this.cameraAcceleration * 2;
  22427. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  22428. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22429. }
  22430. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  22431. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22432. }
  22433. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  22434. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22435. }
  22436. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  22437. this.setTarget(targetPosition);
  22438. };
  22439. /**
  22440. * Attached controls to the current camera.
  22441. * @param element Defines the element the controls should be listened from
  22442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22443. */
  22444. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  22445. this.inputs.attachElement(element, noPreventDefault);
  22446. this._reset = function () {
  22447. };
  22448. };
  22449. /**
  22450. * Detach the current controls from the camera.
  22451. * The camera will stop reacting to inputs.
  22452. * @param element Defines the element to stop listening the inputs from
  22453. */
  22454. FollowCamera.prototype.detachControl = function (element) {
  22455. this.inputs.detachElement(element);
  22456. if (this._reset) {
  22457. this._reset();
  22458. }
  22459. };
  22460. /** @hidden */
  22461. FollowCamera.prototype._checkInputs = function () {
  22462. this.inputs.checkInputs();
  22463. this._checkLimits();
  22464. _super.prototype._checkInputs.call(this);
  22465. if (this.lockedTarget) {
  22466. this._follow(this.lockedTarget);
  22467. }
  22468. };
  22469. FollowCamera.prototype._checkLimits = function () {
  22470. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  22471. this.radius = this.lowerRadiusLimit;
  22472. }
  22473. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  22474. this.radius = this.upperRadiusLimit;
  22475. }
  22476. if (this.lowerHeightOffsetLimit !== null &&
  22477. this.heightOffset < this.lowerHeightOffsetLimit) {
  22478. this.heightOffset = this.lowerHeightOffsetLimit;
  22479. }
  22480. if (this.upperHeightOffsetLimit !== null &&
  22481. this.heightOffset > this.upperHeightOffsetLimit) {
  22482. this.heightOffset = this.upperHeightOffsetLimit;
  22483. }
  22484. if (this.lowerRotationOffsetLimit !== null &&
  22485. this.rotationOffset < this.lowerRotationOffsetLimit) {
  22486. this.rotationOffset = this.lowerRotationOffsetLimit;
  22487. }
  22488. if (this.upperRotationOffsetLimit !== null &&
  22489. this.rotationOffset > this.upperRotationOffsetLimit) {
  22490. this.rotationOffset = this.upperRotationOffsetLimit;
  22491. }
  22492. };
  22493. /**
  22494. * Gets the camera class name.
  22495. * @returns the class name
  22496. */
  22497. FollowCamera.prototype.getClassName = function () {
  22498. return "FollowCamera";
  22499. };
  22500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22502. ], FollowCamera.prototype, "radius", void 0);
  22503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22505. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  22506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22508. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  22509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22511. ], FollowCamera.prototype, "rotationOffset", void 0);
  22512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22514. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  22515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22517. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  22518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22520. ], FollowCamera.prototype, "heightOffset", void 0);
  22521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22523. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  22524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22526. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  22527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22529. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  22530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22532. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  22533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22535. ], FollowCamera.prototype, "lockedTarget", void 0);
  22536. return FollowCamera;
  22537. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22538. /**
  22539. * Arc Rotate version of the follow camera.
  22540. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  22541. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22542. */
  22543. var ArcFollowCamera = /** @class */ (function (_super) {
  22544. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  22545. /**
  22546. * Instantiates a new ArcFollowCamera
  22547. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22548. * @param name Define the name of the camera
  22549. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  22550. * @param beta Define the rotation angle of the camera around the elevation axis
  22551. * @param radius Define the radius of the camera from its target point
  22552. * @param target Define the target of the camera
  22553. * @param scene Define the scene the camera belongs to
  22554. */
  22555. function ArcFollowCamera(name,
  22556. /** The longitudinal angle of the camera */
  22557. alpha,
  22558. /** The latitudinal angle of the camera */
  22559. beta,
  22560. /** The radius of the camera from its target */
  22561. radius,
  22562. /** Define the camera target (the messh it should follow) */
  22563. target, scene) {
  22564. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22565. _this.alpha = alpha;
  22566. _this.beta = beta;
  22567. _this.radius = radius;
  22568. _this.target = target;
  22569. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22570. _this._follow();
  22571. return _this;
  22572. }
  22573. ArcFollowCamera.prototype._follow = function () {
  22574. if (!this.target) {
  22575. return;
  22576. }
  22577. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22578. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22579. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22580. var targetPosition = this.target.getAbsolutePosition();
  22581. this.position = targetPosition.add(this._cartesianCoordinates);
  22582. this.setTarget(targetPosition);
  22583. };
  22584. /** @hidden */
  22585. ArcFollowCamera.prototype._checkInputs = function () {
  22586. _super.prototype._checkInputs.call(this);
  22587. this._follow();
  22588. };
  22589. /**
  22590. * Returns the class name of the object.
  22591. * It is mostly used internally for serialization purposes.
  22592. */
  22593. ArcFollowCamera.prototype.getClassName = function () {
  22594. return "ArcFollowCamera";
  22595. };
  22596. return ArcFollowCamera;
  22597. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22598. /***/ }),
  22599. /***/ "./Cameras/followCameraInputsManager.ts":
  22600. /*!**********************************************!*\
  22601. !*** ./Cameras/followCameraInputsManager.ts ***!
  22602. \**********************************************/
  22603. /*! exports provided: FollowCameraInputsManager */
  22604. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22605. "use strict";
  22606. __webpack_require__.r(__webpack_exports__);
  22607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22608. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22609. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22610. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22611. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22612. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  22613. /**
  22614. * Default Inputs manager for the FollowCamera.
  22615. * It groups all the default supported inputs for ease of use.
  22616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22617. */
  22618. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22619. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22620. /**
  22621. * Instantiates a new FollowCameraInputsManager.
  22622. * @param camera Defines the camera the inputs belong to
  22623. */
  22624. function FollowCameraInputsManager(camera) {
  22625. return _super.call(this, camera) || this;
  22626. }
  22627. /**
  22628. * Add keyboard input support to the input manager.
  22629. * @returns the current input manager
  22630. */
  22631. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22632. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22633. return this;
  22634. };
  22635. /**
  22636. * Add mouse wheel input support to the input manager.
  22637. * @returns the current input manager
  22638. */
  22639. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22640. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22641. return this;
  22642. };
  22643. /**
  22644. * Add pointers input support to the input manager.
  22645. * @returns the current input manager
  22646. */
  22647. FollowCameraInputsManager.prototype.addPointers = function () {
  22648. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  22649. return this;
  22650. };
  22651. /**
  22652. * Add orientation input support to the input manager.
  22653. * @returns the current input manager
  22654. */
  22655. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22656. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22657. return this;
  22658. };
  22659. return FollowCameraInputsManager;
  22660. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22661. /***/ }),
  22662. /***/ "./Cameras/freeCamera.ts":
  22663. /*!*******************************!*\
  22664. !*** ./Cameras/freeCamera.ts ***!
  22665. \*******************************/
  22666. /*! exports provided: FreeCamera */
  22667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22668. "use strict";
  22669. __webpack_require__.r(__webpack_exports__);
  22670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22672. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22673. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22674. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22675. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22676. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22677. /**
  22678. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22679. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22680. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22681. */
  22682. var FreeCamera = /** @class */ (function (_super) {
  22683. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22684. /**
  22685. * Instantiates a Free Camera.
  22686. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22687. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22688. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22689. * @param name Define the name of the camera in the scene
  22690. * @param position Define the start position of the camera in the scene
  22691. * @param scene Define the scene the camera belongs to
  22692. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22693. */
  22694. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22695. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22696. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22697. /**
  22698. * Define the collision ellipsoid of the camera.
  22699. * This is helpful to simulate a camera body like the player body around the camera
  22700. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22701. */
  22702. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22703. /**
  22704. * Define an offset for the position of the ellipsoid around the camera.
  22705. * This can be helpful to determine the center of the body near the gravity center of the body
  22706. * instead of its head.
  22707. */
  22708. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22709. /**
  22710. * Enable or disable collisions of the camera with the rest of the scene objects.
  22711. */
  22712. _this.checkCollisions = false;
  22713. /**
  22714. * Enable or disable gravity on the camera.
  22715. */
  22716. _this.applyGravity = false;
  22717. _this._needMoveForGravity = false;
  22718. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22719. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22720. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22721. // Collisions
  22722. _this._collisionMask = -1;
  22723. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22724. if (collidedMesh === void 0) { collidedMesh = null; }
  22725. var updatePosition = function (newPos) {
  22726. _this._newPosition.copyFrom(newPos);
  22727. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22728. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22729. _this.position.addInPlace(_this._diffPosition);
  22730. if (_this.onCollide && collidedMesh) {
  22731. _this.onCollide(collidedMesh);
  22732. }
  22733. }
  22734. };
  22735. updatePosition(newPosition);
  22736. };
  22737. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22738. _this.inputs.addKeyboard().addMouse();
  22739. return _this;
  22740. }
  22741. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22742. /**
  22743. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22744. * Higher values reduce sensitivity.
  22745. */
  22746. get: function () {
  22747. var mouse = this.inputs.attached["mouse"];
  22748. if (mouse) {
  22749. return mouse.angularSensibility;
  22750. }
  22751. return 0;
  22752. },
  22753. /**
  22754. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22755. * Higher values reduce sensitivity.
  22756. */
  22757. set: function (value) {
  22758. var mouse = this.inputs.attached["mouse"];
  22759. if (mouse) {
  22760. mouse.angularSensibility = value;
  22761. }
  22762. },
  22763. enumerable: true,
  22764. configurable: true
  22765. });
  22766. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22767. /**
  22768. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22769. */
  22770. get: function () {
  22771. var keyboard = this.inputs.attached["keyboard"];
  22772. if (keyboard) {
  22773. return keyboard.keysUp;
  22774. }
  22775. return [];
  22776. },
  22777. set: function (value) {
  22778. var keyboard = this.inputs.attached["keyboard"];
  22779. if (keyboard) {
  22780. keyboard.keysUp = value;
  22781. }
  22782. },
  22783. enumerable: true,
  22784. configurable: true
  22785. });
  22786. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22787. /**
  22788. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22789. */
  22790. get: function () {
  22791. var keyboard = this.inputs.attached["keyboard"];
  22792. if (keyboard) {
  22793. return keyboard.keysDown;
  22794. }
  22795. return [];
  22796. },
  22797. set: function (value) {
  22798. var keyboard = this.inputs.attached["keyboard"];
  22799. if (keyboard) {
  22800. keyboard.keysDown = value;
  22801. }
  22802. },
  22803. enumerable: true,
  22804. configurable: true
  22805. });
  22806. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22807. /**
  22808. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22809. */
  22810. get: function () {
  22811. var keyboard = this.inputs.attached["keyboard"];
  22812. if (keyboard) {
  22813. return keyboard.keysLeft;
  22814. }
  22815. return [];
  22816. },
  22817. set: function (value) {
  22818. var keyboard = this.inputs.attached["keyboard"];
  22819. if (keyboard) {
  22820. keyboard.keysLeft = value;
  22821. }
  22822. },
  22823. enumerable: true,
  22824. configurable: true
  22825. });
  22826. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22827. /**
  22828. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22829. */
  22830. get: function () {
  22831. var keyboard = this.inputs.attached["keyboard"];
  22832. if (keyboard) {
  22833. return keyboard.keysRight;
  22834. }
  22835. return [];
  22836. },
  22837. set: function (value) {
  22838. var keyboard = this.inputs.attached["keyboard"];
  22839. if (keyboard) {
  22840. keyboard.keysRight = value;
  22841. }
  22842. },
  22843. enumerable: true,
  22844. configurable: true
  22845. });
  22846. /**
  22847. * Attached controls to the current camera.
  22848. * @param element Defines the element the controls should be listened from
  22849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22850. */
  22851. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22852. this.inputs.attachElement(element, noPreventDefault);
  22853. };
  22854. /**
  22855. * Detach the current controls from the camera.
  22856. * The camera will stop reacting to inputs.
  22857. * @param element Defines the element to stop listening the inputs from
  22858. */
  22859. FreeCamera.prototype.detachControl = function (element) {
  22860. this.inputs.detachElement(element);
  22861. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22862. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22863. };
  22864. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22865. /**
  22866. * Define a collision mask to limit the list of object the camera can collide with
  22867. */
  22868. get: function () {
  22869. return this._collisionMask;
  22870. },
  22871. set: function (mask) {
  22872. this._collisionMask = !isNaN(mask) ? mask : -1;
  22873. },
  22874. enumerable: true,
  22875. configurable: true
  22876. });
  22877. /** @hidden */
  22878. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22879. var globalPosition;
  22880. if (this.parent) {
  22881. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22882. }
  22883. else {
  22884. globalPosition = this.position;
  22885. }
  22886. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22887. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22888. var coordinator = this.getScene().collisionCoordinator;
  22889. if (!this._collider) {
  22890. this._collider = coordinator.createCollider();
  22891. }
  22892. this._collider._radius = this.ellipsoid;
  22893. this._collider.collisionMask = this._collisionMask;
  22894. //no need for clone, as long as gravity is not on.
  22895. var actualDisplacement = displacement;
  22896. //add gravity to the direction to prevent the dual-collision checking
  22897. if (this.applyGravity) {
  22898. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22899. actualDisplacement = displacement.add(this.getScene().gravity);
  22900. }
  22901. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22902. };
  22903. /** @hidden */
  22904. FreeCamera.prototype._checkInputs = function () {
  22905. if (!this._localDirection) {
  22906. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22907. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22908. }
  22909. this.inputs.checkInputs();
  22910. _super.prototype._checkInputs.call(this);
  22911. };
  22912. /** @hidden */
  22913. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22914. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22915. };
  22916. /** @hidden */
  22917. FreeCamera.prototype._updatePosition = function () {
  22918. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22919. this._collideWithWorld(this.cameraDirection);
  22920. }
  22921. else {
  22922. _super.prototype._updatePosition.call(this);
  22923. }
  22924. };
  22925. /**
  22926. * Destroy the camera and release the current resources hold by it.
  22927. */
  22928. FreeCamera.prototype.dispose = function () {
  22929. this.inputs.clear();
  22930. _super.prototype.dispose.call(this);
  22931. };
  22932. /**
  22933. * Gets the current object class name.
  22934. * @return the class name
  22935. */
  22936. FreeCamera.prototype.getClassName = function () {
  22937. return "FreeCamera";
  22938. };
  22939. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22941. ], FreeCamera.prototype, "ellipsoid", void 0);
  22942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22944. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22945. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22947. ], FreeCamera.prototype, "checkCollisions", void 0);
  22948. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22949. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22950. ], FreeCamera.prototype, "applyGravity", void 0);
  22951. return FreeCamera;
  22952. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22953. /***/ }),
  22954. /***/ "./Cameras/freeCameraInputsManager.ts":
  22955. /*!********************************************!*\
  22956. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22957. \********************************************/
  22958. /*! exports provided: FreeCameraInputsManager */
  22959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22960. "use strict";
  22961. __webpack_require__.r(__webpack_exports__);
  22962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22963. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22964. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22965. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22966. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22967. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22968. /**
  22969. * Default Inputs manager for the FreeCamera.
  22970. * It groups all the default supported inputs for ease of use.
  22971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22972. */
  22973. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22975. /**
  22976. * Instantiates a new FreeCameraInputsManager.
  22977. * @param camera Defines the camera the inputs belong to
  22978. */
  22979. function FreeCameraInputsManager(camera) {
  22980. return _super.call(this, camera) || this;
  22981. }
  22982. /**
  22983. * Add keyboard input support to the input manager.
  22984. * @returns the current input manager
  22985. */
  22986. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22987. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22988. return this;
  22989. };
  22990. /**
  22991. * Add mouse input support to the input manager.
  22992. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22993. * @returns the current input manager
  22994. */
  22995. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22996. if (touchEnabled === void 0) { touchEnabled = true; }
  22997. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22998. return this;
  22999. };
  23000. /**
  23001. * Add touch input support to the input manager.
  23002. * @returns the current input manager
  23003. */
  23004. FreeCameraInputsManager.prototype.addTouch = function () {
  23005. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  23006. return this;
  23007. };
  23008. return FreeCameraInputsManager;
  23009. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  23010. /***/ }),
  23011. /***/ "./Cameras/gamepadCamera.ts":
  23012. /*!**********************************!*\
  23013. !*** ./Cameras/gamepadCamera.ts ***!
  23014. \**********************************/
  23015. /*! exports provided: GamepadCamera */
  23016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23017. "use strict";
  23018. __webpack_require__.r(__webpack_exports__);
  23019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  23020. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23021. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23022. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23023. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23024. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  23025. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23026. });
  23027. /**
  23028. * This represents a FPS type of camera. This is only here for back compat purpose.
  23029. * Please use the UniversalCamera instead as both are identical.
  23030. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23031. */
  23032. var GamepadCamera = /** @class */ (function (_super) {
  23033. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  23034. /**
  23035. * Instantiates a new Gamepad Camera
  23036. * This represents a FPS type of camera. This is only here for back compat purpose.
  23037. * Please use the UniversalCamera instead as both are identical.
  23038. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23039. * @param name Define the name of the camera in the scene
  23040. * @param position Define the start position of the camera in the scene
  23041. * @param scene Define the scene the camera belongs to
  23042. */
  23043. function GamepadCamera(name, position, scene) {
  23044. return _super.call(this, name, position, scene) || this;
  23045. }
  23046. /**
  23047. * Gets the current object class name.
  23048. * @return the class name
  23049. */
  23050. GamepadCamera.prototype.getClassName = function () {
  23051. return "GamepadCamera";
  23052. };
  23053. return GamepadCamera;
  23054. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  23055. /***/ }),
  23056. /***/ "./Cameras/index.ts":
  23057. /*!**************************!*\
  23058. !*** ./Cameras/index.ts ***!
  23059. \**************************/
  23060. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  23061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23062. "use strict";
  23063. __webpack_require__.r(__webpack_exports__);
  23064. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  23065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  23066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  23067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  23068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  23069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  23070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  23071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  23072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  23073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  23074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  23075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  23076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  23077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  23078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  23079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  23080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  23081. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  23083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  23084. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  23086. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  23088. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  23090. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  23091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  23092. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  23094. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  23095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  23096. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  23097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  23098. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  23099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  23100. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  23101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  23102. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  23103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  23104. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  23105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  23106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  23107. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  23108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  23109. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  23110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  23111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  23112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  23113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  23114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  23115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  23116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  23117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  23118. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  23120. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  23121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  23122. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  23123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  23124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  23125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  23126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  23127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  23128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  23129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  23130. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  23131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  23132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  23133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  23134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  23135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  23136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  23137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  23138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  23139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  23140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  23141. /***/ }),
  23142. /***/ "./Cameras/targetCamera.ts":
  23143. /*!*********************************!*\
  23144. !*** ./Cameras/targetCamera.ts ***!
  23145. \*********************************/
  23146. /*! exports provided: TargetCamera */
  23147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23148. "use strict";
  23149. __webpack_require__.r(__webpack_exports__);
  23150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  23151. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23152. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23153. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23154. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23155. /**
  23156. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  23157. * This is the base of the follow, arc rotate cameras and Free camera
  23158. * @see http://doc.babylonjs.com/features/cameras
  23159. */
  23160. var TargetCamera = /** @class */ (function (_super) {
  23161. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  23162. /**
  23163. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  23164. * This is the base of the follow, arc rotate cameras and Free camera
  23165. * @see http://doc.babylonjs.com/features/cameras
  23166. * @param name Defines the name of the camera in the scene
  23167. * @param position Defines the start position of the camera in the scene
  23168. * @param scene Defines the scene the camera belongs to
  23169. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23170. */
  23171. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23172. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23173. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23174. /**
  23175. * Define the current direction the camera is moving to
  23176. */
  23177. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23178. /**
  23179. * Define the current rotation the camera is rotating to
  23180. */
  23181. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  23182. /**
  23183. * When set, the up vector of the camera will be updated by the rotation of the camera
  23184. */
  23185. _this.updateUpVectorFromRotation = false;
  23186. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23187. /**
  23188. * Define the current rotation of the camera
  23189. */
  23190. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23191. /**
  23192. * Define the current speed of the camera
  23193. */
  23194. _this.speed = 2.0;
  23195. /**
  23196. * Add cconstraint to the camera to prevent it to move freely in all directions and
  23197. * around all axis.
  23198. */
  23199. _this.noRotationConstraint = false;
  23200. /**
  23201. * Define the current target of the camera as an object or a position.
  23202. */
  23203. _this.lockedTarget = null;
  23204. /** @hidden */
  23205. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23206. /** @hidden */
  23207. _this._initialFocalDistance = 1;
  23208. /** @hidden */
  23209. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23210. /** @hidden */
  23211. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23212. /** @hidden */
  23213. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23214. /** @hidden */
  23215. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23216. /** @hidden */
  23217. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  23218. /** @hidden */
  23219. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23220. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23221. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23222. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  23223. _this._cachedRotationZ = 0;
  23224. _this._cachedQuaternionRotationZ = 0;
  23225. return _this;
  23226. }
  23227. /**
  23228. * Gets the position in front of the camera at a given distance.
  23229. * @param distance The distance from the camera we want the position to be
  23230. * @returns the position
  23231. */
  23232. TargetCamera.prototype.getFrontPosition = function (distance) {
  23233. this.getWorldMatrix();
  23234. var direction = this.getTarget().subtract(this.position);
  23235. direction.normalize();
  23236. direction.scaleInPlace(distance);
  23237. return this.globalPosition.add(direction);
  23238. };
  23239. /** @hidden */
  23240. TargetCamera.prototype._getLockedTargetPosition = function () {
  23241. if (!this.lockedTarget) {
  23242. return null;
  23243. }
  23244. if (this.lockedTarget.absolutePosition) {
  23245. this.lockedTarget.computeWorldMatrix();
  23246. }
  23247. return this.lockedTarget.absolutePosition || this.lockedTarget;
  23248. };
  23249. /**
  23250. * Store current camera state of the camera (fov, position, rotation, etc..)
  23251. * @returns the camera
  23252. */
  23253. TargetCamera.prototype.storeState = function () {
  23254. this._storedPosition = this.position.clone();
  23255. this._storedRotation = this.rotation.clone();
  23256. if (this.rotationQuaternion) {
  23257. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  23258. }
  23259. return _super.prototype.storeState.call(this);
  23260. };
  23261. /**
  23262. * Restored camera state. You must call storeState() first
  23263. * @returns whether it was successful or not
  23264. * @hidden
  23265. */
  23266. TargetCamera.prototype._restoreStateValues = function () {
  23267. if (!_super.prototype._restoreStateValues.call(this)) {
  23268. return false;
  23269. }
  23270. this.position = this._storedPosition.clone();
  23271. this.rotation = this._storedRotation.clone();
  23272. if (this.rotationQuaternion) {
  23273. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  23274. }
  23275. this.cameraDirection.copyFromFloats(0, 0, 0);
  23276. this.cameraRotation.copyFromFloats(0, 0);
  23277. return true;
  23278. };
  23279. /** @hidden */
  23280. TargetCamera.prototype._initCache = function () {
  23281. _super.prototype._initCache.call(this);
  23282. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23283. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23284. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23285. };
  23286. /** @hidden */
  23287. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  23288. if (!ignoreParentClass) {
  23289. _super.prototype._updateCache.call(this);
  23290. }
  23291. var lockedTargetPosition = this._getLockedTargetPosition();
  23292. if (!lockedTargetPosition) {
  23293. this._cache.lockedTarget = null;
  23294. }
  23295. else {
  23296. if (!this._cache.lockedTarget) {
  23297. this._cache.lockedTarget = lockedTargetPosition.clone();
  23298. }
  23299. else {
  23300. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  23301. }
  23302. }
  23303. this._cache.rotation.copyFrom(this.rotation);
  23304. if (this.rotationQuaternion) {
  23305. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23306. }
  23307. };
  23308. // Synchronized
  23309. /** @hidden */
  23310. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  23311. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  23312. return false;
  23313. }
  23314. var lockedTargetPosition = this._getLockedTargetPosition();
  23315. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  23316. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  23317. };
  23318. // Methods
  23319. /** @hidden */
  23320. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  23321. var engine = this.getEngine();
  23322. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  23323. };
  23324. // Target
  23325. /**
  23326. * Defines the target the camera should look at.
  23327. * This will automatically adapt alpha beta and radius to fit within the new target.
  23328. * @param target Defines the new target as a Vector or a mesh
  23329. */
  23330. TargetCamera.prototype.setTarget = function (target) {
  23331. this.upVector.normalize();
  23332. this._initialFocalDistance = target.subtract(this.position).length();
  23333. if (this.position.z === target.z) {
  23334. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  23335. }
  23336. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  23337. this._camMatrix.invert();
  23338. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  23339. var vDir = target.subtract(this.position);
  23340. if (vDir.x >= 0.0) {
  23341. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  23342. }
  23343. else {
  23344. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  23345. }
  23346. this.rotation.z = 0;
  23347. if (isNaN(this.rotation.x)) {
  23348. this.rotation.x = 0;
  23349. }
  23350. if (isNaN(this.rotation.y)) {
  23351. this.rotation.y = 0;
  23352. }
  23353. if (isNaN(this.rotation.z)) {
  23354. this.rotation.z = 0;
  23355. }
  23356. if (this.rotationQuaternion) {
  23357. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23358. }
  23359. };
  23360. /**
  23361. * Return the current target position of the camera. This value is expressed in local space.
  23362. * @returns the target position
  23363. */
  23364. TargetCamera.prototype.getTarget = function () {
  23365. return this._currentTarget;
  23366. };
  23367. /** @hidden */
  23368. TargetCamera.prototype._decideIfNeedsToMove = function () {
  23369. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23370. };
  23371. /** @hidden */
  23372. TargetCamera.prototype._updatePosition = function () {
  23373. if (this.parent) {
  23374. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  23375. _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]);
  23376. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23377. return;
  23378. }
  23379. this.position.addInPlace(this.cameraDirection);
  23380. };
  23381. /** @hidden */
  23382. TargetCamera.prototype._checkInputs = function () {
  23383. var needToMove = this._decideIfNeedsToMove();
  23384. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  23385. // Move
  23386. if (needToMove) {
  23387. this._updatePosition();
  23388. }
  23389. // Rotate
  23390. if (needToRotate) {
  23391. this.rotation.x += this.cameraRotation.x;
  23392. this.rotation.y += this.cameraRotation.y;
  23393. //rotate, if quaternion is set and rotation was used
  23394. if (this.rotationQuaternion) {
  23395. var len = this.rotation.lengthSquared();
  23396. if (len) {
  23397. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23398. }
  23399. }
  23400. if (!this.noRotationConstraint) {
  23401. var limit = (Math.PI / 2) * 0.95;
  23402. if (this.rotation.x > limit) {
  23403. this.rotation.x = limit;
  23404. }
  23405. if (this.rotation.x < -limit) {
  23406. this.rotation.x = -limit;
  23407. }
  23408. }
  23409. }
  23410. // Inertia
  23411. if (needToMove) {
  23412. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23413. this.cameraDirection.x = 0;
  23414. }
  23415. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23416. this.cameraDirection.y = 0;
  23417. }
  23418. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23419. this.cameraDirection.z = 0;
  23420. }
  23421. this.cameraDirection.scaleInPlace(this.inertia);
  23422. }
  23423. if (needToRotate) {
  23424. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23425. this.cameraRotation.x = 0;
  23426. }
  23427. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23428. this.cameraRotation.y = 0;
  23429. }
  23430. this.cameraRotation.scaleInPlace(this.inertia);
  23431. }
  23432. _super.prototype._checkInputs.call(this);
  23433. };
  23434. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  23435. if (this.rotationQuaternion) {
  23436. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  23437. }
  23438. else {
  23439. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  23440. }
  23441. };
  23442. /**
  23443. * 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)
  23444. * @returns the current camera
  23445. */
  23446. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  23447. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  23448. return this;
  23449. };
  23450. /** @hidden */
  23451. TargetCamera.prototype._getViewMatrix = function () {
  23452. if (this.lockedTarget) {
  23453. this.setTarget(this._getLockedTargetPosition());
  23454. }
  23455. // Compute
  23456. this._updateCameraRotationMatrix();
  23457. // Apply the changed rotation to the upVector
  23458. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  23459. this._rotateUpVectorWithCameraRotationMatrix();
  23460. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  23461. }
  23462. else if (this._cachedRotationZ != this.rotation.z) {
  23463. this._rotateUpVectorWithCameraRotationMatrix();
  23464. this._cachedRotationZ = this.rotation.z;
  23465. }
  23466. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  23467. // Computing target and final matrix
  23468. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  23469. if (this.updateUpVectorFromRotation) {
  23470. if (this.rotationQuaternion) {
  23471. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  23472. }
  23473. else {
  23474. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  23475. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  23476. }
  23477. }
  23478. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  23479. return this._viewMatrix;
  23480. };
  23481. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  23482. if (this.parent) {
  23483. var parentWorldMatrix = this.parent.getWorldMatrix();
  23484. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  23485. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  23486. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  23487. this._markSyncedWithParent();
  23488. }
  23489. else {
  23490. this._globalPosition.copyFrom(position);
  23491. this._globalCurrentTarget.copyFrom(target);
  23492. this._globalCurrentUpVector.copyFrom(up);
  23493. }
  23494. if (this.getScene().useRightHandedSystem) {
  23495. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23496. }
  23497. else {
  23498. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23499. }
  23500. };
  23501. /**
  23502. * @hidden
  23503. */
  23504. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  23505. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  23506. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  23507. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  23508. if (!this.rotationQuaternion) {
  23509. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23510. }
  23511. rigCamera._cameraRigParams = {};
  23512. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23513. }
  23514. return rigCamera;
  23515. }
  23516. return null;
  23517. };
  23518. /**
  23519. * @hidden
  23520. */
  23521. TargetCamera.prototype._updateRigCameras = function () {
  23522. var camLeft = this._rigCameras[0];
  23523. var camRight = this._rigCameras[1];
  23524. this.computeWorldMatrix();
  23525. switch (this.cameraRigMode) {
  23526. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  23527. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  23528. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  23529. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  23530. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  23531. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  23532. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  23533. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  23534. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  23535. break;
  23536. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  23537. if (camLeft.rotationQuaternion) {
  23538. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23539. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23540. }
  23541. else {
  23542. camLeft.rotation.copyFrom(this.rotation);
  23543. camRight.rotation.copyFrom(this.rotation);
  23544. }
  23545. camLeft.position.copyFrom(this.position);
  23546. camRight.position.copyFrom(this.position);
  23547. break;
  23548. }
  23549. _super.prototype._updateRigCameras.call(this);
  23550. };
  23551. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  23552. var target = this.getTarget();
  23553. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  23554. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  23555. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  23556. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23557. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  23558. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23559. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23560. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23561. rigCamera.setTarget(newFocalTarget);
  23562. };
  23563. /**
  23564. * Gets the current object class name.
  23565. * @return the class name
  23566. */
  23567. TargetCamera.prototype.getClassName = function () {
  23568. return "TargetCamera";
  23569. };
  23570. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23571. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23572. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23573. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23574. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23575. ], TargetCamera.prototype, "rotation", void 0);
  23576. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23577. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23578. ], TargetCamera.prototype, "speed", void 0);
  23579. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23580. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23581. ], TargetCamera.prototype, "lockedTarget", void 0);
  23582. return TargetCamera;
  23583. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23584. /***/ }),
  23585. /***/ "./Cameras/touchCamera.ts":
  23586. /*!********************************!*\
  23587. !*** ./Cameras/touchCamera.ts ***!
  23588. \********************************/
  23589. /*! exports provided: TouchCamera */
  23590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23591. "use strict";
  23592. __webpack_require__.r(__webpack_exports__);
  23593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23594. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23595. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23596. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23597. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23598. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23599. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23600. });
  23601. /**
  23602. * This represents a FPS type of camera controlled by touch.
  23603. * This is like a universal camera minus the Gamepad controls.
  23604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23605. */
  23606. var TouchCamera = /** @class */ (function (_super) {
  23607. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23608. /**
  23609. * Instantiates a new touch camera.
  23610. * This represents a FPS type of camera controlled by touch.
  23611. * This is like a universal camera minus the Gamepad controls.
  23612. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23613. * @param name Define the name of the camera in the scene
  23614. * @param position Define the start position of the camera in the scene
  23615. * @param scene Define the scene the camera belongs to
  23616. */
  23617. function TouchCamera(name, position, scene) {
  23618. var _this = _super.call(this, name, position, scene) || this;
  23619. _this.inputs.addTouch();
  23620. _this._setupInputs();
  23621. return _this;
  23622. }
  23623. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23624. /**
  23625. * Defines the touch sensibility for rotation.
  23626. * The higher the faster.
  23627. */
  23628. get: function () {
  23629. var touch = this.inputs.attached["touch"];
  23630. if (touch) {
  23631. return touch.touchAngularSensibility;
  23632. }
  23633. return 0;
  23634. },
  23635. set: function (value) {
  23636. var touch = this.inputs.attached["touch"];
  23637. if (touch) {
  23638. touch.touchAngularSensibility = value;
  23639. }
  23640. },
  23641. enumerable: true,
  23642. configurable: true
  23643. });
  23644. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23645. /**
  23646. * Defines the touch sensibility for move.
  23647. * The higher the faster.
  23648. */
  23649. get: function () {
  23650. var touch = this.inputs.attached["touch"];
  23651. if (touch) {
  23652. return touch.touchMoveSensibility;
  23653. }
  23654. return 0;
  23655. },
  23656. set: function (value) {
  23657. var touch = this.inputs.attached["touch"];
  23658. if (touch) {
  23659. touch.touchMoveSensibility = value;
  23660. }
  23661. },
  23662. enumerable: true,
  23663. configurable: true
  23664. });
  23665. /**
  23666. * Gets the current object class name.
  23667. * @return the class name
  23668. */
  23669. TouchCamera.prototype.getClassName = function () {
  23670. return "TouchCamera";
  23671. };
  23672. /** @hidden */
  23673. TouchCamera.prototype._setupInputs = function () {
  23674. var mouse = this.inputs.attached["mouse"];
  23675. if (mouse) {
  23676. mouse.touchEnabled = false;
  23677. }
  23678. };
  23679. return TouchCamera;
  23680. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23681. /***/ }),
  23682. /***/ "./Cameras/universalCamera.ts":
  23683. /*!************************************!*\
  23684. !*** ./Cameras/universalCamera.ts ***!
  23685. \************************************/
  23686. /*! exports provided: UniversalCamera */
  23687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23688. "use strict";
  23689. __webpack_require__.r(__webpack_exports__);
  23690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23691. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23692. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23693. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23694. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23695. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23696. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23697. // Forcing to use the Universal camera
  23698. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23699. });
  23700. /**
  23701. * 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,
  23702. * which still works and will still be found in many Playgrounds.
  23703. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23704. */
  23705. var UniversalCamera = /** @class */ (function (_super) {
  23706. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23707. /**
  23708. * 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,
  23709. * which still works and will still be found in many Playgrounds.
  23710. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23711. * @param name Define the name of the camera in the scene
  23712. * @param position Define the start position of the camera in the scene
  23713. * @param scene Define the scene the camera belongs to
  23714. */
  23715. function UniversalCamera(name, position, scene) {
  23716. var _this = _super.call(this, name, position, scene) || this;
  23717. _this.inputs.addGamepad();
  23718. return _this;
  23719. }
  23720. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23721. /**
  23722. * Defines the gamepad rotation sensiblity.
  23723. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23724. */
  23725. get: function () {
  23726. var gamepad = this.inputs.attached["gamepad"];
  23727. if (gamepad) {
  23728. return gamepad.gamepadAngularSensibility;
  23729. }
  23730. return 0;
  23731. },
  23732. set: function (value) {
  23733. var gamepad = this.inputs.attached["gamepad"];
  23734. if (gamepad) {
  23735. gamepad.gamepadAngularSensibility = value;
  23736. }
  23737. },
  23738. enumerable: true,
  23739. configurable: true
  23740. });
  23741. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23742. /**
  23743. * Defines the gamepad move sensiblity.
  23744. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23745. */
  23746. get: function () {
  23747. var gamepad = this.inputs.attached["gamepad"];
  23748. if (gamepad) {
  23749. return gamepad.gamepadMoveSensibility;
  23750. }
  23751. return 0;
  23752. },
  23753. set: function (value) {
  23754. var gamepad = this.inputs.attached["gamepad"];
  23755. if (gamepad) {
  23756. gamepad.gamepadMoveSensibility = value;
  23757. }
  23758. },
  23759. enumerable: true,
  23760. configurable: true
  23761. });
  23762. /**
  23763. * Gets the current object class name.
  23764. * @return the class name
  23765. */
  23766. UniversalCamera.prototype.getClassName = function () {
  23767. return "UniversalCamera";
  23768. };
  23769. return UniversalCamera;
  23770. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23771. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23772. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23773. };
  23774. /***/ }),
  23775. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23776. /*!*******************************************!*\
  23777. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23778. \*******************************************/
  23779. /*! exports provided: VirtualJoysticksCamera */
  23780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23781. "use strict";
  23782. __webpack_require__.r(__webpack_exports__);
  23783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23784. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23785. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23786. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23787. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23788. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23789. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23790. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23791. });
  23792. /**
  23793. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23794. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23795. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23796. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23797. */
  23798. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23799. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23800. /**
  23801. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23802. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23803. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23804. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23805. * @param name Define the name of the camera in the scene
  23806. * @param position Define the start position of the camera in the scene
  23807. * @param scene Define the scene the camera belongs to
  23808. */
  23809. function VirtualJoysticksCamera(name, position, scene) {
  23810. var _this = _super.call(this, name, position, scene) || this;
  23811. _this.inputs.addVirtualJoystick();
  23812. return _this;
  23813. }
  23814. /**
  23815. * Gets the current object class name.
  23816. * @return the class name
  23817. */
  23818. VirtualJoysticksCamera.prototype.getClassName = function () {
  23819. return "VirtualJoysticksCamera";
  23820. };
  23821. return VirtualJoysticksCamera;
  23822. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23823. /***/ }),
  23824. /***/ "./Collisions/collider.ts":
  23825. /*!********************************!*\
  23826. !*** ./Collisions/collider.ts ***!
  23827. \********************************/
  23828. /*! exports provided: Collider */
  23829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23830. "use strict";
  23831. __webpack_require__.r(__webpack_exports__);
  23832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23833. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23834. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23835. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23836. return false;
  23837. }
  23838. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23839. return false;
  23840. }
  23841. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23842. return false;
  23843. }
  23844. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23845. return false;
  23846. }
  23847. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23848. return false;
  23849. }
  23850. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23851. return false;
  23852. }
  23853. return true;
  23854. };
  23855. var getLowestRoot = (function () {
  23856. var result = { root: 0, found: false };
  23857. return function (a, b, c, maxR) {
  23858. result.root = 0;
  23859. result.found = false;
  23860. var determinant = b * b - 4.0 * a * c;
  23861. if (determinant < 0) {
  23862. return result;
  23863. }
  23864. var sqrtD = Math.sqrt(determinant);
  23865. var r1 = (-b - sqrtD) / (2.0 * a);
  23866. var r2 = (-b + sqrtD) / (2.0 * a);
  23867. if (r1 > r2) {
  23868. var temp = r2;
  23869. r2 = r1;
  23870. r1 = temp;
  23871. }
  23872. if (r1 > 0 && r1 < maxR) {
  23873. result.root = r1;
  23874. result.found = true;
  23875. return result;
  23876. }
  23877. if (r2 > 0 && r2 < maxR) {
  23878. result.root = r2;
  23879. result.found = true;
  23880. return result;
  23881. }
  23882. return result;
  23883. };
  23884. })();
  23885. /** @hidden */
  23886. var Collider = /** @class */ (function () {
  23887. function Collider() {
  23888. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23889. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23890. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23891. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23892. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23893. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23894. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23895. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23896. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23897. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23898. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23899. /** @hidden */
  23900. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23901. /** @hidden */
  23902. this._retry = 0;
  23903. /** @hidden */
  23904. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23905. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23906. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23907. this._collisionMask = -1;
  23908. }
  23909. Object.defineProperty(Collider.prototype, "collisionMask", {
  23910. get: function () {
  23911. return this._collisionMask;
  23912. },
  23913. set: function (mask) {
  23914. this._collisionMask = !isNaN(mask) ? mask : -1;
  23915. },
  23916. enumerable: true,
  23917. configurable: true
  23918. });
  23919. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23920. /**
  23921. * Gets the plane normal used to compute the sliding response (in local space)
  23922. */
  23923. get: function () {
  23924. return this._slidePlaneNormal;
  23925. },
  23926. enumerable: true,
  23927. configurable: true
  23928. });
  23929. // Methods
  23930. /** @hidden */
  23931. Collider.prototype._initialize = function (source, dir, e) {
  23932. this._velocity = dir;
  23933. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23934. this._basePoint = source;
  23935. source.multiplyToRef(this._radius, this._basePointWorld);
  23936. dir.multiplyToRef(this._radius, this._velocityWorld);
  23937. this._velocityWorldLength = this._velocityWorld.length();
  23938. this._epsilon = e;
  23939. this.collisionFound = false;
  23940. };
  23941. /** @hidden */
  23942. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23943. pa.subtractToRef(point, this._tempVector);
  23944. pb.subtractToRef(point, this._tempVector2);
  23945. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23946. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23947. if (d < 0) {
  23948. return false;
  23949. }
  23950. pc.subtractToRef(point, this._tempVector3);
  23951. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23952. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23953. if (d < 0) {
  23954. return false;
  23955. }
  23956. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23957. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23958. return d >= 0;
  23959. };
  23960. /** @hidden */
  23961. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23962. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23963. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23964. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23965. return false;
  23966. }
  23967. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23968. return false;
  23969. }
  23970. return true;
  23971. };
  23972. /** @hidden */
  23973. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23974. var t0;
  23975. var embeddedInPlane = false;
  23976. //defensive programming, actually not needed.
  23977. if (!trianglePlaneArray) {
  23978. trianglePlaneArray = [];
  23979. }
  23980. if (!trianglePlaneArray[faceIndex]) {
  23981. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23982. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23983. }
  23984. var trianglePlane = trianglePlaneArray[faceIndex];
  23985. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23986. return;
  23987. }
  23988. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23989. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23990. if (normalDotVelocity == 0) {
  23991. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23992. return;
  23993. }
  23994. embeddedInPlane = true;
  23995. t0 = 0;
  23996. }
  23997. else {
  23998. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23999. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24000. if (t0 > t1) {
  24001. var temp = t1;
  24002. t1 = t0;
  24003. t0 = temp;
  24004. }
  24005. if (t0 > 1.0 || t1 < 0.0) {
  24006. return;
  24007. }
  24008. if (t0 < 0) {
  24009. t0 = 0;
  24010. }
  24011. if (t0 > 1.0) {
  24012. t0 = 1.0;
  24013. }
  24014. }
  24015. this._collisionPoint.copyFromFloats(0, 0, 0);
  24016. var found = false;
  24017. var t = 1.0;
  24018. if (!embeddedInPlane) {
  24019. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  24020. this._velocity.scaleToRef(t0, this._tempVector);
  24021. this._planeIntersectionPoint.addInPlace(this._tempVector);
  24022. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  24023. found = true;
  24024. t = t0;
  24025. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  24026. }
  24027. }
  24028. if (!found) {
  24029. var velocitySquaredLength = this._velocity.lengthSquared();
  24030. var a = velocitySquaredLength;
  24031. this._basePoint.subtractToRef(p1, this._tempVector);
  24032. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24033. var c = this._tempVector.lengthSquared() - 1.0;
  24034. var lowestRoot = getLowestRoot(a, b, c, t);
  24035. if (lowestRoot.found) {
  24036. t = lowestRoot.root;
  24037. found = true;
  24038. this._collisionPoint.copyFrom(p1);
  24039. }
  24040. this._basePoint.subtractToRef(p2, this._tempVector);
  24041. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24042. c = this._tempVector.lengthSquared() - 1.0;
  24043. lowestRoot = getLowestRoot(a, b, c, t);
  24044. if (lowestRoot.found) {
  24045. t = lowestRoot.root;
  24046. found = true;
  24047. this._collisionPoint.copyFrom(p2);
  24048. }
  24049. this._basePoint.subtractToRef(p3, this._tempVector);
  24050. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24051. c = this._tempVector.lengthSquared() - 1.0;
  24052. lowestRoot = getLowestRoot(a, b, c, t);
  24053. if (lowestRoot.found) {
  24054. t = lowestRoot.root;
  24055. found = true;
  24056. this._collisionPoint.copyFrom(p3);
  24057. }
  24058. p2.subtractToRef(p1, this._edge);
  24059. p1.subtractToRef(this._basePoint, this._baseToVertex);
  24060. var edgeSquaredLength = this._edge.lengthSquared();
  24061. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24062. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24063. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24064. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24065. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24066. lowestRoot = getLowestRoot(a, b, c, t);
  24067. if (lowestRoot.found) {
  24068. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24069. if (f >= 0.0 && f <= 1.0) {
  24070. t = lowestRoot.root;
  24071. found = true;
  24072. this._edge.scaleInPlace(f);
  24073. p1.addToRef(this._edge, this._collisionPoint);
  24074. }
  24075. }
  24076. p3.subtractToRef(p2, this._edge);
  24077. p2.subtractToRef(this._basePoint, this._baseToVertex);
  24078. edgeSquaredLength = this._edge.lengthSquared();
  24079. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24080. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24081. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24082. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24083. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24084. lowestRoot = getLowestRoot(a, b, c, t);
  24085. if (lowestRoot.found) {
  24086. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24087. if (f >= 0.0 && f <= 1.0) {
  24088. t = lowestRoot.root;
  24089. found = true;
  24090. this._edge.scaleInPlace(f);
  24091. p2.addToRef(this._edge, this._collisionPoint);
  24092. }
  24093. }
  24094. p1.subtractToRef(p3, this._edge);
  24095. p3.subtractToRef(this._basePoint, this._baseToVertex);
  24096. edgeSquaredLength = this._edge.lengthSquared();
  24097. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24098. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24099. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24100. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24101. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24102. lowestRoot = getLowestRoot(a, b, c, t);
  24103. if (lowestRoot.found) {
  24104. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24105. if (f >= 0.0 && f <= 1.0) {
  24106. t = lowestRoot.root;
  24107. found = true;
  24108. this._edge.scaleInPlace(f);
  24109. p3.addToRef(this._edge, this._collisionPoint);
  24110. }
  24111. }
  24112. }
  24113. if (found) {
  24114. var distToCollision = t * this._velocity.length();
  24115. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  24116. if (!this.intersectionPoint) {
  24117. this.intersectionPoint = this._collisionPoint.clone();
  24118. }
  24119. else {
  24120. this.intersectionPoint.copyFrom(this._collisionPoint);
  24121. }
  24122. this._nearestDistance = distToCollision;
  24123. this.collisionFound = true;
  24124. }
  24125. }
  24126. };
  24127. /** @hidden */
  24128. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  24129. for (var i = indexStart; i < indexEnd; i += 3) {
  24130. var p1 = pts[indices[i] - decal];
  24131. var p2 = pts[indices[i + 1] - decal];
  24132. var p3 = pts[indices[i + 2] - decal];
  24133. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  24134. }
  24135. };
  24136. /** @hidden */
  24137. Collider.prototype._getResponse = function (pos, vel) {
  24138. pos.addToRef(vel, this._destinationPoint);
  24139. vel.scaleInPlace((this._nearestDistance / vel.length()));
  24140. this._basePoint.addToRef(vel, pos);
  24141. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  24142. this._slidePlaneNormal.normalize();
  24143. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  24144. pos.addInPlace(this._displacementVector);
  24145. this.intersectionPoint.addInPlace(this._displacementVector);
  24146. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  24147. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  24148. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  24149. };
  24150. return Collider;
  24151. }());
  24152. /***/ }),
  24153. /***/ "./Collisions/collisionCoordinator.ts":
  24154. /*!********************************************!*\
  24155. !*** ./Collisions/collisionCoordinator.ts ***!
  24156. \********************************************/
  24157. /*! exports provided: DefaultCollisionCoordinator */
  24158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24159. "use strict";
  24160. __webpack_require__.r(__webpack_exports__);
  24161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  24162. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  24163. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24164. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  24165. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24166. /** @hidden */
  24167. var DefaultCollisionCoordinator = /** @class */ (function () {
  24168. function DefaultCollisionCoordinator() {
  24169. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24170. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24171. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24172. }
  24173. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  24174. position.divideToRef(collider._radius, this._scaledPosition);
  24175. displacement.divideToRef(collider._radius, this._scaledVelocity);
  24176. collider.collidedMesh = null;
  24177. collider._retry = 0;
  24178. collider._initialVelocity = this._scaledVelocity;
  24179. collider._initialPosition = this._scaledPosition;
  24180. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  24181. this._finalPosition.multiplyInPlace(collider._radius);
  24182. //run the callback
  24183. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  24184. };
  24185. DefaultCollisionCoordinator.prototype.createCollider = function () {
  24186. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  24187. };
  24188. DefaultCollisionCoordinator.prototype.init = function (scene) {
  24189. this._scene = scene;
  24190. };
  24191. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  24192. if (excludedMesh === void 0) { excludedMesh = null; }
  24193. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  24194. if (collider._retry >= maximumRetry) {
  24195. finalPosition.copyFrom(position);
  24196. return;
  24197. }
  24198. // Check if this is a mesh else camera or -1
  24199. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  24200. collider._initialize(position, velocity, closeDistance);
  24201. // Check all meshes
  24202. for (var index = 0; index < this._scene.meshes.length; index++) {
  24203. var mesh = this._scene.meshes[index];
  24204. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  24205. mesh._checkCollision(collider);
  24206. }
  24207. }
  24208. if (!collider.collisionFound) {
  24209. position.addToRef(velocity, finalPosition);
  24210. return;
  24211. }
  24212. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  24213. collider._getResponse(position, velocity);
  24214. }
  24215. if (velocity.length() <= closeDistance) {
  24216. finalPosition.copyFrom(position);
  24217. return;
  24218. }
  24219. collider._retry++;
  24220. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  24221. };
  24222. return DefaultCollisionCoordinator;
  24223. }());
  24224. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  24225. return new DefaultCollisionCoordinator();
  24226. };
  24227. /***/ }),
  24228. /***/ "./Collisions/index.ts":
  24229. /*!*****************************!*\
  24230. !*** ./Collisions/index.ts ***!
  24231. \*****************************/
  24232. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  24233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24234. "use strict";
  24235. __webpack_require__.r(__webpack_exports__);
  24236. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  24238. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  24239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  24240. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  24241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  24242. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  24244. /***/ }),
  24245. /***/ "./Collisions/intersectionInfo.ts":
  24246. /*!****************************************!*\
  24247. !*** ./Collisions/intersectionInfo.ts ***!
  24248. \****************************************/
  24249. /*! exports provided: IntersectionInfo */
  24250. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24251. "use strict";
  24252. __webpack_require__.r(__webpack_exports__);
  24253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  24254. /**
  24255. * @hidden
  24256. */
  24257. var IntersectionInfo = /** @class */ (function () {
  24258. function IntersectionInfo(bu, bv, distance) {
  24259. this.bu = bu;
  24260. this.bv = bv;
  24261. this.distance = distance;
  24262. this.faceId = 0;
  24263. this.subMeshId = 0;
  24264. }
  24265. return IntersectionInfo;
  24266. }());
  24267. /***/ }),
  24268. /***/ "./Collisions/pickingInfo.ts":
  24269. /*!***********************************!*\
  24270. !*** ./Collisions/pickingInfo.ts ***!
  24271. \***********************************/
  24272. /*! exports provided: PickingInfo */
  24273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24274. "use strict";
  24275. __webpack_require__.r(__webpack_exports__);
  24276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  24277. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24278. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  24279. /**
  24280. * Information about the result of picking within a scene
  24281. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24282. */
  24283. var PickingInfo = /** @class */ (function () {
  24284. function PickingInfo() {
  24285. /** @hidden */
  24286. this._pickingUnavailable = false;
  24287. /**
  24288. * If the pick collided with an object
  24289. */
  24290. this.hit = false;
  24291. /**
  24292. * Distance away where the pick collided
  24293. */
  24294. this.distance = 0;
  24295. /**
  24296. * The location of pick collision
  24297. */
  24298. this.pickedPoint = null;
  24299. /**
  24300. * The mesh corresponding the the pick collision
  24301. */
  24302. this.pickedMesh = null;
  24303. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  24304. this.bu = 0;
  24305. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  24306. this.bv = 0;
  24307. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24308. this.faceId = -1;
  24309. /** Id of the the submesh that was picked */
  24310. this.subMeshId = 0;
  24311. /** If a sprite was picked, this will be the sprite the pick collided with */
  24312. this.pickedSprite = null;
  24313. /**
  24314. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24315. */
  24316. this.originMesh = null;
  24317. /**
  24318. * The ray that was used to perform the picking.
  24319. */
  24320. this.ray = null;
  24321. }
  24322. /**
  24323. * Gets the normal correspodning to the face the pick collided with
  24324. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24325. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24326. * @returns The normal correspodning to the face the pick collided with
  24327. */
  24328. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  24329. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  24330. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  24331. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  24332. return null;
  24333. }
  24334. var indices = this.pickedMesh.getIndices();
  24335. if (!indices) {
  24336. return null;
  24337. }
  24338. var result;
  24339. if (useVerticesNormals) {
  24340. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  24341. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  24342. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  24343. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  24344. normal0 = normal0.scale(this.bu);
  24345. normal1 = normal1.scale(this.bv);
  24346. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  24347. 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);
  24348. }
  24349. else {
  24350. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  24351. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  24352. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  24353. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  24354. var p1p2 = vertex1.subtract(vertex2);
  24355. var p3p2 = vertex3.subtract(vertex2);
  24356. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  24357. }
  24358. if (useWorldCoordinates) {
  24359. var wm = this.pickedMesh.getWorldMatrix();
  24360. if (this.pickedMesh.nonUniformScaling) {
  24361. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  24362. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  24363. wm.setTranslationFromFloats(0, 0, 0);
  24364. wm.invert();
  24365. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  24366. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  24367. }
  24368. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  24369. }
  24370. result.normalize();
  24371. return result;
  24372. };
  24373. /**
  24374. * Gets the texture coordinates of where the pick occured
  24375. * @returns the vector containing the coordnates of the texture
  24376. */
  24377. PickingInfo.prototype.getTextureCoordinates = function () {
  24378. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  24379. return null;
  24380. }
  24381. var indices = this.pickedMesh.getIndices();
  24382. if (!indices) {
  24383. return null;
  24384. }
  24385. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  24386. if (!uvs) {
  24387. return null;
  24388. }
  24389. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  24390. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  24391. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  24392. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  24393. uv1 = uv1.scale(this.bu);
  24394. uv2 = uv2.scale(this.bv);
  24395. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  24396. };
  24397. return PickingInfo;
  24398. }());
  24399. /***/ }),
  24400. /***/ "./Culling/Octrees/index.ts":
  24401. /*!**********************************!*\
  24402. !*** ./Culling/Octrees/index.ts ***!
  24403. \**********************************/
  24404. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  24405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24406. "use strict";
  24407. __webpack_require__.r(__webpack_exports__);
  24408. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  24410. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  24412. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  24413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  24414. /***/ }),
  24415. /***/ "./Culling/Octrees/octree.ts":
  24416. /*!***********************************!*\
  24417. !*** ./Culling/Octrees/octree.ts ***!
  24418. \***********************************/
  24419. /*! exports provided: Octree */
  24420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24421. "use strict";
  24422. __webpack_require__.r(__webpack_exports__);
  24423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  24424. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  24425. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24426. /**
  24427. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  24428. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24429. */
  24430. var Octree = /** @class */ (function () {
  24431. /**
  24432. * Creates a octree
  24433. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24434. * @param creationFunc function to be used to instatiate the octree
  24435. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  24436. * @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.)
  24437. */
  24438. function Octree(creationFunc, maxBlockCapacity,
  24439. /** 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.) */
  24440. maxDepth) {
  24441. if (maxDepth === void 0) { maxDepth = 2; }
  24442. this.maxDepth = maxDepth;
  24443. /**
  24444. * Content stored in the octree
  24445. */
  24446. this.dynamicContent = new Array();
  24447. this._maxBlockCapacity = maxBlockCapacity || 64;
  24448. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  24449. this._creationFunc = creationFunc;
  24450. }
  24451. // Methods
  24452. /**
  24453. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  24454. * @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);
  24455. * @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);
  24456. * @param entries meshes to be added to the octree blocks
  24457. */
  24458. Octree.prototype.update = function (worldMin, worldMax, entries) {
  24459. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  24460. };
  24461. /**
  24462. * Adds a mesh to the octree
  24463. * @param entry Mesh to add to the octree
  24464. */
  24465. Octree.prototype.addMesh = function (entry) {
  24466. for (var index = 0; index < this.blocks.length; index++) {
  24467. var block = this.blocks[index];
  24468. block.addEntry(entry);
  24469. }
  24470. };
  24471. /**
  24472. * Remove an element from the octree
  24473. * @param entry defines the element to remove
  24474. */
  24475. Octree.prototype.removeMesh = function (entry) {
  24476. for (var index = 0; index < this.blocks.length; index++) {
  24477. var block = this.blocks[index];
  24478. block.removeEntry(entry);
  24479. }
  24480. };
  24481. /**
  24482. * Selects an array of meshes within the frustum
  24483. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  24484. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  24485. * @returns array of meshes within the frustum
  24486. */
  24487. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  24488. this._selectionContent.reset();
  24489. for (var index = 0; index < this.blocks.length; index++) {
  24490. var block = this.blocks[index];
  24491. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  24492. }
  24493. if (allowDuplicate) {
  24494. this._selectionContent.concat(this.dynamicContent);
  24495. }
  24496. else {
  24497. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24498. }
  24499. return this._selectionContent;
  24500. };
  24501. /**
  24502. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  24503. * @param sphereCenter defines the bounding sphere center
  24504. * @param sphereRadius defines the bounding sphere radius
  24505. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24506. * @returns an array of objects that intersect the sphere
  24507. */
  24508. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  24509. this._selectionContent.reset();
  24510. for (var index = 0; index < this.blocks.length; index++) {
  24511. var block = this.blocks[index];
  24512. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  24513. }
  24514. if (allowDuplicate) {
  24515. this._selectionContent.concat(this.dynamicContent);
  24516. }
  24517. else {
  24518. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24519. }
  24520. return this._selectionContent;
  24521. };
  24522. /**
  24523. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  24524. * @param ray defines the ray to test with
  24525. * @returns array of intersected objects
  24526. */
  24527. Octree.prototype.intersectsRay = function (ray) {
  24528. this._selectionContent.reset();
  24529. for (var index = 0; index < this.blocks.length; index++) {
  24530. var block = this.blocks[index];
  24531. block.intersectsRay(ray, this._selectionContent);
  24532. }
  24533. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24534. return this._selectionContent;
  24535. };
  24536. /**
  24537. * Adds a mesh into the octree block if it intersects the block
  24538. */
  24539. Octree.CreationFuncForMeshes = function (entry, block) {
  24540. var boundingInfo = entry.getBoundingInfo();
  24541. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24542. block.entries.push(entry);
  24543. }
  24544. };
  24545. /**
  24546. * Adds a submesh into the octree block if it intersects the block
  24547. */
  24548. Octree.CreationFuncForSubMeshes = function (entry, block) {
  24549. var boundingInfo = entry.getBoundingInfo();
  24550. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24551. block.entries.push(entry);
  24552. }
  24553. };
  24554. return Octree;
  24555. }());
  24556. /***/ }),
  24557. /***/ "./Culling/Octrees/octreeBlock.ts":
  24558. /*!****************************************!*\
  24559. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24560. \****************************************/
  24561. /*! exports provided: OctreeBlock */
  24562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24563. "use strict";
  24564. __webpack_require__.r(__webpack_exports__);
  24565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24566. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24567. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24568. /**
  24569. * Class used to store a cell in an octree
  24570. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24571. */
  24572. var OctreeBlock = /** @class */ (function () {
  24573. /**
  24574. * Creates a new block
  24575. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24576. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24577. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24578. * @param depth defines the current depth of this block in the octree
  24579. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24580. * @param creationFunc defines a callback to call when an element is added to the block
  24581. */
  24582. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24583. /**
  24584. * Gets the content of the current block
  24585. */
  24586. this.entries = new Array();
  24587. this._boundingVectors = new Array();
  24588. this._capacity = capacity;
  24589. this._depth = depth;
  24590. this._maxDepth = maxDepth;
  24591. this._creationFunc = creationFunc;
  24592. this._minPoint = minPoint;
  24593. this._maxPoint = maxPoint;
  24594. this._boundingVectors.push(minPoint.clone());
  24595. this._boundingVectors.push(maxPoint.clone());
  24596. this._boundingVectors.push(minPoint.clone());
  24597. this._boundingVectors[2].x = maxPoint.x;
  24598. this._boundingVectors.push(minPoint.clone());
  24599. this._boundingVectors[3].y = maxPoint.y;
  24600. this._boundingVectors.push(minPoint.clone());
  24601. this._boundingVectors[4].z = maxPoint.z;
  24602. this._boundingVectors.push(maxPoint.clone());
  24603. this._boundingVectors[5].z = minPoint.z;
  24604. this._boundingVectors.push(maxPoint.clone());
  24605. this._boundingVectors[6].x = minPoint.x;
  24606. this._boundingVectors.push(maxPoint.clone());
  24607. this._boundingVectors[7].y = minPoint.y;
  24608. }
  24609. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24610. // Property
  24611. /**
  24612. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24613. */
  24614. get: function () {
  24615. return this._capacity;
  24616. },
  24617. enumerable: true,
  24618. configurable: true
  24619. });
  24620. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24621. /**
  24622. * Gets the minimum vector (in world space) of the block's bounding box
  24623. */
  24624. get: function () {
  24625. return this._minPoint;
  24626. },
  24627. enumerable: true,
  24628. configurable: true
  24629. });
  24630. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24631. /**
  24632. * Gets the maximum vector (in world space) of the block's bounding box
  24633. */
  24634. get: function () {
  24635. return this._maxPoint;
  24636. },
  24637. enumerable: true,
  24638. configurable: true
  24639. });
  24640. // Methods
  24641. /**
  24642. * Add a new element to this block
  24643. * @param entry defines the element to add
  24644. */
  24645. OctreeBlock.prototype.addEntry = function (entry) {
  24646. if (this.blocks) {
  24647. for (var index = 0; index < this.blocks.length; index++) {
  24648. var block = this.blocks[index];
  24649. block.addEntry(entry);
  24650. }
  24651. return;
  24652. }
  24653. this._creationFunc(entry, this);
  24654. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24655. this.createInnerBlocks();
  24656. }
  24657. };
  24658. /**
  24659. * Remove an element from this block
  24660. * @param entry defines the element to remove
  24661. */
  24662. OctreeBlock.prototype.removeEntry = function (entry) {
  24663. if (this.blocks) {
  24664. for (var index = 0; index < this.blocks.length; index++) {
  24665. var block = this.blocks[index];
  24666. block.removeEntry(entry);
  24667. }
  24668. return;
  24669. }
  24670. var entryIndex = this.entries.indexOf(entry);
  24671. if (entryIndex > -1) {
  24672. this.entries.splice(entryIndex, 1);
  24673. }
  24674. };
  24675. /**
  24676. * Add an array of elements to this block
  24677. * @param entries defines the array of elements to add
  24678. */
  24679. OctreeBlock.prototype.addEntries = function (entries) {
  24680. for (var index = 0; index < entries.length; index++) {
  24681. var mesh = entries[index];
  24682. this.addEntry(mesh);
  24683. }
  24684. };
  24685. /**
  24686. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24687. * @param frustumPlanes defines the frustum planes to test
  24688. * @param selection defines the array to store current content if selection is positive
  24689. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24690. */
  24691. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24692. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24693. if (this.blocks) {
  24694. for (var index = 0; index < this.blocks.length; index++) {
  24695. var block = this.blocks[index];
  24696. block.select(frustumPlanes, selection, allowDuplicate);
  24697. }
  24698. return;
  24699. }
  24700. if (allowDuplicate) {
  24701. selection.concat(this.entries);
  24702. }
  24703. else {
  24704. selection.concatWithNoDuplicate(this.entries);
  24705. }
  24706. }
  24707. };
  24708. /**
  24709. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24710. * @param sphereCenter defines the bounding sphere center
  24711. * @param sphereRadius defines the bounding sphere radius
  24712. * @param selection defines the array to store current content if selection is positive
  24713. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24714. */
  24715. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24716. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24717. if (this.blocks) {
  24718. for (var index = 0; index < this.blocks.length; index++) {
  24719. var block = this.blocks[index];
  24720. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24721. }
  24722. return;
  24723. }
  24724. if (allowDuplicate) {
  24725. selection.concat(this.entries);
  24726. }
  24727. else {
  24728. selection.concatWithNoDuplicate(this.entries);
  24729. }
  24730. }
  24731. };
  24732. /**
  24733. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24734. * @param ray defines the ray to test with
  24735. * @param selection defines the array to store current content if selection is positive
  24736. */
  24737. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24738. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24739. if (this.blocks) {
  24740. for (var index = 0; index < this.blocks.length; index++) {
  24741. var block = this.blocks[index];
  24742. block.intersectsRay(ray, selection);
  24743. }
  24744. return;
  24745. }
  24746. selection.concatWithNoDuplicate(this.entries);
  24747. }
  24748. };
  24749. /**
  24750. * Subdivide the content into child blocks (this block will then be empty)
  24751. */
  24752. OctreeBlock.prototype.createInnerBlocks = function () {
  24753. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24754. };
  24755. /**
  24756. * @hidden
  24757. */
  24758. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24759. target.blocks = new Array();
  24760. 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);
  24761. // Segmenting space
  24762. for (var x = 0; x < 2; x++) {
  24763. for (var y = 0; y < 2; y++) {
  24764. for (var z = 0; z < 2; z++) {
  24765. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24766. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24767. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24768. block.addEntries(entries);
  24769. target.blocks.push(block);
  24770. }
  24771. }
  24772. }
  24773. };
  24774. return OctreeBlock;
  24775. }());
  24776. /***/ }),
  24777. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24778. /*!*************************************************!*\
  24779. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24780. \*************************************************/
  24781. /*! exports provided: OctreeSceneComponent */
  24782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24783. "use strict";
  24784. __webpack_require__.r(__webpack_exports__);
  24785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24786. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24787. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24788. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24789. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24790. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24791. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24792. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24793. if (maxCapacity === void 0) { maxCapacity = 64; }
  24794. if (maxDepth === void 0) { maxDepth = 2; }
  24795. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24796. if (!component) {
  24797. component = new OctreeSceneComponent(this);
  24798. this._addComponent(component);
  24799. }
  24800. if (!this._selectionOctree) {
  24801. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24802. }
  24803. var worldExtends = this.getWorldExtends();
  24804. // Update octree
  24805. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24806. return this._selectionOctree;
  24807. };
  24808. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24809. get: function () {
  24810. return this._selectionOctree;
  24811. },
  24812. enumerable: true,
  24813. configurable: true
  24814. });
  24815. /**
  24816. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24817. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24818. * @param maxCapacity defines the maximum size of each block (64 by default)
  24819. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24820. * @returns the new octree
  24821. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24823. */
  24824. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24825. if (maxCapacity === void 0) { maxCapacity = 64; }
  24826. if (maxDepth === void 0) { maxDepth = 2; }
  24827. var scene = this.getScene();
  24828. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24829. if (!component) {
  24830. component = new OctreeSceneComponent(scene);
  24831. scene._addComponent(component);
  24832. }
  24833. if (!this._submeshesOctree) {
  24834. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24835. }
  24836. this.computeWorldMatrix(true);
  24837. var boundingInfo = this.getBoundingInfo();
  24838. // Update octree
  24839. var bbox = boundingInfo.boundingBox;
  24840. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24841. return this._submeshesOctree;
  24842. };
  24843. /**
  24844. * Defines the octree scene component responsible to manage any octrees
  24845. * in a given scene.
  24846. */
  24847. var OctreeSceneComponent = /** @class */ (function () {
  24848. /**
  24849. * Creates a new instance of the component for the given scene
  24850. * @param scene Defines the scene to register the component in
  24851. */
  24852. function OctreeSceneComponent(scene) {
  24853. /**
  24854. * The component name helpfull to identify the component in the list of scene components.
  24855. */
  24856. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24857. /**
  24858. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24859. */
  24860. this.checksIsEnabled = true;
  24861. 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));
  24862. this.scene = scene;
  24863. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24864. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24865. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24866. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24867. }
  24868. /**
  24869. * Registers the component in a given scene
  24870. */
  24871. OctreeSceneComponent.prototype.register = function () {
  24872. var _this = this;
  24873. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24874. var sceneOctree = _this.scene.selectionOctree;
  24875. if (sceneOctree !== undefined && sceneOctree !== null) {
  24876. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24877. if (index !== -1) {
  24878. sceneOctree.dynamicContent.splice(index, 1);
  24879. }
  24880. }
  24881. });
  24882. this.scene.onMeshImportedObservable.add(function (mesh) {
  24883. var sceneOctree = _this.scene.selectionOctree;
  24884. if (sceneOctree !== undefined && sceneOctree !== null) {
  24885. sceneOctree.addMesh(mesh);
  24886. }
  24887. });
  24888. };
  24889. /**
  24890. * Return the list of active meshes
  24891. * @returns the list of active meshes
  24892. */
  24893. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24894. if (this.scene._selectionOctree) {
  24895. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24896. return selection;
  24897. }
  24898. return this.scene._getDefaultMeshCandidates();
  24899. };
  24900. /**
  24901. * Return the list of active sub meshes
  24902. * @param mesh The mesh to get the candidates sub meshes from
  24903. * @returns the list of active sub meshes
  24904. */
  24905. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24906. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24907. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24908. return intersections;
  24909. }
  24910. return this.scene._getDefaultSubMeshCandidates(mesh);
  24911. };
  24912. /**
  24913. * Return the list of sub meshes intersecting with a given local ray
  24914. * @param mesh defines the mesh to find the submesh for
  24915. * @param localRay defines the ray in local space
  24916. * @returns the list of intersecting sub meshes
  24917. */
  24918. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24919. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24920. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24921. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24922. return intersections;
  24923. }
  24924. return this.scene._getDefaultSubMeshCandidates(mesh);
  24925. };
  24926. /**
  24927. * Return the list of sub meshes colliding with a collider
  24928. * @param mesh defines the mesh to find the submesh for
  24929. * @param collider defines the collider to evaluate the collision against
  24930. * @returns the list of colliding sub meshes
  24931. */
  24932. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24933. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24934. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24935. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24936. return intersections;
  24937. }
  24938. return this.scene._getDefaultSubMeshCandidates(mesh);
  24939. };
  24940. /**
  24941. * Rebuilds the elements related to this component in case of
  24942. * context lost for instance.
  24943. */
  24944. OctreeSceneComponent.prototype.rebuild = function () {
  24945. // Nothing to do here.
  24946. };
  24947. /**
  24948. * Disposes the component and the associated ressources.
  24949. */
  24950. OctreeSceneComponent.prototype.dispose = function () {
  24951. // Nothing to do here.
  24952. };
  24953. return OctreeSceneComponent;
  24954. }());
  24955. /***/ }),
  24956. /***/ "./Culling/boundingBox.ts":
  24957. /*!********************************!*\
  24958. !*** ./Culling/boundingBox.ts ***!
  24959. \********************************/
  24960. /*! exports provided: BoundingBox */
  24961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24962. "use strict";
  24963. __webpack_require__.r(__webpack_exports__);
  24964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24965. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24966. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24967. /**
  24968. * Class used to store bounding box information
  24969. */
  24970. var BoundingBox = /** @class */ (function () {
  24971. /**
  24972. * Creates a new bounding box
  24973. * @param min defines the minimum vector (in local space)
  24974. * @param max defines the maximum vector (in local space)
  24975. * @param worldMatrix defines the new world matrix
  24976. */
  24977. function BoundingBox(min, max, worldMatrix) {
  24978. /**
  24979. * Gets the 8 vectors representing the bounding box in local space
  24980. */
  24981. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24982. /**
  24983. * Gets the center of the bounding box in local space
  24984. */
  24985. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24986. /**
  24987. * Gets the center of the bounding box in world space
  24988. */
  24989. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24990. /**
  24991. * Gets the extend size in local space
  24992. */
  24993. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24994. /**
  24995. * Gets the extend size in world space
  24996. */
  24997. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24998. /**
  24999. * Gets the OBB (object bounding box) directions
  25000. */
  25001. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25002. /**
  25003. * Gets the 8 vectors representing the bounding box in world space
  25004. */
  25005. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25006. /**
  25007. * Gets the minimum vector in world space
  25008. */
  25009. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25010. /**
  25011. * Gets the maximum vector in world space
  25012. */
  25013. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25014. /**
  25015. * Gets the minimum vector in local space
  25016. */
  25017. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25018. /**
  25019. * Gets the maximum vector in local space
  25020. */
  25021. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25022. this.reConstruct(min, max, worldMatrix);
  25023. }
  25024. // Methods
  25025. /**
  25026. * Recreates the entire bounding box from scratch as if we call the constructor in place
  25027. * @param min defines the new minimum vector (in local space)
  25028. * @param max defines the new maximum vector (in local space)
  25029. * @param worldMatrix defines the new world matrix
  25030. */
  25031. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  25032. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25033. var vectors = this.vectors;
  25034. this.minimum.copyFromFloats(minX, minY, minZ);
  25035. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  25036. vectors[0].copyFromFloats(minX, minY, minZ);
  25037. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  25038. vectors[2].copyFromFloats(maxX, minY, minZ);
  25039. vectors[3].copyFromFloats(minX, maxY, minZ);
  25040. vectors[4].copyFromFloats(minX, minY, maxZ);
  25041. vectors[5].copyFromFloats(maxX, maxY, minZ);
  25042. vectors[6].copyFromFloats(minX, maxY, maxZ);
  25043. vectors[7].copyFromFloats(maxX, minY, maxZ);
  25044. // OBB
  25045. max.addToRef(min, this.center).scaleInPlace(0.5);
  25046. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  25047. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25048. };
  25049. /**
  25050. * Scale the current bounding box by applying a scale factor
  25051. * @param factor defines the scale factor to apply
  25052. * @returns the current bounding box
  25053. */
  25054. BoundingBox.prototype.scale = function (factor) {
  25055. var tmpVectors = BoundingBox.TmpVector3;
  25056. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  25057. var len = diff.length();
  25058. diff.normalizeFromLength(len);
  25059. var distance = len * factor;
  25060. var newRadius = diff.scaleInPlace(distance * 0.5);
  25061. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  25062. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  25063. this.reConstruct(min, max, this._worldMatrix);
  25064. return this;
  25065. };
  25066. /**
  25067. * Gets the world matrix of the bounding box
  25068. * @returns a matrix
  25069. */
  25070. BoundingBox.prototype.getWorldMatrix = function () {
  25071. return this._worldMatrix;
  25072. };
  25073. /** @hidden */
  25074. BoundingBox.prototype._update = function (world) {
  25075. var minWorld = this.minimumWorld;
  25076. var maxWorld = this.maximumWorld;
  25077. var directions = this.directions;
  25078. var vectorsWorld = this.vectorsWorld;
  25079. var vectors = this.vectors;
  25080. if (!world.isIdentity()) {
  25081. minWorld.setAll(Number.MAX_VALUE);
  25082. maxWorld.setAll(-Number.MAX_VALUE);
  25083. for (var index = 0; index < 8; ++index) {
  25084. var v = vectorsWorld[index];
  25085. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  25086. minWorld.minimizeInPlace(v);
  25087. maxWorld.maximizeInPlace(v);
  25088. }
  25089. // Extend
  25090. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  25091. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  25092. }
  25093. else {
  25094. minWorld.copyFrom(this.minimum);
  25095. maxWorld.copyFrom(this.maximum);
  25096. for (var index = 0; index < 8; ++index) {
  25097. vectorsWorld[index].copyFrom(vectors[index]);
  25098. }
  25099. // Extend
  25100. this.extendSizeWorld.copyFrom(this.extendSize);
  25101. this.centerWorld.copyFrom(this.center);
  25102. }
  25103. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  25104. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  25105. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  25106. this._worldMatrix = world;
  25107. };
  25108. /**
  25109. * Tests if the bounding box is intersecting the frustum planes
  25110. * @param frustumPlanes defines the frustum planes to test
  25111. * @returns true if there is an intersection
  25112. */
  25113. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  25114. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  25115. };
  25116. /**
  25117. * Tests if the bounding box is entirely inside the frustum planes
  25118. * @param frustumPlanes defines the frustum planes to test
  25119. * @returns true if there is an inclusion
  25120. */
  25121. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25122. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  25123. };
  25124. /**
  25125. * Tests if a point is inside the bounding box
  25126. * @param point defines the point to test
  25127. * @returns true if the point is inside the bounding box
  25128. */
  25129. BoundingBox.prototype.intersectsPoint = function (point) {
  25130. var min = this.minimumWorld;
  25131. var max = this.maximumWorld;
  25132. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25133. var pointX = point.x, pointY = point.y, pointZ = point.z;
  25134. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  25135. if (maxX - pointX < delta || delta > pointX - minX) {
  25136. return false;
  25137. }
  25138. if (maxY - pointY < delta || delta > pointY - minY) {
  25139. return false;
  25140. }
  25141. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  25142. return false;
  25143. }
  25144. return true;
  25145. };
  25146. /**
  25147. * Tests if the bounding box intersects with a bounding sphere
  25148. * @param sphere defines the sphere to test
  25149. * @returns true if there is an intersection
  25150. */
  25151. BoundingBox.prototype.intersectsSphere = function (sphere) {
  25152. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  25153. };
  25154. /**
  25155. * Tests if the bounding box intersects with a box defined by a min and max vectors
  25156. * @param min defines the min vector to use
  25157. * @param max defines the max vector to use
  25158. * @returns true if there is an intersection
  25159. */
  25160. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  25161. var myMin = this.minimumWorld;
  25162. var myMax = this.maximumWorld;
  25163. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  25164. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25165. if (myMaxX < minX || myMinX > maxX) {
  25166. return false;
  25167. }
  25168. if (myMaxY < minY || myMinY > maxY) {
  25169. return false;
  25170. }
  25171. if (myMaxZ < minZ || myMinZ > maxZ) {
  25172. return false;
  25173. }
  25174. return true;
  25175. };
  25176. // Statics
  25177. /**
  25178. * Tests if two bounding boxes are intersections
  25179. * @param box0 defines the first box to test
  25180. * @param box1 defines the second box to test
  25181. * @returns true if there is an intersection
  25182. */
  25183. BoundingBox.Intersects = function (box0, box1) {
  25184. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  25185. };
  25186. /**
  25187. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  25188. * @param minPoint defines the minimum vector of the bounding box
  25189. * @param maxPoint defines the maximum vector of the bounding box
  25190. * @param sphereCenter defines the sphere center
  25191. * @param sphereRadius defines the sphere radius
  25192. * @returns true if there is an intersection
  25193. */
  25194. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  25195. var vector = BoundingBox.TmpVector3[0];
  25196. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  25197. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  25198. return (num <= (sphereRadius * sphereRadius));
  25199. };
  25200. /**
  25201. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  25202. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25203. * @param frustumPlanes defines the frustum planes to test
  25204. * @return true if there is an inclusion
  25205. */
  25206. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  25207. for (var p = 0; p < 6; ++p) {
  25208. var frustumPlane = frustumPlanes[p];
  25209. for (var i = 0; i < 8; ++i) {
  25210. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  25211. return false;
  25212. }
  25213. }
  25214. }
  25215. return true;
  25216. };
  25217. /**
  25218. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  25219. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25220. * @param frustumPlanes defines the frustum planes to test
  25221. * @return true if there is an intersection
  25222. */
  25223. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  25224. for (var p = 0; p < 6; ++p) {
  25225. var canReturnFalse = true;
  25226. var frustumPlane = frustumPlanes[p];
  25227. for (var i = 0; i < 8; ++i) {
  25228. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  25229. canReturnFalse = false;
  25230. break;
  25231. }
  25232. }
  25233. if (canReturnFalse) {
  25234. return false;
  25235. }
  25236. }
  25237. return true;
  25238. };
  25239. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25240. return BoundingBox;
  25241. }());
  25242. /***/ }),
  25243. /***/ "./Culling/boundingInfo.ts":
  25244. /*!*********************************!*\
  25245. !*** ./Culling/boundingInfo.ts ***!
  25246. \*********************************/
  25247. /*! exports provided: BoundingInfo */
  25248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25249. "use strict";
  25250. __webpack_require__.r(__webpack_exports__);
  25251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  25252. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25253. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25254. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  25255. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25256. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25257. var _result0 = { min: 0, max: 0 };
  25258. var _result1 = { min: 0, max: 0 };
  25259. var computeBoxExtents = function (axis, box, result) {
  25260. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  25261. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  25262. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  25263. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  25264. var r = r0 + r1 + r2;
  25265. result.min = p - r;
  25266. result.max = p + r;
  25267. };
  25268. var axisOverlap = function (axis, box0, box1) {
  25269. computeBoxExtents(axis, box0, _result0);
  25270. computeBoxExtents(axis, box1, _result1);
  25271. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  25272. };
  25273. /**
  25274. * Info for a bounding data of a mesh
  25275. */
  25276. var BoundingInfo = /** @class */ (function () {
  25277. /**
  25278. * Constructs bounding info
  25279. * @param minimum min vector of the bounding box/sphere
  25280. * @param maximum max vector of the bounding box/sphere
  25281. * @param worldMatrix defines the new world matrix
  25282. */
  25283. function BoundingInfo(minimum, maximum, worldMatrix) {
  25284. this._isLocked = false;
  25285. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  25286. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  25287. }
  25288. /**
  25289. * Recreates the entire bounding info from scratch as if we call the constructor in place
  25290. * @param min defines the new minimum vector (in local space)
  25291. * @param max defines the new maximum vector (in local space)
  25292. * @param worldMatrix defines the new world matrix
  25293. */
  25294. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  25295. this.boundingBox.reConstruct(min, max, worldMatrix);
  25296. this.boundingSphere.reConstruct(min, max, worldMatrix);
  25297. };
  25298. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  25299. /**
  25300. * min vector of the bounding box/sphere
  25301. */
  25302. get: function () {
  25303. return this.boundingBox.minimum;
  25304. },
  25305. enumerable: true,
  25306. configurable: true
  25307. });
  25308. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  25309. /**
  25310. * max vector of the bounding box/sphere
  25311. */
  25312. get: function () {
  25313. return this.boundingBox.maximum;
  25314. },
  25315. enumerable: true,
  25316. configurable: true
  25317. });
  25318. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  25319. /**
  25320. * If the info is locked and won't be updated to avoid perf overhead
  25321. */
  25322. get: function () {
  25323. return this._isLocked;
  25324. },
  25325. set: function (value) {
  25326. this._isLocked = value;
  25327. },
  25328. enumerable: true,
  25329. configurable: true
  25330. });
  25331. // Methods
  25332. /**
  25333. * Updates the bounding sphere and box
  25334. * @param world world matrix to be used to update
  25335. */
  25336. BoundingInfo.prototype.update = function (world) {
  25337. if (this._isLocked) {
  25338. return;
  25339. }
  25340. this.boundingBox._update(world);
  25341. this.boundingSphere._update(world);
  25342. };
  25343. /**
  25344. * Recreate the bounding info to be centered around a specific point given a specific extend.
  25345. * @param center New center of the bounding info
  25346. * @param extend New extend of the bounding info
  25347. * @returns the current bounding info
  25348. */
  25349. BoundingInfo.prototype.centerOn = function (center, extend) {
  25350. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  25351. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  25352. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25353. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25354. return this;
  25355. };
  25356. /**
  25357. * Scale the current bounding info by applying a scale factor
  25358. * @param factor defines the scale factor to apply
  25359. * @returns the current bounding info
  25360. */
  25361. BoundingInfo.prototype.scale = function (factor) {
  25362. this.boundingBox.scale(factor);
  25363. this.boundingSphere.scale(factor);
  25364. return this;
  25365. };
  25366. /**
  25367. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  25368. * @param frustumPlanes defines the frustum to test
  25369. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  25370. * @returns true if the bounding info is in the frustum planes
  25371. */
  25372. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  25373. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  25374. 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);
  25375. if (inclusionTest) {
  25376. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  25377. return true;
  25378. }
  25379. }
  25380. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  25381. return false;
  25382. }
  25383. 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);
  25384. if (bSphereOnlyTest) {
  25385. return true;
  25386. }
  25387. return this.boundingBox.isInFrustum(frustumPlanes);
  25388. };
  25389. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  25390. /**
  25391. * Gets the world distance between the min and max points of the bounding box
  25392. */
  25393. get: function () {
  25394. var boundingBox = this.boundingBox;
  25395. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  25396. return diag.length();
  25397. },
  25398. enumerable: true,
  25399. configurable: true
  25400. });
  25401. /**
  25402. * Checks if a cullable object (mesh...) is in the camera frustum
  25403. * Unlike isInFrustum this cheks the full bounding box
  25404. * @param frustumPlanes Camera near/planes
  25405. * @returns true if the object is in frustum otherwise false
  25406. */
  25407. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25408. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  25409. };
  25410. /** @hidden */
  25411. BoundingInfo.prototype._checkCollision = function (collider) {
  25412. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  25413. };
  25414. /**
  25415. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  25416. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25417. * @param point the point to check intersection with
  25418. * @returns if the point intersects
  25419. */
  25420. BoundingInfo.prototype.intersectsPoint = function (point) {
  25421. if (!this.boundingSphere.centerWorld) {
  25422. return false;
  25423. }
  25424. if (!this.boundingSphere.intersectsPoint(point)) {
  25425. return false;
  25426. }
  25427. if (!this.boundingBox.intersectsPoint(point)) {
  25428. return false;
  25429. }
  25430. return true;
  25431. };
  25432. /**
  25433. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  25434. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25435. * @param boundingInfo the bounding info to check intersection with
  25436. * @param precise if the intersection should be done using OBB
  25437. * @returns if the bounding info intersects
  25438. */
  25439. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  25440. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  25441. return false;
  25442. }
  25443. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  25444. return false;
  25445. }
  25446. if (!precise) {
  25447. return true;
  25448. }
  25449. var box0 = this.boundingBox;
  25450. var box1 = boundingInfo.boundingBox;
  25451. if (!axisOverlap(box0.directions[0], box0, box1)) {
  25452. return false;
  25453. }
  25454. if (!axisOverlap(box0.directions[1], box0, box1)) {
  25455. return false;
  25456. }
  25457. if (!axisOverlap(box0.directions[2], box0, box1)) {
  25458. return false;
  25459. }
  25460. if (!axisOverlap(box1.directions[0], box0, box1)) {
  25461. return false;
  25462. }
  25463. if (!axisOverlap(box1.directions[1], box0, box1)) {
  25464. return false;
  25465. }
  25466. if (!axisOverlap(box1.directions[2], box0, box1)) {
  25467. return false;
  25468. }
  25469. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  25470. return false;
  25471. }
  25472. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  25473. return false;
  25474. }
  25475. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  25476. return false;
  25477. }
  25478. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  25479. return false;
  25480. }
  25481. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  25482. return false;
  25483. }
  25484. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  25485. return false;
  25486. }
  25487. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  25488. return false;
  25489. }
  25490. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  25491. return false;
  25492. }
  25493. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  25494. return false;
  25495. }
  25496. return true;
  25497. };
  25498. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25499. return BoundingInfo;
  25500. }());
  25501. /***/ }),
  25502. /***/ "./Culling/boundingSphere.ts":
  25503. /*!***********************************!*\
  25504. !*** ./Culling/boundingSphere.ts ***!
  25505. \***********************************/
  25506. /*! exports provided: BoundingSphere */
  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__, "BoundingSphere", function() { return BoundingSphere; });
  25511. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25512. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25513. /**
  25514. * Class used to store bounding sphere information
  25515. */
  25516. var BoundingSphere = /** @class */ (function () {
  25517. /**
  25518. * Creates a new bounding sphere
  25519. * @param min defines the minimum vector (in local space)
  25520. * @param max defines the maximum vector (in local space)
  25521. * @param worldMatrix defines the new world matrix
  25522. */
  25523. function BoundingSphere(min, max, worldMatrix) {
  25524. /**
  25525. * Gets the center of the bounding sphere in local space
  25526. */
  25527. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25528. /**
  25529. * Gets the center of the bounding sphere in world space
  25530. */
  25531. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25532. /**
  25533. * Gets the minimum vector in local space
  25534. */
  25535. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25536. /**
  25537. * Gets the maximum vector in local space
  25538. */
  25539. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25540. this.reConstruct(min, max, worldMatrix);
  25541. }
  25542. /**
  25543. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  25544. * @param min defines the new minimum vector (in local space)
  25545. * @param max defines the new maximum vector (in local space)
  25546. * @param worldMatrix defines the new world matrix
  25547. */
  25548. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  25549. this.minimum.copyFrom(min);
  25550. this.maximum.copyFrom(max);
  25551. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  25552. max.addToRef(min, this.center).scaleInPlace(0.5);
  25553. this.radius = distance * 0.5;
  25554. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25555. };
  25556. /**
  25557. * Scale the current bounding sphere by applying a scale factor
  25558. * @param factor defines the scale factor to apply
  25559. * @returns the current bounding box
  25560. */
  25561. BoundingSphere.prototype.scale = function (factor) {
  25562. var newRadius = this.radius * factor;
  25563. var tmpVectors = BoundingSphere.TmpVector3;
  25564. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25565. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25566. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25567. this.reConstruct(min, max, this._worldMatrix);
  25568. return this;
  25569. };
  25570. /**
  25571. * Gets the world matrix of the bounding box
  25572. * @returns a matrix
  25573. */
  25574. BoundingSphere.prototype.getWorldMatrix = function () {
  25575. return this._worldMatrix;
  25576. };
  25577. // Methods
  25578. /** @hidden */
  25579. BoundingSphere.prototype._update = function (worldMatrix) {
  25580. if (!worldMatrix.isIdentity()) {
  25581. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25582. var tempVector = BoundingSphere.TmpVector3[0];
  25583. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25584. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25585. }
  25586. else {
  25587. this.centerWorld.copyFrom(this.center);
  25588. this.radiusWorld = this.radius;
  25589. }
  25590. };
  25591. /**
  25592. * Tests if the bounding sphere is intersecting the frustum planes
  25593. * @param frustumPlanes defines the frustum planes to test
  25594. * @returns true if there is an intersection
  25595. */
  25596. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25597. var center = this.centerWorld;
  25598. var radius = this.radiusWorld;
  25599. for (var i = 0; i < 6; i++) {
  25600. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25601. return false;
  25602. }
  25603. }
  25604. return true;
  25605. };
  25606. /**
  25607. * Tests if the bounding sphere center is in between the frustum planes.
  25608. * Used for optimistic fast inclusion.
  25609. * @param frustumPlanes defines the frustum planes to test
  25610. * @returns true if the sphere center is in between the frustum planes
  25611. */
  25612. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25613. var center = this.centerWorld;
  25614. for (var i = 0; i < 6; i++) {
  25615. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25616. return false;
  25617. }
  25618. }
  25619. return true;
  25620. };
  25621. /**
  25622. * Tests if a point is inside the bounding sphere
  25623. * @param point defines the point to test
  25624. * @returns true if the point is inside the bounding sphere
  25625. */
  25626. BoundingSphere.prototype.intersectsPoint = function (point) {
  25627. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25628. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25629. return false;
  25630. }
  25631. return true;
  25632. };
  25633. // Statics
  25634. /**
  25635. * Checks if two sphere intersct
  25636. * @param sphere0 sphere 0
  25637. * @param sphere1 sphere 1
  25638. * @returns true if the speres intersect
  25639. */
  25640. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25641. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25642. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25643. if (radiusSum * radiusSum < squareDistance) {
  25644. return false;
  25645. }
  25646. return true;
  25647. };
  25648. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25649. return BoundingSphere;
  25650. }());
  25651. /***/ }),
  25652. /***/ "./Culling/index.ts":
  25653. /*!**************************!*\
  25654. !*** ./Culling/index.ts ***!
  25655. \**************************/
  25656. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25658. "use strict";
  25659. __webpack_require__.r(__webpack_exports__);
  25660. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25662. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25664. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25666. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25670. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25672. /***/ }),
  25673. /***/ "./Culling/ray.ts":
  25674. /*!************************!*\
  25675. !*** ./Culling/ray.ts ***!
  25676. \************************/
  25677. /*! exports provided: Ray */
  25678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25679. "use strict";
  25680. __webpack_require__.r(__webpack_exports__);
  25681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25682. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25683. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25684. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25685. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25686. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25687. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25688. /**
  25689. * Class representing a ray with position and direction
  25690. */
  25691. var Ray = /** @class */ (function () {
  25692. /**
  25693. * Creates a new ray
  25694. * @param origin origin point
  25695. * @param direction direction
  25696. * @param length length of the ray
  25697. */
  25698. function Ray(
  25699. /** origin point */
  25700. origin,
  25701. /** direction */
  25702. direction,
  25703. /** length of the ray */
  25704. length) {
  25705. if (length === void 0) { length = Number.MAX_VALUE; }
  25706. this.origin = origin;
  25707. this.direction = direction;
  25708. this.length = length;
  25709. }
  25710. // Methods
  25711. /**
  25712. * Checks if the ray intersects a box
  25713. * @param minimum bound of the box
  25714. * @param maximum bound of the box
  25715. * @param intersectionTreshold extra extend to be added to the box in all direction
  25716. * @returns if the box was hit
  25717. */
  25718. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25719. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25720. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25721. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25722. var d = 0.0;
  25723. var maxValue = Number.MAX_VALUE;
  25724. var inv;
  25725. var min;
  25726. var max;
  25727. var temp;
  25728. if (Math.abs(this.direction.x) < 0.0000001) {
  25729. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25730. return false;
  25731. }
  25732. }
  25733. else {
  25734. inv = 1.0 / this.direction.x;
  25735. min = (newMinimum.x - this.origin.x) * inv;
  25736. max = (newMaximum.x - this.origin.x) * inv;
  25737. if (max === -Infinity) {
  25738. max = Infinity;
  25739. }
  25740. if (min > max) {
  25741. temp = min;
  25742. min = max;
  25743. max = temp;
  25744. }
  25745. d = Math.max(min, d);
  25746. maxValue = Math.min(max, maxValue);
  25747. if (d > maxValue) {
  25748. return false;
  25749. }
  25750. }
  25751. if (Math.abs(this.direction.y) < 0.0000001) {
  25752. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25753. return false;
  25754. }
  25755. }
  25756. else {
  25757. inv = 1.0 / this.direction.y;
  25758. min = (newMinimum.y - this.origin.y) * inv;
  25759. max = (newMaximum.y - this.origin.y) * inv;
  25760. if (max === -Infinity) {
  25761. max = Infinity;
  25762. }
  25763. if (min > max) {
  25764. temp = min;
  25765. min = max;
  25766. max = temp;
  25767. }
  25768. d = Math.max(min, d);
  25769. maxValue = Math.min(max, maxValue);
  25770. if (d > maxValue) {
  25771. return false;
  25772. }
  25773. }
  25774. if (Math.abs(this.direction.z) < 0.0000001) {
  25775. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25776. return false;
  25777. }
  25778. }
  25779. else {
  25780. inv = 1.0 / this.direction.z;
  25781. min = (newMinimum.z - this.origin.z) * inv;
  25782. max = (newMaximum.z - this.origin.z) * inv;
  25783. if (max === -Infinity) {
  25784. max = Infinity;
  25785. }
  25786. if (min > max) {
  25787. temp = min;
  25788. min = max;
  25789. max = temp;
  25790. }
  25791. d = Math.max(min, d);
  25792. maxValue = Math.min(max, maxValue);
  25793. if (d > maxValue) {
  25794. return false;
  25795. }
  25796. }
  25797. return true;
  25798. };
  25799. /**
  25800. * Checks if the ray intersects a box
  25801. * @param box the bounding box to check
  25802. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25803. * @returns if the box was hit
  25804. */
  25805. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25806. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25807. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25808. };
  25809. /**
  25810. * If the ray hits a sphere
  25811. * @param sphere the bounding sphere to check
  25812. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25813. * @returns true if it hits the sphere
  25814. */
  25815. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25816. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25817. var x = sphere.center.x - this.origin.x;
  25818. var y = sphere.center.y - this.origin.y;
  25819. var z = sphere.center.z - this.origin.z;
  25820. var pyth = (x * x) + (y * y) + (z * z);
  25821. var radius = sphere.radius + intersectionTreshold;
  25822. var rr = radius * radius;
  25823. if (pyth <= rr) {
  25824. return true;
  25825. }
  25826. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25827. if (dot < 0.0) {
  25828. return false;
  25829. }
  25830. var temp = pyth - (dot * dot);
  25831. return temp <= rr;
  25832. };
  25833. /**
  25834. * If the ray hits a triange
  25835. * @param vertex0 triangle vertex
  25836. * @param vertex1 triangle vertex
  25837. * @param vertex2 triangle vertex
  25838. * @returns intersection information if hit
  25839. */
  25840. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25841. var edge1 = Ray.TmpVector3[0];
  25842. var edge2 = Ray.TmpVector3[1];
  25843. var pvec = Ray.TmpVector3[2];
  25844. var tvec = Ray.TmpVector3[3];
  25845. var qvec = Ray.TmpVector3[4];
  25846. vertex1.subtractToRef(vertex0, edge1);
  25847. vertex2.subtractToRef(vertex0, edge2);
  25848. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25849. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25850. if (det === 0) {
  25851. return null;
  25852. }
  25853. var invdet = 1 / det;
  25854. this.origin.subtractToRef(vertex0, tvec);
  25855. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25856. if (bu < 0 || bu > 1.0) {
  25857. return null;
  25858. }
  25859. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25860. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25861. if (bv < 0 || bu + bv > 1.0) {
  25862. return null;
  25863. }
  25864. //check if the distance is longer than the predefined length.
  25865. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25866. if (distance > this.length) {
  25867. return null;
  25868. }
  25869. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25870. };
  25871. /**
  25872. * Checks if ray intersects a plane
  25873. * @param plane the plane to check
  25874. * @returns the distance away it was hit
  25875. */
  25876. Ray.prototype.intersectsPlane = function (plane) {
  25877. var distance;
  25878. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25879. if (Math.abs(result1) < 9.99999997475243E-07) {
  25880. return null;
  25881. }
  25882. else {
  25883. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25884. distance = (-plane.d - result2) / result1;
  25885. if (distance < 0.0) {
  25886. if (distance < -9.99999997475243E-07) {
  25887. return null;
  25888. }
  25889. else {
  25890. return 0;
  25891. }
  25892. }
  25893. return distance;
  25894. }
  25895. };
  25896. /**
  25897. * Checks if ray intersects a mesh
  25898. * @param mesh the mesh to check
  25899. * @param fastCheck if only the bounding box should checked
  25900. * @returns picking info of the intersecton
  25901. */
  25902. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25903. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25904. mesh.getWorldMatrix().invertToRef(tm);
  25905. if (this._tmpRay) {
  25906. Ray.TransformToRef(this, tm, this._tmpRay);
  25907. }
  25908. else {
  25909. this._tmpRay = Ray.Transform(this, tm);
  25910. }
  25911. return mesh.intersects(this._tmpRay, fastCheck);
  25912. };
  25913. /**
  25914. * Checks if ray intersects a mesh
  25915. * @param meshes the meshes to check
  25916. * @param fastCheck if only the bounding box should checked
  25917. * @param results array to store result in
  25918. * @returns Array of picking infos
  25919. */
  25920. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25921. if (results) {
  25922. results.length = 0;
  25923. }
  25924. else {
  25925. results = [];
  25926. }
  25927. for (var i = 0; i < meshes.length; i++) {
  25928. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25929. if (pickInfo.hit) {
  25930. results.push(pickInfo);
  25931. }
  25932. }
  25933. results.sort(this._comparePickingInfo);
  25934. return results;
  25935. };
  25936. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25937. if (pickingInfoA.distance < pickingInfoB.distance) {
  25938. return -1;
  25939. }
  25940. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25941. return 1;
  25942. }
  25943. else {
  25944. return 0;
  25945. }
  25946. };
  25947. /**
  25948. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25949. * @param sega the first point of the segment to test the intersection against
  25950. * @param segb the second point of the segment to test the intersection against
  25951. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25952. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25953. */
  25954. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25955. var o = this.origin;
  25956. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25957. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25958. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25959. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25960. segb.subtractToRef(sega, u);
  25961. this.direction.scaleToRef(Ray.rayl, v);
  25962. o.addToRef(v, rsegb);
  25963. sega.subtractToRef(o, w);
  25964. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25965. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25966. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25967. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25968. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25969. var D = a * c - b * b; // always >= 0
  25970. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25971. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25972. // compute the line parameters of the two closest points
  25973. if (D < Ray.smallnum) { // the lines are almost parallel
  25974. sN = 0.0; // force using point P0 on segment S1
  25975. sD = 1.0; // to prevent possible division by 0.0 later
  25976. tN = e;
  25977. tD = c;
  25978. }
  25979. else { // get the closest points on the infinite lines
  25980. sN = (b * e - c * d);
  25981. tN = (a * e - b * d);
  25982. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25983. sN = 0.0;
  25984. tN = e;
  25985. tD = c;
  25986. }
  25987. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25988. sN = sD;
  25989. tN = e + b;
  25990. tD = c;
  25991. }
  25992. }
  25993. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25994. tN = 0.0;
  25995. // recompute sc for this edge
  25996. if (-d < 0.0) {
  25997. sN = 0.0;
  25998. }
  25999. else if (-d > a) {
  26000. sN = sD;
  26001. }
  26002. else {
  26003. sN = -d;
  26004. sD = a;
  26005. }
  26006. }
  26007. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  26008. tN = tD;
  26009. // recompute sc for this edge
  26010. if ((-d + b) < 0.0) {
  26011. sN = 0;
  26012. }
  26013. else if ((-d + b) > a) {
  26014. sN = sD;
  26015. }
  26016. else {
  26017. sN = (-d + b);
  26018. sD = a;
  26019. }
  26020. }
  26021. // finally do the division to get sc and tc
  26022. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  26023. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  26024. // get the difference of the two closest points
  26025. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  26026. v.scaleToRef(tc, qtc);
  26027. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  26028. u.scaleToRef(sc, qsc);
  26029. qsc.addInPlace(w);
  26030. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  26031. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  26032. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  26033. if (isIntersected) {
  26034. return qsc.length();
  26035. }
  26036. return -1;
  26037. };
  26038. /**
  26039. * Update the ray from viewport position
  26040. * @param x position
  26041. * @param y y position
  26042. * @param viewportWidth viewport width
  26043. * @param viewportHeight viewport height
  26044. * @param world world matrix
  26045. * @param view view matrix
  26046. * @param projection projection matrix
  26047. * @returns this ray updated
  26048. */
  26049. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26050. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  26051. return this;
  26052. };
  26053. // Statics
  26054. /**
  26055. * Creates a ray with origin and direction of 0,0,0
  26056. * @returns the new ray
  26057. */
  26058. Ray.Zero = function () {
  26059. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  26060. };
  26061. /**
  26062. * Creates a new ray from screen space and viewport
  26063. * @param x position
  26064. * @param y y position
  26065. * @param viewportWidth viewport width
  26066. * @param viewportHeight viewport height
  26067. * @param world world matrix
  26068. * @param view view matrix
  26069. * @param projection projection matrix
  26070. * @returns new ray
  26071. */
  26072. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26073. var result = Ray.Zero();
  26074. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  26075. };
  26076. /**
  26077. * 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
  26078. * transformed to the given world matrix.
  26079. * @param origin The origin point
  26080. * @param end The end point
  26081. * @param world a matrix to transform the ray to. Default is the identity matrix.
  26082. * @returns the new ray
  26083. */
  26084. Ray.CreateNewFromTo = function (origin, end, world) {
  26085. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  26086. var direction = end.subtract(origin);
  26087. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  26088. direction.normalize();
  26089. return Ray.Transform(new Ray(origin, direction, length), world);
  26090. };
  26091. /**
  26092. * Transforms a ray by a matrix
  26093. * @param ray ray to transform
  26094. * @param matrix matrix to apply
  26095. * @returns the resulting new ray
  26096. */
  26097. Ray.Transform = function (ray, matrix) {
  26098. 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));
  26099. Ray.TransformToRef(ray, matrix, result);
  26100. return result;
  26101. };
  26102. /**
  26103. * Transforms a ray by a matrix
  26104. * @param ray ray to transform
  26105. * @param matrix matrix to apply
  26106. * @param result ray to store result in
  26107. */
  26108. Ray.TransformToRef = function (ray, matrix, result) {
  26109. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  26110. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  26111. result.length = ray.length;
  26112. var dir = result.direction;
  26113. var len = dir.length();
  26114. if (!(len === 0 || len === 1)) {
  26115. var num = 1.0 / len;
  26116. dir.x *= num;
  26117. dir.y *= num;
  26118. dir.z *= num;
  26119. result.length *= len;
  26120. }
  26121. };
  26122. /**
  26123. * Unproject a ray from screen space to object space
  26124. * @param sourceX defines the screen space x coordinate to use
  26125. * @param sourceY defines the screen space y coordinate to use
  26126. * @param viewportWidth defines the current width of the viewport
  26127. * @param viewportHeight defines the current height of the viewport
  26128. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  26129. * @param view defines the view matrix to use
  26130. * @param projection defines the projection matrix to use
  26131. */
  26132. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  26133. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26134. world.multiplyToRef(view, matrix);
  26135. matrix.multiplyToRef(projection, matrix);
  26136. matrix.invert();
  26137. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26138. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  26139. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  26140. nearScreenSource.z = -1.0;
  26141. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  26142. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26143. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26144. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  26145. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  26146. this.origin.copyFrom(nearVec3);
  26147. farVec3.subtractToRef(nearVec3, this.direction);
  26148. this.direction.normalize();
  26149. };
  26150. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26151. Ray.smallnum = 0.00000001;
  26152. Ray.rayl = 10e8;
  26153. return Ray;
  26154. }());
  26155. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  26156. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26157. var result = Ray.Zero();
  26158. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  26159. return result;
  26160. };
  26161. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  26162. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26163. var engine = this.getEngine();
  26164. if (!camera) {
  26165. if (!this.activeCamera) {
  26166. throw new Error("Active camera not set");
  26167. }
  26168. camera = this.activeCamera;
  26169. }
  26170. var cameraViewport = camera.viewport;
  26171. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26172. // Moving coordinates to local viewport world
  26173. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26174. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26175. result.update(x, y, viewport.width, viewport.height, world ? world : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly, cameraViewSpace ? _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
  26176. return this;
  26177. };
  26178. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  26179. var result = Ray.Zero();
  26180. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  26181. return result;
  26182. };
  26183. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  26184. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26185. return this;
  26186. }
  26187. var engine = this.getEngine();
  26188. if (!camera) {
  26189. if (!this.activeCamera) {
  26190. throw new Error("Active camera not set");
  26191. }
  26192. camera = this.activeCamera;
  26193. }
  26194. var cameraViewport = camera.viewport;
  26195. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26196. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26197. // Moving coordinates to local viewport world
  26198. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26199. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26200. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  26201. return this;
  26202. };
  26203. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  26204. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26205. return null;
  26206. }
  26207. var pickingInfo = null;
  26208. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26209. var mesh = this.meshes[meshIndex];
  26210. if (predicate) {
  26211. if (!predicate(mesh)) {
  26212. continue;
  26213. }
  26214. }
  26215. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26216. continue;
  26217. }
  26218. var world = mesh.getWorldMatrix();
  26219. var ray = rayFunction(world);
  26220. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  26221. if (!result || !result.hit) {
  26222. continue;
  26223. }
  26224. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  26225. continue;
  26226. }
  26227. pickingInfo = result;
  26228. if (fastCheck) {
  26229. break;
  26230. }
  26231. }
  26232. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  26233. };
  26234. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  26235. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26236. return null;
  26237. }
  26238. var pickingInfos = new Array();
  26239. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26240. var mesh = this.meshes[meshIndex];
  26241. if (predicate) {
  26242. if (!predicate(mesh)) {
  26243. continue;
  26244. }
  26245. }
  26246. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26247. continue;
  26248. }
  26249. var world = mesh.getWorldMatrix();
  26250. var ray = rayFunction(world);
  26251. var result = mesh.intersects(ray, false, trianglePredicate);
  26252. if (!result || !result.hit) {
  26253. continue;
  26254. }
  26255. pickingInfos.push(result);
  26256. }
  26257. return pickingInfos;
  26258. };
  26259. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  26260. var _this = this;
  26261. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26262. return null;
  26263. }
  26264. var result = this._internalPick(function (world) {
  26265. if (!_this._tempPickingRay) {
  26266. _this._tempPickingRay = Ray.Zero();
  26267. }
  26268. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  26269. return _this._tempPickingRay;
  26270. }, predicate, fastCheck, trianglePredicate);
  26271. if (result) {
  26272. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  26273. }
  26274. return result;
  26275. };
  26276. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  26277. var _this = this;
  26278. var result = this._internalPick(function (world) {
  26279. if (!_this._pickWithRayInverseMatrix) {
  26280. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26281. }
  26282. world.invertToRef(_this._pickWithRayInverseMatrix);
  26283. if (!_this._cachedRayForTransform) {
  26284. _this._cachedRayForTransform = Ray.Zero();
  26285. }
  26286. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26287. return _this._cachedRayForTransform;
  26288. }, predicate, fastCheck, trianglePredicate);
  26289. if (result) {
  26290. result.ray = ray;
  26291. }
  26292. return result;
  26293. };
  26294. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  26295. var _this = this;
  26296. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  26297. };
  26298. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  26299. var _this = this;
  26300. return this._internalMultiPick(function (world) {
  26301. if (!_this._pickWithRayInverseMatrix) {
  26302. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26303. }
  26304. world.invertToRef(_this._pickWithRayInverseMatrix);
  26305. if (!_this._cachedRayForTransform) {
  26306. _this._cachedRayForTransform = Ray.Zero();
  26307. }
  26308. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26309. return _this._cachedRayForTransform;
  26310. }, predicate, trianglePredicate);
  26311. };
  26312. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  26313. if (length === void 0) { length = 100; }
  26314. if (!transform) {
  26315. transform = this.getWorldMatrix();
  26316. }
  26317. if (!origin) {
  26318. origin = this.position;
  26319. }
  26320. var forward = this._scene.useRightHandedSystem ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1) : new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1);
  26321. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  26322. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  26323. return new Ray(origin, direction, length);
  26324. };
  26325. /***/ }),
  26326. /***/ "./Debug/axesViewer.ts":
  26327. /*!*****************************!*\
  26328. !*** ./Debug/axesViewer.ts ***!
  26329. \*****************************/
  26330. /*! exports provided: AxesViewer */
  26331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26332. "use strict";
  26333. __webpack_require__.r(__webpack_exports__);
  26334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  26335. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26336. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26337. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  26338. /**
  26339. * The Axes viewer will show 3 axes in a specific point in space
  26340. */
  26341. var AxesViewer = /** @class */ (function () {
  26342. /**
  26343. * Creates a new AxesViewer
  26344. * @param scene defines the hosting scene
  26345. * @param scaleLines defines a number used to scale line length (1 by default)
  26346. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  26347. * @param xAxis defines the node hierarchy used to render the x-axis
  26348. * @param yAxis defines the node hierarchy used to render the y-axis
  26349. * @param zAxis defines the node hierarchy used to render the z-axis
  26350. */
  26351. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  26352. if (scaleLines === void 0) { scaleLines = 1; }
  26353. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  26354. this._scaleLinesFactor = 4;
  26355. this._instanced = false;
  26356. /**
  26357. * Gets or sets a number used to scale line length
  26358. */
  26359. this.scaleLines = 1;
  26360. this.scaleLines = scaleLines;
  26361. if (!xAxis) {
  26362. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26363. redColoredMaterial.disableLighting = true;
  26364. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  26365. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  26366. }
  26367. if (!yAxis) {
  26368. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26369. greenColoredMaterial.disableLighting = true;
  26370. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  26371. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  26372. }
  26373. if (!zAxis) {
  26374. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26375. blueColoredMaterial.disableLighting = true;
  26376. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  26377. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  26378. }
  26379. this._xAxis = xAxis;
  26380. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26381. this._yAxis = yAxis;
  26382. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26383. this._zAxis = zAxis;
  26384. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26385. if (renderingGroupId != null) {
  26386. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  26387. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  26388. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  26389. }
  26390. this.scene = scene;
  26391. 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());
  26392. }
  26393. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  26394. /** Gets the node hierarchy used to render x-axis */
  26395. get: function () {
  26396. return this._xAxis;
  26397. },
  26398. enumerable: true,
  26399. configurable: true
  26400. });
  26401. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  26402. /** Gets the node hierarchy used to render y-axis */
  26403. get: function () {
  26404. return this._yAxis;
  26405. },
  26406. enumerable: true,
  26407. configurable: true
  26408. });
  26409. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  26410. /** Gets the node hierarchy used to render z-axis */
  26411. get: function () {
  26412. return this._zAxis;
  26413. },
  26414. enumerable: true,
  26415. configurable: true
  26416. });
  26417. /**
  26418. * Force the viewer to update
  26419. * @param position defines the position of the viewer
  26420. * @param xaxis defines the x axis of the viewer
  26421. * @param yaxis defines the y axis of the viewer
  26422. * @param zaxis defines the z axis of the viewer
  26423. */
  26424. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  26425. this._xAxis.position.copyFrom(position);
  26426. this._xAxis.setDirection(xaxis);
  26427. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26428. this._yAxis.position.copyFrom(position);
  26429. this._yAxis.setDirection(yaxis);
  26430. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26431. this._zAxis.position.copyFrom(position);
  26432. this._zAxis.setDirection(zaxis);
  26433. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26434. };
  26435. /**
  26436. * Creates an instance of this axes viewer.
  26437. * @returns a new axes viewer with instanced meshes
  26438. */
  26439. AxesViewer.prototype.createInstance = function () {
  26440. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  26441. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  26442. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  26443. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  26444. axesViewer._instanced = true;
  26445. return axesViewer;
  26446. };
  26447. /** Releases resources */
  26448. AxesViewer.prototype.dispose = function () {
  26449. if (this._xAxis) {
  26450. this._xAxis.dispose(false, !this._instanced);
  26451. delete this._xAxis;
  26452. }
  26453. if (this._yAxis) {
  26454. this._yAxis.dispose(false, !this._instanced);
  26455. delete this._yAxis;
  26456. }
  26457. if (this._zAxis) {
  26458. this._zAxis.dispose(false, !this._instanced);
  26459. delete this._zAxis;
  26460. }
  26461. delete this.scene;
  26462. };
  26463. AxesViewer._SetRenderingGroupId = function (node, id) {
  26464. node.getChildMeshes().forEach(function (mesh) {
  26465. mesh.renderingGroupId = id;
  26466. });
  26467. };
  26468. return AxesViewer;
  26469. }());
  26470. /***/ }),
  26471. /***/ "./Debug/boneAxesViewer.ts":
  26472. /*!*********************************!*\
  26473. !*** ./Debug/boneAxesViewer.ts ***!
  26474. \*********************************/
  26475. /*! exports provided: BoneAxesViewer */
  26476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26477. "use strict";
  26478. __webpack_require__.r(__webpack_exports__);
  26479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  26480. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26481. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  26482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26483. /**
  26484. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  26485. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  26486. */
  26487. var BoneAxesViewer = /** @class */ (function (_super) {
  26488. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  26489. /**
  26490. * Creates a new BoneAxesViewer
  26491. * @param scene defines the hosting scene
  26492. * @param bone defines the target bone
  26493. * @param mesh defines the target mesh
  26494. * @param scaleLines defines a scaling factor for line length (1 by default)
  26495. */
  26496. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  26497. if (scaleLines === void 0) { scaleLines = 1; }
  26498. var _this = _super.call(this, scene, scaleLines) || this;
  26499. /** Gets current position */
  26500. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26501. /** Gets direction of X axis */
  26502. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26503. /** Gets direction of Y axis */
  26504. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26505. /** Gets direction of Z axis */
  26506. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26507. _this.mesh = mesh;
  26508. _this.bone = bone;
  26509. return _this;
  26510. }
  26511. /**
  26512. * Force the viewer to update
  26513. */
  26514. BoneAxesViewer.prototype.update = function () {
  26515. if (!this.mesh || !this.bone) {
  26516. return;
  26517. }
  26518. var bone = this.bone;
  26519. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  26520. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  26521. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  26522. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  26523. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  26524. };
  26525. /** Releases resources */
  26526. BoneAxesViewer.prototype.dispose = function () {
  26527. if (this.mesh) {
  26528. this.mesh = null;
  26529. this.bone = null;
  26530. _super.prototype.dispose.call(this);
  26531. }
  26532. };
  26533. return BoneAxesViewer;
  26534. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  26535. /***/ }),
  26536. /***/ "./Debug/debugLayer.ts":
  26537. /*!*****************************!*\
  26538. !*** ./Debug/debugLayer.ts ***!
  26539. \*****************************/
  26540. /*! exports provided: DebugLayer */
  26541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26542. "use strict";
  26543. __webpack_require__.r(__webpack_exports__);
  26544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  26545. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26546. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26547. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26548. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26549. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  26550. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  26551. get: function () {
  26552. if (!this._debugLayer) {
  26553. this._debugLayer = new DebugLayer(this);
  26554. }
  26555. return this._debugLayer;
  26556. },
  26557. enumerable: true,
  26558. configurable: true
  26559. });
  26560. /**
  26561. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26562. * what is happening in your scene
  26563. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26564. */
  26565. var DebugLayer = /** @class */ (function () {
  26566. /**
  26567. * Instantiates a new debug layer.
  26568. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26569. * what is happening in your scene
  26570. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26571. * @param scene Defines the scene to inspect
  26572. */
  26573. function DebugLayer(scene) {
  26574. var _this = this;
  26575. this.BJSINSPECTOR = this._getGlobalInspector();
  26576. /**
  26577. * Observable triggered when a property is changed through the inspector.
  26578. */
  26579. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26580. this._scene = scene;
  26581. this._scene.onDisposeObservable.add(function () {
  26582. // Debug layer
  26583. if (_this._scene._debugLayer) {
  26584. _this._scene._debugLayer.hide();
  26585. }
  26586. });
  26587. }
  26588. /** Creates the inspector window. */
  26589. DebugLayer.prototype._createInspector = function (config) {
  26590. if (this.isVisible()) {
  26591. return;
  26592. }
  26593. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26594. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26595. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26596. };
  26597. /**
  26598. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  26599. * @param entity defines the entity to select
  26600. * @param lineContainerTitle defines the specific block to highlight
  26601. */
  26602. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26603. if (this.BJSINSPECTOR) {
  26604. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26605. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26606. }
  26607. };
  26608. /** Get the inspector from bundle or global */
  26609. DebugLayer.prototype._getGlobalInspector = function () {
  26610. // UMD Global name detection from Webpack Bundle UMD Name.
  26611. if (typeof INSPECTOR !== 'undefined') {
  26612. return INSPECTOR;
  26613. }
  26614. // In case of module let s check the global emitted from the Inspector entry point.
  26615. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26616. return BABYLON;
  26617. }
  26618. return undefined;
  26619. };
  26620. /**
  26621. * Get if the inspector is visible or not.
  26622. * @returns true if visible otherwise, false
  26623. */
  26624. DebugLayer.prototype.isVisible = function () {
  26625. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26626. };
  26627. /**
  26628. * Hide the inspector and close its window.
  26629. */
  26630. DebugLayer.prototype.hide = function () {
  26631. if (this.BJSINSPECTOR) {
  26632. this.BJSINSPECTOR.Inspector.Hide();
  26633. }
  26634. };
  26635. /**
  26636. * Launch the debugLayer.
  26637. * @param config Define the configuration of the inspector
  26638. * @return a promise fulfilled when the debug layer is visible
  26639. */
  26640. DebugLayer.prototype.show = function (config) {
  26641. var _this = this;
  26642. return new Promise(function (resolve, reject) {
  26643. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26644. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26645. // Load inspector and add it to the DOM
  26646. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26647. _this._createInspector(config);
  26648. resolve(_this);
  26649. });
  26650. }
  26651. else {
  26652. // Otherwise creates the inspector
  26653. _this._createInspector(config);
  26654. resolve(_this);
  26655. }
  26656. });
  26657. };
  26658. /**
  26659. * Define the url to get the inspector script from.
  26660. * By default it uses the babylonjs CDN.
  26661. * @ignoreNaming
  26662. */
  26663. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26664. return DebugLayer;
  26665. }());
  26666. /***/ }),
  26667. /***/ "./Debug/index.ts":
  26668. /*!************************!*\
  26669. !*** ./Debug/index.ts ***!
  26670. \************************/
  26671. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26673. "use strict";
  26674. __webpack_require__.r(__webpack_exports__);
  26675. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26677. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26679. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26681. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26683. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26685. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26687. /***/ }),
  26688. /***/ "./Debug/physicsViewer.ts":
  26689. /*!********************************!*\
  26690. !*** ./Debug/physicsViewer.ts ***!
  26691. \********************************/
  26692. /*! exports provided: PhysicsViewer */
  26693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26694. "use strict";
  26695. __webpack_require__.r(__webpack_exports__);
  26696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26697. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26698. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26699. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26700. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26701. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26702. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26703. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26704. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26705. /**
  26706. * Used to show the physics impostor around the specific mesh
  26707. */
  26708. var PhysicsViewer = /** @class */ (function () {
  26709. /**
  26710. * Creates a new PhysicsViewer
  26711. * @param scene defines the hosting scene
  26712. */
  26713. function PhysicsViewer(scene) {
  26714. /** @hidden */
  26715. this._impostors = [];
  26716. /** @hidden */
  26717. this._meshes = [];
  26718. /** @hidden */
  26719. this._numMeshes = 0;
  26720. this._debugMeshMeshes = new Array();
  26721. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  26722. var physicEngine = this._scene.getPhysicsEngine();
  26723. if (physicEngine) {
  26724. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26725. }
  26726. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"](this._scene, false);
  26727. this._utilityLayer.pickUtilitySceneFirst = false;
  26728. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26729. }
  26730. /** @hidden */
  26731. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26732. var plugin = this._physicsEnginePlugin;
  26733. for (var i = 0; i < this._numMeshes; i++) {
  26734. var impostor = this._impostors[i];
  26735. if (!impostor) {
  26736. continue;
  26737. }
  26738. if (impostor.isDisposed) {
  26739. this.hideImpostor(this._impostors[i--]);
  26740. }
  26741. else {
  26742. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor) {
  26743. continue;
  26744. }
  26745. var mesh = this._meshes[i];
  26746. if (mesh && plugin) {
  26747. plugin.syncMeshWithImpostor(mesh, impostor);
  26748. }
  26749. }
  26750. }
  26751. };
  26752. /**
  26753. * Renders a specified physic impostor
  26754. * @param impostor defines the impostor to render
  26755. * @param targetMesh defines the mesh represented by the impostor
  26756. * @returns the new debug mesh used to render the impostor
  26757. */
  26758. PhysicsViewer.prototype.showImpostor = function (impostor, targetMesh) {
  26759. if (!this._scene) {
  26760. return null;
  26761. }
  26762. for (var i = 0; i < this._numMeshes; i++) {
  26763. if (this._impostors[i] == impostor) {
  26764. return null;
  26765. }
  26766. }
  26767. var debugMesh = this._getDebugMesh(impostor, targetMesh);
  26768. if (debugMesh) {
  26769. this._impostors[this._numMeshes] = impostor;
  26770. this._meshes[this._numMeshes] = debugMesh;
  26771. if (this._numMeshes === 0) {
  26772. this._renderFunction = this._updateDebugMeshes.bind(this);
  26773. this._scene.registerBeforeRender(this._renderFunction);
  26774. }
  26775. this._numMeshes++;
  26776. }
  26777. return debugMesh;
  26778. };
  26779. /**
  26780. * Hides a specified physic impostor
  26781. * @param impostor defines the impostor to hide
  26782. */
  26783. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26784. if (!impostor || !this._scene || !this._utilityLayer) {
  26785. return;
  26786. }
  26787. var removed = false;
  26788. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26789. for (var i = 0; i < this._numMeshes; i++) {
  26790. if (this._impostors[i] == impostor) {
  26791. var mesh = this._meshes[i];
  26792. if (!mesh) {
  26793. continue;
  26794. }
  26795. utilityLayerScene.removeMesh(mesh);
  26796. mesh.dispose();
  26797. var index = this._debugMeshMeshes.indexOf(mesh);
  26798. if (index > -1) {
  26799. this._debugMeshMeshes.splice(index, 1);
  26800. }
  26801. this._numMeshes--;
  26802. if (this._numMeshes > 0) {
  26803. this._meshes[i] = this._meshes[this._numMeshes];
  26804. this._impostors[i] = this._impostors[this._numMeshes];
  26805. this._meshes[this._numMeshes] = null;
  26806. this._impostors[this._numMeshes] = null;
  26807. }
  26808. else {
  26809. this._meshes[0] = null;
  26810. this._impostors[0] = null;
  26811. }
  26812. removed = true;
  26813. break;
  26814. }
  26815. }
  26816. if (removed && this._numMeshes === 0) {
  26817. this._scene.unregisterBeforeRender(this._renderFunction);
  26818. }
  26819. };
  26820. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26821. if (!this._debugMaterial) {
  26822. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]('', scene);
  26823. this._debugMaterial.wireframe = true;
  26824. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].White();
  26825. this._debugMaterial.disableLighting = true;
  26826. }
  26827. return this._debugMaterial;
  26828. };
  26829. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26830. if (!this._debugBoxMesh) {
  26831. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26832. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26833. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26834. this._debugBoxMesh.setEnabled(false);
  26835. }
  26836. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26837. };
  26838. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26839. if (!this._debugSphereMesh) {
  26840. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26841. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26842. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26843. this._debugSphereMesh.setEnabled(false);
  26844. }
  26845. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26846. };
  26847. PhysicsViewer.prototype._getDebugMeshMesh = function (mesh, scene) {
  26848. var wireframeOver = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](mesh.name, scene, null, mesh);
  26849. wireframeOver.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  26850. wireframeOver.setParent(mesh);
  26851. wireframeOver.material = this._getDebugMaterial(scene);
  26852. this._debugMeshMeshes.push(wireframeOver);
  26853. return wireframeOver;
  26854. };
  26855. PhysicsViewer.prototype._getDebugMesh = function (impostor, targetMesh) {
  26856. if (!this._utilityLayer) {
  26857. return null;
  26858. }
  26859. var mesh = null;
  26860. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26861. switch (impostor.type) {
  26862. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].BoxImpostor:
  26863. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26864. impostor.getBoxSizeToRef(mesh.scaling);
  26865. break;
  26866. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].SphereImpostor:
  26867. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26868. var radius = impostor.getRadius();
  26869. mesh.scaling.x = radius * 2;
  26870. mesh.scaling.y = radius * 2;
  26871. mesh.scaling.z = radius * 2;
  26872. break;
  26873. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor:
  26874. if (targetMesh) {
  26875. mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
  26876. }
  26877. break;
  26878. }
  26879. return mesh;
  26880. };
  26881. /** Releases all resources */
  26882. PhysicsViewer.prototype.dispose = function () {
  26883. var count = this._numMeshes;
  26884. for (var index = 0; index < count; index++) {
  26885. this.hideImpostor(this._impostors[0]);
  26886. }
  26887. if (this._debugBoxMesh) {
  26888. this._debugBoxMesh.dispose();
  26889. }
  26890. if (this._debugSphereMesh) {
  26891. this._debugSphereMesh.dispose();
  26892. }
  26893. if (this._debugMaterial) {
  26894. this._debugMaterial.dispose();
  26895. }
  26896. this._impostors.length = 0;
  26897. this._scene = null;
  26898. this._physicsEnginePlugin = null;
  26899. if (this._utilityLayer) {
  26900. this._utilityLayer.dispose();
  26901. this._utilityLayer = null;
  26902. }
  26903. };
  26904. return PhysicsViewer;
  26905. }());
  26906. /***/ }),
  26907. /***/ "./Debug/rayHelper.ts":
  26908. /*!****************************!*\
  26909. !*** ./Debug/rayHelper.ts ***!
  26910. \****************************/
  26911. /*! exports provided: RayHelper */
  26912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26913. "use strict";
  26914. __webpack_require__.r(__webpack_exports__);
  26915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26916. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26917. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26918. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26919. /**
  26920. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26921. * in order to better appreciate the issue one might have.
  26922. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26923. */
  26924. var RayHelper = /** @class */ (function () {
  26925. /**
  26926. * Instantiate a new ray helper.
  26927. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26928. * in order to better appreciate the issue one might have.
  26929. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26930. * @param ray Defines the ray we are currently tryin to visualize
  26931. */
  26932. function RayHelper(ray) {
  26933. this.ray = ray;
  26934. }
  26935. /**
  26936. * Helper function to create a colored helper in a scene in one line.
  26937. * @param ray Defines the ray we are currently tryin to visualize
  26938. * @param scene Defines the scene the ray is used in
  26939. * @param color Defines the color we want to see the ray in
  26940. * @returns The newly created ray helper.
  26941. */
  26942. RayHelper.CreateAndShow = function (ray, scene, color) {
  26943. var helper = new RayHelper(ray);
  26944. helper.show(scene, color);
  26945. return helper;
  26946. };
  26947. /**
  26948. * Shows the ray we are willing to debug.
  26949. * @param scene Defines the scene the ray needs to be rendered in
  26950. * @param color Defines the color the ray needs to be rendered in
  26951. */
  26952. RayHelper.prototype.show = function (scene, color) {
  26953. if (!this._renderFunction && this.ray) {
  26954. var ray = this.ray;
  26955. this._renderFunction = this._render.bind(this);
  26956. this._scene = scene;
  26957. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26958. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26959. if (this._renderFunction) {
  26960. this._scene.registerBeforeRender(this._renderFunction);
  26961. }
  26962. }
  26963. if (color && this._renderLine) {
  26964. this._renderLine.color.copyFrom(color);
  26965. }
  26966. };
  26967. /**
  26968. * Hides the ray we are debugging.
  26969. */
  26970. RayHelper.prototype.hide = function () {
  26971. if (this._renderFunction && this._scene) {
  26972. this._scene.unregisterBeforeRender(this._renderFunction);
  26973. this._scene = null;
  26974. this._renderFunction = null;
  26975. if (this._renderLine) {
  26976. this._renderLine.dispose();
  26977. this._renderLine = null;
  26978. }
  26979. this._renderPoints = [];
  26980. }
  26981. };
  26982. RayHelper.prototype._render = function () {
  26983. var ray = this.ray;
  26984. if (!ray) {
  26985. return;
  26986. }
  26987. var point = this._renderPoints[1];
  26988. var len = Math.min(ray.length, 1000000);
  26989. point.copyFrom(ray.direction);
  26990. point.scaleInPlace(len);
  26991. point.addInPlace(ray.origin);
  26992. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26993. };
  26994. /**
  26995. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26996. * @param mesh Defines the mesh we want the helper attached to
  26997. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26998. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26999. * @param length Defines the length of the ray
  27000. */
  27001. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  27002. this._attachedToMesh = mesh;
  27003. var ray = this.ray;
  27004. if (!ray) {
  27005. return;
  27006. }
  27007. if (!ray.direction) {
  27008. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27009. }
  27010. if (!ray.origin) {
  27011. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27012. }
  27013. if (length) {
  27014. ray.length = length;
  27015. }
  27016. if (!meshSpaceOrigin) {
  27017. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27018. }
  27019. if (!meshSpaceDirection) {
  27020. // -1 so that this will work with Mesh.lookAt
  27021. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  27022. }
  27023. if (!this._meshSpaceDirection) {
  27024. this._meshSpaceDirection = meshSpaceDirection.clone();
  27025. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  27026. }
  27027. else {
  27028. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  27029. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  27030. }
  27031. if (!this._updateToMeshFunction) {
  27032. this._updateToMeshFunction = this._updateToMesh.bind(this);
  27033. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  27034. }
  27035. this._updateToMesh();
  27036. };
  27037. /**
  27038. * Detach the ray helper from the mesh it has previously been attached to.
  27039. */
  27040. RayHelper.prototype.detachFromMesh = function () {
  27041. if (this._attachedToMesh) {
  27042. if (this._updateToMeshFunction) {
  27043. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  27044. }
  27045. this._attachedToMesh = null;
  27046. this._updateToMeshFunction = null;
  27047. }
  27048. };
  27049. RayHelper.prototype._updateToMesh = function () {
  27050. var ray = this.ray;
  27051. if (!this._attachedToMesh || !ray) {
  27052. return;
  27053. }
  27054. if (this._attachedToMesh._isDisposed) {
  27055. this.detachFromMesh();
  27056. return;
  27057. }
  27058. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  27059. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  27060. };
  27061. /**
  27062. * Dispose the helper and release its associated resources.
  27063. */
  27064. RayHelper.prototype.dispose = function () {
  27065. this.hide();
  27066. this.detachFromMesh();
  27067. this.ray = null;
  27068. };
  27069. return RayHelper;
  27070. }());
  27071. /***/ }),
  27072. /***/ "./Debug/skeletonViewer.ts":
  27073. /*!*********************************!*\
  27074. !*** ./Debug/skeletonViewer.ts ***!
  27075. \*********************************/
  27076. /*! exports provided: SkeletonViewer */
  27077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27078. "use strict";
  27079. __webpack_require__.r(__webpack_exports__);
  27080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  27081. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27082. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27083. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  27084. /**
  27085. * Class used to render a debug view of a given skeleton
  27086. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  27087. */
  27088. var SkeletonViewer = /** @class */ (function () {
  27089. /**
  27090. * Creates a new SkeletonViewer
  27091. * @param skeleton defines the skeleton to render
  27092. * @param mesh defines the mesh attached to the skeleton
  27093. * @param scene defines the hosting scene
  27094. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  27095. * @param renderingGroupId defines the rendering group id to use with the viewer
  27096. */
  27097. function SkeletonViewer(
  27098. /** defines the skeleton to render */
  27099. skeleton,
  27100. /** defines the mesh attached to the skeleton */
  27101. mesh, scene,
  27102. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  27103. autoUpdateBonesMatrices,
  27104. /** defines the rendering group id to use with the viewer */
  27105. renderingGroupId) {
  27106. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  27107. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  27108. this.skeleton = skeleton;
  27109. this.mesh = mesh;
  27110. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  27111. this.renderingGroupId = renderingGroupId;
  27112. /** Gets or sets the color used to render the skeleton */
  27113. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  27114. this._debugLines = new Array();
  27115. this._isEnabled = false;
  27116. this._scene = scene;
  27117. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  27118. this._utilityLayer.pickUtilitySceneFirst = false;
  27119. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  27120. this.update();
  27121. this._renderFunction = this.update.bind(this);
  27122. }
  27123. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  27124. /**
  27125. * Returns the mesh used to render the bones
  27126. */
  27127. get: function () {
  27128. return this._debugMesh;
  27129. },
  27130. enumerable: true,
  27131. configurable: true
  27132. });
  27133. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  27134. get: function () {
  27135. return this._isEnabled;
  27136. },
  27137. /** Gets or sets a boolean indicating if the viewer is enabled */
  27138. set: function (value) {
  27139. if (this._isEnabled === value) {
  27140. return;
  27141. }
  27142. this._isEnabled = value;
  27143. if (value) {
  27144. this._scene.registerBeforeRender(this._renderFunction);
  27145. }
  27146. else {
  27147. this._scene.unregisterBeforeRender(this._renderFunction);
  27148. }
  27149. },
  27150. enumerable: true,
  27151. configurable: true
  27152. });
  27153. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  27154. if (x === void 0) { x = 0; }
  27155. if (y === void 0) { y = 0; }
  27156. if (z === void 0) { z = 0; }
  27157. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  27158. var parentBone = bone.getParent();
  27159. tmat.copyFrom(bone.getLocalMatrix());
  27160. if (x !== 0 || y !== 0 || z !== 0) {
  27161. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  27162. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  27163. tmat2.setTranslationFromFloats(x, y, z);
  27164. tmat2.multiplyToRef(tmat, tmat);
  27165. }
  27166. if (parentBone) {
  27167. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  27168. }
  27169. tmat.multiplyToRef(meshMat, tmat);
  27170. position.x = tmat.m[12];
  27171. position.y = tmat.m[13];
  27172. position.z = tmat.m[14];
  27173. };
  27174. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  27175. var len = bones.length;
  27176. var meshPos = this.mesh.position;
  27177. for (var i = 0; i < len; i++) {
  27178. var bone = bones[i];
  27179. var points = this._debugLines[i];
  27180. if (!points) {
  27181. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27182. this._debugLines[i] = points;
  27183. }
  27184. this._getBonePosition(points[0], bone, meshMat);
  27185. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  27186. points[0].subtractInPlace(meshPos);
  27187. points[1].subtractInPlace(meshPos);
  27188. }
  27189. };
  27190. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  27191. var len = bones.length;
  27192. var boneNum = 0;
  27193. var meshPos = this.mesh.position;
  27194. for (var i = len - 1; i >= 0; i--) {
  27195. var childBone = bones[i];
  27196. var parentBone = childBone.getParent();
  27197. if (!parentBone) {
  27198. continue;
  27199. }
  27200. var points = this._debugLines[boneNum];
  27201. if (!points) {
  27202. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27203. this._debugLines[boneNum] = points;
  27204. }
  27205. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  27206. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  27207. points[0].subtractInPlace(meshPos);
  27208. points[1].subtractInPlace(meshPos);
  27209. boneNum++;
  27210. }
  27211. };
  27212. /** Update the viewer to sync with current skeleton state */
  27213. SkeletonViewer.prototype.update = function () {
  27214. if (!this._utilityLayer) {
  27215. return;
  27216. }
  27217. if (this.autoUpdateBonesMatrices) {
  27218. this.skeleton.computeAbsoluteTransforms();
  27219. }
  27220. if (this.skeleton.bones[0].length === undefined) {
  27221. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  27222. }
  27223. else {
  27224. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  27225. }
  27226. var targetScene = this._utilityLayer.utilityLayerScene;
  27227. if (!this._debugMesh) {
  27228. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  27229. this._debugMesh.renderingGroupId = this.renderingGroupId;
  27230. }
  27231. else {
  27232. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  27233. }
  27234. this._debugMesh.position.copyFrom(this.mesh.position);
  27235. this._debugMesh.color = this.color;
  27236. };
  27237. /** Release associated resources */
  27238. SkeletonViewer.prototype.dispose = function () {
  27239. this.isEnabled = false;
  27240. if (this._debugMesh) {
  27241. this.isEnabled = false;
  27242. this._debugMesh.dispose();
  27243. this._debugMesh = null;
  27244. }
  27245. if (this._utilityLayer) {
  27246. this._utilityLayer.dispose();
  27247. this._utilityLayer = null;
  27248. }
  27249. };
  27250. return SkeletonViewer;
  27251. }());
  27252. /***/ }),
  27253. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  27254. /*!*****************************************************!*\
  27255. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  27256. \*****************************************************/
  27257. /*! exports provided: _OcclusionDataStorage */
  27258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27259. "use strict";
  27260. __webpack_require__.r(__webpack_exports__);
  27261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  27262. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27263. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  27264. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  27265. /** @hidden */
  27266. var _OcclusionDataStorage = /** @class */ (function () {
  27267. function _OcclusionDataStorage() {
  27268. /** @hidden */
  27269. this.occlusionInternalRetryCounter = 0;
  27270. /** @hidden */
  27271. this.isOcclusionQueryInProgress = false;
  27272. /** @hidden */
  27273. this.isOccluded = false;
  27274. /** @hidden */
  27275. this.occlusionRetryCount = -1;
  27276. /** @hidden */
  27277. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  27278. /** @hidden */
  27279. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  27280. }
  27281. return _OcclusionDataStorage;
  27282. }());
  27283. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  27284. return this._gl.createQuery();
  27285. };
  27286. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  27287. this._gl.deleteQuery(query);
  27288. return this;
  27289. };
  27290. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  27291. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  27292. };
  27293. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  27294. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  27295. };
  27296. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  27297. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27298. this._gl.beginQuery(glAlgorithm, query);
  27299. return this;
  27300. };
  27301. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  27302. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27303. this._gl.endQuery(glAlgorithm);
  27304. return this;
  27305. };
  27306. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  27307. var timerQuery = this.getCaps().timerQuery;
  27308. if (timerQuery.createQueryEXT) {
  27309. return timerQuery.createQueryEXT();
  27310. }
  27311. return this.createQuery();
  27312. };
  27313. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  27314. var timerQuery = this.getCaps().timerQuery;
  27315. if (timerQuery.deleteQueryEXT) {
  27316. timerQuery.deleteQueryEXT(query);
  27317. return;
  27318. }
  27319. this.deleteQuery(query);
  27320. };
  27321. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  27322. var timerQuery = this.getCaps().timerQuery;
  27323. if (timerQuery.getQueryObjectEXT) {
  27324. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  27325. }
  27326. return this.getQueryResult(query);
  27327. };
  27328. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  27329. var timerQuery = this.getCaps().timerQuery;
  27330. if (timerQuery.getQueryObjectEXT) {
  27331. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  27332. }
  27333. return this.isQueryResultAvailable(query);
  27334. };
  27335. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  27336. var caps = this.getCaps();
  27337. var timerQuery = caps.timerQuery;
  27338. if (!timerQuery) {
  27339. return null;
  27340. }
  27341. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  27342. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27343. if (caps.canUseTimestampForTimerQuery) {
  27344. token._startTimeQuery = this._createTimeQuery();
  27345. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  27346. }
  27347. else {
  27348. if (this._currentNonTimestampToken) {
  27349. return this._currentNonTimestampToken;
  27350. }
  27351. token._timeElapsedQuery = this._createTimeQuery();
  27352. if (timerQuery.beginQueryEXT) {
  27353. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27354. }
  27355. else {
  27356. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27357. }
  27358. this._currentNonTimestampToken = token;
  27359. }
  27360. return token;
  27361. };
  27362. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  27363. var caps = this.getCaps();
  27364. var timerQuery = caps.timerQuery;
  27365. if (!timerQuery || !token) {
  27366. return -1;
  27367. }
  27368. if (caps.canUseTimestampForTimerQuery) {
  27369. if (!token._startTimeQuery) {
  27370. return -1;
  27371. }
  27372. if (!token._endTimeQuery) {
  27373. token._endTimeQuery = this._createTimeQuery();
  27374. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  27375. }
  27376. }
  27377. else if (!token._timeElapsedQueryEnded) {
  27378. if (!token._timeElapsedQuery) {
  27379. return -1;
  27380. }
  27381. if (timerQuery.endQueryEXT) {
  27382. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  27383. }
  27384. else {
  27385. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  27386. }
  27387. token._timeElapsedQueryEnded = true;
  27388. }
  27389. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27390. var available = false;
  27391. if (token._endTimeQuery) {
  27392. available = this._getTimeQueryAvailability(token._endTimeQuery);
  27393. }
  27394. else if (token._timeElapsedQuery) {
  27395. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  27396. }
  27397. if (available && !disjoint) {
  27398. var result = 0;
  27399. if (caps.canUseTimestampForTimerQuery) {
  27400. if (!token._startTimeQuery || !token._endTimeQuery) {
  27401. return -1;
  27402. }
  27403. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  27404. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  27405. result = timeEnd - timeStart;
  27406. this._deleteTimeQuery(token._startTimeQuery);
  27407. this._deleteTimeQuery(token._endTimeQuery);
  27408. token._startTimeQuery = null;
  27409. token._endTimeQuery = null;
  27410. }
  27411. else {
  27412. if (!token._timeElapsedQuery) {
  27413. return -1;
  27414. }
  27415. result = this._getTimeQueryResult(token._timeElapsedQuery);
  27416. this._deleteTimeQuery(token._timeElapsedQuery);
  27417. token._timeElapsedQuery = null;
  27418. token._timeElapsedQueryEnded = false;
  27419. this._currentNonTimestampToken = null;
  27420. }
  27421. return result;
  27422. }
  27423. return -1;
  27424. };
  27425. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  27426. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  27427. };
  27428. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  27429. get: function () {
  27430. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  27431. },
  27432. enumerable: false,
  27433. configurable: true
  27434. });
  27435. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  27436. get: function () {
  27437. if (!this.__occlusionDataStorage) {
  27438. this.__occlusionDataStorage = new _OcclusionDataStorage();
  27439. }
  27440. return this.__occlusionDataStorage;
  27441. },
  27442. enumerable: false,
  27443. configurable: true
  27444. });
  27445. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  27446. get: function () {
  27447. return this._occlusionDataStorage.isOccluded;
  27448. },
  27449. set: function (value) {
  27450. this._occlusionDataStorage.isOccluded = value;
  27451. },
  27452. enumerable: true,
  27453. configurable: true
  27454. });
  27455. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  27456. get: function () {
  27457. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  27458. },
  27459. set: function (value) {
  27460. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  27461. },
  27462. enumerable: true,
  27463. configurable: true
  27464. });
  27465. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  27466. get: function () {
  27467. return this._occlusionDataStorage.occlusionType;
  27468. },
  27469. set: function (value) {
  27470. this._occlusionDataStorage.occlusionType = value;
  27471. },
  27472. enumerable: true,
  27473. configurable: true
  27474. });
  27475. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  27476. get: function () {
  27477. return this._occlusionDataStorage.occlusionRetryCount;
  27478. },
  27479. set: function (value) {
  27480. this._occlusionDataStorage.occlusionRetryCount = value;
  27481. },
  27482. enumerable: true,
  27483. configurable: true
  27484. });
  27485. // We also need to update AbstractMesh as there is a portion of the code there
  27486. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  27487. var dataStorage = this._occlusionDataStorage;
  27488. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  27489. dataStorage.isOccluded = false;
  27490. return false;
  27491. }
  27492. var engine = this.getEngine();
  27493. if (engine.webGLVersion < 2) {
  27494. dataStorage.isOccluded = false;
  27495. return false;
  27496. }
  27497. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  27498. dataStorage.isOccluded = false;
  27499. return false;
  27500. }
  27501. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  27502. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  27503. if (isOcclusionQueryAvailable) {
  27504. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  27505. dataStorage.isOcclusionQueryInProgress = false;
  27506. dataStorage.occlusionInternalRetryCounter = 0;
  27507. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  27508. }
  27509. else {
  27510. dataStorage.occlusionInternalRetryCounter++;
  27511. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  27512. dataStorage.isOcclusionQueryInProgress = false;
  27513. dataStorage.occlusionInternalRetryCounter = 0;
  27514. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  27515. // if strict continue the last state of the object.
  27516. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  27517. }
  27518. else {
  27519. return false;
  27520. }
  27521. }
  27522. }
  27523. var scene = this.getScene();
  27524. if (scene.getBoundingBoxRenderer) {
  27525. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  27526. if (!this._occlusionQuery) {
  27527. this._occlusionQuery = engine.createQuery();
  27528. }
  27529. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  27530. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  27531. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  27532. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  27533. }
  27534. return dataStorage.isOccluded;
  27535. };
  27536. /***/ }),
  27537. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  27538. /*!********************************************************!*\
  27539. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  27540. \********************************************************/
  27541. /*! exports provided: _forceTransformFeedbackToBundle */
  27542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27543. "use strict";
  27544. __webpack_require__.r(__webpack_exports__);
  27545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  27546. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27547. /** @hidden */
  27548. var _forceTransformFeedbackToBundle = true;
  27549. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  27550. return this._gl.createTransformFeedback();
  27551. };
  27552. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  27553. this._gl.deleteTransformFeedback(value);
  27554. };
  27555. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  27556. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  27557. };
  27558. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  27559. if (usePoints === void 0) { usePoints = true; }
  27560. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  27561. };
  27562. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  27563. this._gl.endTransformFeedback();
  27564. };
  27565. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  27566. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  27567. };
  27568. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  27569. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  27570. };
  27571. /***/ }),
  27572. /***/ "./Engines/Extensions/index.ts":
  27573. /*!*************************************!*\
  27574. !*** ./Engines/Extensions/index.ts ***!
  27575. \*************************************/
  27576. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  27577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27578. "use strict";
  27579. __webpack_require__.r(__webpack_exports__);
  27580. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  27581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  27582. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  27583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  27584. /***/ }),
  27585. /***/ "./Engines/constants.ts":
  27586. /*!******************************!*\
  27587. !*** ./Engines/constants.ts ***!
  27588. \******************************/
  27589. /*! exports provided: Constants */
  27590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27591. "use strict";
  27592. __webpack_require__.r(__webpack_exports__);
  27593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  27594. /** Defines the cross module used constants to avoid circular dependncies */
  27595. var Constants = /** @class */ (function () {
  27596. function Constants() {
  27597. }
  27598. /** Defines that alpha blending is disabled */
  27599. Constants.ALPHA_DISABLE = 0;
  27600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27601. Constants.ALPHA_ADD = 1;
  27602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27603. Constants.ALPHA_COMBINE = 2;
  27604. /** Defines that alpha blending to DEST - SRC * DEST */
  27605. Constants.ALPHA_SUBTRACT = 3;
  27606. /** Defines that alpha blending to SRC * DEST */
  27607. Constants.ALPHA_MULTIPLY = 4;
  27608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27609. Constants.ALPHA_MAXIMIZED = 5;
  27610. /** Defines that alpha blending to SRC + DEST */
  27611. Constants.ALPHA_ONEONE = 6;
  27612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27613. Constants.ALPHA_PREMULTIPLIED = 7;
  27614. /**
  27615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27617. */
  27618. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27620. Constants.ALPHA_INTERPOLATE = 9;
  27621. /**
  27622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27624. */
  27625. Constants.ALPHA_SCREENMODE = 10;
  27626. /** Defines that the ressource is not delayed*/
  27627. Constants.DELAYLOADSTATE_NONE = 0;
  27628. /** Defines that the ressource was successfully delay loaded */
  27629. Constants.DELAYLOADSTATE_LOADED = 1;
  27630. /** Defines that the ressource is currently delay loading */
  27631. Constants.DELAYLOADSTATE_LOADING = 2;
  27632. /** Defines that the ressource is delayed and has not started loading */
  27633. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27634. // Depht or Stencil test Constants.
  27635. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27636. Constants.NEVER = 0x0200;
  27637. /** 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 */
  27638. Constants.ALWAYS = 0x0207;
  27639. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27640. Constants.LESS = 0x0201;
  27641. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27642. Constants.EQUAL = 0x0202;
  27643. /** 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 */
  27644. Constants.LEQUAL = 0x0203;
  27645. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27646. Constants.GREATER = 0x0204;
  27647. /** 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 */
  27648. Constants.GEQUAL = 0x0206;
  27649. /** 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 */
  27650. Constants.NOTEQUAL = 0x0205;
  27651. // Stencil Actions Constants.
  27652. /** Passed to stencilOperation to specify that stencil value must be kept */
  27653. Constants.KEEP = 0x1E00;
  27654. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27655. Constants.REPLACE = 0x1E01;
  27656. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27657. Constants.INCR = 0x1E02;
  27658. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27659. Constants.DECR = 0x1E03;
  27660. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27661. Constants.INVERT = 0x150A;
  27662. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27663. Constants.INCR_WRAP = 0x8507;
  27664. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27665. Constants.DECR_WRAP = 0x8508;
  27666. /** Texture is not repeating outside of 0..1 UVs */
  27667. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27668. /** Texture is repeating outside of 0..1 UVs */
  27669. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27670. /** Texture is repeating and mirrored */
  27671. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27672. /** ALPHA */
  27673. Constants.TEXTUREFORMAT_ALPHA = 0;
  27674. /** LUMINANCE */
  27675. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27676. /** LUMINANCE_ALPHA */
  27677. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27678. /** RGB */
  27679. Constants.TEXTUREFORMAT_RGB = 4;
  27680. /** RGBA */
  27681. Constants.TEXTUREFORMAT_RGBA = 5;
  27682. /** RED */
  27683. Constants.TEXTUREFORMAT_RED = 6;
  27684. /** RED (2nd reference) */
  27685. Constants.TEXTUREFORMAT_R = 6;
  27686. /** RG */
  27687. Constants.TEXTUREFORMAT_RG = 7;
  27688. /** RED_INTEGER */
  27689. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27690. /** RED_INTEGER (2nd reference) */
  27691. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27692. /** RG_INTEGER */
  27693. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27694. /** RGB_INTEGER */
  27695. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27696. /** RGBA_INTEGER */
  27697. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27698. /** UNSIGNED_BYTE */
  27699. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27700. /** UNSIGNED_BYTE (2nd reference) */
  27701. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27702. /** FLOAT */
  27703. Constants.TEXTURETYPE_FLOAT = 1;
  27704. /** HALF_FLOAT */
  27705. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27706. /** BYTE */
  27707. Constants.TEXTURETYPE_BYTE = 3;
  27708. /** SHORT */
  27709. Constants.TEXTURETYPE_SHORT = 4;
  27710. /** UNSIGNED_SHORT */
  27711. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27712. /** INT */
  27713. Constants.TEXTURETYPE_INT = 6;
  27714. /** UNSIGNED_INT */
  27715. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27716. /** UNSIGNED_SHORT_4_4_4_4 */
  27717. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27718. /** UNSIGNED_SHORT_5_5_5_1 */
  27719. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27720. /** UNSIGNED_SHORT_5_6_5 */
  27721. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27722. /** UNSIGNED_INT_2_10_10_10_REV */
  27723. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27724. /** UNSIGNED_INT_24_8 */
  27725. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27726. /** UNSIGNED_INT_10F_11F_11F_REV */
  27727. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27728. /** UNSIGNED_INT_5_9_9_9_REV */
  27729. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27730. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27731. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27732. /** nearest is mag = nearest and min = nearest and mip = linear */
  27733. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27734. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27735. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27736. /** Trilinear is mag = linear and min = linear and mip = linear */
  27737. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27738. /** nearest is mag = nearest and min = nearest and mip = linear */
  27739. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27740. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27741. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27742. /** Trilinear is mag = linear and min = linear and mip = linear */
  27743. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27744. /** mag = nearest and min = nearest and mip = nearest */
  27745. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27746. /** mag = nearest and min = linear and mip = nearest */
  27747. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27748. /** mag = nearest and min = linear and mip = linear */
  27749. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27750. /** mag = nearest and min = linear and mip = none */
  27751. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27752. /** mag = nearest and min = nearest and mip = none */
  27753. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27754. /** mag = linear and min = nearest and mip = nearest */
  27755. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27756. /** mag = linear and min = nearest and mip = linear */
  27757. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27758. /** mag = linear and min = linear and mip = none */
  27759. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27760. /** mag = linear and min = nearest and mip = none */
  27761. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27762. /** Explicit coordinates mode */
  27763. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27764. /** Spherical coordinates mode */
  27765. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27766. /** Planar coordinates mode */
  27767. Constants.TEXTURE_PLANAR_MODE = 2;
  27768. /** Cubic coordinates mode */
  27769. Constants.TEXTURE_CUBIC_MODE = 3;
  27770. /** Projection coordinates mode */
  27771. Constants.TEXTURE_PROJECTION_MODE = 4;
  27772. /** Skybox coordinates mode */
  27773. Constants.TEXTURE_SKYBOX_MODE = 5;
  27774. /** Inverse Cubic coordinates mode */
  27775. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27776. /** Equirectangular coordinates mode */
  27777. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27778. /** Equirectangular Fixed coordinates mode */
  27779. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27780. /** Equirectangular Fixed Mirrored coordinates mode */
  27781. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27782. // Texture rescaling mode
  27783. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27784. Constants.SCALEMODE_FLOOR = 1;
  27785. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27786. Constants.SCALEMODE_NEAREST = 2;
  27787. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27788. Constants.SCALEMODE_CEILING = 3;
  27789. /**
  27790. * The dirty texture flag value
  27791. */
  27792. Constants.MATERIAL_TextureDirtyFlag = 1;
  27793. /**
  27794. * The dirty light flag value
  27795. */
  27796. Constants.MATERIAL_LightDirtyFlag = 2;
  27797. /**
  27798. * The dirty fresnel flag value
  27799. */
  27800. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27801. /**
  27802. * The dirty attribute flag value
  27803. */
  27804. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27805. /**
  27806. * The dirty misc flag value
  27807. */
  27808. Constants.MATERIAL_MiscDirtyFlag = 16;
  27809. /**
  27810. * The all dirty flag value
  27811. */
  27812. Constants.MATERIAL_AllDirtyFlag = 31;
  27813. /**
  27814. * Returns the triangle fill mode
  27815. */
  27816. Constants.MATERIAL_TriangleFillMode = 0;
  27817. /**
  27818. * Returns the wireframe mode
  27819. */
  27820. Constants.MATERIAL_WireFrameFillMode = 1;
  27821. /**
  27822. * Returns the point fill mode
  27823. */
  27824. Constants.MATERIAL_PointFillMode = 2;
  27825. /**
  27826. * Returns the point list draw mode
  27827. */
  27828. Constants.MATERIAL_PointListDrawMode = 3;
  27829. /**
  27830. * Returns the line list draw mode
  27831. */
  27832. Constants.MATERIAL_LineListDrawMode = 4;
  27833. /**
  27834. * Returns the line loop draw mode
  27835. */
  27836. Constants.MATERIAL_LineLoopDrawMode = 5;
  27837. /**
  27838. * Returns the line strip draw mode
  27839. */
  27840. Constants.MATERIAL_LineStripDrawMode = 6;
  27841. /**
  27842. * Returns the triangle strip draw mode
  27843. */
  27844. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27845. /**
  27846. * Returns the triangle fan draw mode
  27847. */
  27848. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27849. /**
  27850. * Stores the clock-wise side orientation
  27851. */
  27852. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27853. /**
  27854. * Stores the counter clock-wise side orientation
  27855. */
  27856. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27857. /**
  27858. * Nothing
  27859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27860. */
  27861. Constants.ACTION_NothingTrigger = 0;
  27862. /**
  27863. * On pick
  27864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27865. */
  27866. Constants.ACTION_OnPickTrigger = 1;
  27867. /**
  27868. * On left pick
  27869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27870. */
  27871. Constants.ACTION_OnLeftPickTrigger = 2;
  27872. /**
  27873. * On right pick
  27874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27875. */
  27876. Constants.ACTION_OnRightPickTrigger = 3;
  27877. /**
  27878. * On center pick
  27879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27880. */
  27881. Constants.ACTION_OnCenterPickTrigger = 4;
  27882. /**
  27883. * On pick down
  27884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27885. */
  27886. Constants.ACTION_OnPickDownTrigger = 5;
  27887. /**
  27888. * On double pick
  27889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27890. */
  27891. Constants.ACTION_OnDoublePickTrigger = 6;
  27892. /**
  27893. * On pick up
  27894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27895. */
  27896. Constants.ACTION_OnPickUpTrigger = 7;
  27897. /**
  27898. * On pick out.
  27899. * This trigger will only be raised if you also declared a OnPickDown
  27900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27901. */
  27902. Constants.ACTION_OnPickOutTrigger = 16;
  27903. /**
  27904. * On long press
  27905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27906. */
  27907. Constants.ACTION_OnLongPressTrigger = 8;
  27908. /**
  27909. * On pointer over
  27910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27911. */
  27912. Constants.ACTION_OnPointerOverTrigger = 9;
  27913. /**
  27914. * On pointer out
  27915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27916. */
  27917. Constants.ACTION_OnPointerOutTrigger = 10;
  27918. /**
  27919. * On every frame
  27920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27921. */
  27922. Constants.ACTION_OnEveryFrameTrigger = 11;
  27923. /**
  27924. * On intersection enter
  27925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27926. */
  27927. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27928. /**
  27929. * On intersection exit
  27930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27931. */
  27932. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27933. /**
  27934. * On key down
  27935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27936. */
  27937. Constants.ACTION_OnKeyDownTrigger = 14;
  27938. /**
  27939. * On key up
  27940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27941. */
  27942. Constants.ACTION_OnKeyUpTrigger = 15;
  27943. /**
  27944. * Billboard mode will only apply to Y axis
  27945. */
  27946. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27947. /**
  27948. * Billboard mode will apply to all axes
  27949. */
  27950. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27951. /**
  27952. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27953. */
  27954. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27955. /**
  27956. * Gets or sets base Assets URL
  27957. */
  27958. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27959. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27960. * Test order :
  27961. * Is the bounding sphere outside the frustum ?
  27962. * If not, are the bounding box vertices outside the frustum ?
  27963. * It not, then the cullable object is in the frustum.
  27964. */
  27965. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27966. /** Culling strategy : Bounding Sphere Only.
  27967. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27968. * It's also less accurate than the standard because some not visible objects can still be selected.
  27969. * Test : is the bounding sphere outside the frustum ?
  27970. * If not, then the cullable object is in the frustum.
  27971. */
  27972. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27973. /** Culling strategy : Optimistic Inclusion.
  27974. * This in an inclusion test first, then the standard exclusion test.
  27975. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27976. * 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.
  27977. * Anyway, it's as accurate as the standard strategy.
  27978. * Test :
  27979. * Is the cullable object bounding sphere center in the frustum ?
  27980. * If not, apply the default culling strategy.
  27981. */
  27982. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27983. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27984. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27985. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27986. * 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.
  27987. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27988. * Test :
  27989. * Is the cullable object bounding sphere center in the frustum ?
  27990. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27991. */
  27992. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27993. /**
  27994. * No logging while loading
  27995. */
  27996. Constants.SCENELOADER_NO_LOGGING = 0;
  27997. /**
  27998. * Minimal logging while loading
  27999. */
  28000. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  28001. /**
  28002. * Summary logging while loading
  28003. */
  28004. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  28005. /**
  28006. * Detailled logging while loading
  28007. */
  28008. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  28009. return Constants;
  28010. }());
  28011. /***/ }),
  28012. /***/ "./Engines/engine.ts":
  28013. /*!***************************!*\
  28014. !*** ./Engines/engine.ts ***!
  28015. \***************************/
  28016. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  28017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28018. "use strict";
  28019. __webpack_require__.r(__webpack_exports__);
  28020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  28021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  28022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  28023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  28024. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  28025. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  28026. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  28027. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  28028. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  28029. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  28030. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  28031. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  28032. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  28033. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  28034. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  28035. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28036. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  28037. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  28038. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  28039. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  28040. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  28041. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  28042. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  28043. /**
  28044. * Keeps track of all the buffer info used in engine.
  28045. */
  28046. var BufferPointer = /** @class */ (function () {
  28047. function BufferPointer() {
  28048. }
  28049. return BufferPointer;
  28050. }());
  28051. /**
  28052. * Interface for attribute information associated with buffer instanciation
  28053. */
  28054. var InstancingAttributeInfo = /** @class */ (function () {
  28055. function InstancingAttributeInfo() {
  28056. }
  28057. return InstancingAttributeInfo;
  28058. }());
  28059. /**
  28060. * Define options used to create a depth texture
  28061. */
  28062. var DepthTextureCreationOptions = /** @class */ (function () {
  28063. function DepthTextureCreationOptions() {
  28064. }
  28065. return DepthTextureCreationOptions;
  28066. }());
  28067. /**
  28068. * Class used to describe the capabilities of the engine relatively to the current browser
  28069. */
  28070. var EngineCapabilities = /** @class */ (function () {
  28071. function EngineCapabilities() {
  28072. }
  28073. return EngineCapabilities;
  28074. }());
  28075. /**
  28076. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28077. */
  28078. var Engine = /** @class */ (function () {
  28079. /**
  28080. * Creates a new engine
  28081. * @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
  28082. * @param antialias defines enable antialiasing (default: false)
  28083. * @param options defines further options to be sent to the getContext() function
  28084. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28085. */
  28086. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  28087. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  28088. var _this = this;
  28089. // Public members
  28090. /**
  28091. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28092. */
  28093. this.forcePOTTextures = false;
  28094. /**
  28095. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28096. */
  28097. this.isFullscreen = false;
  28098. /**
  28099. * Gets a boolean indicating if the pointer is currently locked
  28100. */
  28101. this.isPointerLock = false;
  28102. /**
  28103. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28104. */
  28105. this.cullBackFaces = true;
  28106. /**
  28107. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28108. */
  28109. this.renderEvenInBackground = true;
  28110. /**
  28111. * Gets or sets a boolean indicating that cache can be kept between frames
  28112. */
  28113. this.preventCacheWipeBetweenFrames = false;
  28114. /**
  28115. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28116. **/
  28117. this.enableOfflineSupport = false;
  28118. /**
  28119. * 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)
  28120. **/
  28121. this.disableManifestCheck = false;
  28122. /**
  28123. * Gets the list of created scenes
  28124. */
  28125. this.scenes = new Array();
  28126. /**
  28127. * Event raised when a new scene is created
  28128. */
  28129. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28130. /**
  28131. * Gets the list of created postprocesses
  28132. */
  28133. this.postProcesses = new Array();
  28134. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28135. this.validateShaderPrograms = false;
  28136. // Observables
  28137. /**
  28138. * Observable event triggered each time the rendering canvas is resized
  28139. */
  28140. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28141. /**
  28142. * Observable event triggered each time the canvas loses focus
  28143. */
  28144. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28145. /**
  28146. * Observable event triggered each time the canvas gains focus
  28147. */
  28148. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28149. /**
  28150. * Observable event triggered each time the canvas receives pointerout event
  28151. */
  28152. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28153. /**
  28154. * Observable event triggered before each texture is initialized
  28155. */
  28156. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28157. //WebVR
  28158. this._vrDisplay = undefined;
  28159. this._vrSupported = false;
  28160. this._vrExclusivePointerMode = false;
  28161. // Uniform buffers list
  28162. /**
  28163. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28164. */
  28165. this.disableUniformBuffers = false;
  28166. /** @hidden */
  28167. this._uniformBuffers = new Array();
  28168. // Observables
  28169. /**
  28170. * Observable raised when the engine begins a new frame
  28171. */
  28172. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28173. /**
  28174. * If set, will be used to request the next animation frame for the render loop
  28175. */
  28176. this.customAnimationFrameRequester = null;
  28177. /**
  28178. * Observable raised when the engine ends the current frame
  28179. */
  28180. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28181. /**
  28182. * Observable raised when the engine is about to compile a shader
  28183. */
  28184. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28185. /**
  28186. * Observable raised when the engine has jsut compiled a shader
  28187. */
  28188. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28189. this._windowIsBackground = false;
  28190. this._webGLVersion = 1.0;
  28191. this._highPrecisionShadersAllowed = true;
  28192. /** @hidden */
  28193. this._badOS = false;
  28194. /** @hidden */
  28195. this._badDesktopOS = false;
  28196. /**
  28197. * Gets or sets a value indicating if we want to disable texture binding optimization.
  28198. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  28199. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  28200. */
  28201. this.disableTextureBindingOptimization = false;
  28202. /**
  28203. * Observable signaled when VR display mode changes
  28204. */
  28205. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28206. /**
  28207. * Observable signaled when VR request present is complete
  28208. */
  28209. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28210. /**
  28211. * Observable signaled when VR request present starts
  28212. */
  28213. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28214. this._colorWrite = true;
  28215. /** @hidden */
  28216. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28217. /** @hidden */
  28218. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28219. this._renderingQueueLaunched = false;
  28220. this._activeRenderLoops = new Array();
  28221. // Deterministic lockstepMaxSteps
  28222. this._deterministicLockstep = false;
  28223. this._lockstepMaxSteps = 4;
  28224. // Lost context
  28225. /**
  28226. * Observable signaled when a context lost event is raised
  28227. */
  28228. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28229. /**
  28230. * Observable signaled when a context restored event is raised
  28231. */
  28232. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28233. this._contextWasLost = false;
  28234. this._doNotHandleContextLost = false;
  28235. // FPS
  28236. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  28237. this._fps = 60;
  28238. this._deltaTime = 0;
  28239. /**
  28240. * Turn this value on if you want to pause FPS computation when in background
  28241. */
  28242. this.disablePerformanceMonitorInBackground = false;
  28243. // States
  28244. /** @hidden */
  28245. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  28246. /** @hidden */
  28247. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  28248. /** @hidden */
  28249. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  28250. /** @hidden */
  28251. this._alphaMode = Engine.ALPHA_DISABLE;
  28252. // Cache
  28253. this._internalTexturesCache = new Array();
  28254. /** @hidden */
  28255. this._activeChannel = 0;
  28256. this._currentTextureChannel = -1;
  28257. /** @hidden */
  28258. this._boundTexturesCache = {};
  28259. this._compiledEffects = {};
  28260. this._vertexAttribArraysEnabled = [];
  28261. this._uintIndicesCurrentlySet = false;
  28262. this._currentBoundBuffer = new Array();
  28263. /** @hidden */
  28264. this._currentFramebuffer = null;
  28265. this._currentBufferPointers = new Array();
  28266. this._currentInstanceLocations = new Array();
  28267. this._currentInstanceBuffers = new Array();
  28268. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28269. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28270. this._vaoRecordInProgress = false;
  28271. this._mustWipeVertexAttributes = false;
  28272. this._nextFreeTextureSlots = new Array();
  28273. this._maxSimultaneousTextures = 0;
  28274. this._activeRequests = new Array();
  28275. // Hardware supported Compressed Textures
  28276. this._texturesSupported = new Array();
  28277. /**
  28278. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28279. */
  28280. this.premultipliedAlpha = true;
  28281. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  28282. this._onVRFullScreenTriggered = function () {
  28283. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  28284. //get the old size before we change
  28285. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  28286. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  28287. //get the width and height, change the render size
  28288. var leftEye = _this._vrDisplay.getEyeParameters('left');
  28289. _this.setHardwareScalingLevel(1);
  28290. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  28291. }
  28292. else {
  28293. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  28294. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  28295. }
  28296. };
  28297. this._unpackFlipYCached = null;
  28298. /**
  28299. * In case you are sharing the context with other applications, it might
  28300. * be interested to not cache the unpack flip y state to ensure a consistent
  28301. * value would be set.
  28302. */
  28303. this.enableUnpackFlipYCached = true;
  28304. this._boundUniforms = {};
  28305. // Register promises
  28306. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  28307. var canvas = null;
  28308. Engine.Instances.push(this);
  28309. if (!canvasOrContext) {
  28310. return;
  28311. }
  28312. options = options || {};
  28313. if (canvasOrContext.getContext) {
  28314. canvas = canvasOrContext;
  28315. this._renderingCanvas = canvas;
  28316. if (antialias != null) {
  28317. options.antialias = antialias;
  28318. }
  28319. if (options.deterministicLockstep === undefined) {
  28320. options.deterministicLockstep = false;
  28321. }
  28322. if (options.lockstepMaxSteps === undefined) {
  28323. options.lockstepMaxSteps = 4;
  28324. }
  28325. if (options.preserveDrawingBuffer === undefined) {
  28326. options.preserveDrawingBuffer = false;
  28327. }
  28328. if (options.audioEngine === undefined) {
  28329. options.audioEngine = true;
  28330. }
  28331. if (options.stencil === undefined) {
  28332. options.stencil = true;
  28333. }
  28334. if (options.premultipliedAlpha === false) {
  28335. this.premultipliedAlpha = false;
  28336. }
  28337. this._deterministicLockstep = options.deterministicLockstep;
  28338. this._lockstepMaxSteps = options.lockstepMaxSteps;
  28339. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  28340. // Exceptions
  28341. if (navigator && navigator.userAgent) {
  28342. var ua = navigator.userAgent;
  28343. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  28344. var exception = _a[_i];
  28345. var key = exception.key;
  28346. var targets = exception.targets;
  28347. if (ua.indexOf(key) > -1) {
  28348. if (exception.capture && exception.captureConstraint) {
  28349. var capture = exception.capture;
  28350. var constraint = exception.captureConstraint;
  28351. var regex = new RegExp(capture);
  28352. var matches = regex.exec(ua);
  28353. if (matches && matches.length > 0) {
  28354. var capturedValue = parseInt(matches[matches.length - 1]);
  28355. if (capturedValue >= constraint) {
  28356. continue;
  28357. }
  28358. }
  28359. }
  28360. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  28361. var target = targets_1[_b];
  28362. switch (target) {
  28363. case "uniformBuffer":
  28364. this.disableUniformBuffers = true;
  28365. break;
  28366. case "textureBindingOptimization":
  28367. this.disableTextureBindingOptimization = true;
  28368. break;
  28369. }
  28370. }
  28371. }
  28372. }
  28373. }
  28374. // GL
  28375. if (!options.disableWebGL2Support) {
  28376. try {
  28377. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  28378. if (this._gl) {
  28379. this._webGLVersion = 2.0;
  28380. // Prevent weird browsers to lie :-)
  28381. if (!this._gl.deleteQuery) {
  28382. this._webGLVersion = 1.0;
  28383. }
  28384. }
  28385. }
  28386. catch (e) {
  28387. // Do nothing
  28388. }
  28389. }
  28390. if (!this._gl) {
  28391. if (!canvas) {
  28392. throw new Error("The provided canvas is null or undefined.");
  28393. }
  28394. try {
  28395. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  28396. }
  28397. catch (e) {
  28398. throw new Error("WebGL not supported");
  28399. }
  28400. }
  28401. if (!this._gl) {
  28402. throw new Error("WebGL not supported");
  28403. }
  28404. // Ensures a consistent color space unpacking of textures cross browser.
  28405. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  28406. this._onCanvasFocus = function () {
  28407. _this.onCanvasFocusObservable.notifyObservers(_this);
  28408. };
  28409. this._onCanvasBlur = function () {
  28410. _this.onCanvasBlurObservable.notifyObservers(_this);
  28411. };
  28412. canvas.addEventListener("focus", this._onCanvasFocus);
  28413. canvas.addEventListener("blur", this._onCanvasBlur);
  28414. this._onBlur = function () {
  28415. if (_this.disablePerformanceMonitorInBackground) {
  28416. _this._performanceMonitor.disable();
  28417. }
  28418. _this._windowIsBackground = true;
  28419. };
  28420. this._onFocus = function () {
  28421. if (_this.disablePerformanceMonitorInBackground) {
  28422. _this._performanceMonitor.enable();
  28423. }
  28424. _this._windowIsBackground = false;
  28425. };
  28426. this._onCanvasPointerOut = function (ev) {
  28427. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  28428. };
  28429. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28430. window.addEventListener("blur", this._onBlur);
  28431. window.addEventListener("focus", this._onFocus);
  28432. }
  28433. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  28434. // Context lost
  28435. if (!this._doNotHandleContextLost) {
  28436. this._onContextLost = function (evt) {
  28437. evt.preventDefault();
  28438. _this._contextWasLost = true;
  28439. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  28440. _this.onContextLostObservable.notifyObservers(_this);
  28441. };
  28442. this._onContextRestored = function () {
  28443. // Adding a timeout to avoid race condition at browser level
  28444. setTimeout(function () {
  28445. // Rebuild gl context
  28446. _this._initGLContext();
  28447. // Rebuild effects
  28448. _this._rebuildEffects();
  28449. // Rebuild textures
  28450. _this._rebuildInternalTextures();
  28451. // Rebuild buffers
  28452. _this._rebuildBuffers();
  28453. // Cache
  28454. _this.wipeCaches(true);
  28455. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  28456. _this.onContextRestoredObservable.notifyObservers(_this);
  28457. _this._contextWasLost = false;
  28458. }, 0);
  28459. };
  28460. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  28461. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  28462. }
  28463. if (!options.doNotHandleTouchAction) {
  28464. this._disableTouchAction();
  28465. }
  28466. }
  28467. else {
  28468. this._gl = canvasOrContext;
  28469. this._renderingCanvas = this._gl.canvas;
  28470. if (this._gl.renderbufferStorageMultisample) {
  28471. this._webGLVersion = 2.0;
  28472. }
  28473. var attributes = this._gl.getContextAttributes();
  28474. if (attributes) {
  28475. options.stencil = attributes.stencil;
  28476. }
  28477. }
  28478. if (options.useHighPrecisionFloats !== undefined) {
  28479. this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
  28480. }
  28481. // Viewport
  28482. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  28483. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  28484. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  28485. this.resize();
  28486. this._isStencilEnable = options.stencil ? true : false;
  28487. this._initGLContext();
  28488. if (canvas) {
  28489. var anyDoc_1 = document;
  28490. // Fullscreen
  28491. this._onFullscreenChange = function () {
  28492. if (anyDoc_1.fullscreen !== undefined) {
  28493. _this.isFullscreen = anyDoc_1.fullscreen;
  28494. }
  28495. else if (anyDoc_1.mozFullScreen !== undefined) {
  28496. _this.isFullscreen = anyDoc_1.mozFullScreen;
  28497. }
  28498. else if (anyDoc_1.webkitIsFullScreen !== undefined) {
  28499. _this.isFullscreen = anyDoc_1.webkitIsFullScreen;
  28500. }
  28501. else if (anyDoc_1.msIsFullScreen !== undefined) {
  28502. _this.isFullscreen = anyDoc_1.msIsFullScreen;
  28503. }
  28504. // Pointer lock
  28505. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  28506. canvas.requestPointerLock = canvas.requestPointerLock ||
  28507. canvas.msRequestPointerLock ||
  28508. canvas.mozRequestPointerLock ||
  28509. canvas.webkitRequestPointerLock;
  28510. if (canvas.requestPointerLock) {
  28511. canvas.requestPointerLock();
  28512. }
  28513. }
  28514. };
  28515. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  28516. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  28517. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  28518. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  28519. // Pointer lock
  28520. this._onPointerLockChange = function () {
  28521. _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas ||
  28522. anyDoc_1.webkitPointerLockElement === canvas ||
  28523. anyDoc_1.msPointerLockElement === canvas ||
  28524. anyDoc_1.pointerLockElement === canvas);
  28525. };
  28526. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  28527. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  28528. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  28529. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  28530. this._onVRDisplayPointerRestricted = function () {
  28531. if (canvas) {
  28532. canvas.requestPointerLock();
  28533. }
  28534. };
  28535. this._onVRDisplayPointerUnrestricted = function () {
  28536. if (!anyDoc_1.exitPointerLock) {
  28537. return;
  28538. }
  28539. anyDoc_1.exitPointerLock();
  28540. };
  28541. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28542. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  28543. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  28544. }
  28545. }
  28546. // Create Audio Engine if needed.
  28547. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  28548. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  28549. }
  28550. // Prepare buffer pointers
  28551. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  28552. this._currentBufferPointers[i] = new BufferPointer();
  28553. }
  28554. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  28555. // Load WebVR Devices
  28556. if (options.autoEnableWebVR) {
  28557. this.initWebVR();
  28558. }
  28559. // Detect if we are running on a faulty buggy OS.
  28560. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  28561. // Detect if we are running on a faulty buggy desktop OS.
  28562. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  28563. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  28564. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  28565. }
  28566. Object.defineProperty(Engine, "Instances", {
  28567. /** Gets the list of created engines */
  28568. get: function () {
  28569. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  28570. },
  28571. enumerable: true,
  28572. configurable: true
  28573. });
  28574. Object.defineProperty(Engine, "LastCreatedEngine", {
  28575. /**
  28576. * Gets the latest created engine
  28577. */
  28578. get: function () {
  28579. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  28580. },
  28581. enumerable: true,
  28582. configurable: true
  28583. });
  28584. Object.defineProperty(Engine, "LastCreatedScene", {
  28585. /**
  28586. * Gets the latest created scene
  28587. */
  28588. get: function () {
  28589. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  28590. },
  28591. enumerable: true,
  28592. configurable: true
  28593. });
  28594. /**
  28595. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28596. * @param flag defines which part of the materials must be marked as dirty
  28597. * @param predicate defines a predicate used to filter which materials should be affected
  28598. */
  28599. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  28600. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  28601. var engine = Engine.Instances[engineIndex];
  28602. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  28603. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  28604. }
  28605. }
  28606. };
  28607. Object.defineProperty(Engine, "NpmPackage", {
  28608. /**
  28609. * Returns the current npm package of the sdk
  28610. */
  28611. // Not mixed with Version for tooling purpose.
  28612. get: function () {
  28613. return "babylonjs@4.0.0-alpha.32";
  28614. },
  28615. enumerable: true,
  28616. configurable: true
  28617. });
  28618. Object.defineProperty(Engine, "Version", {
  28619. /**
  28620. * Returns the current version of the framework
  28621. */
  28622. get: function () {
  28623. return "4.0.0-alpha.32";
  28624. },
  28625. enumerable: true,
  28626. configurable: true
  28627. });
  28628. Object.defineProperty(Engine.prototype, "description", {
  28629. /**
  28630. * Returns a string describing the current engine
  28631. */
  28632. get: function () {
  28633. var description = "WebGL" + this.webGLVersion;
  28634. if (this._caps.parallelShaderCompile) {
  28635. description += " - Parallel shader compilation";
  28636. }
  28637. return description;
  28638. },
  28639. enumerable: true,
  28640. configurable: true
  28641. });
  28642. Object.defineProperty(Engine, "ShadersRepository", {
  28643. /**
  28644. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28645. */
  28646. get: function () {
  28647. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28648. },
  28649. set: function (value) {
  28650. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28651. },
  28652. enumerable: true,
  28653. configurable: true
  28654. });
  28655. /**
  28656. * Method called to create the default loading screen.
  28657. * This can be overriden in your own app.
  28658. * @param canvas The rendering canvas element
  28659. * @returns The loading screen
  28660. */
  28661. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28662. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28663. };
  28664. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28665. /**
  28666. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28667. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28668. */
  28669. get: function () {
  28670. return this._vrExclusivePointerMode;
  28671. },
  28672. enumerable: true,
  28673. configurable: true
  28674. });
  28675. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28676. /**
  28677. * Gets a boolean indicating that the engine supports uniform buffers
  28678. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28679. */
  28680. get: function () {
  28681. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28682. },
  28683. enumerable: true,
  28684. configurable: true
  28685. });
  28686. Object.defineProperty(Engine.prototype, "_shouldUseHighPrecisionShader", {
  28687. /** @hidden */
  28688. get: function () {
  28689. return this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed;
  28690. },
  28691. enumerable: true,
  28692. configurable: true
  28693. });
  28694. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28695. /**
  28696. * Gets a boolean indicating that only power of 2 textures are supported
  28697. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28698. */
  28699. get: function () {
  28700. return this._webGLVersion < 2 || this.forcePOTTextures;
  28701. },
  28702. enumerable: true,
  28703. configurable: true
  28704. });
  28705. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28706. /**
  28707. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28709. */
  28710. get: function () {
  28711. return this._doNotHandleContextLost;
  28712. },
  28713. set: function (value) {
  28714. this._doNotHandleContextLost = value;
  28715. },
  28716. enumerable: true,
  28717. configurable: true
  28718. });
  28719. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28720. /**
  28721. * Gets the performance monitor attached to this engine
  28722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28723. */
  28724. get: function () {
  28725. return this._performanceMonitor;
  28726. },
  28727. enumerable: true,
  28728. configurable: true
  28729. });
  28730. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28731. /**
  28732. * Gets the list of texture formats supported
  28733. */
  28734. get: function () {
  28735. return this._texturesSupported;
  28736. },
  28737. enumerable: true,
  28738. configurable: true
  28739. });
  28740. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28741. /**
  28742. * Gets the list of texture formats in use
  28743. */
  28744. get: function () {
  28745. return this._textureFormatInUse;
  28746. },
  28747. enumerable: true,
  28748. configurable: true
  28749. });
  28750. Object.defineProperty(Engine.prototype, "currentViewport", {
  28751. /**
  28752. * Gets the current viewport
  28753. */
  28754. get: function () {
  28755. return this._cachedViewport;
  28756. },
  28757. enumerable: true,
  28758. configurable: true
  28759. });
  28760. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28761. /**
  28762. * Gets the default empty texture
  28763. */
  28764. get: function () {
  28765. if (!this._emptyTexture) {
  28766. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28767. }
  28768. return this._emptyTexture;
  28769. },
  28770. enumerable: true,
  28771. configurable: true
  28772. });
  28773. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28774. /**
  28775. * Gets the default empty 3D texture
  28776. */
  28777. get: function () {
  28778. if (!this._emptyTexture3D) {
  28779. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28780. }
  28781. return this._emptyTexture3D;
  28782. },
  28783. enumerable: true,
  28784. configurable: true
  28785. });
  28786. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28787. /**
  28788. * Gets the default empty cube texture
  28789. */
  28790. get: function () {
  28791. if (!this._emptyCubeTexture) {
  28792. var faceData = new Uint8Array(4);
  28793. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28794. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28795. }
  28796. return this._emptyCubeTexture;
  28797. },
  28798. enumerable: true,
  28799. configurable: true
  28800. });
  28801. Engine.prototype._disableTouchAction = function () {
  28802. if (!this._renderingCanvas) {
  28803. return;
  28804. }
  28805. this._renderingCanvas.setAttribute("touch-action", "none");
  28806. this._renderingCanvas.style.touchAction = "none";
  28807. this._renderingCanvas.style.msTouchAction = "none";
  28808. };
  28809. Engine.prototype._rebuildInternalTextures = function () {
  28810. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28811. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28812. var internalTexture = currentState_1[_i];
  28813. internalTexture._rebuild();
  28814. }
  28815. };
  28816. Engine.prototype._rebuildEffects = function () {
  28817. for (var key in this._compiledEffects) {
  28818. var effect = this._compiledEffects[key];
  28819. effect._prepareEffect();
  28820. }
  28821. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  28822. };
  28823. /**
  28824. * Gets a boolean indicating if all created effects are ready
  28825. * @returns true if all effects are ready
  28826. */
  28827. Engine.prototype.areAllEffectsReady = function () {
  28828. for (var key in this._compiledEffects) {
  28829. var effect = this._compiledEffects[key];
  28830. if (!effect.isReady()) {
  28831. return false;
  28832. }
  28833. }
  28834. return true;
  28835. };
  28836. Engine.prototype._rebuildBuffers = function () {
  28837. // Index / Vertex
  28838. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28839. var scene = _a[_i];
  28840. scene.resetCachedMaterial();
  28841. scene._rebuildGeometries();
  28842. scene._rebuildTextures();
  28843. }
  28844. // Uniforms
  28845. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28846. var uniformBuffer = _c[_b];
  28847. uniformBuffer._rebuild();
  28848. }
  28849. };
  28850. Engine.prototype._initGLContext = function () {
  28851. // Caps
  28852. this._caps = new EngineCapabilities();
  28853. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28854. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28855. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28856. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28857. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28858. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28859. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28860. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28861. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28862. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28863. // Infos
  28864. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28865. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28866. if (rendererInfo != null) {
  28867. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28868. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28869. }
  28870. if (!this._glVendor) {
  28871. this._glVendor = "Unknown vendor";
  28872. }
  28873. if (!this._glRenderer) {
  28874. this._glRenderer = "Unknown renderer";
  28875. }
  28876. // Constants
  28877. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28878. if (this._gl.RGBA16F !== 0x881A) {
  28879. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28880. }
  28881. if (this._gl.RGBA32F !== 0x8814) {
  28882. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28883. }
  28884. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28885. this._gl.DEPTH24_STENCIL8 = 35056;
  28886. }
  28887. // Extensions
  28888. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28889. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28890. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28891. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28892. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28893. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28894. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28895. 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');
  28896. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28897. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28898. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28899. this._caps.highPrecisionShaderSupported = false;
  28900. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28901. if (this._caps.timerQuery) {
  28902. if (this._webGLVersion === 1) {
  28903. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28904. }
  28905. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28906. }
  28907. // Checks if some of the format renders first to allow the use of webgl inspector.
  28908. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28909. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28910. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28911. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28912. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28913. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28914. if (this._webGLVersion > 1) {
  28915. this._gl.HALF_FLOAT_OES = 0x140B;
  28916. }
  28917. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28918. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28919. this._caps.multiview = this._gl.getExtension('WEBGL_multiview');
  28920. // Draw buffers
  28921. if (this._webGLVersion > 1) {
  28922. this._caps.drawBuffersExtension = true;
  28923. }
  28924. else {
  28925. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28926. if (drawBuffersExtension !== null) {
  28927. this._caps.drawBuffersExtension = true;
  28928. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28929. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28930. for (var i = 0; i < 16; i++) {
  28931. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28932. }
  28933. }
  28934. else {
  28935. this._caps.drawBuffersExtension = false;
  28936. }
  28937. }
  28938. // Shader compiler threads
  28939. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28940. // Depth Texture
  28941. if (this._webGLVersion > 1) {
  28942. this._caps.depthTextureExtension = true;
  28943. }
  28944. else {
  28945. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28946. if (depthTextureExtension != null) {
  28947. this._caps.depthTextureExtension = true;
  28948. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28949. }
  28950. }
  28951. // Vertex array object
  28952. if (this._webGLVersion > 1) {
  28953. this._caps.vertexArrayObject = true;
  28954. }
  28955. else {
  28956. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28957. if (vertexArrayObjectExtension != null) {
  28958. this._caps.vertexArrayObject = true;
  28959. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28960. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28961. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28962. }
  28963. else {
  28964. this._caps.vertexArrayObject = false;
  28965. }
  28966. }
  28967. // Instances count
  28968. if (this._webGLVersion > 1) {
  28969. this._caps.instancedArrays = true;
  28970. }
  28971. else {
  28972. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28973. if (instanceExtension != null) {
  28974. this._caps.instancedArrays = true;
  28975. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28976. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28977. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28978. }
  28979. else {
  28980. this._caps.instancedArrays = false;
  28981. }
  28982. }
  28983. // Intelligently add supported compressed formats in order to check for.
  28984. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28985. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28986. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28987. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28988. if (this._caps.astc) {
  28989. this.texturesSupported.push('-astc.ktx');
  28990. }
  28991. if (this._caps.s3tc) {
  28992. this.texturesSupported.push('-dxt.ktx');
  28993. }
  28994. if (this._caps.pvrtc) {
  28995. this.texturesSupported.push('-pvrtc.ktx');
  28996. }
  28997. if (this._caps.etc2) {
  28998. this.texturesSupported.push('-etc2.ktx');
  28999. }
  29000. if (this._caps.etc1) {
  29001. this.texturesSupported.push('-etc1.ktx');
  29002. }
  29003. if (this._gl.getShaderPrecisionFormat) {
  29004. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  29005. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  29006. if (vertex_highp && fragment_highp) {
  29007. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  29008. }
  29009. }
  29010. // Depth buffer
  29011. this.setDepthBuffer(true);
  29012. this.setDepthFunctionToLessOrEqual();
  29013. this.setDepthWrite(true);
  29014. // Texture maps
  29015. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  29016. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  29017. this._nextFreeTextureSlots.push(slot);
  29018. }
  29019. };
  29020. Object.defineProperty(Engine.prototype, "webGLVersion", {
  29021. /**
  29022. * Gets version of the current webGL context
  29023. */
  29024. get: function () {
  29025. return this._webGLVersion;
  29026. },
  29027. enumerable: true,
  29028. configurable: true
  29029. });
  29030. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  29031. /**
  29032. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29033. */
  29034. get: function () {
  29035. return this._isStencilEnable;
  29036. },
  29037. enumerable: true,
  29038. configurable: true
  29039. });
  29040. Engine.prototype._prepareWorkingCanvas = function () {
  29041. if (this._workingCanvas) {
  29042. return;
  29043. }
  29044. this._workingCanvas = document.createElement("canvas");
  29045. var context = this._workingCanvas.getContext("2d");
  29046. if (context) {
  29047. this._workingContext = context;
  29048. }
  29049. };
  29050. /**
  29051. * Reset the texture cache to empty state
  29052. */
  29053. Engine.prototype.resetTextureCache = function () {
  29054. for (var key in this._boundTexturesCache) {
  29055. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  29056. continue;
  29057. }
  29058. var boundTexture = this._boundTexturesCache[key];
  29059. if (boundTexture) {
  29060. this._removeDesignatedSlot(boundTexture);
  29061. }
  29062. this._boundTexturesCache[key] = null;
  29063. }
  29064. if (!this.disableTextureBindingOptimization) {
  29065. this._nextFreeTextureSlots = [];
  29066. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  29067. this._nextFreeTextureSlots.push(slot);
  29068. }
  29069. }
  29070. this._currentTextureChannel = -1;
  29071. };
  29072. /**
  29073. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29074. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29075. * @returns true if engine is in deterministic lock step mode
  29076. */
  29077. Engine.prototype.isDeterministicLockStep = function () {
  29078. return this._deterministicLockstep;
  29079. };
  29080. /**
  29081. * Gets the max steps when engine is running in deterministic lock step
  29082. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29083. * @returns the max steps
  29084. */
  29085. Engine.prototype.getLockstepMaxSteps = function () {
  29086. return this._lockstepMaxSteps;
  29087. };
  29088. /**
  29089. * Gets an object containing information about the current webGL context
  29090. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29091. */
  29092. Engine.prototype.getGlInfo = function () {
  29093. return {
  29094. vendor: this._glVendor,
  29095. renderer: this._glRenderer,
  29096. version: this._glVersion
  29097. };
  29098. };
  29099. /**
  29100. * Gets current aspect ratio
  29101. * @param camera defines the camera to use to get the aspect ratio
  29102. * @param useScreen defines if screen size must be used (or the current render target if any)
  29103. * @returns a number defining the aspect ratio
  29104. */
  29105. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  29106. if (useScreen === void 0) { useScreen = false; }
  29107. var viewport = camera.viewport;
  29108. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  29109. };
  29110. /**
  29111. * Gets current screen aspect ratio
  29112. * @returns a number defining the aspect ratio
  29113. */
  29114. Engine.prototype.getScreenAspectRatio = function () {
  29115. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  29116. };
  29117. /**
  29118. * Gets the current render width
  29119. * @param useScreen defines if screen size must be used (or the current render target if any)
  29120. * @returns a number defining the current render width
  29121. */
  29122. Engine.prototype.getRenderWidth = function (useScreen) {
  29123. if (useScreen === void 0) { useScreen = false; }
  29124. if (!useScreen && this._currentRenderTarget) {
  29125. return this._currentRenderTarget.width;
  29126. }
  29127. return this._gl.drawingBufferWidth;
  29128. };
  29129. /**
  29130. * Gets the current render height
  29131. * @param useScreen defines if screen size must be used (or the current render target if any)
  29132. * @returns a number defining the current render height
  29133. */
  29134. Engine.prototype.getRenderHeight = function (useScreen) {
  29135. if (useScreen === void 0) { useScreen = false; }
  29136. if (!useScreen && this._currentRenderTarget) {
  29137. return this._currentRenderTarget.height;
  29138. }
  29139. return this._gl.drawingBufferHeight;
  29140. };
  29141. /**
  29142. * Gets the HTML canvas attached with the current webGL context
  29143. * @returns a HTML canvas
  29144. */
  29145. Engine.prototype.getRenderingCanvas = function () {
  29146. return this._renderingCanvas;
  29147. };
  29148. /**
  29149. * Gets the client rect of the HTML canvas attached with the current webGL context
  29150. * @returns a client rectanglee
  29151. */
  29152. Engine.prototype.getRenderingCanvasClientRect = function () {
  29153. if (!this._renderingCanvas) {
  29154. return null;
  29155. }
  29156. return this._renderingCanvas.getBoundingClientRect();
  29157. };
  29158. /**
  29159. * Defines the hardware scaling level.
  29160. * By default the hardware scaling level is computed from the window device ratio.
  29161. * 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.
  29162. * @param level defines the level to use
  29163. */
  29164. Engine.prototype.setHardwareScalingLevel = function (level) {
  29165. this._hardwareScalingLevel = level;
  29166. this.resize();
  29167. };
  29168. /**
  29169. * Gets the current hardware scaling level.
  29170. * By default the hardware scaling level is computed from the window device ratio.
  29171. * 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.
  29172. * @returns a number indicating the current hardware scaling level
  29173. */
  29174. Engine.prototype.getHardwareScalingLevel = function () {
  29175. return this._hardwareScalingLevel;
  29176. };
  29177. /**
  29178. * Gets the list of loaded textures
  29179. * @returns an array containing all loaded textures
  29180. */
  29181. Engine.prototype.getLoadedTexturesCache = function () {
  29182. return this._internalTexturesCache;
  29183. };
  29184. /**
  29185. * Gets the object containing all engine capabilities
  29186. * @returns the EngineCapabilities object
  29187. */
  29188. Engine.prototype.getCaps = function () {
  29189. return this._caps;
  29190. };
  29191. /**
  29192. * Gets the current depth function
  29193. * @returns a number defining the depth function
  29194. */
  29195. Engine.prototype.getDepthFunction = function () {
  29196. return this._depthCullingState.depthFunc;
  29197. };
  29198. /**
  29199. * Sets the current depth function
  29200. * @param depthFunc defines the function to use
  29201. */
  29202. Engine.prototype.setDepthFunction = function (depthFunc) {
  29203. this._depthCullingState.depthFunc = depthFunc;
  29204. };
  29205. /**
  29206. * Sets the current depth function to GREATER
  29207. */
  29208. Engine.prototype.setDepthFunctionToGreater = function () {
  29209. this._depthCullingState.depthFunc = this._gl.GREATER;
  29210. };
  29211. /**
  29212. * Sets the current depth function to GEQUAL
  29213. */
  29214. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  29215. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  29216. };
  29217. /**
  29218. * Sets the current depth function to LESS
  29219. */
  29220. Engine.prototype.setDepthFunctionToLess = function () {
  29221. this._depthCullingState.depthFunc = this._gl.LESS;
  29222. };
  29223. /**
  29224. * Caches the the state of the stencil buffer
  29225. */
  29226. Engine.prototype.cacheStencilState = function () {
  29227. this._cachedStencilBuffer = this.getStencilBuffer();
  29228. this._cachedStencilFunction = this.getStencilFunction();
  29229. this._cachedStencilMask = this.getStencilMask();
  29230. this._cachedStencilOperationPass = this.getStencilOperationPass();
  29231. this._cachedStencilOperationFail = this.getStencilOperationFail();
  29232. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail();
  29233. this._cachedStencilReference = this.getStencilFunctionReference();
  29234. };
  29235. /**
  29236. * Restores the state of the stencil buffer
  29237. */
  29238. Engine.prototype.restoreStencilState = function () {
  29239. this.setStencilFunction(this._cachedStencilFunction);
  29240. this.setStencilMask(this._cachedStencilMask);
  29241. this.setStencilBuffer(this._cachedStencilBuffer);
  29242. this.setStencilOperationPass(this._cachedStencilOperationPass);
  29243. this.setStencilOperationFail(this._cachedStencilOperationFail);
  29244. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail);
  29245. this.setStencilFunctionReference(this._cachedStencilReference);
  29246. };
  29247. /**
  29248. * Sets the current depth function to LEQUAL
  29249. */
  29250. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  29251. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  29252. };
  29253. /**
  29254. * Gets a boolean indicating if stencil buffer is enabled
  29255. * @returns the current stencil buffer state
  29256. */
  29257. Engine.prototype.getStencilBuffer = function () {
  29258. return this._stencilState.stencilTest;
  29259. };
  29260. /**
  29261. * Enable or disable the stencil buffer
  29262. * @param enable defines if the stencil buffer must be enabled or disabled
  29263. */
  29264. Engine.prototype.setStencilBuffer = function (enable) {
  29265. this._stencilState.stencilTest = enable;
  29266. };
  29267. /**
  29268. * Gets the current stencil mask
  29269. * @returns a number defining the new stencil mask to use
  29270. */
  29271. Engine.prototype.getStencilMask = function () {
  29272. return this._stencilState.stencilMask;
  29273. };
  29274. /**
  29275. * Sets the current stencil mask
  29276. * @param mask defines the new stencil mask to use
  29277. */
  29278. Engine.prototype.setStencilMask = function (mask) {
  29279. this._stencilState.stencilMask = mask;
  29280. };
  29281. /**
  29282. * Gets the current stencil function
  29283. * @returns a number defining the stencil function to use
  29284. */
  29285. Engine.prototype.getStencilFunction = function () {
  29286. return this._stencilState.stencilFunc;
  29287. };
  29288. /**
  29289. * Gets the current stencil reference value
  29290. * @returns a number defining the stencil reference value to use
  29291. */
  29292. Engine.prototype.getStencilFunctionReference = function () {
  29293. return this._stencilState.stencilFuncRef;
  29294. };
  29295. /**
  29296. * Gets the current stencil mask
  29297. * @returns a number defining the stencil mask to use
  29298. */
  29299. Engine.prototype.getStencilFunctionMask = function () {
  29300. return this._stencilState.stencilFuncMask;
  29301. };
  29302. /**
  29303. * Sets the current stencil function
  29304. * @param stencilFunc defines the new stencil function to use
  29305. */
  29306. Engine.prototype.setStencilFunction = function (stencilFunc) {
  29307. this._stencilState.stencilFunc = stencilFunc;
  29308. };
  29309. /**
  29310. * Sets the current stencil reference
  29311. * @param reference defines the new stencil reference to use
  29312. */
  29313. Engine.prototype.setStencilFunctionReference = function (reference) {
  29314. this._stencilState.stencilFuncRef = reference;
  29315. };
  29316. /**
  29317. * Sets the current stencil mask
  29318. * @param mask defines the new stencil mask to use
  29319. */
  29320. Engine.prototype.setStencilFunctionMask = function (mask) {
  29321. this._stencilState.stencilFuncMask = mask;
  29322. };
  29323. /**
  29324. * Gets the current stencil operation when stencil fails
  29325. * @returns a number defining stencil operation to use when stencil fails
  29326. */
  29327. Engine.prototype.getStencilOperationFail = function () {
  29328. return this._stencilState.stencilOpStencilFail;
  29329. };
  29330. /**
  29331. * Gets the current stencil operation when depth fails
  29332. * @returns a number defining stencil operation to use when depth fails
  29333. */
  29334. Engine.prototype.getStencilOperationDepthFail = function () {
  29335. return this._stencilState.stencilOpDepthFail;
  29336. };
  29337. /**
  29338. * Gets the current stencil operation when stencil passes
  29339. * @returns a number defining stencil operation to use when stencil passes
  29340. */
  29341. Engine.prototype.getStencilOperationPass = function () {
  29342. return this._stencilState.stencilOpStencilDepthPass;
  29343. };
  29344. /**
  29345. * Sets the stencil operation to use when stencil fails
  29346. * @param operation defines the stencil operation to use when stencil fails
  29347. */
  29348. Engine.prototype.setStencilOperationFail = function (operation) {
  29349. this._stencilState.stencilOpStencilFail = operation;
  29350. };
  29351. /**
  29352. * Sets the stencil operation to use when depth fails
  29353. * @param operation defines the stencil operation to use when depth fails
  29354. */
  29355. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  29356. this._stencilState.stencilOpDepthFail = operation;
  29357. };
  29358. /**
  29359. * Sets the stencil operation to use when stencil passes
  29360. * @param operation defines the stencil operation to use when stencil passes
  29361. */
  29362. Engine.prototype.setStencilOperationPass = function (operation) {
  29363. this._stencilState.stencilOpStencilDepthPass = operation;
  29364. };
  29365. /**
  29366. * Sets a boolean indicating if the dithering state is enabled or disabled
  29367. * @param value defines the dithering state
  29368. */
  29369. Engine.prototype.setDitheringState = function (value) {
  29370. if (value) {
  29371. this._gl.enable(this._gl.DITHER);
  29372. }
  29373. else {
  29374. this._gl.disable(this._gl.DITHER);
  29375. }
  29376. };
  29377. /**
  29378. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29379. * @param value defines the rasterizer state
  29380. */
  29381. Engine.prototype.setRasterizerState = function (value) {
  29382. if (value) {
  29383. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  29384. }
  29385. else {
  29386. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  29387. }
  29388. };
  29389. /**
  29390. * stop executing a render loop function and remove it from the execution array
  29391. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29392. */
  29393. Engine.prototype.stopRenderLoop = function (renderFunction) {
  29394. if (!renderFunction) {
  29395. this._activeRenderLoops = [];
  29396. return;
  29397. }
  29398. var index = this._activeRenderLoops.indexOf(renderFunction);
  29399. if (index >= 0) {
  29400. this._activeRenderLoops.splice(index, 1);
  29401. }
  29402. };
  29403. /** @hidden */
  29404. Engine.prototype._renderLoop = function () {
  29405. if (!this._contextWasLost) {
  29406. var shouldRender = true;
  29407. if (!this.renderEvenInBackground && this._windowIsBackground) {
  29408. shouldRender = false;
  29409. }
  29410. if (shouldRender) {
  29411. // Start new frame
  29412. this.beginFrame();
  29413. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  29414. var renderFunction = this._activeRenderLoops[index];
  29415. renderFunction();
  29416. }
  29417. // Present
  29418. this.endFrame();
  29419. }
  29420. }
  29421. if (this._activeRenderLoops.length > 0) {
  29422. // Register new frame
  29423. if (this.customAnimationFrameRequester) {
  29424. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  29425. this._frameHandler = this.customAnimationFrameRequester.requestID;
  29426. }
  29427. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29428. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  29429. }
  29430. else {
  29431. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29432. }
  29433. }
  29434. else {
  29435. this._renderingQueueLaunched = false;
  29436. }
  29437. };
  29438. /**
  29439. * Register and execute a render loop. The engine can have more than one render function
  29440. * @param renderFunction defines the function to continuously execute
  29441. */
  29442. Engine.prototype.runRenderLoop = function (renderFunction) {
  29443. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  29444. return;
  29445. }
  29446. this._activeRenderLoops.push(renderFunction);
  29447. if (!this._renderingQueueLaunched) {
  29448. this._renderingQueueLaunched = true;
  29449. this._bindedRenderFunction = this._renderLoop.bind(this);
  29450. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29451. }
  29452. };
  29453. /**
  29454. * Toggle full screen mode
  29455. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29456. */
  29457. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  29458. if (this.isFullscreen) {
  29459. this.exitFullscreen();
  29460. }
  29461. else {
  29462. this.enterFullscreen(requestPointerLock);
  29463. }
  29464. };
  29465. /**
  29466. * Enters full screen mode
  29467. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29468. */
  29469. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  29470. if (!this.isFullscreen) {
  29471. this._pointerLockRequested = requestPointerLock;
  29472. if (this._renderingCanvas) {
  29473. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  29474. }
  29475. }
  29476. };
  29477. /**
  29478. * Exits full screen mode
  29479. */
  29480. Engine.prototype.exitFullscreen = function () {
  29481. if (this.isFullscreen) {
  29482. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  29483. }
  29484. };
  29485. /**
  29486. * Clear the current render buffer or the current render target (if any is set up)
  29487. * @param color defines the color to use
  29488. * @param backBuffer defines if the back buffer must be cleared
  29489. * @param depth defines if the depth buffer must be cleared
  29490. * @param stencil defines if the stencil buffer must be cleared
  29491. */
  29492. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  29493. if (stencil === void 0) { stencil = false; }
  29494. this.applyStates();
  29495. var mode = 0;
  29496. if (backBuffer && color) {
  29497. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  29498. mode |= this._gl.COLOR_BUFFER_BIT;
  29499. }
  29500. if (depth) {
  29501. this._gl.clearDepth(1.0);
  29502. mode |= this._gl.DEPTH_BUFFER_BIT;
  29503. }
  29504. if (stencil) {
  29505. this._gl.clearStencil(0);
  29506. mode |= this._gl.STENCIL_BUFFER_BIT;
  29507. }
  29508. this._gl.clear(mode);
  29509. };
  29510. /**
  29511. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29512. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29513. * @param y defines the y-coordinate of the corner of the clear rectangle
  29514. * @param width defines the width of the clear rectangle
  29515. * @param height defines the height of the clear rectangle
  29516. * @param clearColor defines the clear color
  29517. */
  29518. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  29519. this.enableScissor(x, y, width, height);
  29520. this.clear(clearColor, true, true, true);
  29521. this.disableScissor();
  29522. };
  29523. /**
  29524. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29525. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29526. * @param y defines the y-coordinate of the corner of the clear rectangle
  29527. * @param width defines the width of the clear rectangle
  29528. * @param height defines the height of the clear rectangle
  29529. */
  29530. Engine.prototype.enableScissor = function (x, y, width, height) {
  29531. var gl = this._gl;
  29532. // Change state
  29533. gl.enable(gl.SCISSOR_TEST);
  29534. gl.scissor(x, y, width, height);
  29535. };
  29536. /**
  29537. * Disable previously set scissor test rectangle
  29538. */
  29539. Engine.prototype.disableScissor = function () {
  29540. var gl = this._gl;
  29541. gl.disable(gl.SCISSOR_TEST);
  29542. };
  29543. /** @hidden */
  29544. Engine.prototype._viewport = function (x, y, width, height) {
  29545. if (x !== this._viewportCached.x ||
  29546. y !== this._viewportCached.y ||
  29547. width !== this._viewportCached.z ||
  29548. height !== this._viewportCached.w) {
  29549. this._viewportCached.x = x;
  29550. this._viewportCached.y = y;
  29551. this._viewportCached.z = width;
  29552. this._viewportCached.w = height;
  29553. this._gl.viewport(x, y, width, height);
  29554. }
  29555. };
  29556. /**
  29557. * Set the WebGL's viewport
  29558. * @param viewport defines the viewport element to be used
  29559. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29560. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29561. */
  29562. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  29563. var width = requiredWidth || this.getRenderWidth();
  29564. var height = requiredHeight || this.getRenderHeight();
  29565. var x = viewport.x || 0;
  29566. var y = viewport.y || 0;
  29567. this._cachedViewport = viewport;
  29568. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  29569. };
  29570. /**
  29571. * Directly set the WebGL Viewport
  29572. * @param x defines the x coordinate of the viewport (in screen space)
  29573. * @param y defines the y coordinate of the viewport (in screen space)
  29574. * @param width defines the width of the viewport (in screen space)
  29575. * @param height defines the height of the viewport (in screen space)
  29576. * @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
  29577. */
  29578. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  29579. var currentViewport = this._cachedViewport;
  29580. this._cachedViewport = null;
  29581. this._viewport(x, y, width, height);
  29582. return currentViewport;
  29583. };
  29584. /**
  29585. * Begin a new frame
  29586. */
  29587. Engine.prototype.beginFrame = function () {
  29588. this.onBeginFrameObservable.notifyObservers(this);
  29589. this._measureFps();
  29590. };
  29591. /**
  29592. * Enf the current frame
  29593. */
  29594. Engine.prototype.endFrame = function () {
  29595. // Force a flush in case we are using a bad OS.
  29596. if (this._badOS) {
  29597. this.flushFramebuffer();
  29598. }
  29599. // Submit frame to the vr device, if enabled
  29600. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29601. // TODO: We should only submit the frame if we read frameData successfully.
  29602. try {
  29603. this._vrDisplay.submitFrame();
  29604. }
  29605. catch (e) {
  29606. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  29607. }
  29608. }
  29609. this.onEndFrameObservable.notifyObservers(this);
  29610. };
  29611. /**
  29612. * Resize the view according to the canvas' size
  29613. */
  29614. Engine.prototype.resize = function () {
  29615. // We're not resizing the size of the canvas while in VR mode & presenting
  29616. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  29617. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  29618. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  29619. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  29620. }
  29621. };
  29622. /**
  29623. * Force a specific size of the canvas
  29624. * @param width defines the new canvas' width
  29625. * @param height defines the new canvas' height
  29626. */
  29627. Engine.prototype.setSize = function (width, height) {
  29628. if (!this._renderingCanvas) {
  29629. return;
  29630. }
  29631. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  29632. return;
  29633. }
  29634. this._renderingCanvas.width = width;
  29635. this._renderingCanvas.height = height;
  29636. for (var index = 0; index < this.scenes.length; index++) {
  29637. var scene = this.scenes[index];
  29638. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  29639. var cam = scene.cameras[camIndex];
  29640. cam._currentRenderId = 0;
  29641. }
  29642. }
  29643. if (this.onResizeObservable.hasObservers) {
  29644. this.onResizeObservable.notifyObservers(this);
  29645. }
  29646. };
  29647. // WebVR functions
  29648. /**
  29649. * Gets a boolean indicating if a webVR device was detected
  29650. * @returns true if a webVR device was detected
  29651. */
  29652. Engine.prototype.isVRDevicePresent = function () {
  29653. return !!this._vrDisplay;
  29654. };
  29655. /**
  29656. * Gets the current webVR device
  29657. * @returns the current webVR device (or null)
  29658. */
  29659. Engine.prototype.getVRDevice = function () {
  29660. return this._vrDisplay;
  29661. };
  29662. /**
  29663. * Initializes a webVR display and starts listening to display change events
  29664. * The onVRDisplayChangedObservable will be notified upon these changes
  29665. * @returns The onVRDisplayChangedObservable
  29666. */
  29667. Engine.prototype.initWebVR = function () {
  29668. this.initWebVRAsync();
  29669. return this.onVRDisplayChangedObservable;
  29670. };
  29671. /**
  29672. * Initializes a webVR display and starts listening to display change events
  29673. * The onVRDisplayChangedObservable will be notified upon these changes
  29674. * @returns A promise containing a VRDisplay and if vr is supported
  29675. */
  29676. Engine.prototype.initWebVRAsync = function () {
  29677. var _this = this;
  29678. var notifyObservers = function () {
  29679. var eventArgs = {
  29680. vrDisplay: _this._vrDisplay,
  29681. vrSupported: _this._vrSupported
  29682. };
  29683. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29684. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29685. };
  29686. if (!this._onVrDisplayConnect) {
  29687. this._onVrDisplayConnect = function (event) {
  29688. _this._vrDisplay = event.display;
  29689. notifyObservers();
  29690. };
  29691. this._onVrDisplayDisconnect = function () {
  29692. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29693. _this._vrDisplay = undefined;
  29694. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29695. notifyObservers();
  29696. };
  29697. this._onVrDisplayPresentChange = function () {
  29698. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29699. };
  29700. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29701. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29702. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29703. }
  29704. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29705. this._webVRInitPromise.then(notifyObservers);
  29706. return this._webVRInitPromise;
  29707. };
  29708. /**
  29709. * Call this function to switch to webVR mode
  29710. * Will do nothing if webVR is not supported or if there is no webVR device
  29711. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29712. */
  29713. Engine.prototype.enableVR = function () {
  29714. var _this = this;
  29715. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29716. var onResolved = function () {
  29717. _this.onVRRequestPresentComplete.notifyObservers(true);
  29718. _this._onVRFullScreenTriggered();
  29719. };
  29720. var onRejected = function () {
  29721. _this.onVRRequestPresentComplete.notifyObservers(false);
  29722. };
  29723. this.onVRRequestPresentStart.notifyObservers(this);
  29724. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29725. }
  29726. };
  29727. /**
  29728. * Call this function to leave webVR mode
  29729. * Will do nothing if webVR is not supported or if there is no webVR device
  29730. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29731. */
  29732. Engine.prototype.disableVR = function () {
  29733. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29734. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29735. }
  29736. };
  29737. Engine.prototype._getVRDisplaysAsync = function () {
  29738. var _this = this;
  29739. return new Promise(function (res) {
  29740. if (navigator.getVRDisplays) {
  29741. navigator.getVRDisplays().then(function (devices) {
  29742. _this._vrSupported = true;
  29743. // note that devices may actually be an empty array. This is fine;
  29744. // we expect this._vrDisplay to be undefined in this case.
  29745. _this._vrDisplay = devices[0];
  29746. res({
  29747. vrDisplay: _this._vrDisplay,
  29748. vrSupported: _this._vrSupported
  29749. });
  29750. });
  29751. }
  29752. else {
  29753. _this._vrDisplay = undefined;
  29754. _this._vrSupported = false;
  29755. res({
  29756. vrDisplay: _this._vrDisplay,
  29757. vrSupported: _this._vrSupported
  29758. });
  29759. }
  29760. });
  29761. };
  29762. /**
  29763. * Binds the frame buffer to the specified texture.
  29764. * @param texture The texture to render to or null for the default canvas
  29765. * @param faceIndex The face of the texture to render to in case of cube texture
  29766. * @param requiredWidth The width of the target to render to
  29767. * @param requiredHeight The height of the target to render to
  29768. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29769. * @param depthStencilTexture The depth stencil texture to use to render
  29770. * @param lodLevel defines le lod level to bind to the frame buffer
  29771. */
  29772. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29773. if (lodLevel === void 0) { lodLevel = 0; }
  29774. if (this._currentRenderTarget) {
  29775. this.unBindFramebuffer(this._currentRenderTarget);
  29776. }
  29777. this._currentRenderTarget = texture;
  29778. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29779. var gl = this._gl;
  29780. if (texture.isCube) {
  29781. if (faceIndex === undefined) {
  29782. faceIndex = 0;
  29783. }
  29784. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29785. if (depthStencilTexture) {
  29786. if (depthStencilTexture._generateStencilBuffer) {
  29787. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29788. }
  29789. else {
  29790. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29791. }
  29792. }
  29793. }
  29794. if (this._cachedViewport && !forceFullscreenViewport) {
  29795. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29796. }
  29797. else {
  29798. if (!requiredWidth) {
  29799. requiredWidth = texture.width;
  29800. if (lodLevel) {
  29801. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29802. }
  29803. }
  29804. if (!requiredHeight) {
  29805. requiredHeight = texture.height;
  29806. if (lodLevel) {
  29807. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29808. }
  29809. }
  29810. this._viewport(0, 0, requiredWidth, requiredHeight);
  29811. }
  29812. this.wipeCaches();
  29813. };
  29814. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29815. if (this._currentFramebuffer !== framebuffer) {
  29816. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29817. this._currentFramebuffer = framebuffer;
  29818. }
  29819. };
  29820. /**
  29821. * Unbind the current render target texture from the webGL context
  29822. * @param texture defines the render target texture to unbind
  29823. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29824. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29825. */
  29826. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  29827. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29828. this._currentRenderTarget = null;
  29829. // If MSAA, we need to bitblt back to main texture
  29830. var gl = this._gl;
  29831. if (texture._MSAAFramebuffer) {
  29832. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  29833. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  29834. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29835. }
  29836. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29837. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  29838. gl.generateMipmap(gl.TEXTURE_2D);
  29839. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29840. }
  29841. if (onBeforeUnbind) {
  29842. if (texture._MSAAFramebuffer) {
  29843. // Bind the correct framebuffer
  29844. this.bindUnboundFramebuffer(texture._framebuffer);
  29845. }
  29846. onBeforeUnbind();
  29847. }
  29848. this.bindUnboundFramebuffer(null);
  29849. };
  29850. /**
  29851. * Unbind a list of render target textures from the webGL context
  29852. * This is used only when drawBuffer extension or webGL2 are active
  29853. * @param textures defines the render target textures to unbind
  29854. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29855. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29856. */
  29857. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  29858. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29859. this._currentRenderTarget = null;
  29860. // If MSAA, we need to bitblt back to main texture
  29861. var gl = this._gl;
  29862. if (textures[0]._MSAAFramebuffer) {
  29863. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  29864. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  29865. var attachments = textures[0]._attachments;
  29866. if (!attachments) {
  29867. attachments = new Array(textures.length);
  29868. textures[0]._attachments = attachments;
  29869. }
  29870. for (var i = 0; i < textures.length; i++) {
  29871. var texture = textures[i];
  29872. for (var j = 0; j < attachments.length; j++) {
  29873. attachments[j] = gl.NONE;
  29874. }
  29875. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29876. gl.readBuffer(attachments[i]);
  29877. gl.drawBuffers(attachments);
  29878. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29879. }
  29880. for (var i = 0; i < attachments.length; i++) {
  29881. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29882. }
  29883. gl.drawBuffers(attachments);
  29884. }
  29885. for (var i = 0; i < textures.length; i++) {
  29886. var texture = textures[i];
  29887. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29888. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29889. gl.generateMipmap(gl.TEXTURE_2D);
  29890. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29891. }
  29892. }
  29893. if (onBeforeUnbind) {
  29894. if (textures[0]._MSAAFramebuffer) {
  29895. // Bind the correct framebuffer
  29896. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29897. }
  29898. onBeforeUnbind();
  29899. }
  29900. this.bindUnboundFramebuffer(null);
  29901. };
  29902. /**
  29903. * Force the mipmap generation for the given render target texture
  29904. * @param texture defines the render target texture to use
  29905. */
  29906. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29907. if (texture.generateMipMaps) {
  29908. var gl = this._gl;
  29909. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29910. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29911. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29912. }
  29913. };
  29914. /**
  29915. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29916. */
  29917. Engine.prototype.flushFramebuffer = function () {
  29918. this._gl.flush();
  29919. };
  29920. /**
  29921. * Unbind the current render target and bind the default framebuffer
  29922. */
  29923. Engine.prototype.restoreDefaultFramebuffer = function () {
  29924. if (this._currentRenderTarget) {
  29925. this.unBindFramebuffer(this._currentRenderTarget);
  29926. }
  29927. else {
  29928. this.bindUnboundFramebuffer(null);
  29929. }
  29930. if (this._cachedViewport) {
  29931. this.setViewport(this._cachedViewport);
  29932. }
  29933. this.wipeCaches();
  29934. };
  29935. // UBOs
  29936. /**
  29937. * Create an uniform buffer
  29938. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29939. * @param elements defines the content of the uniform buffer
  29940. * @returns the webGL uniform buffer
  29941. */
  29942. Engine.prototype.createUniformBuffer = function (elements) {
  29943. var ubo = this._gl.createBuffer();
  29944. if (!ubo) {
  29945. throw new Error("Unable to create uniform buffer");
  29946. }
  29947. this.bindUniformBuffer(ubo);
  29948. if (elements instanceof Float32Array) {
  29949. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29950. }
  29951. else {
  29952. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29953. }
  29954. this.bindUniformBuffer(null);
  29955. ubo.references = 1;
  29956. return ubo;
  29957. };
  29958. /**
  29959. * Create a dynamic uniform buffer
  29960. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29961. * @param elements defines the content of the uniform buffer
  29962. * @returns the webGL uniform buffer
  29963. */
  29964. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29965. var ubo = this._gl.createBuffer();
  29966. if (!ubo) {
  29967. throw new Error("Unable to create dynamic uniform buffer");
  29968. }
  29969. this.bindUniformBuffer(ubo);
  29970. if (elements instanceof Float32Array) {
  29971. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29972. }
  29973. else {
  29974. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29975. }
  29976. this.bindUniformBuffer(null);
  29977. ubo.references = 1;
  29978. return ubo;
  29979. };
  29980. /**
  29981. * Update an existing uniform buffer
  29982. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29983. * @param uniformBuffer defines the target uniform buffer
  29984. * @param elements defines the content to update
  29985. * @param offset defines the offset in the uniform buffer where update should start
  29986. * @param count defines the size of the data to update
  29987. */
  29988. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29989. this.bindUniformBuffer(uniformBuffer);
  29990. if (offset === undefined) {
  29991. offset = 0;
  29992. }
  29993. if (count === undefined) {
  29994. if (elements instanceof Float32Array) {
  29995. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29996. }
  29997. else {
  29998. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29999. }
  30000. }
  30001. else {
  30002. if (elements instanceof Float32Array) {
  30003. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  30004. }
  30005. else {
  30006. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  30007. }
  30008. }
  30009. this.bindUniformBuffer(null);
  30010. };
  30011. // VBOs
  30012. Engine.prototype._resetVertexBufferBinding = function () {
  30013. this.bindArrayBuffer(null);
  30014. this._cachedVertexBuffers = null;
  30015. };
  30016. /**
  30017. * Creates a vertex buffer
  30018. * @param data the data for the vertex buffer
  30019. * @returns the new WebGL static buffer
  30020. */
  30021. Engine.prototype.createVertexBuffer = function (data) {
  30022. var vbo = this._gl.createBuffer();
  30023. if (!vbo) {
  30024. throw new Error("Unable to create vertex buffer");
  30025. }
  30026. this.bindArrayBuffer(vbo);
  30027. if (data instanceof Array) {
  30028. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  30029. }
  30030. else {
  30031. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  30032. }
  30033. this._resetVertexBufferBinding();
  30034. vbo.references = 1;
  30035. return vbo;
  30036. };
  30037. /**
  30038. * Creates a dynamic vertex buffer
  30039. * @param data the data for the dynamic vertex buffer
  30040. * @returns the new WebGL dynamic buffer
  30041. */
  30042. Engine.prototype.createDynamicVertexBuffer = function (data) {
  30043. var vbo = this._gl.createBuffer();
  30044. if (!vbo) {
  30045. throw new Error("Unable to create dynamic vertex buffer");
  30046. }
  30047. this.bindArrayBuffer(vbo);
  30048. if (data instanceof Array) {
  30049. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  30050. }
  30051. else {
  30052. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  30053. }
  30054. this._resetVertexBufferBinding();
  30055. vbo.references = 1;
  30056. return vbo;
  30057. };
  30058. /**
  30059. * Update a dynamic index buffer
  30060. * @param indexBuffer defines the target index buffer
  30061. * @param indices defines the data to update
  30062. * @param offset defines the offset in the target index buffer where update should start
  30063. */
  30064. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  30065. if (offset === void 0) { offset = 0; }
  30066. // Force cache update
  30067. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  30068. this.bindIndexBuffer(indexBuffer);
  30069. var arrayBuffer;
  30070. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  30071. arrayBuffer = indices;
  30072. }
  30073. else {
  30074. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30075. }
  30076. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  30077. this._resetIndexBufferBinding();
  30078. };
  30079. /**
  30080. * Updates a dynamic vertex buffer.
  30081. * @param vertexBuffer the vertex buffer to update
  30082. * @param data the data used to update the vertex buffer
  30083. * @param byteOffset the byte offset of the data
  30084. * @param byteLength the byte length of the data
  30085. */
  30086. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  30087. this.bindArrayBuffer(vertexBuffer);
  30088. if (byteOffset === undefined) {
  30089. byteOffset = 0;
  30090. }
  30091. if (byteLength === undefined) {
  30092. if (data instanceof Array) {
  30093. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  30094. }
  30095. else {
  30096. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  30097. }
  30098. }
  30099. else {
  30100. if (data instanceof Array) {
  30101. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  30102. }
  30103. else {
  30104. if (data instanceof ArrayBuffer) {
  30105. data = new Uint8Array(data, byteOffset, byteLength);
  30106. }
  30107. else {
  30108. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  30109. }
  30110. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30111. }
  30112. }
  30113. this._resetVertexBufferBinding();
  30114. };
  30115. Engine.prototype._resetIndexBufferBinding = function () {
  30116. this.bindIndexBuffer(null);
  30117. this._cachedIndexBuffer = null;
  30118. };
  30119. /**
  30120. * Creates a new index buffer
  30121. * @param indices defines the content of the index buffer
  30122. * @param updatable defines if the index buffer must be updatable
  30123. * @returns a new webGL buffer
  30124. */
  30125. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  30126. var vbo = this._gl.createBuffer();
  30127. if (!vbo) {
  30128. throw new Error("Unable to create index buffer");
  30129. }
  30130. this.bindIndexBuffer(vbo);
  30131. // Check for 32 bits indices
  30132. var arrayBuffer;
  30133. var need32Bits = false;
  30134. if (indices instanceof Uint16Array) {
  30135. arrayBuffer = indices;
  30136. }
  30137. else {
  30138. //check 32 bit support
  30139. if (this._caps.uintIndices) {
  30140. if (indices instanceof Uint32Array) {
  30141. arrayBuffer = indices;
  30142. need32Bits = true;
  30143. }
  30144. else {
  30145. //number[] or Int32Array, check if 32 bit is necessary
  30146. for (var index = 0; index < indices.length; index++) {
  30147. if (indices[index] > 65535) {
  30148. need32Bits = true;
  30149. break;
  30150. }
  30151. }
  30152. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30153. }
  30154. }
  30155. else {
  30156. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  30157. arrayBuffer = new Uint16Array(indices);
  30158. }
  30159. }
  30160. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  30161. this._resetIndexBufferBinding();
  30162. vbo.references = 1;
  30163. vbo.is32Bits = need32Bits;
  30164. return vbo;
  30165. };
  30166. /**
  30167. * Bind a webGL buffer to the webGL context
  30168. * @param buffer defines the buffer to bind
  30169. */
  30170. Engine.prototype.bindArrayBuffer = function (buffer) {
  30171. if (!this._vaoRecordInProgress) {
  30172. this._unbindVertexArrayObject();
  30173. }
  30174. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  30175. };
  30176. /**
  30177. * Bind an uniform buffer to the current webGL context
  30178. * @param buffer defines the buffer to bind
  30179. */
  30180. Engine.prototype.bindUniformBuffer = function (buffer) {
  30181. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  30182. };
  30183. /**
  30184. * Bind a buffer to the current webGL context at a given location
  30185. * @param buffer defines the buffer to bind
  30186. * @param location defines the index where to bind the buffer
  30187. */
  30188. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  30189. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  30190. };
  30191. /**
  30192. * Bind a specific block at a given index in a specific shader program
  30193. * @param shaderProgram defines the shader program
  30194. * @param blockName defines the block name
  30195. * @param index defines the index where to bind the block
  30196. */
  30197. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  30198. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  30199. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  30200. };
  30201. Engine.prototype.bindIndexBuffer = function (buffer) {
  30202. if (!this._vaoRecordInProgress) {
  30203. this._unbindVertexArrayObject();
  30204. }
  30205. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  30206. };
  30207. Engine.prototype.bindBuffer = function (buffer, target) {
  30208. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  30209. this._gl.bindBuffer(target, buffer);
  30210. this._currentBoundBuffer[target] = buffer;
  30211. }
  30212. };
  30213. /**
  30214. * update the bound buffer with the given data
  30215. * @param data defines the data to update
  30216. */
  30217. Engine.prototype.updateArrayBuffer = function (data) {
  30218. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30219. };
  30220. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  30221. var pointer = this._currentBufferPointers[indx];
  30222. var changed = false;
  30223. if (!pointer.active) {
  30224. changed = true;
  30225. pointer.active = true;
  30226. pointer.index = indx;
  30227. pointer.size = size;
  30228. pointer.type = type;
  30229. pointer.normalized = normalized;
  30230. pointer.stride = stride;
  30231. pointer.offset = offset;
  30232. pointer.buffer = buffer;
  30233. }
  30234. else {
  30235. if (pointer.buffer !== buffer) {
  30236. pointer.buffer = buffer;
  30237. changed = true;
  30238. }
  30239. if (pointer.size !== size) {
  30240. pointer.size = size;
  30241. changed = true;
  30242. }
  30243. if (pointer.type !== type) {
  30244. pointer.type = type;
  30245. changed = true;
  30246. }
  30247. if (pointer.normalized !== normalized) {
  30248. pointer.normalized = normalized;
  30249. changed = true;
  30250. }
  30251. if (pointer.stride !== stride) {
  30252. pointer.stride = stride;
  30253. changed = true;
  30254. }
  30255. if (pointer.offset !== offset) {
  30256. pointer.offset = offset;
  30257. changed = true;
  30258. }
  30259. }
  30260. if (changed || this._vaoRecordInProgress) {
  30261. this.bindArrayBuffer(buffer);
  30262. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  30263. }
  30264. };
  30265. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  30266. if (indexBuffer == null) {
  30267. return;
  30268. }
  30269. if (this._cachedIndexBuffer !== indexBuffer) {
  30270. this._cachedIndexBuffer = indexBuffer;
  30271. this.bindIndexBuffer(indexBuffer);
  30272. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  30273. }
  30274. };
  30275. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  30276. var attributes = effect.getAttributesNames();
  30277. if (!this._vaoRecordInProgress) {
  30278. this._unbindVertexArrayObject();
  30279. }
  30280. this.unbindAllAttributes();
  30281. for (var index = 0; index < attributes.length; index++) {
  30282. var order = effect.getAttributeLocation(index);
  30283. if (order >= 0) {
  30284. var vertexBuffer = vertexBuffers[attributes[index]];
  30285. if (!vertexBuffer) {
  30286. continue;
  30287. }
  30288. this._gl.enableVertexAttribArray(order);
  30289. if (!this._vaoRecordInProgress) {
  30290. this._vertexAttribArraysEnabled[order] = true;
  30291. }
  30292. var buffer = vertexBuffer.getBuffer();
  30293. if (buffer) {
  30294. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  30295. if (vertexBuffer.getIsInstanced()) {
  30296. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  30297. if (!this._vaoRecordInProgress) {
  30298. this._currentInstanceLocations.push(order);
  30299. this._currentInstanceBuffers.push(buffer);
  30300. }
  30301. }
  30302. }
  30303. }
  30304. }
  30305. };
  30306. /**
  30307. * Records a vertex array object
  30308. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30309. * @param vertexBuffers defines the list of vertex buffers to store
  30310. * @param indexBuffer defines the index buffer to store
  30311. * @param effect defines the effect to store
  30312. * @returns the new vertex array object
  30313. */
  30314. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  30315. var vao = this._gl.createVertexArray();
  30316. this._vaoRecordInProgress = true;
  30317. this._gl.bindVertexArray(vao);
  30318. this._mustWipeVertexAttributes = true;
  30319. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30320. this.bindIndexBuffer(indexBuffer);
  30321. this._vaoRecordInProgress = false;
  30322. this._gl.bindVertexArray(null);
  30323. return vao;
  30324. };
  30325. /**
  30326. * Bind a specific vertex array object
  30327. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30328. * @param vertexArrayObject defines the vertex array object to bind
  30329. * @param indexBuffer defines the index buffer to bind
  30330. */
  30331. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  30332. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  30333. this._cachedVertexArrayObject = vertexArrayObject;
  30334. this._gl.bindVertexArray(vertexArrayObject);
  30335. this._cachedVertexBuffers = null;
  30336. this._cachedIndexBuffer = null;
  30337. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  30338. this._mustWipeVertexAttributes = true;
  30339. }
  30340. };
  30341. /**
  30342. * Bind webGl buffers directly to the webGL context
  30343. * @param vertexBuffer defines the vertex buffer to bind
  30344. * @param indexBuffer defines the index buffer to bind
  30345. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30346. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30347. * @param effect defines the effect associated with the vertex buffer
  30348. */
  30349. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  30350. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  30351. this._cachedVertexBuffers = vertexBuffer;
  30352. this._cachedEffectForVertexBuffers = effect;
  30353. var attributesCount = effect.getAttributesCount();
  30354. this._unbindVertexArrayObject();
  30355. this.unbindAllAttributes();
  30356. var offset = 0;
  30357. for (var index = 0; index < attributesCount; index++) {
  30358. if (index < vertexDeclaration.length) {
  30359. var order = effect.getAttributeLocation(index);
  30360. if (order >= 0) {
  30361. this._gl.enableVertexAttribArray(order);
  30362. this._vertexAttribArraysEnabled[order] = true;
  30363. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  30364. }
  30365. offset += vertexDeclaration[index] * 4;
  30366. }
  30367. }
  30368. }
  30369. this._bindIndexBufferWithCache(indexBuffer);
  30370. };
  30371. Engine.prototype._unbindVertexArrayObject = function () {
  30372. if (!this._cachedVertexArrayObject) {
  30373. return;
  30374. }
  30375. this._cachedVertexArrayObject = null;
  30376. this._gl.bindVertexArray(null);
  30377. };
  30378. /**
  30379. * Bind a list of vertex buffers to the webGL context
  30380. * @param vertexBuffers defines the list of vertex buffers to bind
  30381. * @param indexBuffer defines the index buffer to bind
  30382. * @param effect defines the effect associated with the vertex buffers
  30383. */
  30384. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  30385. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  30386. this._cachedVertexBuffers = vertexBuffers;
  30387. this._cachedEffectForVertexBuffers = effect;
  30388. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30389. }
  30390. this._bindIndexBufferWithCache(indexBuffer);
  30391. };
  30392. /**
  30393. * Unbind all instance attributes
  30394. */
  30395. Engine.prototype.unbindInstanceAttributes = function () {
  30396. var boundBuffer;
  30397. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  30398. var instancesBuffer = this._currentInstanceBuffers[i];
  30399. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  30400. boundBuffer = instancesBuffer;
  30401. this.bindArrayBuffer(instancesBuffer);
  30402. }
  30403. var offsetLocation = this._currentInstanceLocations[i];
  30404. this._gl.vertexAttribDivisor(offsetLocation, 0);
  30405. }
  30406. this._currentInstanceBuffers.length = 0;
  30407. this._currentInstanceLocations.length = 0;
  30408. };
  30409. /**
  30410. * Release and free the memory of a vertex array object
  30411. * @param vao defines the vertex array object to delete
  30412. */
  30413. Engine.prototype.releaseVertexArrayObject = function (vao) {
  30414. this._gl.deleteVertexArray(vao);
  30415. };
  30416. /** @hidden */
  30417. Engine.prototype._releaseBuffer = function (buffer) {
  30418. buffer.references--;
  30419. if (buffer.references === 0) {
  30420. this._gl.deleteBuffer(buffer);
  30421. return true;
  30422. }
  30423. return false;
  30424. };
  30425. /**
  30426. * Creates a webGL buffer to use with instanciation
  30427. * @param capacity defines the size of the buffer
  30428. * @returns the webGL buffer
  30429. */
  30430. Engine.prototype.createInstancesBuffer = function (capacity) {
  30431. var buffer = this._gl.createBuffer();
  30432. if (!buffer) {
  30433. throw new Error("Unable to create instance buffer");
  30434. }
  30435. buffer.capacity = capacity;
  30436. this.bindArrayBuffer(buffer);
  30437. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  30438. return buffer;
  30439. };
  30440. /**
  30441. * Delete a webGL buffer used with instanciation
  30442. * @param buffer defines the webGL buffer to delete
  30443. */
  30444. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  30445. this._gl.deleteBuffer(buffer);
  30446. };
  30447. /**
  30448. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30449. * @param instancesBuffer defines the webGL buffer to update and bind
  30450. * @param data defines the data to store in the buffer
  30451. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30452. */
  30453. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  30454. this.bindArrayBuffer(instancesBuffer);
  30455. if (data) {
  30456. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30457. }
  30458. if (offsetLocations[0].index !== undefined) {
  30459. var stride = 0;
  30460. for (var i = 0; i < offsetLocations.length; i++) {
  30461. var ai = offsetLocations[i];
  30462. stride += ai.attributeSize * 4;
  30463. }
  30464. for (var i = 0; i < offsetLocations.length; i++) {
  30465. var ai = offsetLocations[i];
  30466. if (!this._vertexAttribArraysEnabled[ai.index]) {
  30467. this._gl.enableVertexAttribArray(ai.index);
  30468. this._vertexAttribArraysEnabled[ai.index] = true;
  30469. }
  30470. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  30471. this._gl.vertexAttribDivisor(ai.index, 1);
  30472. this._currentInstanceLocations.push(ai.index);
  30473. this._currentInstanceBuffers.push(instancesBuffer);
  30474. }
  30475. }
  30476. else {
  30477. for (var index = 0; index < 4; index++) {
  30478. var offsetLocation = offsetLocations[index];
  30479. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  30480. this._gl.enableVertexAttribArray(offsetLocation);
  30481. this._vertexAttribArraysEnabled[offsetLocation] = true;
  30482. }
  30483. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  30484. this._gl.vertexAttribDivisor(offsetLocation, 1);
  30485. this._currentInstanceLocations.push(offsetLocation);
  30486. this._currentInstanceBuffers.push(instancesBuffer);
  30487. }
  30488. }
  30489. };
  30490. /**
  30491. * Apply all cached states (depth, culling, stencil and alpha)
  30492. */
  30493. Engine.prototype.applyStates = function () {
  30494. this._depthCullingState.apply(this._gl);
  30495. this._stencilState.apply(this._gl);
  30496. this._alphaState.apply(this._gl);
  30497. };
  30498. /**
  30499. * Send a draw order
  30500. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30501. * @param indexStart defines the starting index
  30502. * @param indexCount defines the number of index to draw
  30503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30504. */
  30505. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  30506. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  30507. };
  30508. /**
  30509. * Draw a list of points
  30510. * @param verticesStart defines the index of first vertex to draw
  30511. * @param verticesCount defines the count of vertices to draw
  30512. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30513. */
  30514. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  30515. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  30516. };
  30517. /**
  30518. * Draw a list of unindexed primitives
  30519. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30520. * @param verticesStart defines the index of first vertex to draw
  30521. * @param verticesCount defines the count of vertices to draw
  30522. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30523. */
  30524. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  30525. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  30526. };
  30527. /**
  30528. * Draw a list of indexed primitives
  30529. * @param fillMode defines the primitive to use
  30530. * @param indexStart defines the starting index
  30531. * @param indexCount defines the number of index to draw
  30532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30533. */
  30534. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  30535. // Apply states
  30536. this.applyStates();
  30537. this._drawCalls.addCount(1, false);
  30538. // Render
  30539. var drawMode = this._drawMode(fillMode);
  30540. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  30541. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  30542. if (instancesCount) {
  30543. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  30544. }
  30545. else {
  30546. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  30547. }
  30548. };
  30549. /**
  30550. * Draw a list of unindexed primitives
  30551. * @param fillMode defines the primitive to use
  30552. * @param verticesStart defines the index of first vertex to draw
  30553. * @param verticesCount defines the count of vertices to draw
  30554. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30555. */
  30556. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  30557. // Apply states
  30558. this.applyStates();
  30559. this._drawCalls.addCount(1, false);
  30560. var drawMode = this._drawMode(fillMode);
  30561. if (instancesCount) {
  30562. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  30563. }
  30564. else {
  30565. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  30566. }
  30567. };
  30568. Engine.prototype._drawMode = function (fillMode) {
  30569. switch (fillMode) {
  30570. // Triangle views
  30571. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  30572. return this._gl.TRIANGLES;
  30573. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  30574. return this._gl.POINTS;
  30575. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  30576. return this._gl.LINES;
  30577. // Draw modes
  30578. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  30579. return this._gl.POINTS;
  30580. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  30581. return this._gl.LINES;
  30582. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  30583. return this._gl.LINE_LOOP;
  30584. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  30585. return this._gl.LINE_STRIP;
  30586. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  30587. return this._gl.TRIANGLE_STRIP;
  30588. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  30589. return this._gl.TRIANGLE_FAN;
  30590. default:
  30591. return this._gl.TRIANGLES;
  30592. }
  30593. };
  30594. // Shaders
  30595. /** @hidden */
  30596. Engine.prototype._releaseEffect = function (effect) {
  30597. if (this._compiledEffects[effect._key]) {
  30598. delete this._compiledEffects[effect._key];
  30599. this._deleteProgram(effect.getProgram());
  30600. }
  30601. };
  30602. /** @hidden */
  30603. Engine.prototype._deleteProgram = function (program) {
  30604. if (program) {
  30605. program.__SPECTOR_rebuildProgram = null;
  30606. if (program.transformFeedback) {
  30607. this.deleteTransformFeedback(program.transformFeedback);
  30608. program.transformFeedback = null;
  30609. }
  30610. this._gl.deleteProgram(program);
  30611. }
  30612. };
  30613. /**
  30614. * Create a new effect (used to store vertex/fragment shaders)
  30615. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30616. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30617. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30618. * @param samplers defines an array of string used to represent textures
  30619. * @param defines defines the string containing the defines to use to compile the shaders
  30620. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30621. * @param onCompiled defines a function to call when the effect creation is successful
  30622. * @param onError defines a function to call when the effect creation has failed
  30623. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30624. * @returns the new Effect
  30625. */
  30626. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  30627. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  30628. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  30629. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  30630. if (this._compiledEffects[name]) {
  30631. var compiledEffect = this._compiledEffects[name];
  30632. if (onCompiled && compiledEffect.isReady()) {
  30633. onCompiled(compiledEffect);
  30634. }
  30635. return compiledEffect;
  30636. }
  30637. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  30638. effect._key = name;
  30639. this._compiledEffects[name] = effect;
  30640. return effect;
  30641. };
  30642. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  30643. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  30644. };
  30645. Engine.prototype._compileRawShader = function (source, type) {
  30646. var gl = this._gl;
  30647. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  30648. if (!shader) {
  30649. throw new Error("Something went wrong while compile the shader.");
  30650. }
  30651. gl.shaderSource(shader, source);
  30652. gl.compileShader(shader);
  30653. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  30654. var log = gl.getShaderInfoLog(shader);
  30655. if (log) {
  30656. throw new Error(log);
  30657. }
  30658. }
  30659. return shader;
  30660. };
  30661. /**
  30662. * Directly creates a webGL program
  30663. * @param vertexCode defines the vertex shader code to use
  30664. * @param fragmentCode defines the fragment shader code to use
  30665. * @param context defines the webGL context to use (if not set, the current one will be used)
  30666. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30667. * @returns the new webGL program
  30668. */
  30669. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30670. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30671. context = context || this._gl;
  30672. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30673. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30674. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30675. };
  30676. /**
  30677. * Creates a webGL program
  30678. * @param vertexCode defines the vertex shader code to use
  30679. * @param fragmentCode defines the fragment shader code to use
  30680. * @param defines defines the string containing the defines to use to compile the shaders
  30681. * @param context defines the webGL context to use (if not set, the current one will be used)
  30682. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30683. * @returns the new webGL program
  30684. */
  30685. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30686. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30687. context = context || this._gl;
  30688. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30689. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30690. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30691. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30692. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30693. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30694. return program;
  30695. };
  30696. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30697. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30698. var shaderProgram = context.createProgram();
  30699. if (!shaderProgram) {
  30700. throw new Error("Unable to create program");
  30701. }
  30702. context.attachShader(shaderProgram, vertexShader);
  30703. context.attachShader(shaderProgram, fragmentShader);
  30704. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30705. var transformFeedback = this.createTransformFeedback();
  30706. this.bindTransformFeedback(transformFeedback);
  30707. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30708. shaderProgram.transformFeedback = transformFeedback;
  30709. }
  30710. context.linkProgram(shaderProgram);
  30711. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30712. this.bindTransformFeedback(null);
  30713. }
  30714. shaderProgram.context = context;
  30715. shaderProgram.vertexShader = vertexShader;
  30716. shaderProgram.fragmentShader = fragmentShader;
  30717. if (!this._caps.parallelShaderCompile) {
  30718. this._finalizeProgram(shaderProgram);
  30719. }
  30720. else {
  30721. shaderProgram.isParallelCompiled = true;
  30722. }
  30723. return shaderProgram;
  30724. };
  30725. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30726. var context = shaderProgram.context;
  30727. var vertexShader = shaderProgram.vertexShader;
  30728. var fragmentShader = shaderProgram.fragmentShader;
  30729. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30730. if (!linked) {
  30731. var error = context.getProgramInfoLog(shaderProgram);
  30732. if (error) {
  30733. throw new Error(error);
  30734. }
  30735. }
  30736. if (this.validateShaderPrograms) {
  30737. context.validateProgram(shaderProgram);
  30738. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30739. if (!validated) {
  30740. var error = context.getProgramInfoLog(shaderProgram);
  30741. if (error) {
  30742. throw new Error(error);
  30743. }
  30744. }
  30745. }
  30746. context.deleteShader(vertexShader);
  30747. context.deleteShader(fragmentShader);
  30748. shaderProgram.context = undefined;
  30749. shaderProgram.vertexShader = undefined;
  30750. shaderProgram.fragmentShader = undefined;
  30751. if (shaderProgram.onCompiled) {
  30752. shaderProgram.onCompiled();
  30753. shaderProgram.onCompiled = undefined;
  30754. }
  30755. };
  30756. /** @hidden */
  30757. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30758. if (!shaderProgram.isParallelCompiled) {
  30759. return true;
  30760. }
  30761. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30762. this._finalizeProgram(shaderProgram);
  30763. return true;
  30764. }
  30765. return false;
  30766. };
  30767. /** @hidden */
  30768. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30769. if (!shaderProgram.isParallelCompiled) {
  30770. action();
  30771. return;
  30772. }
  30773. shaderProgram.onCompiled = action;
  30774. };
  30775. /**
  30776. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30777. * @param shaderProgram defines the webGL program to use
  30778. * @param uniformsNames defines the list of uniform names
  30779. * @returns an array of webGL uniform locations
  30780. */
  30781. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30782. var results = new Array();
  30783. for (var index = 0; index < uniformsNames.length; index++) {
  30784. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30785. }
  30786. return results;
  30787. };
  30788. /**
  30789. * Gets the lsit of active attributes for a given webGL program
  30790. * @param shaderProgram defines the webGL program to use
  30791. * @param attributesNames defines the list of attribute names to get
  30792. * @returns an array of indices indicating the offset of each attribute
  30793. */
  30794. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30795. var results = [];
  30796. for (var index = 0; index < attributesNames.length; index++) {
  30797. try {
  30798. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30799. }
  30800. catch (e) {
  30801. results.push(-1);
  30802. }
  30803. }
  30804. return results;
  30805. };
  30806. /**
  30807. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30808. * @param effect defines the effect to activate
  30809. */
  30810. Engine.prototype.enableEffect = function (effect) {
  30811. if (!effect || effect === this._currentEffect) {
  30812. return;
  30813. }
  30814. // Use program
  30815. this.bindSamplers(effect);
  30816. this._currentEffect = effect;
  30817. if (effect.onBind) {
  30818. effect.onBind(effect);
  30819. }
  30820. if (effect._onBindObservable) {
  30821. effect._onBindObservable.notifyObservers(effect);
  30822. }
  30823. };
  30824. /**
  30825. * Set the value of an uniform to an array of int32
  30826. * @param uniform defines the webGL uniform location where to store the value
  30827. * @param array defines the array of int32 to store
  30828. */
  30829. Engine.prototype.setIntArray = function (uniform, array) {
  30830. if (!uniform) {
  30831. return;
  30832. }
  30833. this._gl.uniform1iv(uniform, array);
  30834. };
  30835. /**
  30836. * Set the value of an uniform to an array of int32 (stored as vec2)
  30837. * @param uniform defines the webGL uniform location where to store the value
  30838. * @param array defines the array of int32 to store
  30839. */
  30840. Engine.prototype.setIntArray2 = function (uniform, array) {
  30841. if (!uniform || array.length % 2 !== 0) {
  30842. return;
  30843. }
  30844. this._gl.uniform2iv(uniform, array);
  30845. };
  30846. /**
  30847. * Set the value of an uniform to an array of int32 (stored as vec3)
  30848. * @param uniform defines the webGL uniform location where to store the value
  30849. * @param array defines the array of int32 to store
  30850. */
  30851. Engine.prototype.setIntArray3 = function (uniform, array) {
  30852. if (!uniform || array.length % 3 !== 0) {
  30853. return;
  30854. }
  30855. this._gl.uniform3iv(uniform, array);
  30856. };
  30857. /**
  30858. * Set the value of an uniform to an array of int32 (stored as vec4)
  30859. * @param uniform defines the webGL uniform location where to store the value
  30860. * @param array defines the array of int32 to store
  30861. */
  30862. Engine.prototype.setIntArray4 = function (uniform, array) {
  30863. if (!uniform || array.length % 4 !== 0) {
  30864. return;
  30865. }
  30866. this._gl.uniform4iv(uniform, array);
  30867. };
  30868. /**
  30869. * Set the value of an uniform to an array of float32
  30870. * @param uniform defines the webGL uniform location where to store the value
  30871. * @param array defines the array of float32 to store
  30872. */
  30873. Engine.prototype.setFloatArray = function (uniform, array) {
  30874. if (!uniform) {
  30875. return;
  30876. }
  30877. this._gl.uniform1fv(uniform, array);
  30878. };
  30879. /**
  30880. * Set the value of an uniform to an array of float32 (stored as vec2)
  30881. * @param uniform defines the webGL uniform location where to store the value
  30882. * @param array defines the array of float32 to store
  30883. */
  30884. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30885. if (!uniform || array.length % 2 !== 0) {
  30886. return;
  30887. }
  30888. this._gl.uniform2fv(uniform, array);
  30889. };
  30890. /**
  30891. * Set the value of an uniform to an array of float32 (stored as vec3)
  30892. * @param uniform defines the webGL uniform location where to store the value
  30893. * @param array defines the array of float32 to store
  30894. */
  30895. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30896. if (!uniform || array.length % 3 !== 0) {
  30897. return;
  30898. }
  30899. this._gl.uniform3fv(uniform, array);
  30900. };
  30901. /**
  30902. * Set the value of an uniform to an array of float32 (stored as vec4)
  30903. * @param uniform defines the webGL uniform location where to store the value
  30904. * @param array defines the array of float32 to store
  30905. */
  30906. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30907. if (!uniform || array.length % 4 !== 0) {
  30908. return;
  30909. }
  30910. this._gl.uniform4fv(uniform, array);
  30911. };
  30912. /**
  30913. * Set the value of an uniform to an array of number
  30914. * @param uniform defines the webGL uniform location where to store the value
  30915. * @param array defines the array of number to store
  30916. */
  30917. Engine.prototype.setArray = function (uniform, array) {
  30918. if (!uniform) {
  30919. return;
  30920. }
  30921. this._gl.uniform1fv(uniform, array);
  30922. };
  30923. /**
  30924. * Set the value of an uniform to an array of number (stored as vec2)
  30925. * @param uniform defines the webGL uniform location where to store the value
  30926. * @param array defines the array of number to store
  30927. */
  30928. Engine.prototype.setArray2 = function (uniform, array) {
  30929. if (!uniform || array.length % 2 !== 0) {
  30930. return;
  30931. }
  30932. this._gl.uniform2fv(uniform, array);
  30933. };
  30934. /**
  30935. * Set the value of an uniform to an array of number (stored as vec3)
  30936. * @param uniform defines the webGL uniform location where to store the value
  30937. * @param array defines the array of number to store
  30938. */
  30939. Engine.prototype.setArray3 = function (uniform, array) {
  30940. if (!uniform || array.length % 3 !== 0) {
  30941. return;
  30942. }
  30943. this._gl.uniform3fv(uniform, array);
  30944. };
  30945. /**
  30946. * Set the value of an uniform to an array of number (stored as vec4)
  30947. * @param uniform defines the webGL uniform location where to store the value
  30948. * @param array defines the array of number to store
  30949. */
  30950. Engine.prototype.setArray4 = function (uniform, array) {
  30951. if (!uniform || array.length % 4 !== 0) {
  30952. return;
  30953. }
  30954. this._gl.uniform4fv(uniform, array);
  30955. };
  30956. /**
  30957. * Set the value of an uniform to an array of float32 (stored as matrices)
  30958. * @param uniform defines the webGL uniform location where to store the value
  30959. * @param matrices defines the array of float32 to store
  30960. */
  30961. Engine.prototype.setMatrices = function (uniform, matrices) {
  30962. if (!uniform) {
  30963. return;
  30964. }
  30965. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30966. };
  30967. /**
  30968. * Set the value of an uniform to a matrix
  30969. * @param uniform defines the webGL uniform location where to store the value
  30970. * @param matrix defines the matrix to store
  30971. */
  30972. Engine.prototype.setMatrix = function (uniform, matrix) {
  30973. if (!uniform) {
  30974. return;
  30975. }
  30976. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30977. };
  30978. /**
  30979. * Set the value of an uniform to a matrix (3x3)
  30980. * @param uniform defines the webGL uniform location where to store the value
  30981. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30982. */
  30983. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30984. if (!uniform) {
  30985. return;
  30986. }
  30987. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30988. };
  30989. /**
  30990. * Set the value of an uniform to a matrix (2x2)
  30991. * @param uniform defines the webGL uniform location where to store the value
  30992. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30993. */
  30994. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30995. if (!uniform) {
  30996. return;
  30997. }
  30998. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30999. };
  31000. /**
  31001. * Set the value of an uniform to a number (int)
  31002. * @param uniform defines the webGL uniform location where to store the value
  31003. * @param value defines the int number to store
  31004. */
  31005. Engine.prototype.setInt = function (uniform, value) {
  31006. if (!uniform) {
  31007. return;
  31008. }
  31009. this._gl.uniform1i(uniform, value);
  31010. };
  31011. /**
  31012. * Set the value of an uniform to a number (float)
  31013. * @param uniform defines the webGL uniform location where to store the value
  31014. * @param value defines the float number to store
  31015. */
  31016. Engine.prototype.setFloat = function (uniform, value) {
  31017. if (!uniform) {
  31018. return;
  31019. }
  31020. this._gl.uniform1f(uniform, value);
  31021. };
  31022. /**
  31023. * Set the value of an uniform to a vec2
  31024. * @param uniform defines the webGL uniform location where to store the value
  31025. * @param x defines the 1st component of the value
  31026. * @param y defines the 2nd component of the value
  31027. */
  31028. Engine.prototype.setFloat2 = function (uniform, x, y) {
  31029. if (!uniform) {
  31030. return;
  31031. }
  31032. this._gl.uniform2f(uniform, x, y);
  31033. };
  31034. /**
  31035. * Set the value of an uniform to a vec3
  31036. * @param uniform defines the webGL uniform location where to store the value
  31037. * @param x defines the 1st component of the value
  31038. * @param y defines the 2nd component of the value
  31039. * @param z defines the 3rd component of the value
  31040. */
  31041. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  31042. if (!uniform) {
  31043. return;
  31044. }
  31045. this._gl.uniform3f(uniform, x, y, z);
  31046. };
  31047. /**
  31048. * Set the value of an uniform to a boolean
  31049. * @param uniform defines the webGL uniform location where to store the value
  31050. * @param bool defines the boolean to store
  31051. */
  31052. Engine.prototype.setBool = function (uniform, bool) {
  31053. if (!uniform) {
  31054. return;
  31055. }
  31056. this._gl.uniform1i(uniform, bool);
  31057. };
  31058. /**
  31059. * Set the value of an uniform to a vec4
  31060. * @param uniform defines the webGL uniform location where to store the value
  31061. * @param x defines the 1st component of the value
  31062. * @param y defines the 2nd component of the value
  31063. * @param z defines the 3rd component of the value
  31064. * @param w defines the 4th component of the value
  31065. */
  31066. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  31067. if (!uniform) {
  31068. return;
  31069. }
  31070. this._gl.uniform4f(uniform, x, y, z, w);
  31071. };
  31072. /**
  31073. * Set the value of an uniform to a Color3
  31074. * @param uniform defines the webGL uniform location where to store the value
  31075. * @param color3 defines the color to store
  31076. */
  31077. Engine.prototype.setColor3 = function (uniform, color3) {
  31078. if (!uniform) {
  31079. return;
  31080. }
  31081. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  31082. };
  31083. /**
  31084. * Set the value of an uniform to a Color3 and an alpha value
  31085. * @param uniform defines the webGL uniform location where to store the value
  31086. * @param color3 defines the color to store
  31087. * @param alpha defines the alpha component to store
  31088. */
  31089. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  31090. if (!uniform) {
  31091. return;
  31092. }
  31093. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  31094. };
  31095. /**
  31096. * Sets a Color4 on a uniform variable
  31097. * @param uniform defines the uniform location
  31098. * @param color4 defines the value to be set
  31099. */
  31100. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  31101. if (!uniform) {
  31102. return;
  31103. }
  31104. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  31105. };
  31106. // States
  31107. /**
  31108. * Set various states to the webGL context
  31109. * @param culling defines backface culling state
  31110. * @param zOffset defines the value to apply to zOffset (0 by default)
  31111. * @param force defines if states must be applied even if cache is up to date
  31112. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31113. */
  31114. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  31115. if (zOffset === void 0) { zOffset = 0; }
  31116. if (reverseSide === void 0) { reverseSide = false; }
  31117. // Culling
  31118. if (this._depthCullingState.cull !== culling || force) {
  31119. this._depthCullingState.cull = culling;
  31120. }
  31121. // Cull face
  31122. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  31123. if (this._depthCullingState.cullFace !== cullFace || force) {
  31124. this._depthCullingState.cullFace = cullFace;
  31125. }
  31126. // Z offset
  31127. this.setZOffset(zOffset);
  31128. // Front face
  31129. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  31130. if (this._depthCullingState.frontFace !== frontFace || force) {
  31131. this._depthCullingState.frontFace = frontFace;
  31132. }
  31133. };
  31134. /**
  31135. * Set the z offset to apply to current rendering
  31136. * @param value defines the offset to apply
  31137. */
  31138. Engine.prototype.setZOffset = function (value) {
  31139. this._depthCullingState.zOffset = value;
  31140. };
  31141. /**
  31142. * Gets the current value of the zOffset
  31143. * @returns the current zOffset state
  31144. */
  31145. Engine.prototype.getZOffset = function () {
  31146. return this._depthCullingState.zOffset;
  31147. };
  31148. /**
  31149. * Enable or disable depth buffering
  31150. * @param enable defines the state to set
  31151. */
  31152. Engine.prototype.setDepthBuffer = function (enable) {
  31153. this._depthCullingState.depthTest = enable;
  31154. };
  31155. /**
  31156. * Gets a boolean indicating if depth writing is enabled
  31157. * @returns the current depth writing state
  31158. */
  31159. Engine.prototype.getDepthWrite = function () {
  31160. return this._depthCullingState.depthMask;
  31161. };
  31162. /**
  31163. * Enable or disable depth writing
  31164. * @param enable defines the state to set
  31165. */
  31166. Engine.prototype.setDepthWrite = function (enable) {
  31167. this._depthCullingState.depthMask = enable;
  31168. };
  31169. /**
  31170. * Enable or disable color writing
  31171. * @param enable defines the state to set
  31172. */
  31173. Engine.prototype.setColorWrite = function (enable) {
  31174. this._gl.colorMask(enable, enable, enable, enable);
  31175. this._colorWrite = enable;
  31176. };
  31177. /**
  31178. * Gets a boolean indicating if color writing is enabled
  31179. * @returns the current color writing state
  31180. */
  31181. Engine.prototype.getColorWrite = function () {
  31182. return this._colorWrite;
  31183. };
  31184. /**
  31185. * Sets alpha constants used by some alpha blending modes
  31186. * @param r defines the red component
  31187. * @param g defines the green component
  31188. * @param b defines the blue component
  31189. * @param a defines the alpha component
  31190. */
  31191. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  31192. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  31193. };
  31194. /**
  31195. * Sets the current alpha mode
  31196. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31197. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31198. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31199. */
  31200. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  31201. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  31202. if (this._alphaMode === mode) {
  31203. return;
  31204. }
  31205. switch (mode) {
  31206. case Engine.ALPHA_DISABLE:
  31207. this._alphaState.alphaBlend = false;
  31208. break;
  31209. case Engine.ALPHA_PREMULTIPLIED:
  31210. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31211. this._alphaState.alphaBlend = true;
  31212. break;
  31213. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  31214. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31215. this._alphaState.alphaBlend = true;
  31216. break;
  31217. case Engine.ALPHA_COMBINE:
  31218. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31219. this._alphaState.alphaBlend = true;
  31220. break;
  31221. case Engine.ALPHA_ONEONE:
  31222. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31223. this._alphaState.alphaBlend = true;
  31224. break;
  31225. case Engine.ALPHA_ADD:
  31226. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31227. this._alphaState.alphaBlend = true;
  31228. break;
  31229. case Engine.ALPHA_SUBTRACT:
  31230. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31231. this._alphaState.alphaBlend = true;
  31232. break;
  31233. case Engine.ALPHA_MULTIPLY:
  31234. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  31235. this._alphaState.alphaBlend = true;
  31236. break;
  31237. case Engine.ALPHA_MAXIMIZED:
  31238. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31239. this._alphaState.alphaBlend = true;
  31240. break;
  31241. case Engine.ALPHA_INTERPOLATE:
  31242. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  31243. this._alphaState.alphaBlend = true;
  31244. break;
  31245. case Engine.ALPHA_SCREENMODE:
  31246. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31247. this._alphaState.alphaBlend = true;
  31248. break;
  31249. }
  31250. if (!noDepthWriteChange) {
  31251. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  31252. }
  31253. this._alphaMode = mode;
  31254. };
  31255. /**
  31256. * Gets the current alpha mode
  31257. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31258. * @returns the current alpha mode
  31259. */
  31260. Engine.prototype.getAlphaMode = function () {
  31261. return this._alphaMode;
  31262. };
  31263. // Textures
  31264. /**
  31265. * Clears the list of texture accessible through engine.
  31266. * This can help preventing texture load conflict due to name collision.
  31267. */
  31268. Engine.prototype.clearInternalTexturesCache = function () {
  31269. this._internalTexturesCache = [];
  31270. };
  31271. /**
  31272. * Force the entire cache to be cleared
  31273. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31274. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31275. */
  31276. Engine.prototype.wipeCaches = function (bruteForce) {
  31277. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  31278. return;
  31279. }
  31280. this._currentEffect = null;
  31281. this._viewportCached.x = 0;
  31282. this._viewportCached.y = 0;
  31283. this._viewportCached.z = 0;
  31284. this._viewportCached.w = 0;
  31285. if (bruteForce) {
  31286. this.resetTextureCache();
  31287. this._currentProgram = null;
  31288. this._stencilState.reset();
  31289. this._depthCullingState.reset();
  31290. this.setDepthFunctionToLessOrEqual();
  31291. this._alphaState.reset();
  31292. this._unpackFlipYCached = null;
  31293. }
  31294. this._resetVertexBufferBinding();
  31295. this._cachedIndexBuffer = null;
  31296. this._cachedEffectForVertexBuffers = null;
  31297. this._unbindVertexArrayObject();
  31298. this.bindIndexBuffer(null);
  31299. };
  31300. /**
  31301. * Set the compressed texture format to use, based on the formats you have, and the formats
  31302. * supported by the hardware / browser.
  31303. *
  31304. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31305. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31306. * to API arguments needed to compressed textures. This puts the burden on the container
  31307. * generator to house the arcane code for determining these for current & future formats.
  31308. *
  31309. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31310. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31311. *
  31312. * Note: The result of this call is not taken into account when a texture is base64.
  31313. *
  31314. * @param formatsAvailable defines the list of those format families you have created
  31315. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31316. *
  31317. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31318. * @returns The extension selected.
  31319. */
  31320. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  31321. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  31322. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  31323. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  31324. return this._textureFormatInUse = this._texturesSupported[i];
  31325. }
  31326. }
  31327. }
  31328. // actively set format to nothing, to allow this to be called more than once
  31329. // and possibly fail the 2nd time
  31330. this._textureFormatInUse = null;
  31331. return null;
  31332. };
  31333. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  31334. var gl = this._gl;
  31335. var magFilter = gl.NEAREST;
  31336. var minFilter = gl.NEAREST;
  31337. switch (samplingMode) {
  31338. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  31339. magFilter = gl.LINEAR;
  31340. if (generateMipMaps) {
  31341. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31342. }
  31343. else {
  31344. minFilter = gl.LINEAR;
  31345. }
  31346. break;
  31347. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  31348. magFilter = gl.LINEAR;
  31349. if (generateMipMaps) {
  31350. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31351. }
  31352. else {
  31353. minFilter = gl.LINEAR;
  31354. }
  31355. break;
  31356. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  31357. magFilter = gl.NEAREST;
  31358. if (generateMipMaps) {
  31359. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31360. }
  31361. else {
  31362. minFilter = gl.NEAREST;
  31363. }
  31364. break;
  31365. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  31366. magFilter = gl.NEAREST;
  31367. if (generateMipMaps) {
  31368. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31369. }
  31370. else {
  31371. minFilter = gl.NEAREST;
  31372. }
  31373. break;
  31374. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  31375. magFilter = gl.NEAREST;
  31376. if (generateMipMaps) {
  31377. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31378. }
  31379. else {
  31380. minFilter = gl.LINEAR;
  31381. }
  31382. break;
  31383. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  31384. magFilter = gl.NEAREST;
  31385. if (generateMipMaps) {
  31386. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31387. }
  31388. else {
  31389. minFilter = gl.LINEAR;
  31390. }
  31391. break;
  31392. case Engine.TEXTURE_NEAREST_LINEAR:
  31393. magFilter = gl.NEAREST;
  31394. minFilter = gl.LINEAR;
  31395. break;
  31396. case Engine.TEXTURE_NEAREST_NEAREST:
  31397. magFilter = gl.NEAREST;
  31398. minFilter = gl.NEAREST;
  31399. break;
  31400. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  31401. magFilter = gl.LINEAR;
  31402. if (generateMipMaps) {
  31403. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31404. }
  31405. else {
  31406. minFilter = gl.NEAREST;
  31407. }
  31408. break;
  31409. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  31410. magFilter = gl.LINEAR;
  31411. if (generateMipMaps) {
  31412. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31413. }
  31414. else {
  31415. minFilter = gl.NEAREST;
  31416. }
  31417. break;
  31418. case Engine.TEXTURE_LINEAR_LINEAR:
  31419. magFilter = gl.LINEAR;
  31420. minFilter = gl.LINEAR;
  31421. break;
  31422. case Engine.TEXTURE_LINEAR_NEAREST:
  31423. magFilter = gl.LINEAR;
  31424. minFilter = gl.NEAREST;
  31425. break;
  31426. }
  31427. return {
  31428. min: minFilter,
  31429. mag: magFilter
  31430. };
  31431. };
  31432. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  31433. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  31434. var img;
  31435. var onload = function () {
  31436. loadedImages[index] = img;
  31437. loadedImages._internalCount++;
  31438. if (scene) {
  31439. scene._removePendingData(img);
  31440. }
  31441. if (loadedImages._internalCount === 6) {
  31442. onfinish(loadedImages);
  31443. }
  31444. };
  31445. var onerror = function (message, exception) {
  31446. if (scene) {
  31447. scene._removePendingData(img);
  31448. }
  31449. if (onErrorCallBack) {
  31450. onErrorCallBack(message, exception);
  31451. }
  31452. };
  31453. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  31454. if (scene) {
  31455. scene._addPendingData(img);
  31456. }
  31457. };
  31458. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  31459. if (onError === void 0) { onError = null; }
  31460. var loadedImages = [];
  31461. loadedImages._internalCount = 0;
  31462. for (var index = 0; index < 6; index++) {
  31463. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  31464. }
  31465. };
  31466. /** @hidden */
  31467. Engine.prototype._createTexture = function () {
  31468. var texture = this._gl.createTexture();
  31469. if (!texture) {
  31470. throw new Error("Unable to create texture");
  31471. }
  31472. return texture;
  31473. };
  31474. /**
  31475. * Usually called from Texture.ts.
  31476. * Passed information to create a WebGLTexture
  31477. * @param urlArg defines a value which contains one of the following:
  31478. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31479. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31480. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31481. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31482. * @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)
  31483. * @param scene needed for loading to the correct scene
  31484. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31485. * @param onLoad optional callback to be called upon successful completion
  31486. * @param onError optional callback to be called upon failure
  31487. * @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
  31488. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31489. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31490. * @param forcedExtension defines the extension to use to pick the right loader
  31491. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31492. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31493. */
  31494. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  31495. var _this = this;
  31496. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31497. if (onLoad === void 0) { onLoad = null; }
  31498. if (onError === void 0) { onError = null; }
  31499. if (buffer === void 0) { buffer = null; }
  31500. if (fallback === void 0) { fallback = null; }
  31501. if (format === void 0) { format = null; }
  31502. if (forcedExtension === void 0) { forcedExtension = null; }
  31503. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31504. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  31505. var fromData = url.substr(0, 5) === "data:";
  31506. var fromBlob = url.substr(0, 5) === "blob:";
  31507. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  31508. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  31509. // establish the file extension, if possible
  31510. var lastDot = url.lastIndexOf('.');
  31511. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  31512. var loader = null;
  31513. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31514. var availableLoader = _a[_i];
  31515. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  31516. loader = availableLoader;
  31517. break;
  31518. }
  31519. }
  31520. if (loader) {
  31521. url = loader.transformUrl(url, this._textureFormatInUse);
  31522. }
  31523. if (scene) {
  31524. scene._addPendingData(texture);
  31525. }
  31526. texture.url = url;
  31527. texture.generateMipMaps = !noMipmap;
  31528. texture.samplingMode = samplingMode;
  31529. texture.invertY = invertY;
  31530. if (!this._doNotHandleContextLost) {
  31531. // Keep a link to the buffer only if we plan to handle context lost
  31532. texture._buffer = buffer;
  31533. }
  31534. var onLoadObserver = null;
  31535. if (onLoad && !fallback) {
  31536. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  31537. }
  31538. if (!fallback) {
  31539. this._internalTexturesCache.push(texture);
  31540. }
  31541. var onInternalError = function (message, exception) {
  31542. if (scene) {
  31543. scene._removePendingData(texture);
  31544. }
  31545. var customFallback = false;
  31546. if (loader) {
  31547. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  31548. if (fallbackUrl) {
  31549. // Add Back
  31550. customFallback = true;
  31551. excludeLoaders.push(loader);
  31552. _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");
  31553. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  31554. }
  31555. }
  31556. if (!customFallback) {
  31557. if (onLoadObserver) {
  31558. texture.onLoadedObservable.remove(onLoadObserver);
  31559. }
  31560. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  31561. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  31562. }
  31563. }
  31564. if (onError) {
  31565. onError(message || "Unknown error", exception);
  31566. }
  31567. };
  31568. // processing for non-image formats
  31569. if (loader) {
  31570. var callback = function (data) {
  31571. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  31572. if (loadFailed) {
  31573. onInternalError("TextureLoader failed to load data");
  31574. }
  31575. else {
  31576. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  31577. done();
  31578. return false;
  31579. }, samplingMode);
  31580. }
  31581. });
  31582. };
  31583. if (!buffer) {
  31584. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  31585. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  31586. });
  31587. }
  31588. else {
  31589. callback(buffer);
  31590. }
  31591. }
  31592. else {
  31593. var onload = function (img) {
  31594. if (fromBlob && !_this._doNotHandleContextLost) {
  31595. // We need to store the image if we need to rebuild the texture
  31596. // in case of a webgl context lost
  31597. texture._buffer = img;
  31598. }
  31599. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  31600. var gl = _this._gl;
  31601. var isPot = (img.width === potWidth && img.height === potHeight);
  31602. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  31603. if (isPot) {
  31604. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31605. return false;
  31606. }
  31607. var maxTextureSize = _this._caps.maxTextureSize;
  31608. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  31609. _this._prepareWorkingCanvas();
  31610. if (!_this._workingCanvas || !_this._workingContext) {
  31611. return false;
  31612. }
  31613. _this._workingCanvas.width = potWidth;
  31614. _this._workingCanvas.height = potHeight;
  31615. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  31616. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31617. texture.width = potWidth;
  31618. texture.height = potHeight;
  31619. return false;
  31620. }
  31621. else {
  31622. // Using shaders when possible to rescale because canvas.drawImage is lossy
  31623. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  31624. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  31625. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31626. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31627. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  31628. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31629. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31630. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  31631. _this._releaseTexture(source_1);
  31632. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31633. continuationCallback();
  31634. });
  31635. }
  31636. return true;
  31637. }, samplingMode);
  31638. };
  31639. if (!fromData || isBase64) {
  31640. if (buffer instanceof HTMLImageElement) {
  31641. onload(buffer);
  31642. }
  31643. else {
  31644. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  31645. }
  31646. }
  31647. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  31648. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  31649. }
  31650. else {
  31651. onload(buffer);
  31652. }
  31653. }
  31654. return texture;
  31655. };
  31656. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  31657. var _this = this;
  31658. var rtt = this.createRenderTargetTexture({
  31659. width: destination.width,
  31660. height: destination.height,
  31661. }, {
  31662. generateMipMaps: false,
  31663. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31664. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31665. generateDepthBuffer: false,
  31666. generateStencilBuffer: false
  31667. });
  31668. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31669. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31670. }
  31671. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31672. _this._rescalePostProcess.onApply = function (effect) {
  31673. effect._bindTexture("textureSampler", source);
  31674. };
  31675. var hostingScene = scene;
  31676. if (!hostingScene) {
  31677. hostingScene = _this.scenes[_this.scenes.length - 1];
  31678. }
  31679. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31680. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31681. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31682. _this.unBindFramebuffer(rtt);
  31683. _this._releaseTexture(rtt);
  31684. if (onComplete) {
  31685. onComplete();
  31686. }
  31687. });
  31688. };
  31689. /**
  31690. * Update a raw texture
  31691. * @param texture defines the texture to update
  31692. * @param data defines the data to store in the texture
  31693. * @param format defines the format of the data
  31694. * @param invertY defines if data must be stored with Y axis inverted
  31695. * @param compression defines the compression used (null by default)
  31696. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31697. */
  31698. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31699. if (compression === void 0) { compression = null; }
  31700. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31701. if (!texture) {
  31702. return;
  31703. }
  31704. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31705. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31706. // babylon's internalFormat but gl's texImage2D format
  31707. var internalFormat = this._getInternalFormat(format);
  31708. var textureType = this._getWebGLTextureType(type);
  31709. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31710. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31711. if (!this._doNotHandleContextLost) {
  31712. texture._bufferView = data;
  31713. texture.format = format;
  31714. texture.type = type;
  31715. texture.invertY = invertY;
  31716. texture._compression = compression;
  31717. }
  31718. if (texture.width % 4 !== 0) {
  31719. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31720. }
  31721. if (compression && data) {
  31722. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31723. }
  31724. else {
  31725. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31726. }
  31727. if (texture.generateMipMaps) {
  31728. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31729. }
  31730. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31731. // this.resetTextureCache();
  31732. texture.isReady = true;
  31733. };
  31734. /**
  31735. * Creates a raw texture
  31736. * @param data defines the data to store in the texture
  31737. * @param width defines the width of the texture
  31738. * @param height defines the height of the texture
  31739. * @param format defines the format of the data
  31740. * @param generateMipMaps defines if the engine should generate the mip levels
  31741. * @param invertY defines if data must be stored with Y axis inverted
  31742. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31743. * @param compression defines the compression used (null by default)
  31744. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31745. * @returns the raw texture inside an InternalTexture
  31746. */
  31747. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31748. if (compression === void 0) { compression = null; }
  31749. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31750. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31751. texture.baseWidth = width;
  31752. texture.baseHeight = height;
  31753. texture.width = width;
  31754. texture.height = height;
  31755. texture.format = format;
  31756. texture.generateMipMaps = generateMipMaps;
  31757. texture.samplingMode = samplingMode;
  31758. texture.invertY = invertY;
  31759. texture._compression = compression;
  31760. texture.type = type;
  31761. if (!this._doNotHandleContextLost) {
  31762. texture._bufferView = data;
  31763. }
  31764. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31765. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31766. // Filters
  31767. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31768. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31769. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31770. if (generateMipMaps) {
  31771. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31772. }
  31773. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31774. this._internalTexturesCache.push(texture);
  31775. return texture;
  31776. };
  31777. /** @hidden */
  31778. Engine.prototype._unpackFlipY = function (value) {
  31779. if (this._unpackFlipYCached !== value) {
  31780. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31781. if (this.enableUnpackFlipYCached) {
  31782. this._unpackFlipYCached = value;
  31783. }
  31784. }
  31785. };
  31786. /** @hidden */
  31787. Engine.prototype._getUnpackAlignement = function () {
  31788. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31789. };
  31790. /**
  31791. * Creates a dynamic texture
  31792. * @param width defines the width of the texture
  31793. * @param height defines the height of the texture
  31794. * @param generateMipMaps defines if the engine should generate the mip levels
  31795. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31796. * @returns the dynamic texture inside an InternalTexture
  31797. */
  31798. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31799. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31800. texture.baseWidth = width;
  31801. texture.baseHeight = height;
  31802. if (generateMipMaps) {
  31803. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31804. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31805. }
  31806. // this.resetTextureCache();
  31807. texture.width = width;
  31808. texture.height = height;
  31809. texture.isReady = false;
  31810. texture.generateMipMaps = generateMipMaps;
  31811. texture.samplingMode = samplingMode;
  31812. this.updateTextureSamplingMode(samplingMode, texture);
  31813. this._internalTexturesCache.push(texture);
  31814. return texture;
  31815. };
  31816. /**
  31817. * Update the sampling mode of a given texture
  31818. * @param samplingMode defines the required sampling mode
  31819. * @param texture defines the texture to update
  31820. */
  31821. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  31822. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  31823. if (texture.isCube) {
  31824. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31825. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31826. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31827. }
  31828. else if (texture.is3D) {
  31829. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31830. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31831. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31832. }
  31833. else {
  31834. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31835. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31836. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31837. }
  31838. texture.samplingMode = samplingMode;
  31839. };
  31840. /**
  31841. * Update the content of a dynamic texture
  31842. * @param texture defines the texture to update
  31843. * @param canvas defines the canvas containing the source
  31844. * @param invertY defines if data must be stored with Y axis inverted
  31845. * @param premulAlpha defines if alpha is stored as premultiplied
  31846. * @param format defines the format of the data
  31847. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31848. */
  31849. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  31850. if (premulAlpha === void 0) { premulAlpha = false; }
  31851. if (forceBindTexture === void 0) { forceBindTexture = false; }
  31852. if (!texture) {
  31853. return;
  31854. }
  31855. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  31856. this._unpackFlipY(invertY);
  31857. if (premulAlpha) {
  31858. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  31859. }
  31860. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  31861. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  31862. if (texture.generateMipMaps) {
  31863. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31864. }
  31865. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31866. if (premulAlpha) {
  31867. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  31868. }
  31869. texture.isReady = true;
  31870. };
  31871. /**
  31872. * Update a video texture
  31873. * @param texture defines the texture to update
  31874. * @param video defines the video element to use
  31875. * @param invertY defines if data must be stored with Y axis inverted
  31876. */
  31877. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31878. if (!texture || texture._isDisabled) {
  31879. return;
  31880. }
  31881. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31882. this._unpackFlipY(!invertY); // Video are upside down by default
  31883. try {
  31884. // Testing video texture support
  31885. if (this._videoTextureSupported === undefined) {
  31886. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31887. if (this._gl.getError() !== 0) {
  31888. this._videoTextureSupported = false;
  31889. }
  31890. else {
  31891. this._videoTextureSupported = true;
  31892. }
  31893. }
  31894. // Copy video through the current working canvas if video texture is not supported
  31895. if (!this._videoTextureSupported) {
  31896. if (!texture._workingCanvas) {
  31897. texture._workingCanvas = document.createElement("canvas");
  31898. var context = texture._workingCanvas.getContext("2d");
  31899. if (!context) {
  31900. throw new Error("Unable to get 2d context");
  31901. }
  31902. texture._workingContext = context;
  31903. texture._workingCanvas.width = texture.width;
  31904. texture._workingCanvas.height = texture.height;
  31905. }
  31906. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31907. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31908. }
  31909. else {
  31910. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31911. }
  31912. if (texture.generateMipMaps) {
  31913. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31914. }
  31915. if (!wasPreviouslyBound) {
  31916. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31917. }
  31918. // this.resetTextureCache();
  31919. texture.isReady = true;
  31920. }
  31921. catch (ex) {
  31922. // Something unexpected
  31923. // Let's disable the texture
  31924. texture._isDisabled = true;
  31925. }
  31926. };
  31927. /**
  31928. * Updates a depth texture Comparison Mode and Function.
  31929. * If the comparison Function is equal to 0, the mode will be set to none.
  31930. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31931. * @param texture The texture to set the comparison function for
  31932. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31933. */
  31934. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31935. if (this.webGLVersion === 1) {
  31936. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31937. return;
  31938. }
  31939. var gl = this._gl;
  31940. if (texture.isCube) {
  31941. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31942. if (comparisonFunction === 0) {
  31943. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31944. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31945. }
  31946. else {
  31947. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31948. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31949. }
  31950. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31951. }
  31952. else {
  31953. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31954. if (comparisonFunction === 0) {
  31955. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31956. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31957. }
  31958. else {
  31959. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31960. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31961. }
  31962. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31963. }
  31964. texture._comparisonFunction = comparisonFunction;
  31965. };
  31966. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31967. var width = size.width || size;
  31968. var height = size.height || size;
  31969. internalTexture.baseWidth = width;
  31970. internalTexture.baseHeight = height;
  31971. internalTexture.width = width;
  31972. internalTexture.height = height;
  31973. internalTexture.isReady = true;
  31974. internalTexture.samples = 1;
  31975. internalTexture.generateMipMaps = false;
  31976. internalTexture._generateDepthBuffer = true;
  31977. internalTexture._generateStencilBuffer = generateStencil;
  31978. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31979. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31980. internalTexture._comparisonFunction = comparisonFunction;
  31981. var gl = this._gl;
  31982. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31983. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31984. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31985. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31986. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31987. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31988. if (comparisonFunction === 0) {
  31989. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31990. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31991. }
  31992. else {
  31993. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31994. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31995. }
  31996. };
  31997. /**
  31998. * Creates a depth stencil texture.
  31999. * This is only available in WebGL 2 or with the depth texture extension available.
  32000. * @param size The size of face edge in the texture.
  32001. * @param options The options defining the texture.
  32002. * @returns The texture
  32003. */
  32004. Engine.prototype.createDepthStencilTexture = function (size, options) {
  32005. if (options.isCube) {
  32006. var width = size.width || size;
  32007. return this._createDepthStencilCubeTexture(width, options);
  32008. }
  32009. else {
  32010. return this._createDepthStencilTexture(size, options);
  32011. }
  32012. };
  32013. /**
  32014. * Creates a depth stencil texture.
  32015. * This is only available in WebGL 2 or with the depth texture extension available.
  32016. * @param size The size of face edge in the texture.
  32017. * @param options The options defining the texture.
  32018. * @returns The texture
  32019. */
  32020. Engine.prototype._createDepthStencilTexture = function (size, options) {
  32021. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  32022. if (!this._caps.depthTextureExtension) {
  32023. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  32024. return internalTexture;
  32025. }
  32026. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32027. var gl = this._gl;
  32028. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  32029. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32030. if (this.webGLVersion > 1) {
  32031. if (internalOptions.generateStencil) {
  32032. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32033. }
  32034. else {
  32035. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32036. }
  32037. }
  32038. else {
  32039. if (internalOptions.generateStencil) {
  32040. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32041. }
  32042. else {
  32043. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32044. }
  32045. }
  32046. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32047. return internalTexture;
  32048. };
  32049. /**
  32050. * Creates a depth stencil cube texture.
  32051. * This is only available in WebGL 2.
  32052. * @param size The size of face edge in the cube texture.
  32053. * @param options The options defining the cube texture.
  32054. * @returns The cube texture
  32055. */
  32056. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  32057. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  32058. internalTexture.isCube = true;
  32059. if (this.webGLVersion === 1) {
  32060. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  32061. return internalTexture;
  32062. }
  32063. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32064. var gl = this._gl;
  32065. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  32066. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32067. // Create the depth/stencil buffer
  32068. for (var face = 0; face < 6; face++) {
  32069. if (internalOptions.generateStencil) {
  32070. 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);
  32071. }
  32072. else {
  32073. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32074. }
  32075. }
  32076. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32077. return internalTexture;
  32078. };
  32079. /**
  32080. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32081. * @param renderTarget The render target to set the frame buffer for
  32082. */
  32083. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  32084. // Create the framebuffer
  32085. var internalTexture = renderTarget.getInternalTexture();
  32086. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  32087. return;
  32088. }
  32089. var gl = this._gl;
  32090. var depthStencilTexture = renderTarget.depthStencilTexture;
  32091. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  32092. if (depthStencilTexture.isCube) {
  32093. if (depthStencilTexture._generateStencilBuffer) {
  32094. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32095. }
  32096. else {
  32097. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32098. }
  32099. }
  32100. else {
  32101. if (depthStencilTexture._generateStencilBuffer) {
  32102. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32103. }
  32104. else {
  32105. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32106. }
  32107. }
  32108. this.bindUnboundFramebuffer(null);
  32109. };
  32110. /**
  32111. * Creates a new render target texture
  32112. * @param size defines the size of the texture
  32113. * @param options defines the options used to create the texture
  32114. * @returns a new render target texture stored in an InternalTexture
  32115. */
  32116. Engine.prototype.createRenderTargetTexture = function (size, options) {
  32117. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  32118. if (options !== undefined && typeof options === "object") {
  32119. fullOptions.generateMipMaps = options.generateMipMaps;
  32120. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32121. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  32122. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  32123. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  32124. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  32125. }
  32126. else {
  32127. fullOptions.generateMipMaps = options;
  32128. fullOptions.generateDepthBuffer = true;
  32129. fullOptions.generateStencilBuffer = false;
  32130. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32131. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32132. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  32133. }
  32134. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32135. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32136. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32137. }
  32138. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32139. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32140. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32141. }
  32142. var gl = this._gl;
  32143. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32144. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32145. var width = size.width || size;
  32146. var height = size.height || size;
  32147. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  32148. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32149. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32150. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32151. }
  32152. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32153. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32154. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32155. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32156. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  32157. // Create the framebuffer
  32158. var currentFrameBuffer = this._currentFramebuffer;
  32159. var framebuffer = gl.createFramebuffer();
  32160. this.bindUnboundFramebuffer(framebuffer);
  32161. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32162. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  32163. if (fullOptions.generateMipMaps) {
  32164. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32165. }
  32166. // Unbind
  32167. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32168. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32169. this.bindUnboundFramebuffer(currentFrameBuffer);
  32170. texture._framebuffer = framebuffer;
  32171. texture.baseWidth = width;
  32172. texture.baseHeight = height;
  32173. texture.width = width;
  32174. texture.height = height;
  32175. texture.isReady = true;
  32176. texture.samples = 1;
  32177. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  32178. texture.samplingMode = fullOptions.samplingMode;
  32179. texture.type = fullOptions.type;
  32180. texture.format = fullOptions.format;
  32181. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32182. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  32183. // this.resetTextureCache();
  32184. this._internalTexturesCache.push(texture);
  32185. return texture;
  32186. };
  32187. /**
  32188. * Create a multi render target texture
  32189. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  32190. * @param size defines the size of the texture
  32191. * @param options defines the creation options
  32192. * @returns the cube texture as an InternalTexture
  32193. */
  32194. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  32195. var generateMipMaps = false;
  32196. var generateDepthBuffer = true;
  32197. var generateStencilBuffer = false;
  32198. var generateDepthTexture = false;
  32199. var textureCount = 1;
  32200. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  32201. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32202. var types = new Array();
  32203. var samplingModes = new Array();
  32204. if (options !== undefined) {
  32205. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  32206. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32207. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  32208. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  32209. textureCount = options.textureCount || 1;
  32210. if (options.types) {
  32211. types = options.types;
  32212. }
  32213. if (options.samplingModes) {
  32214. samplingModes = options.samplingModes;
  32215. }
  32216. }
  32217. var gl = this._gl;
  32218. // Create the framebuffer
  32219. var framebuffer = gl.createFramebuffer();
  32220. this.bindUnboundFramebuffer(framebuffer);
  32221. var width = size.width || size;
  32222. var height = size.height || size;
  32223. var textures = [];
  32224. var attachments = [];
  32225. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  32226. for (var i = 0; i < textureCount; i++) {
  32227. var samplingMode = samplingModes[i] || defaultSamplingMode;
  32228. var type = types[i] || defaultType;
  32229. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32230. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32231. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32232. }
  32233. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32234. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32235. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32236. }
  32237. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32238. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32239. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32240. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32241. }
  32242. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32243. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32244. textures.push(texture);
  32245. attachments.push(attachment);
  32246. gl.activeTexture(gl["TEXTURE" + i]);
  32247. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  32248. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32249. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32250. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32251. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32252. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32253. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32254. if (generateMipMaps) {
  32255. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32256. }
  32257. // Unbind
  32258. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32259. texture._framebuffer = framebuffer;
  32260. texture._depthStencilBuffer = depthStencilBuffer;
  32261. texture.baseWidth = width;
  32262. texture.baseHeight = height;
  32263. texture.width = width;
  32264. texture.height = height;
  32265. texture.isReady = true;
  32266. texture.samples = 1;
  32267. texture.generateMipMaps = generateMipMaps;
  32268. texture.samplingMode = samplingMode;
  32269. texture.type = type;
  32270. texture._generateDepthBuffer = generateDepthBuffer;
  32271. texture._generateStencilBuffer = generateStencilBuffer;
  32272. texture._attachments = attachments;
  32273. this._internalTexturesCache.push(texture);
  32274. }
  32275. if (generateDepthTexture && this._caps.depthTextureExtension) {
  32276. // Depth texture
  32277. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32278. gl.activeTexture(gl.TEXTURE0);
  32279. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  32280. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32281. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32282. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32283. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32284. 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);
  32285. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  32286. depthTexture._framebuffer = framebuffer;
  32287. depthTexture.baseWidth = width;
  32288. depthTexture.baseHeight = height;
  32289. depthTexture.width = width;
  32290. depthTexture.height = height;
  32291. depthTexture.isReady = true;
  32292. depthTexture.samples = 1;
  32293. depthTexture.generateMipMaps = generateMipMaps;
  32294. depthTexture.samplingMode = gl.NEAREST;
  32295. depthTexture._generateDepthBuffer = generateDepthBuffer;
  32296. depthTexture._generateStencilBuffer = generateStencilBuffer;
  32297. textures.push(depthTexture);
  32298. this._internalTexturesCache.push(depthTexture);
  32299. }
  32300. gl.drawBuffers(attachments);
  32301. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32302. this.bindUnboundFramebuffer(null);
  32303. this.resetTextureCache();
  32304. return textures;
  32305. };
  32306. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  32307. if (samples === void 0) { samples = 1; }
  32308. var depthStencilBuffer = null;
  32309. var gl = this._gl;
  32310. // Create the depth/stencil buffer
  32311. if (generateStencilBuffer) {
  32312. depthStencilBuffer = gl.createRenderbuffer();
  32313. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32314. if (samples > 1) {
  32315. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  32316. }
  32317. else {
  32318. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  32319. }
  32320. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32321. }
  32322. else if (generateDepthBuffer) {
  32323. depthStencilBuffer = gl.createRenderbuffer();
  32324. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32325. if (samples > 1) {
  32326. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  32327. }
  32328. else {
  32329. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  32330. }
  32331. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32332. }
  32333. return depthStencilBuffer;
  32334. };
  32335. /**
  32336. * Updates the sample count of a render target texture
  32337. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32338. * @param texture defines the texture to update
  32339. * @param samples defines the sample count to set
  32340. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32341. */
  32342. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  32343. if (this.webGLVersion < 2 || !texture) {
  32344. return 1;
  32345. }
  32346. if (texture.samples === samples) {
  32347. return samples;
  32348. }
  32349. var gl = this._gl;
  32350. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32351. // Dispose previous render buffers
  32352. if (texture._depthStencilBuffer) {
  32353. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32354. texture._depthStencilBuffer = null;
  32355. }
  32356. if (texture._MSAAFramebuffer) {
  32357. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32358. texture._MSAAFramebuffer = null;
  32359. }
  32360. if (texture._MSAARenderBuffer) {
  32361. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32362. texture._MSAARenderBuffer = null;
  32363. }
  32364. if (samples > 1) {
  32365. var framebuffer = gl.createFramebuffer();
  32366. if (!framebuffer) {
  32367. throw new Error("Unable to create multi sampled framebuffer");
  32368. }
  32369. texture._MSAAFramebuffer = framebuffer;
  32370. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  32371. var colorRenderbuffer = gl.createRenderbuffer();
  32372. if (!colorRenderbuffer) {
  32373. throw new Error("Unable to create multi sampled framebuffer");
  32374. }
  32375. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32376. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32377. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  32378. texture._MSAARenderBuffer = colorRenderbuffer;
  32379. }
  32380. else {
  32381. this.bindUnboundFramebuffer(texture._framebuffer);
  32382. }
  32383. texture.samples = samples;
  32384. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  32385. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32386. this.bindUnboundFramebuffer(null);
  32387. return samples;
  32388. };
  32389. /**
  32390. * Update the sample count for a given multiple render target texture
  32391. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32392. * @param textures defines the textures to update
  32393. * @param samples defines the sample count to set
  32394. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32395. */
  32396. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  32397. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  32398. return 1;
  32399. }
  32400. if (textures[0].samples === samples) {
  32401. return samples;
  32402. }
  32403. var gl = this._gl;
  32404. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32405. // Dispose previous render buffers
  32406. if (textures[0]._depthStencilBuffer) {
  32407. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  32408. textures[0]._depthStencilBuffer = null;
  32409. }
  32410. if (textures[0]._MSAAFramebuffer) {
  32411. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  32412. textures[0]._MSAAFramebuffer = null;
  32413. }
  32414. for (var i = 0; i < textures.length; i++) {
  32415. if (textures[i]._MSAARenderBuffer) {
  32416. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  32417. textures[i]._MSAARenderBuffer = null;
  32418. }
  32419. }
  32420. if (samples > 1) {
  32421. var framebuffer = gl.createFramebuffer();
  32422. if (!framebuffer) {
  32423. throw new Error("Unable to create multi sampled framebuffer");
  32424. }
  32425. this.bindUnboundFramebuffer(framebuffer);
  32426. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  32427. var attachments = [];
  32428. for (var i = 0; i < textures.length; i++) {
  32429. var texture = textures[i];
  32430. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32431. var colorRenderbuffer = gl.createRenderbuffer();
  32432. if (!colorRenderbuffer) {
  32433. throw new Error("Unable to create multi sampled framebuffer");
  32434. }
  32435. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32436. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32437. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  32438. texture._MSAAFramebuffer = framebuffer;
  32439. texture._MSAARenderBuffer = colorRenderbuffer;
  32440. texture.samples = samples;
  32441. texture._depthStencilBuffer = depthStencilBuffer;
  32442. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32443. attachments.push(attachment);
  32444. }
  32445. gl.drawBuffers(attachments);
  32446. }
  32447. else {
  32448. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  32449. }
  32450. this.bindUnboundFramebuffer(null);
  32451. return samples;
  32452. };
  32453. /** @hidden */
  32454. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  32455. if (faceIndex === void 0) { faceIndex = 0; }
  32456. if (lod === void 0) { lod = 0; }
  32457. var gl = this._gl;
  32458. var target = gl.TEXTURE_2D;
  32459. if (texture.isCube) {
  32460. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32461. }
  32462. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  32463. };
  32464. /** @hidden */
  32465. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  32466. if (faceIndex === void 0) { faceIndex = 0; }
  32467. if (lod === void 0) { lod = 0; }
  32468. var gl = this._gl;
  32469. var textureType = this._getWebGLTextureType(texture.type);
  32470. var format = this._getInternalFormat(texture.format);
  32471. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32472. this._unpackFlipY(texture.invertY);
  32473. var target = gl.TEXTURE_2D;
  32474. if (texture.isCube) {
  32475. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32476. }
  32477. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  32478. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  32479. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  32480. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  32481. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  32482. };
  32483. /** @hidden */
  32484. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  32485. if (faceIndex === void 0) { faceIndex = 0; }
  32486. if (lod === void 0) { lod = 0; }
  32487. var gl = this._gl;
  32488. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32489. this._bindTextureDirectly(bindTarget, texture, true);
  32490. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  32491. this._bindTextureDirectly(bindTarget, null, true);
  32492. };
  32493. /** @hidden */
  32494. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  32495. if (faceIndex === void 0) { faceIndex = 0; }
  32496. if (lod === void 0) { lod = 0; }
  32497. var gl = this._gl;
  32498. var textureType = this._getWebGLTextureType(texture.type);
  32499. var format = this._getInternalFormat(texture.format);
  32500. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32501. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32502. this._bindTextureDirectly(bindTarget, texture, true);
  32503. this._unpackFlipY(texture.invertY);
  32504. var target = gl.TEXTURE_2D;
  32505. if (texture.isCube) {
  32506. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32507. }
  32508. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  32509. this._bindTextureDirectly(bindTarget, null, true);
  32510. };
  32511. /**
  32512. * Creates a new multiview render target
  32513. * @param width defines the width of the texture
  32514. * @param height defines the height of the texture
  32515. * @returns the created multiview texture
  32516. */
  32517. Engine.prototype.createMultiviewRenderTargetTexture = function (width, height) {
  32518. var gl = this._gl;
  32519. if (!this.getCaps().multiview) {
  32520. throw "Multiview is not supported";
  32521. }
  32522. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  32523. internalTexture.width = width;
  32524. internalTexture.height = height;
  32525. internalTexture._framebuffer = gl.createFramebuffer();
  32526. internalTexture._colorTextureArray = gl.createTexture();
  32527. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._colorTextureArray);
  32528. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, width, height, 2);
  32529. internalTexture._depthStencilTextureArray = gl.createTexture();
  32530. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._depthStencilTextureArray);
  32531. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.DEPTH32F_STENCIL8, width, height, 2);
  32532. internalTexture.isReady = true;
  32533. return internalTexture;
  32534. };
  32535. /**
  32536. * Binds a multiview framebuffer to be drawn to
  32537. * @param multiviewTexture texture to bind
  32538. */
  32539. Engine.prototype.bindMultiviewFramebuffer = function (multiviewTexture) {
  32540. var gl = this._gl;
  32541. var ext = this.getCaps().multiview;
  32542. this.bindFramebuffer(multiviewTexture, undefined, undefined, undefined, true);
  32543. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, multiviewTexture._framebuffer);
  32544. if (multiviewTexture._colorTextureArray && multiviewTexture._depthStencilTextureArray) {
  32545. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, 0, 2);
  32546. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, 0, 2);
  32547. }
  32548. else {
  32549. throw "Invalid multiview frame buffer";
  32550. }
  32551. };
  32552. /**
  32553. * Creates a new render target cube texture
  32554. * @param size defines the size of the texture
  32555. * @param options defines the options used to create the texture
  32556. * @returns a new render target cube texture stored in an InternalTexture
  32557. */
  32558. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  32559. 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);
  32560. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  32561. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32562. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32563. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32564. }
  32565. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32566. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32567. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32568. }
  32569. var gl = this._gl;
  32570. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32571. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32572. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  32573. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32574. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32575. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  32576. }
  32577. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32578. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32579. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32580. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32581. for (var face = 0; face < 6; face++) {
  32582. 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);
  32583. }
  32584. // Create the framebuffer
  32585. var framebuffer = gl.createFramebuffer();
  32586. this.bindUnboundFramebuffer(framebuffer);
  32587. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  32588. // MipMaps
  32589. if (fullOptions.generateMipMaps) {
  32590. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32591. }
  32592. // Unbind
  32593. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32594. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32595. this.bindUnboundFramebuffer(null);
  32596. texture._framebuffer = framebuffer;
  32597. texture.width = size;
  32598. texture.height = size;
  32599. texture.isReady = true;
  32600. texture.isCube = true;
  32601. texture.samples = 1;
  32602. texture.generateMipMaps = fullOptions.generateMipMaps;
  32603. texture.samplingMode = fullOptions.samplingMode;
  32604. texture.type = fullOptions.type;
  32605. texture.format = fullOptions.format;
  32606. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32607. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  32608. this._internalTexturesCache.push(texture);
  32609. return texture;
  32610. };
  32611. /**
  32612. * Creates a cube texture
  32613. * @param rootUrl defines the url where the files to load is located
  32614. * @param scene defines the current scene
  32615. * @param files defines the list of files to load (1 per face)
  32616. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  32617. * @param onLoad defines an optional callback raised when the texture is loaded
  32618. * @param onError defines an optional callback raised if there is an issue to load the texture
  32619. * @param format defines the format of the data
  32620. * @param forcedExtension defines the extension to use to pick the right loader
  32621. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  32622. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  32623. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  32624. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  32625. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  32626. * @returns the cube texture as an InternalTexture
  32627. */
  32628. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  32629. var _this = this;
  32630. if (onLoad === void 0) { onLoad = null; }
  32631. if (onError === void 0) { onError = null; }
  32632. if (forcedExtension === void 0) { forcedExtension = null; }
  32633. if (createPolynomials === void 0) { createPolynomials = false; }
  32634. if (lodScale === void 0) { lodScale = 0; }
  32635. if (lodOffset === void 0) { lodOffset = 0; }
  32636. if (fallback === void 0) { fallback = null; }
  32637. if (excludeLoaders === void 0) { excludeLoaders = []; }
  32638. var gl = this._gl;
  32639. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  32640. texture.isCube = true;
  32641. texture.url = rootUrl;
  32642. texture.generateMipMaps = !noMipmap;
  32643. texture._lodGenerationScale = lodScale;
  32644. texture._lodGenerationOffset = lodOffset;
  32645. if (!this._doNotHandleContextLost) {
  32646. texture._extension = forcedExtension;
  32647. texture._files = files;
  32648. }
  32649. var lastDot = rootUrl.lastIndexOf('.');
  32650. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  32651. var loader = null;
  32652. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  32653. var availableLoader = _a[_i];
  32654. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  32655. loader = availableLoader;
  32656. break;
  32657. }
  32658. }
  32659. var onInternalError = function (request, exception) {
  32660. if (loader) {
  32661. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  32662. _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");
  32663. if (fallbackUrl) {
  32664. excludeLoaders.push(loader);
  32665. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  32666. return;
  32667. }
  32668. }
  32669. if (onError && request) {
  32670. onError(request.status + " " + request.statusText, exception);
  32671. }
  32672. };
  32673. if (loader) {
  32674. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  32675. var onloaddata = function (data) {
  32676. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32677. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  32678. };
  32679. if (files && files.length === 6) {
  32680. if (loader.supportCascades) {
  32681. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  32682. }
  32683. else if (onError) {
  32684. onError("Textures type does not support cascades.");
  32685. }
  32686. }
  32687. else {
  32688. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  32689. }
  32690. }
  32691. else {
  32692. if (!files) {
  32693. throw new Error("Cannot load cubemap because files were not defined");
  32694. }
  32695. this._cascadeLoadImgs(scene, function (imgs) {
  32696. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  32697. var height = width;
  32698. _this._prepareWorkingCanvas();
  32699. if (!_this._workingCanvas || !_this._workingContext) {
  32700. return;
  32701. }
  32702. _this._workingCanvas.width = width;
  32703. _this._workingCanvas.height = height;
  32704. var faces = [
  32705. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32706. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32707. ];
  32708. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32709. _this._unpackFlipY(false);
  32710. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32711. for (var index = 0; index < faces.length; index++) {
  32712. if (imgs[index].width !== width || imgs[index].height !== height) {
  32713. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32714. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32715. }
  32716. else {
  32717. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, imgs[index]);
  32718. }
  32719. }
  32720. if (!noMipmap) {
  32721. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32722. }
  32723. _this._setCubeMapTextureParams(!noMipmap);
  32724. texture.width = width;
  32725. texture.height = height;
  32726. texture.isReady = true;
  32727. if (format) {
  32728. texture.format = format;
  32729. }
  32730. texture.onLoadedObservable.notifyObservers(texture);
  32731. texture.onLoadedObservable.clear();
  32732. if (onLoad) {
  32733. onLoad();
  32734. }
  32735. }, files, onError);
  32736. }
  32737. this._internalTexturesCache.push(texture);
  32738. return texture;
  32739. };
  32740. /**
  32741. * @hidden
  32742. */
  32743. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32744. var gl = this._gl;
  32745. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32746. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32747. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32748. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32749. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32750. // this.resetTextureCache();
  32751. };
  32752. /**
  32753. * Update a raw cube texture
  32754. * @param texture defines the texture to udpdate
  32755. * @param data defines the data to store
  32756. * @param format defines the data format
  32757. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32758. * @param invertY defines if data must be stored with Y axis inverted
  32759. * @param compression defines the compression used (null by default)
  32760. * @param level defines which level of the texture to update
  32761. */
  32762. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32763. if (compression === void 0) { compression = null; }
  32764. if (level === void 0) { level = 0; }
  32765. texture._bufferViewArray = data;
  32766. texture.format = format;
  32767. texture.type = type;
  32768. texture.invertY = invertY;
  32769. texture._compression = compression;
  32770. var gl = this._gl;
  32771. var textureType = this._getWebGLTextureType(type);
  32772. var internalFormat = this._getInternalFormat(format);
  32773. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32774. var needConversion = false;
  32775. if (internalFormat === gl.RGB) {
  32776. internalFormat = gl.RGBA;
  32777. needConversion = true;
  32778. }
  32779. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32780. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32781. if (texture.width % 4 !== 0) {
  32782. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32783. }
  32784. // Data are known to be in +X +Y +Z -X -Y -Z
  32785. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32786. var faceData = data[faceIndex];
  32787. if (compression) {
  32788. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32789. }
  32790. else {
  32791. if (needConversion) {
  32792. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32793. }
  32794. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32795. }
  32796. }
  32797. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32798. if (isPot && texture.generateMipMaps && level === 0) {
  32799. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32800. }
  32801. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32802. // this.resetTextureCache();
  32803. texture.isReady = true;
  32804. };
  32805. /**
  32806. * Creates a new raw cube texture
  32807. * @param data defines the array of data to use to create each face
  32808. * @param size defines the size of the textures
  32809. * @param format defines the format of the data
  32810. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32811. * @param generateMipMaps defines if the engine should generate the mip levels
  32812. * @param invertY defines if data must be stored with Y axis inverted
  32813. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32814. * @param compression defines the compression used (null by default)
  32815. * @returns the cube texture as an InternalTexture
  32816. */
  32817. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32818. if (compression === void 0) { compression = null; }
  32819. var gl = this._gl;
  32820. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32821. texture.isCube = true;
  32822. texture.format = format;
  32823. texture.type = type;
  32824. if (!this._doNotHandleContextLost) {
  32825. texture._bufferViewArray = data;
  32826. }
  32827. var textureType = this._getWebGLTextureType(type);
  32828. var internalFormat = this._getInternalFormat(format);
  32829. if (internalFormat === gl.RGB) {
  32830. internalFormat = gl.RGBA;
  32831. }
  32832. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32833. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32834. generateMipMaps = false;
  32835. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32836. _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.");
  32837. }
  32838. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32839. generateMipMaps = false;
  32840. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32841. _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.");
  32842. }
  32843. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32844. generateMipMaps = false;
  32845. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32846. }
  32847. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  32848. generateMipMaps = false;
  32849. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  32850. }
  32851. var width = size;
  32852. var height = width;
  32853. texture.width = width;
  32854. texture.height = height;
  32855. // Double check on POT to generate Mips.
  32856. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32857. if (!isPot) {
  32858. generateMipMaps = false;
  32859. }
  32860. // Upload data if needed. The texture won't be ready until then.
  32861. if (data) {
  32862. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  32863. }
  32864. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32865. // Filters
  32866. if (data && generateMipMaps) {
  32867. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32868. }
  32869. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32870. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32871. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32872. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32873. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32874. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32875. texture.generateMipMaps = generateMipMaps;
  32876. return texture;
  32877. };
  32878. /**
  32879. * Creates a new raw cube texture from a specified url
  32880. * @param url defines the url where the data is located
  32881. * @param scene defines the current scene
  32882. * @param size defines the size of the textures
  32883. * @param format defines the format of the data
  32884. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32885. * @param noMipmap defines if the engine should avoid generating the mip levels
  32886. * @param callback defines a callback used to extract texture data from loaded data
  32887. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  32888. * @param onLoad defines a callback called when texture is loaded
  32889. * @param onError defines a callback called if there is an error
  32890. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32891. * @param invertY defines if data must be stored with Y axis inverted
  32892. * @returns the cube texture as an InternalTexture
  32893. */
  32894. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  32895. var _this = this;
  32896. if (onLoad === void 0) { onLoad = null; }
  32897. if (onError === void 0) { onError = null; }
  32898. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32899. if (invertY === void 0) { invertY = false; }
  32900. var gl = this._gl;
  32901. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  32902. scene._addPendingData(texture);
  32903. texture.url = url;
  32904. this._internalTexturesCache.push(texture);
  32905. var onerror = function (request, exception) {
  32906. scene._removePendingData(texture);
  32907. if (onError && request) {
  32908. onError(request.status + " " + request.statusText, exception);
  32909. }
  32910. };
  32911. var internalCallback = function (data) {
  32912. var width = texture.width;
  32913. var faceDataArrays = callback(data);
  32914. if (!faceDataArrays) {
  32915. return;
  32916. }
  32917. if (mipmapGenerator) {
  32918. var textureType = _this._getWebGLTextureType(type);
  32919. var internalFormat = _this._getInternalFormat(format);
  32920. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32921. var needConversion = false;
  32922. if (internalFormat === gl.RGB) {
  32923. internalFormat = gl.RGBA;
  32924. needConversion = true;
  32925. }
  32926. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32927. _this._unpackFlipY(false);
  32928. var mipData = mipmapGenerator(faceDataArrays);
  32929. for (var level = 0; level < mipData.length; level++) {
  32930. var mipSize = width >> level;
  32931. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32932. var mipFaceData = mipData[level][faceIndex];
  32933. if (needConversion) {
  32934. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32935. }
  32936. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32937. }
  32938. }
  32939. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32940. }
  32941. else {
  32942. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32943. }
  32944. texture.isReady = true;
  32945. // this.resetTextureCache();
  32946. scene._removePendingData(texture);
  32947. if (onLoad) {
  32948. onLoad();
  32949. }
  32950. };
  32951. this._loadFile(url, function (data) {
  32952. internalCallback(data);
  32953. }, undefined, scene.offlineProvider, true, onerror);
  32954. return texture;
  32955. };
  32956. /**
  32957. * Update a raw 3D texture
  32958. * @param texture defines the texture to update
  32959. * @param data defines the data to store
  32960. * @param format defines the data format
  32961. * @param invertY defines if data must be stored with Y axis inverted
  32962. * @param compression defines the used compression (can be null)
  32963. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32964. */
  32965. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32966. if (compression === void 0) { compression = null; }
  32967. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32968. var internalType = this._getWebGLTextureType(textureType);
  32969. var internalFormat = this._getInternalFormat(format);
  32970. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32971. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32972. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32973. if (!this._doNotHandleContextLost) {
  32974. texture._bufferView = data;
  32975. texture.format = format;
  32976. texture.invertY = invertY;
  32977. texture._compression = compression;
  32978. }
  32979. if (texture.width % 4 !== 0) {
  32980. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32981. }
  32982. if (compression && data) {
  32983. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32984. }
  32985. else {
  32986. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32987. }
  32988. if (texture.generateMipMaps) {
  32989. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32990. }
  32991. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32992. // this.resetTextureCache();
  32993. texture.isReady = true;
  32994. };
  32995. /**
  32996. * Creates a new raw 3D texture
  32997. * @param data defines the data used to create the texture
  32998. * @param width defines the width of the texture
  32999. * @param height defines the height of the texture
  33000. * @param depth defines the depth of the texture
  33001. * @param format defines the format of the texture
  33002. * @param generateMipMaps defines if the engine must generate mip levels
  33003. * @param invertY defines if data must be stored with Y axis inverted
  33004. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33005. * @param compression defines the compressed used (can be null)
  33006. * @param textureType defines the compressed used (can be null)
  33007. * @returns a new raw 3D texture (stored in an InternalTexture)
  33008. */
  33009. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  33010. if (compression === void 0) { compression = null; }
  33011. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33012. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  33013. texture.baseWidth = width;
  33014. texture.baseHeight = height;
  33015. texture.baseDepth = depth;
  33016. texture.width = width;
  33017. texture.height = height;
  33018. texture.depth = depth;
  33019. texture.format = format;
  33020. texture.type = textureType;
  33021. texture.generateMipMaps = generateMipMaps;
  33022. texture.samplingMode = samplingMode;
  33023. texture.is3D = true;
  33024. if (!this._doNotHandleContextLost) {
  33025. texture._bufferView = data;
  33026. }
  33027. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  33028. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  33029. // Filters
  33030. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  33031. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  33032. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  33033. if (generateMipMaps) {
  33034. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  33035. }
  33036. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33037. this._internalTexturesCache.push(texture);
  33038. return texture;
  33039. };
  33040. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  33041. var gl = this._gl;
  33042. if (!gl) {
  33043. return;
  33044. }
  33045. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  33046. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  33047. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  33048. if (!noMipmap && !isCompressed) {
  33049. gl.generateMipmap(gl.TEXTURE_2D);
  33050. }
  33051. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  33052. // this.resetTextureCache();
  33053. if (scene) {
  33054. scene._removePendingData(texture);
  33055. }
  33056. texture.onLoadedObservable.notifyObservers(texture);
  33057. texture.onLoadedObservable.clear();
  33058. };
  33059. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  33060. var _this = this;
  33061. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33062. var maxTextureSize = this.getCaps().maxTextureSize;
  33063. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  33064. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  33065. var gl = this._gl;
  33066. if (!gl) {
  33067. return;
  33068. }
  33069. if (!texture._webGLTexture) {
  33070. // this.resetTextureCache();
  33071. if (scene) {
  33072. scene._removePendingData(texture);
  33073. }
  33074. return;
  33075. }
  33076. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  33077. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33078. texture.baseWidth = width;
  33079. texture.baseHeight = height;
  33080. texture.width = potWidth;
  33081. texture.height = potHeight;
  33082. texture.isReady = true;
  33083. if (processFunction(potWidth, potHeight, function () {
  33084. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33085. })) {
  33086. // Returning as texture needs extra async steps
  33087. return;
  33088. }
  33089. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33090. };
  33091. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  33092. // Create new RGBA data container.
  33093. var rgbaData;
  33094. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  33095. rgbaData = new Float32Array(width * height * 4);
  33096. }
  33097. else {
  33098. rgbaData = new Uint32Array(width * height * 4);
  33099. }
  33100. // Convert each pixel.
  33101. for (var x = 0; x < width; x++) {
  33102. for (var y = 0; y < height; y++) {
  33103. var index = (y * width + x) * 3;
  33104. var newIndex = (y * width + x) * 4;
  33105. // Map Old Value to new value.
  33106. rgbaData[newIndex + 0] = rgbData[index + 0];
  33107. rgbaData[newIndex + 1] = rgbData[index + 1];
  33108. rgbaData[newIndex + 2] = rgbData[index + 2];
  33109. // Add fully opaque alpha channel.
  33110. rgbaData[newIndex + 3] = 1;
  33111. }
  33112. }
  33113. return rgbaData;
  33114. };
  33115. /** @hidden */
  33116. Engine.prototype._releaseFramebufferObjects = function (texture) {
  33117. var gl = this._gl;
  33118. if (texture._framebuffer) {
  33119. gl.deleteFramebuffer(texture._framebuffer);
  33120. texture._framebuffer = null;
  33121. }
  33122. if (texture._depthStencilBuffer) {
  33123. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  33124. texture._depthStencilBuffer = null;
  33125. }
  33126. if (texture._MSAAFramebuffer) {
  33127. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  33128. texture._MSAAFramebuffer = null;
  33129. }
  33130. if (texture._MSAARenderBuffer) {
  33131. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  33132. texture._MSAARenderBuffer = null;
  33133. }
  33134. };
  33135. /** @hidden */
  33136. Engine.prototype._releaseTexture = function (texture) {
  33137. var gl = this._gl;
  33138. this._releaseFramebufferObjects(texture);
  33139. gl.deleteTexture(texture._webGLTexture);
  33140. // Unbind channels
  33141. this.unbindAllTextures();
  33142. var index = this._internalTexturesCache.indexOf(texture);
  33143. if (index !== -1) {
  33144. this._internalTexturesCache.splice(index, 1);
  33145. }
  33146. // Integrated fixed lod samplers.
  33147. if (texture._lodTextureHigh) {
  33148. texture._lodTextureHigh.dispose();
  33149. }
  33150. if (texture._lodTextureMid) {
  33151. texture._lodTextureMid.dispose();
  33152. }
  33153. if (texture._lodTextureLow) {
  33154. texture._lodTextureLow.dispose();
  33155. }
  33156. // Set output texture of post process to null if the texture has been released/disposed
  33157. this.scenes.forEach(function (scene) {
  33158. scene.postProcesses.forEach(function (postProcess) {
  33159. if (postProcess._outputTexture == texture) {
  33160. postProcess._outputTexture = null;
  33161. }
  33162. });
  33163. scene.cameras.forEach(function (camera) {
  33164. camera._postProcesses.forEach(function (postProcess) {
  33165. if (postProcess) {
  33166. if (postProcess._outputTexture == texture) {
  33167. postProcess._outputTexture = null;
  33168. }
  33169. }
  33170. });
  33171. });
  33172. });
  33173. };
  33174. Engine.prototype.setProgram = function (program) {
  33175. if (this._currentProgram !== program) {
  33176. this._gl.useProgram(program);
  33177. this._currentProgram = program;
  33178. }
  33179. };
  33180. /**
  33181. * Binds an effect to the webGL context
  33182. * @param effect defines the effect to bind
  33183. */
  33184. Engine.prototype.bindSamplers = function (effect) {
  33185. this.setProgram(effect.getProgram());
  33186. var samplers = effect.getSamplers();
  33187. for (var index = 0; index < samplers.length; index++) {
  33188. var uniform = effect.getUniform(samplers[index]);
  33189. if (uniform) {
  33190. this._boundUniforms[index] = uniform;
  33191. }
  33192. }
  33193. this._currentEffect = null;
  33194. };
  33195. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  33196. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  33197. return;
  33198. }
  33199. // Remove
  33200. this._linkTrackers(internalTexture.previous, internalTexture.next);
  33201. // Bind last to it
  33202. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  33203. // Bind to dummy
  33204. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  33205. };
  33206. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  33207. if (!internalTexture) {
  33208. return -1;
  33209. }
  33210. internalTexture._initialSlot = channel;
  33211. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  33212. if (channel !== internalTexture._designatedSlot) {
  33213. this._textureCollisions.addCount(1, false);
  33214. }
  33215. }
  33216. else {
  33217. if (channel !== internalTexture._designatedSlot) {
  33218. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  33219. return internalTexture._designatedSlot;
  33220. }
  33221. else {
  33222. // No slot for this texture, let's pick a new one (if we find a free slot)
  33223. if (this._nextFreeTextureSlots.length) {
  33224. return this._nextFreeTextureSlots[0];
  33225. }
  33226. // We need to recycle the oldest bound texture, sorry.
  33227. this._textureCollisions.addCount(1, false);
  33228. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  33229. }
  33230. }
  33231. }
  33232. return channel;
  33233. };
  33234. Engine.prototype._linkTrackers = function (previous, next) {
  33235. previous.next = next;
  33236. next.previous = previous;
  33237. };
  33238. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  33239. var currentSlot = internalTexture._designatedSlot;
  33240. if (currentSlot === -1) {
  33241. return -1;
  33242. }
  33243. internalTexture._designatedSlot = -1;
  33244. if (this.disableTextureBindingOptimization) {
  33245. return -1;
  33246. }
  33247. // Remove from bound list
  33248. this._linkTrackers(internalTexture.previous, internalTexture.next);
  33249. // Free the slot
  33250. this._boundTexturesCache[currentSlot] = null;
  33251. this._nextFreeTextureSlots.push(currentSlot);
  33252. return currentSlot;
  33253. };
  33254. Engine.prototype._activateCurrentTexture = function () {
  33255. if (this._currentTextureChannel !== this._activeChannel) {
  33256. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  33257. this._currentTextureChannel = this._activeChannel;
  33258. }
  33259. };
  33260. /** @hidden */
  33261. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  33262. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  33263. if (force === void 0) { force = false; }
  33264. var wasPreviouslyBound = false;
  33265. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  33266. this._activeChannel = texture._designatedSlot;
  33267. }
  33268. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  33269. var isTextureForRendering = texture && texture._initialSlot > -1;
  33270. if (currentTextureBound !== texture || force) {
  33271. if (currentTextureBound) {
  33272. this._removeDesignatedSlot(currentTextureBound);
  33273. }
  33274. this._activateCurrentTexture();
  33275. if (texture && texture.isMultiview) {
  33276. this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);
  33277. }
  33278. else {
  33279. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  33280. }
  33281. this._boundTexturesCache[this._activeChannel] = texture;
  33282. if (texture) {
  33283. if (!this.disableTextureBindingOptimization) {
  33284. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  33285. if (slotIndex > -1) {
  33286. this._nextFreeTextureSlots.splice(slotIndex, 1);
  33287. }
  33288. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  33289. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  33290. }
  33291. texture._designatedSlot = this._activeChannel;
  33292. }
  33293. }
  33294. else if (forTextureDataUpdate) {
  33295. wasPreviouslyBound = true;
  33296. this._activateCurrentTexture();
  33297. }
  33298. if (isTextureForRendering && !forTextureDataUpdate) {
  33299. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  33300. }
  33301. return wasPreviouslyBound;
  33302. };
  33303. /** @hidden */
  33304. Engine.prototype._bindTexture = function (channel, texture) {
  33305. if (channel < 0) {
  33306. return;
  33307. }
  33308. if (texture) {
  33309. channel = this._getCorrectTextureChannel(channel, texture);
  33310. }
  33311. this._activeChannel = channel;
  33312. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  33313. };
  33314. /**
  33315. * Sets a texture to the webGL context from a postprocess
  33316. * @param channel defines the channel to use
  33317. * @param postProcess defines the source postprocess
  33318. */
  33319. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  33320. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  33321. };
  33322. /**
  33323. * Binds the output of the passed in post process to the texture channel specified
  33324. * @param channel The channel the texture should be bound to
  33325. * @param postProcess The post process which's output should be bound
  33326. */
  33327. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  33328. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  33329. };
  33330. /**
  33331. * Unbind all textures from the webGL context
  33332. */
  33333. Engine.prototype.unbindAllTextures = function () {
  33334. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  33335. this._activeChannel = channel;
  33336. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33337. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33338. if (this.webGLVersion > 1) {
  33339. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33340. }
  33341. }
  33342. };
  33343. /**
  33344. * Sets a texture to the according uniform.
  33345. * @param channel The texture channel
  33346. * @param uniform The uniform to set
  33347. * @param texture The texture to apply
  33348. */
  33349. Engine.prototype.setTexture = function (channel, uniform, texture) {
  33350. if (channel < 0) {
  33351. return;
  33352. }
  33353. if (uniform) {
  33354. this._boundUniforms[channel] = uniform;
  33355. }
  33356. this._setTexture(channel, texture);
  33357. };
  33358. /**
  33359. * Sets a depth stencil texture from a render target to the according uniform.
  33360. * @param channel The texture channel
  33361. * @param uniform The uniform to set
  33362. * @param texture The render target texture containing the depth stencil texture to apply
  33363. */
  33364. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  33365. if (channel < 0) {
  33366. return;
  33367. }
  33368. if (uniform) {
  33369. this._boundUniforms[channel] = uniform;
  33370. }
  33371. if (!texture || !texture.depthStencilTexture) {
  33372. this._setTexture(channel, null);
  33373. }
  33374. else {
  33375. this._setTexture(channel, texture, false, true);
  33376. }
  33377. };
  33378. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  33379. var uniform = this._boundUniforms[sourceSlot];
  33380. if (uniform._currentState === destination) {
  33381. return;
  33382. }
  33383. this._gl.uniform1i(uniform, destination);
  33384. uniform._currentState = destination;
  33385. };
  33386. Engine.prototype._getTextureWrapMode = function (mode) {
  33387. switch (mode) {
  33388. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  33389. return this._gl.REPEAT;
  33390. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  33391. return this._gl.CLAMP_TO_EDGE;
  33392. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  33393. return this._gl.MIRRORED_REPEAT;
  33394. }
  33395. return this._gl.REPEAT;
  33396. };
  33397. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  33398. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  33399. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  33400. // Not ready?
  33401. if (!texture) {
  33402. if (this._boundTexturesCache[channel] != null) {
  33403. this._activeChannel = channel;
  33404. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33405. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33406. if (this.webGLVersion > 1) {
  33407. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33408. }
  33409. }
  33410. return false;
  33411. }
  33412. // Video
  33413. if (texture.video) {
  33414. this._activeChannel = channel;
  33415. texture.update();
  33416. }
  33417. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  33418. texture.delayLoad();
  33419. return false;
  33420. }
  33421. var internalTexture;
  33422. if (depthStencilTexture) {
  33423. internalTexture = texture.depthStencilTexture;
  33424. }
  33425. else if (texture.isReady()) {
  33426. internalTexture = texture.getInternalTexture();
  33427. }
  33428. else if (texture.isCube) {
  33429. internalTexture = this.emptyCubeTexture;
  33430. }
  33431. else if (texture.is3D) {
  33432. internalTexture = this.emptyTexture3D;
  33433. }
  33434. else {
  33435. internalTexture = this.emptyTexture;
  33436. }
  33437. if (!isPartOfTextureArray) {
  33438. channel = this._getCorrectTextureChannel(channel, internalTexture);
  33439. }
  33440. var needToBind = true;
  33441. if (this._boundTexturesCache[channel] === internalTexture) {
  33442. this._moveBoundTextureOnTop(internalTexture);
  33443. if (!isPartOfTextureArray) {
  33444. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  33445. }
  33446. needToBind = false;
  33447. }
  33448. this._activeChannel = channel;
  33449. if (internalTexture && internalTexture.isMultiview) {
  33450. if (needToBind) {
  33451. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, internalTexture, isPartOfTextureArray);
  33452. }
  33453. }
  33454. else if (internalTexture && internalTexture.is3D) {
  33455. if (needToBind) {
  33456. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  33457. }
  33458. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33459. internalTexture._cachedWrapU = texture.wrapU;
  33460. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33461. }
  33462. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33463. internalTexture._cachedWrapV = texture.wrapV;
  33464. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33465. }
  33466. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  33467. internalTexture._cachedWrapR = texture.wrapR;
  33468. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  33469. }
  33470. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  33471. }
  33472. else if (internalTexture && internalTexture.isCube) {
  33473. if (needToBind) {
  33474. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  33475. }
  33476. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  33477. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  33478. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  33479. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  33480. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  33481. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  33482. }
  33483. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  33484. }
  33485. else {
  33486. if (needToBind) {
  33487. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  33488. }
  33489. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33490. internalTexture._cachedWrapU = texture.wrapU;
  33491. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33492. }
  33493. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33494. internalTexture._cachedWrapV = texture.wrapV;
  33495. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33496. }
  33497. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  33498. }
  33499. return true;
  33500. };
  33501. /**
  33502. * Sets an array of texture to the webGL context
  33503. * @param channel defines the channel where the texture array must be set
  33504. * @param uniform defines the associated uniform location
  33505. * @param textures defines the array of textures to bind
  33506. */
  33507. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  33508. if (channel < 0 || !uniform) {
  33509. return;
  33510. }
  33511. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  33512. this._textureUnits = new Int32Array(textures.length);
  33513. }
  33514. for (var i = 0; i < textures.length; i++) {
  33515. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  33516. }
  33517. this._gl.uniform1iv(uniform, this._textureUnits);
  33518. for (var index = 0; index < textures.length; index++) {
  33519. this._setTexture(this._textureUnits[index], textures[index], true);
  33520. }
  33521. };
  33522. /** @hidden */
  33523. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  33524. var internalTexture = texture.getInternalTexture();
  33525. if (!internalTexture) {
  33526. return;
  33527. }
  33528. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  33529. var value = texture.anisotropicFilteringLevel;
  33530. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  33531. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  33532. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  33533. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  33534. }
  33535. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  33536. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  33537. internalTexture._cachedAnisotropicFilteringLevel = value;
  33538. }
  33539. };
  33540. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  33541. this._bindTextureDirectly(target, texture, true, true);
  33542. this._gl.texParameterf(target, parameter, value);
  33543. };
  33544. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  33545. if (texture) {
  33546. this._bindTextureDirectly(target, texture, true, true);
  33547. }
  33548. this._gl.texParameteri(target, parameter, value);
  33549. };
  33550. /**
  33551. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33552. * @param x defines the x coordinate of the rectangle where pixels must be read
  33553. * @param y defines the y coordinate of the rectangle where pixels must be read
  33554. * @param width defines the width of the rectangle where pixels must be read
  33555. * @param height defines the height of the rectangle where pixels must be read
  33556. * @returns a Uint8Array containing RGBA colors
  33557. */
  33558. Engine.prototype.readPixels = function (x, y, width, height) {
  33559. var data = new Uint8Array(height * width * 4);
  33560. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  33561. return data;
  33562. };
  33563. /**
  33564. * Add an externaly attached data from its key.
  33565. * This method call will fail and return false, if such key already exists.
  33566. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33567. * @param key the unique key that identifies the data
  33568. * @param data the data object to associate to the key for this Engine instance
  33569. * @return true if no such key were already present and the data was added successfully, false otherwise
  33570. */
  33571. Engine.prototype.addExternalData = function (key, data) {
  33572. if (!this._externalData) {
  33573. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33574. }
  33575. return this._externalData.add(key, data);
  33576. };
  33577. /**
  33578. * Get an externaly attached data from its key
  33579. * @param key the unique key that identifies the data
  33580. * @return the associated data, if present (can be null), or undefined if not present
  33581. */
  33582. Engine.prototype.getExternalData = function (key) {
  33583. if (!this._externalData) {
  33584. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33585. }
  33586. return this._externalData.get(key);
  33587. };
  33588. /**
  33589. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33590. * @param key the unique key that identifies the data
  33591. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33592. * @return the associated data, can be null if the factory returned null.
  33593. */
  33594. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  33595. if (!this._externalData) {
  33596. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33597. }
  33598. return this._externalData.getOrAddWithFactory(key, factory);
  33599. };
  33600. /**
  33601. * Remove an externaly attached data from the Engine instance
  33602. * @param key the unique key that identifies the data
  33603. * @return true if the data was successfully removed, false if it doesn't exist
  33604. */
  33605. Engine.prototype.removeExternalData = function (key) {
  33606. if (!this._externalData) {
  33607. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33608. }
  33609. return this._externalData.remove(key);
  33610. };
  33611. /**
  33612. * Unbind all vertex attributes from the webGL context
  33613. */
  33614. Engine.prototype.unbindAllAttributes = function () {
  33615. if (this._mustWipeVertexAttributes) {
  33616. this._mustWipeVertexAttributes = false;
  33617. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  33618. this._gl.disableVertexAttribArray(i);
  33619. this._vertexAttribArraysEnabled[i] = false;
  33620. this._currentBufferPointers[i].active = false;
  33621. }
  33622. return;
  33623. }
  33624. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  33625. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  33626. continue;
  33627. }
  33628. this._gl.disableVertexAttribArray(i);
  33629. this._vertexAttribArraysEnabled[i] = false;
  33630. this._currentBufferPointers[i].active = false;
  33631. }
  33632. };
  33633. /**
  33634. * 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
  33635. */
  33636. Engine.prototype.releaseEffects = function () {
  33637. for (var name in this._compiledEffects) {
  33638. this._deleteProgram(this._compiledEffects[name]._program);
  33639. }
  33640. this._compiledEffects = {};
  33641. };
  33642. /**
  33643. * Dispose and release all associated resources
  33644. */
  33645. Engine.prototype.dispose = function () {
  33646. this.hideLoadingUI();
  33647. this.stopRenderLoop();
  33648. this.onNewSceneAddedObservable.clear();
  33649. // Release postProcesses
  33650. while (this.postProcesses.length) {
  33651. this.postProcesses[0].dispose();
  33652. }
  33653. // Empty texture
  33654. if (this._emptyTexture) {
  33655. this._releaseTexture(this._emptyTexture);
  33656. this._emptyTexture = null;
  33657. }
  33658. if (this._emptyCubeTexture) {
  33659. this._releaseTexture(this._emptyCubeTexture);
  33660. this._emptyCubeTexture = null;
  33661. }
  33662. // Rescale PP
  33663. if (this._rescalePostProcess) {
  33664. this._rescalePostProcess.dispose();
  33665. }
  33666. // Release scenes
  33667. while (this.scenes.length) {
  33668. this.scenes[0].dispose();
  33669. }
  33670. // Release audio engine
  33671. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  33672. Engine.audioEngine.dispose();
  33673. }
  33674. // Release effects
  33675. this.releaseEffects();
  33676. // Unbind
  33677. this.unbindAllAttributes();
  33678. this._boundUniforms = [];
  33679. if (this._dummyFramebuffer) {
  33680. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  33681. }
  33682. //WebVR
  33683. this.disableVR();
  33684. // Events
  33685. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33686. window.removeEventListener("blur", this._onBlur);
  33687. window.removeEventListener("focus", this._onFocus);
  33688. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  33689. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  33690. if (this._renderingCanvas) {
  33691. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  33692. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  33693. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  33694. if (!this._doNotHandleContextLost) {
  33695. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  33696. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  33697. }
  33698. }
  33699. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  33700. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  33701. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  33702. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  33703. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  33704. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  33705. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  33706. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  33707. if (this._onVrDisplayConnect) {
  33708. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  33709. if (this._onVrDisplayDisconnect) {
  33710. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  33711. }
  33712. if (this._onVrDisplayPresentChange) {
  33713. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  33714. }
  33715. this._onVrDisplayConnect = null;
  33716. this._onVrDisplayDisconnect = null;
  33717. }
  33718. }
  33719. // Remove from Instances
  33720. var index = Engine.Instances.indexOf(this);
  33721. if (index >= 0) {
  33722. Engine.Instances.splice(index, 1);
  33723. }
  33724. this._workingCanvas = null;
  33725. this._workingContext = null;
  33726. this._currentBufferPointers = [];
  33727. this._renderingCanvas = null;
  33728. this._currentProgram = null;
  33729. this._bindedRenderFunction = null;
  33730. this.onResizeObservable.clear();
  33731. this.onCanvasBlurObservable.clear();
  33732. this.onCanvasFocusObservable.clear();
  33733. this.onCanvasPointerOutObservable.clear();
  33734. this.onBeginFrameObservable.clear();
  33735. this.onEndFrameObservable.clear();
  33736. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33737. // Abort active requests
  33738. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33739. var request = _a[_i];
  33740. request.abort();
  33741. }
  33742. };
  33743. // Loading screen
  33744. /**
  33745. * Display the loading screen
  33746. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33747. */
  33748. Engine.prototype.displayLoadingUI = function () {
  33749. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33750. return;
  33751. }
  33752. var loadingScreen = this.loadingScreen;
  33753. if (loadingScreen) {
  33754. loadingScreen.displayLoadingUI();
  33755. }
  33756. };
  33757. /**
  33758. * Hide the loading screen
  33759. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33760. */
  33761. Engine.prototype.hideLoadingUI = function () {
  33762. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33763. return;
  33764. }
  33765. var loadingScreen = this.loadingScreen;
  33766. if (loadingScreen) {
  33767. loadingScreen.hideLoadingUI();
  33768. }
  33769. };
  33770. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33771. /**
  33772. * Gets the current loading screen object
  33773. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33774. */
  33775. get: function () {
  33776. if (!this._loadingScreen && this._renderingCanvas) {
  33777. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33778. }
  33779. return this._loadingScreen;
  33780. },
  33781. /**
  33782. * Sets the current loading screen object
  33783. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33784. */
  33785. set: function (loadingScreen) {
  33786. this._loadingScreen = loadingScreen;
  33787. },
  33788. enumerable: true,
  33789. configurable: true
  33790. });
  33791. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33792. /**
  33793. * Sets the current loading screen text
  33794. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33795. */
  33796. set: function (text) {
  33797. this.loadingScreen.loadingUIText = text;
  33798. },
  33799. enumerable: true,
  33800. configurable: true
  33801. });
  33802. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33803. /**
  33804. * Sets the current loading screen background color
  33805. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33806. */
  33807. set: function (color) {
  33808. this.loadingScreen.loadingUIBackgroundColor = color;
  33809. },
  33810. enumerable: true,
  33811. configurable: true
  33812. });
  33813. /**
  33814. * Attach a new callback raised when context lost event is fired
  33815. * @param callback defines the callback to call
  33816. */
  33817. Engine.prototype.attachContextLostEvent = function (callback) {
  33818. if (this._renderingCanvas) {
  33819. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33820. }
  33821. };
  33822. /**
  33823. * Attach a new callback raised when context restored event is fired
  33824. * @param callback defines the callback to call
  33825. */
  33826. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33827. if (this._renderingCanvas) {
  33828. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33829. }
  33830. };
  33831. /**
  33832. * Gets the source code of the vertex shader associated with a specific webGL program
  33833. * @param program defines the program to use
  33834. * @returns a string containing the source code of the vertex shader associated with the program
  33835. */
  33836. Engine.prototype.getVertexShaderSource = function (program) {
  33837. var shaders = this._gl.getAttachedShaders(program);
  33838. if (!shaders) {
  33839. return null;
  33840. }
  33841. return this._gl.getShaderSource(shaders[0]);
  33842. };
  33843. /**
  33844. * Gets the source code of the fragment shader associated with a specific webGL program
  33845. * @param program defines the program to use
  33846. * @returns a string containing the source code of the fragment shader associated with the program
  33847. */
  33848. Engine.prototype.getFragmentShaderSource = function (program) {
  33849. var shaders = this._gl.getAttachedShaders(program);
  33850. if (!shaders) {
  33851. return null;
  33852. }
  33853. return this._gl.getShaderSource(shaders[1]);
  33854. };
  33855. /**
  33856. * Get the current error code of the webGL context
  33857. * @returns the error code
  33858. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33859. */
  33860. Engine.prototype.getError = function () {
  33861. return this._gl.getError();
  33862. };
  33863. // FPS
  33864. /**
  33865. * Gets the current framerate
  33866. * @returns a number representing the framerate
  33867. */
  33868. Engine.prototype.getFps = function () {
  33869. return this._fps;
  33870. };
  33871. /**
  33872. * Gets the time spent between current and previous frame
  33873. * @returns a number representing the delta time in ms
  33874. */
  33875. Engine.prototype.getDeltaTime = function () {
  33876. return this._deltaTime;
  33877. };
  33878. Engine.prototype._measureFps = function () {
  33879. this._performanceMonitor.sampleFrame();
  33880. this._fps = this._performanceMonitor.averageFPS;
  33881. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  33882. };
  33883. /** @hidden */
  33884. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  33885. if (faceIndex === void 0) { faceIndex = -1; }
  33886. if (level === void 0) { level = 0; }
  33887. if (buffer === void 0) { buffer = null; }
  33888. var gl = this._gl;
  33889. if (!this._dummyFramebuffer) {
  33890. var dummy = gl.createFramebuffer();
  33891. if (!dummy) {
  33892. throw new Error("Unable to create dummy framebuffer");
  33893. }
  33894. this._dummyFramebuffer = dummy;
  33895. }
  33896. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  33897. if (faceIndex > -1) {
  33898. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  33899. }
  33900. else {
  33901. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  33902. }
  33903. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  33904. switch (readType) {
  33905. case gl.UNSIGNED_BYTE:
  33906. if (!buffer) {
  33907. buffer = new Uint8Array(4 * width * height);
  33908. }
  33909. readType = gl.UNSIGNED_BYTE;
  33910. break;
  33911. default:
  33912. if (!buffer) {
  33913. buffer = new Float32Array(4 * width * height);
  33914. }
  33915. readType = gl.FLOAT;
  33916. break;
  33917. }
  33918. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  33919. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  33920. return buffer;
  33921. };
  33922. Engine.prototype._canRenderToFloatFramebuffer = function () {
  33923. if (this._webGLVersion > 1) {
  33924. return this._caps.colorBufferFloat;
  33925. }
  33926. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  33927. };
  33928. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33929. if (this._webGLVersion > 1) {
  33930. return this._caps.colorBufferFloat;
  33931. }
  33932. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33933. };
  33934. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33935. Engine.prototype._canRenderToFramebuffer = function (type) {
  33936. var gl = this._gl;
  33937. //clear existing errors
  33938. while (gl.getError() !== gl.NO_ERROR) { }
  33939. var successful = true;
  33940. var texture = gl.createTexture();
  33941. gl.bindTexture(gl.TEXTURE_2D, texture);
  33942. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33943. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33944. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33945. var fb = gl.createFramebuffer();
  33946. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33947. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33948. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33949. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33950. successful = successful && (gl.getError() === gl.NO_ERROR);
  33951. //try render by clearing frame buffer's color buffer
  33952. if (successful) {
  33953. gl.clear(gl.COLOR_BUFFER_BIT);
  33954. successful = successful && (gl.getError() === gl.NO_ERROR);
  33955. }
  33956. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33957. if (successful) {
  33958. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33959. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33960. var readFormat = gl.RGBA;
  33961. var readType = gl.UNSIGNED_BYTE;
  33962. var buffer = new Uint8Array(4);
  33963. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33964. successful = successful && (gl.getError() === gl.NO_ERROR);
  33965. }
  33966. //clean up
  33967. gl.deleteTexture(texture);
  33968. gl.deleteFramebuffer(fb);
  33969. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33970. //clear accumulated errors
  33971. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33972. return successful;
  33973. };
  33974. /** @hidden */
  33975. Engine.prototype._getWebGLTextureType = function (type) {
  33976. if (this._webGLVersion === 1) {
  33977. switch (type) {
  33978. case Engine.TEXTURETYPE_FLOAT:
  33979. return this._gl.FLOAT;
  33980. case Engine.TEXTURETYPE_HALF_FLOAT:
  33981. return this._gl.HALF_FLOAT_OES;
  33982. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33983. return this._gl.UNSIGNED_BYTE;
  33984. }
  33985. return this._gl.UNSIGNED_BYTE;
  33986. }
  33987. switch (type) {
  33988. case Engine.TEXTURETYPE_BYTE:
  33989. return this._gl.BYTE;
  33990. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33991. return this._gl.UNSIGNED_BYTE;
  33992. case Engine.TEXTURETYPE_SHORT:
  33993. return this._gl.SHORT;
  33994. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33995. return this._gl.UNSIGNED_SHORT;
  33996. case Engine.TEXTURETYPE_INT:
  33997. return this._gl.INT;
  33998. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33999. return this._gl.UNSIGNED_INT;
  34000. case Engine.TEXTURETYPE_FLOAT:
  34001. return this._gl.FLOAT;
  34002. case Engine.TEXTURETYPE_HALF_FLOAT:
  34003. return this._gl.HALF_FLOAT;
  34004. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34005. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  34006. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34007. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  34008. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34009. return this._gl.UNSIGNED_SHORT_5_6_5;
  34010. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34011. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  34012. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  34013. return this._gl.UNSIGNED_INT_24_8;
  34014. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34015. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  34016. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34017. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  34018. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  34019. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  34020. }
  34021. return this._gl.UNSIGNED_BYTE;
  34022. };
  34023. Engine.prototype._getInternalFormat = function (format) {
  34024. var internalFormat = this._gl.RGBA;
  34025. switch (format) {
  34026. case Engine.TEXTUREFORMAT_ALPHA:
  34027. internalFormat = this._gl.ALPHA;
  34028. break;
  34029. case Engine.TEXTUREFORMAT_LUMINANCE:
  34030. internalFormat = this._gl.LUMINANCE;
  34031. break;
  34032. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34033. internalFormat = this._gl.LUMINANCE_ALPHA;
  34034. break;
  34035. case Engine.TEXTUREFORMAT_RED:
  34036. internalFormat = this._gl.RED;
  34037. break;
  34038. case Engine.TEXTUREFORMAT_RG:
  34039. internalFormat = this._gl.RG;
  34040. break;
  34041. case Engine.TEXTUREFORMAT_RGB:
  34042. internalFormat = this._gl.RGB;
  34043. break;
  34044. case Engine.TEXTUREFORMAT_RGBA:
  34045. internalFormat = this._gl.RGBA;
  34046. break;
  34047. }
  34048. if (this._webGLVersion > 1) {
  34049. switch (format) {
  34050. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34051. internalFormat = this._gl.RED_INTEGER;
  34052. break;
  34053. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34054. internalFormat = this._gl.RG_INTEGER;
  34055. break;
  34056. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34057. internalFormat = this._gl.RGB_INTEGER;
  34058. break;
  34059. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34060. internalFormat = this._gl.RGBA_INTEGER;
  34061. break;
  34062. }
  34063. }
  34064. return internalFormat;
  34065. };
  34066. /** @hidden */
  34067. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  34068. if (this._webGLVersion === 1) {
  34069. if (format !== undefined) {
  34070. switch (format) {
  34071. case Engine.TEXTUREFORMAT_ALPHA:
  34072. return this._gl.ALPHA;
  34073. case Engine.TEXTUREFORMAT_LUMINANCE:
  34074. return this._gl.LUMINANCE;
  34075. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34076. return this._gl.LUMINANCE_ALPHA;
  34077. }
  34078. }
  34079. return this._gl.RGBA;
  34080. }
  34081. switch (type) {
  34082. case Engine.TEXTURETYPE_BYTE:
  34083. switch (format) {
  34084. case Engine.TEXTUREFORMAT_RED:
  34085. return this._gl.R8_SNORM;
  34086. case Engine.TEXTUREFORMAT_RG:
  34087. return this._gl.RG8_SNORM;
  34088. case Engine.TEXTUREFORMAT_RGB:
  34089. return this._gl.RGB8_SNORM;
  34090. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34091. return this._gl.R8I;
  34092. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34093. return this._gl.RG8I;
  34094. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34095. return this._gl.RGB8I;
  34096. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34097. return this._gl.RGBA8I;
  34098. default:
  34099. return this._gl.RGBA8_SNORM;
  34100. }
  34101. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34102. switch (format) {
  34103. case Engine.TEXTUREFORMAT_RED:
  34104. return this._gl.R8;
  34105. case Engine.TEXTUREFORMAT_RG:
  34106. return this._gl.RG8;
  34107. case Engine.TEXTUREFORMAT_RGB:
  34108. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  34109. case Engine.TEXTUREFORMAT_RGBA:
  34110. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  34111. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34112. return this._gl.R8UI;
  34113. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34114. return this._gl.RG8UI;
  34115. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34116. return this._gl.RGB8UI;
  34117. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34118. return this._gl.RGBA8UI;
  34119. default:
  34120. return this._gl.RGBA8;
  34121. }
  34122. case Engine.TEXTURETYPE_SHORT:
  34123. switch (format) {
  34124. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34125. return this._gl.R16I;
  34126. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34127. return this._gl.RG16I;
  34128. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34129. return this._gl.RGB16I;
  34130. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34131. return this._gl.RGBA16I;
  34132. default:
  34133. return this._gl.RGBA16I;
  34134. }
  34135. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34136. switch (format) {
  34137. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34138. return this._gl.R16UI;
  34139. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34140. return this._gl.RG16UI;
  34141. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34142. return this._gl.RGB16UI;
  34143. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34144. return this._gl.RGBA16UI;
  34145. default:
  34146. return this._gl.RGBA16UI;
  34147. }
  34148. case Engine.TEXTURETYPE_INT:
  34149. switch (format) {
  34150. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34151. return this._gl.R32I;
  34152. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34153. return this._gl.RG32I;
  34154. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34155. return this._gl.RGB32I;
  34156. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34157. return this._gl.RGBA32I;
  34158. default:
  34159. return this._gl.RGBA32I;
  34160. }
  34161. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34162. switch (format) {
  34163. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34164. return this._gl.R32UI;
  34165. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34166. return this._gl.RG32UI;
  34167. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34168. return this._gl.RGB32UI;
  34169. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34170. return this._gl.RGBA32UI;
  34171. default:
  34172. return this._gl.RGBA32UI;
  34173. }
  34174. case Engine.TEXTURETYPE_FLOAT:
  34175. switch (format) {
  34176. case Engine.TEXTUREFORMAT_RED:
  34177. return this._gl.R32F; // By default. Other possibility is R16F.
  34178. case Engine.TEXTUREFORMAT_RG:
  34179. return this._gl.RG32F; // By default. Other possibility is RG16F.
  34180. case Engine.TEXTUREFORMAT_RGB:
  34181. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  34182. case Engine.TEXTUREFORMAT_RGBA:
  34183. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  34184. default:
  34185. return this._gl.RGBA32F;
  34186. }
  34187. case Engine.TEXTURETYPE_HALF_FLOAT:
  34188. switch (format) {
  34189. case Engine.TEXTUREFORMAT_RED:
  34190. return this._gl.R16F;
  34191. case Engine.TEXTUREFORMAT_RG:
  34192. return this._gl.RG16F;
  34193. case Engine.TEXTUREFORMAT_RGB:
  34194. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  34195. case Engine.TEXTUREFORMAT_RGBA:
  34196. return this._gl.RGBA16F;
  34197. default:
  34198. return this._gl.RGBA16F;
  34199. }
  34200. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34201. return this._gl.RGB565;
  34202. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34203. return this._gl.R11F_G11F_B10F;
  34204. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34205. return this._gl.RGB9_E5;
  34206. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34207. return this._gl.RGBA4;
  34208. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34209. return this._gl.RGB5_A1;
  34210. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34211. switch (format) {
  34212. case Engine.TEXTUREFORMAT_RGBA:
  34213. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  34214. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34215. return this._gl.RGB10_A2UI;
  34216. default:
  34217. return this._gl.RGB10_A2;
  34218. }
  34219. }
  34220. return this._gl.RGBA8;
  34221. };
  34222. /** @hidden */
  34223. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  34224. if (type === Engine.TEXTURETYPE_FLOAT) {
  34225. return this._gl.RGBA32F;
  34226. }
  34227. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  34228. return this._gl.RGBA16F;
  34229. }
  34230. return this._gl.RGBA8;
  34231. };
  34232. /** @hidden */
  34233. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  34234. var _this = this;
  34235. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  34236. this._activeRequests.push(request);
  34237. request.onCompleteObservable.add(function (request) {
  34238. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  34239. });
  34240. return request;
  34241. };
  34242. /** @hidden */
  34243. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  34244. var _this = this;
  34245. return new Promise(function (resolve, reject) {
  34246. _this._loadFile(url, function (data) {
  34247. resolve(data);
  34248. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  34249. reject(exception);
  34250. });
  34251. });
  34252. };
  34253. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  34254. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  34255. var onload = function (data) {
  34256. loadedFiles[index] = data;
  34257. loadedFiles._internalCount++;
  34258. if (loadedFiles._internalCount === 6) {
  34259. onfinish(loadedFiles);
  34260. }
  34261. };
  34262. var onerror = function (request, exception) {
  34263. if (onErrorCallBack && request) {
  34264. onErrorCallBack(request.status + " " + request.statusText, exception);
  34265. }
  34266. };
  34267. this._loadFile(url, onload, undefined, undefined, true, onerror);
  34268. };
  34269. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  34270. if (onError === void 0) { onError = null; }
  34271. var loadedFiles = [];
  34272. loadedFiles._internalCount = 0;
  34273. for (var index = 0; index < 6; index++) {
  34274. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  34275. }
  34276. };
  34277. // Statics
  34278. /**
  34279. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34280. * @returns true if the engine can be created
  34281. * @ignorenaming
  34282. */
  34283. Engine.isSupported = function () {
  34284. try {
  34285. var tempcanvas = document.createElement("canvas");
  34286. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  34287. return gl != null && !!window.WebGLRenderingContext;
  34288. }
  34289. catch (e) {
  34290. return false;
  34291. }
  34292. };
  34293. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34294. Engine.ExceptionList = [
  34295. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  34296. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34297. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34298. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34299. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34300. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  34301. ];
  34302. /**
  34303. * Hidden
  34304. */
  34305. Engine._TextureLoaders = [];
  34306. // Const statics
  34307. /** Defines that alpha blending is disabled */
  34308. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  34309. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34310. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  34311. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34312. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  34313. /** Defines that alpha blending to DEST - SRC * DEST */
  34314. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  34315. /** Defines that alpha blending to SRC * DEST */
  34316. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  34317. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34318. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  34319. /** Defines that alpha blending to SRC + DEST */
  34320. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  34321. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34322. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  34323. /**
  34324. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34325. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34326. */
  34327. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  34328. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34329. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  34330. /**
  34331. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34332. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34333. */
  34334. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  34335. /** Defines that the ressource is not delayed*/
  34336. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  34337. /** Defines that the ressource was successfully delay loaded */
  34338. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  34339. /** Defines that the ressource is currently delay loading */
  34340. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  34341. /** Defines that the ressource is delayed and has not started loading */
  34342. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  34343. // Depht or Stencil test Constants.
  34344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34345. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  34346. /** 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 */
  34347. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  34348. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34349. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  34350. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34351. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  34352. /** 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 */
  34353. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  34354. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34355. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  34356. /** 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 */
  34357. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  34358. /** 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 */
  34359. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  34360. // Stencil Actions Constants.
  34361. /** Passed to stencilOperation to specify that stencil value must be kept */
  34362. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  34363. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34364. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  34365. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34366. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  34367. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34368. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  34369. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34370. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  34371. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34372. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  34373. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34374. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  34375. /** Texture is not repeating outside of 0..1 UVs */
  34376. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  34377. /** Texture is repeating outside of 0..1 UVs */
  34378. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  34379. /** Texture is repeating and mirrored */
  34380. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  34381. /** ALPHA */
  34382. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  34383. /** LUMINANCE */
  34384. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  34385. /** LUMINANCE_ALPHA */
  34386. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  34387. /** RGB */
  34388. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  34389. /** RGBA */
  34390. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  34391. /** RED */
  34392. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  34393. /** RED (2nd reference) */
  34394. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  34395. /** RG */
  34396. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  34397. /** RED_INTEGER */
  34398. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  34399. /** RED_INTEGER (2nd reference) */
  34400. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  34401. /** RG_INTEGER */
  34402. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  34403. /** RGB_INTEGER */
  34404. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  34405. /** RGBA_INTEGER */
  34406. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  34407. /** UNSIGNED_BYTE */
  34408. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  34409. /** UNSIGNED_BYTE (2nd reference) */
  34410. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34411. /** FLOAT */
  34412. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  34413. /** HALF_FLOAT */
  34414. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  34415. /** BYTE */
  34416. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  34417. /** SHORT */
  34418. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  34419. /** UNSIGNED_SHORT */
  34420. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  34421. /** INT */
  34422. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  34423. /** UNSIGNED_INT */
  34424. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  34425. /** UNSIGNED_SHORT_4_4_4_4 */
  34426. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  34427. /** UNSIGNED_SHORT_5_5_5_1 */
  34428. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  34429. /** UNSIGNED_SHORT_5_6_5 */
  34430. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  34431. /** UNSIGNED_INT_2_10_10_10_REV */
  34432. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  34433. /** UNSIGNED_INT_24_8 */
  34434. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  34435. /** UNSIGNED_INT_10F_11F_11F_REV */
  34436. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  34437. /** UNSIGNED_INT_5_9_9_9_REV */
  34438. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  34439. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34440. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  34441. /** nearest is mag = nearest and min = nearest and mip = linear */
  34442. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  34443. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34444. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  34445. /** Trilinear is mag = linear and min = linear and mip = linear */
  34446. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34447. /** nearest is mag = nearest and min = nearest and mip = linear */
  34448. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  34449. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34450. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  34451. /** Trilinear is mag = linear and min = linear and mip = linear */
  34452. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  34453. /** mag = nearest and min = nearest and mip = nearest */
  34454. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  34455. /** mag = nearest and min = linear and mip = nearest */
  34456. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  34457. /** mag = nearest and min = linear and mip = linear */
  34458. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  34459. /** mag = nearest and min = linear and mip = none */
  34460. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  34461. /** mag = nearest and min = nearest and mip = none */
  34462. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  34463. /** mag = linear and min = nearest and mip = nearest */
  34464. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  34465. /** mag = linear and min = nearest and mip = linear */
  34466. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  34467. /** mag = linear and min = linear and mip = none */
  34468. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  34469. /** mag = linear and min = nearest and mip = none */
  34470. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  34471. /** Explicit coordinates mode */
  34472. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  34473. /** Spherical coordinates mode */
  34474. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  34475. /** Planar coordinates mode */
  34476. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  34477. /** Cubic coordinates mode */
  34478. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  34479. /** Projection coordinates mode */
  34480. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  34481. /** Skybox coordinates mode */
  34482. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  34483. /** Inverse Cubic coordinates mode */
  34484. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  34485. /** Equirectangular coordinates mode */
  34486. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  34487. /** Equirectangular Fixed coordinates mode */
  34488. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  34489. /** Equirectangular Fixed Mirrored coordinates mode */
  34490. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  34491. // Texture rescaling mode
  34492. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34493. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  34494. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34495. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  34496. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34497. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  34498. // Updatable statics so stick with vars here
  34499. /**
  34500. * Gets or sets the epsilon value used by collision engine
  34501. */
  34502. Engine.CollisionsEpsilon = 0.001;
  34503. /**
  34504. * Method called to create the default rescale post process on each engine.
  34505. */
  34506. Engine._RescalePostProcessFactory = null;
  34507. return Engine;
  34508. }());
  34509. /***/ }),
  34510. /***/ "./Engines/engineStore.ts":
  34511. /*!********************************!*\
  34512. !*** ./Engines/engineStore.ts ***!
  34513. \********************************/
  34514. /*! exports provided: EngineStore */
  34515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34516. "use strict";
  34517. __webpack_require__.r(__webpack_exports__);
  34518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  34519. /**
  34520. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34521. * during the life time of the application.
  34522. */
  34523. var EngineStore = /** @class */ (function () {
  34524. function EngineStore() {
  34525. }
  34526. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  34527. /**
  34528. * Gets the latest created engine
  34529. */
  34530. get: function () {
  34531. if (this.Instances.length === 0) {
  34532. return null;
  34533. }
  34534. return this.Instances[this.Instances.length - 1];
  34535. },
  34536. enumerable: true,
  34537. configurable: true
  34538. });
  34539. Object.defineProperty(EngineStore, "LastCreatedScene", {
  34540. /**
  34541. * Gets the latest created scene
  34542. */
  34543. get: function () {
  34544. var lastCreatedEngine = this.LastCreatedEngine;
  34545. if (!lastCreatedEngine) {
  34546. return null;
  34547. }
  34548. if (lastCreatedEngine.scenes.length === 0) {
  34549. return null;
  34550. }
  34551. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  34552. },
  34553. enumerable: true,
  34554. configurable: true
  34555. });
  34556. /** Gets the list of created engines */
  34557. EngineStore.Instances = new Array();
  34558. return EngineStore;
  34559. }());
  34560. /***/ }),
  34561. /***/ "./Engines/index.ts":
  34562. /*!**************************!*\
  34563. !*** ./Engines/index.ts ***!
  34564. \**************************/
  34565. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  34566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34567. "use strict";
  34568. __webpack_require__.r(__webpack_exports__);
  34569. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  34571. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  34572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  34573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  34574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  34575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  34576. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  34577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  34578. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  34579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  34580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  34581. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  34582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  34583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  34584. /***/ }),
  34585. /***/ "./Engines/nullEngine.ts":
  34586. /*!*******************************!*\
  34587. !*** ./Engines/nullEngine.ts ***!
  34588. \*******************************/
  34589. /*! exports provided: NullEngineOptions, NullEngine */
  34590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34591. "use strict";
  34592. __webpack_require__.r(__webpack_exports__);
  34593. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  34594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  34595. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34596. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  34597. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  34598. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  34599. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  34600. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34601. /**
  34602. * Options to create the null engine
  34603. */
  34604. var NullEngineOptions = /** @class */ (function () {
  34605. function NullEngineOptions() {
  34606. /**
  34607. * Render width (Default: 512)
  34608. */
  34609. this.renderWidth = 512;
  34610. /**
  34611. * Render height (Default: 256)
  34612. */
  34613. this.renderHeight = 256;
  34614. /**
  34615. * Texture size (Default: 512)
  34616. */
  34617. this.textureSize = 512;
  34618. /**
  34619. * If delta time between frames should be constant
  34620. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34621. */
  34622. this.deterministicLockstep = false;
  34623. /**
  34624. * Maximum about of steps between frames (Default: 4)
  34625. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34626. */
  34627. this.lockstepMaxSteps = 4;
  34628. }
  34629. return NullEngineOptions;
  34630. }());
  34631. /**
  34632. * The null engine class provides support for headless version of babylon.js.
  34633. * This can be used in server side scenario or for testing purposes
  34634. */
  34635. var NullEngine = /** @class */ (function (_super) {
  34636. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  34637. function NullEngine(options) {
  34638. if (options === void 0) { options = new NullEngineOptions(); }
  34639. var _this = _super.call(this, null) || this;
  34640. if (options.deterministicLockstep === undefined) {
  34641. options.deterministicLockstep = false;
  34642. }
  34643. if (options.lockstepMaxSteps === undefined) {
  34644. options.lockstepMaxSteps = 4;
  34645. }
  34646. _this._options = options;
  34647. // Init caps
  34648. // We consider we are on a webgl1 capable device
  34649. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  34650. _this._caps.maxTexturesImageUnits = 16;
  34651. _this._caps.maxVertexTextureImageUnits = 16;
  34652. _this._caps.maxTextureSize = 512;
  34653. _this._caps.maxCubemapTextureSize = 512;
  34654. _this._caps.maxRenderTextureSize = 512;
  34655. _this._caps.maxVertexAttribs = 16;
  34656. _this._caps.maxVaryingVectors = 16;
  34657. _this._caps.maxFragmentUniformVectors = 16;
  34658. _this._caps.maxVertexUniformVectors = 16;
  34659. // Extensions
  34660. _this._caps.standardDerivatives = false;
  34661. _this._caps.astc = null;
  34662. _this._caps.s3tc = null;
  34663. _this._caps.pvrtc = null;
  34664. _this._caps.etc1 = null;
  34665. _this._caps.etc2 = null;
  34666. _this._caps.textureAnisotropicFilterExtension = null;
  34667. _this._caps.maxAnisotropy = 0;
  34668. _this._caps.uintIndices = false;
  34669. _this._caps.fragmentDepthSupported = false;
  34670. _this._caps.highPrecisionShaderSupported = true;
  34671. _this._caps.colorBufferFloat = false;
  34672. _this._caps.textureFloat = false;
  34673. _this._caps.textureFloatLinearFiltering = false;
  34674. _this._caps.textureFloatRender = false;
  34675. _this._caps.textureHalfFloat = false;
  34676. _this._caps.textureHalfFloatLinearFiltering = false;
  34677. _this._caps.textureHalfFloatRender = false;
  34678. _this._caps.textureLOD = false;
  34679. _this._caps.drawBuffersExtension = false;
  34680. _this._caps.depthTextureExtension = false;
  34681. _this._caps.vertexArrayObject = false;
  34682. _this._caps.instancedArrays = false;
  34683. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  34684. // Wrappers
  34685. var theCurrentGlobal = (typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : window);
  34686. if (typeof URL === "undefined") {
  34687. theCurrentGlobal.URL = {
  34688. createObjectURL: function () { },
  34689. revokeObjectURL: function () { }
  34690. };
  34691. }
  34692. if (typeof Blob === "undefined") {
  34693. theCurrentGlobal.Blob = function () { };
  34694. }
  34695. return _this;
  34696. }
  34697. /**
  34698. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34699. */
  34700. NullEngine.prototype.isDeterministicLockStep = function () {
  34701. return this._options.deterministicLockstep;
  34702. };
  34703. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  34704. NullEngine.prototype.getLockstepMaxSteps = function () {
  34705. return this._options.lockstepMaxSteps;
  34706. };
  34707. /**
  34708. * Sets hardware scaling, used to save performance if needed
  34709. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34710. */
  34711. NullEngine.prototype.getHardwareScalingLevel = function () {
  34712. return 1.0;
  34713. };
  34714. NullEngine.prototype.createVertexBuffer = function (vertices) {
  34715. return {
  34716. capacity: 0,
  34717. references: 1,
  34718. is32Bits: false
  34719. };
  34720. };
  34721. NullEngine.prototype.createIndexBuffer = function (indices) {
  34722. return {
  34723. capacity: 0,
  34724. references: 1,
  34725. is32Bits: false
  34726. };
  34727. };
  34728. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34729. if (stencil === void 0) { stencil = false; }
  34730. };
  34731. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34732. if (useScreen === void 0) { useScreen = false; }
  34733. if (!useScreen && this._currentRenderTarget) {
  34734. return this._currentRenderTarget.width;
  34735. }
  34736. return this._options.renderWidth;
  34737. };
  34738. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34739. if (useScreen === void 0) { useScreen = false; }
  34740. if (!useScreen && this._currentRenderTarget) {
  34741. return this._currentRenderTarget.height;
  34742. }
  34743. return this._options.renderHeight;
  34744. };
  34745. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34746. this._cachedViewport = viewport;
  34747. };
  34748. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34749. return {
  34750. transformFeedback: null,
  34751. __SPECTOR_rebuildProgram: null,
  34752. isParallelCompiled: false
  34753. };
  34754. };
  34755. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34756. return [];
  34757. };
  34758. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34759. return [];
  34760. };
  34761. NullEngine.prototype.bindSamplers = function (effect) {
  34762. this._currentEffect = null;
  34763. };
  34764. NullEngine.prototype.enableEffect = function (effect) {
  34765. this._currentEffect = effect;
  34766. if (effect.onBind) {
  34767. effect.onBind(effect);
  34768. }
  34769. if (effect._onBindObservable) {
  34770. effect._onBindObservable.notifyObservers(effect);
  34771. }
  34772. };
  34773. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34774. if (zOffset === void 0) { zOffset = 0; }
  34775. if (reverseSide === void 0) { reverseSide = false; }
  34776. };
  34777. NullEngine.prototype.setIntArray = function (uniform, array) {
  34778. };
  34779. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34780. };
  34781. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34782. };
  34783. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34784. };
  34785. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34786. };
  34787. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34788. };
  34789. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34790. };
  34791. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34792. };
  34793. NullEngine.prototype.setArray = function (uniform, array) {
  34794. };
  34795. NullEngine.prototype.setArray2 = function (uniform, array) {
  34796. };
  34797. NullEngine.prototype.setArray3 = function (uniform, array) {
  34798. };
  34799. NullEngine.prototype.setArray4 = function (uniform, array) {
  34800. };
  34801. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34802. };
  34803. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34804. };
  34805. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34806. };
  34807. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34808. };
  34809. NullEngine.prototype.setFloat = function (uniform, value) {
  34810. };
  34811. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34812. };
  34813. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34814. };
  34815. NullEngine.prototype.setBool = function (uniform, bool) {
  34816. };
  34817. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34818. };
  34819. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34820. };
  34821. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34822. };
  34823. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34824. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34825. if (this._alphaMode === mode) {
  34826. return;
  34827. }
  34828. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34829. if (!noDepthWriteChange) {
  34830. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34831. }
  34832. this._alphaMode = mode;
  34833. };
  34834. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34835. };
  34836. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34837. if (this.preventCacheWipeBetweenFrames) {
  34838. return;
  34839. }
  34840. this.resetTextureCache();
  34841. this._currentEffect = null;
  34842. if (bruteForce) {
  34843. this._currentProgram = null;
  34844. this._stencilState.reset();
  34845. this._depthCullingState.reset();
  34846. this._alphaState.reset();
  34847. }
  34848. this._cachedVertexBuffers = null;
  34849. this._cachedIndexBuffer = null;
  34850. this._cachedEffectForVertexBuffers = null;
  34851. };
  34852. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  34853. };
  34854. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  34855. };
  34856. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  34857. };
  34858. /** @hidden */
  34859. NullEngine.prototype._createTexture = function () {
  34860. return {};
  34861. };
  34862. /** @hidden */
  34863. NullEngine.prototype._releaseTexture = function (texture) {
  34864. };
  34865. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  34866. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34867. if (onLoad === void 0) { onLoad = null; }
  34868. if (onError === void 0) { onError = null; }
  34869. if (buffer === void 0) { buffer = null; }
  34870. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  34871. var url = String(urlArg);
  34872. texture.url = url;
  34873. texture.generateMipMaps = !noMipmap;
  34874. texture.samplingMode = samplingMode;
  34875. texture.invertY = invertY;
  34876. texture.baseWidth = this._options.textureSize;
  34877. texture.baseHeight = this._options.textureSize;
  34878. texture.width = this._options.textureSize;
  34879. texture.height = this._options.textureSize;
  34880. if (format) {
  34881. texture.format = format;
  34882. }
  34883. texture.isReady = true;
  34884. if (onLoad) {
  34885. onLoad();
  34886. }
  34887. this._internalTexturesCache.push(texture);
  34888. return texture;
  34889. };
  34890. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  34891. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  34892. if (options !== undefined && typeof options === "object") {
  34893. fullOptions.generateMipMaps = options.generateMipMaps;
  34894. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34895. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34896. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  34897. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34898. }
  34899. else {
  34900. fullOptions.generateMipMaps = options;
  34901. fullOptions.generateDepthBuffer = true;
  34902. fullOptions.generateStencilBuffer = false;
  34903. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34904. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34905. }
  34906. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34907. var width = size.width || size;
  34908. var height = size.height || size;
  34909. texture._depthStencilBuffer = {};
  34910. texture._framebuffer = {};
  34911. texture.baseWidth = width;
  34912. texture.baseHeight = height;
  34913. texture.width = width;
  34914. texture.height = height;
  34915. texture.isReady = true;
  34916. texture.samples = 1;
  34917. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34918. texture.samplingMode = fullOptions.samplingMode;
  34919. texture.type = fullOptions.type;
  34920. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34921. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34922. this._internalTexturesCache.push(texture);
  34923. return texture;
  34924. };
  34925. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34926. texture.samplingMode = samplingMode;
  34927. };
  34928. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34929. if (this._currentRenderTarget) {
  34930. this.unBindFramebuffer(this._currentRenderTarget);
  34931. }
  34932. this._currentRenderTarget = texture;
  34933. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34934. if (this._cachedViewport && !forceFullscreenViewport) {
  34935. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34936. }
  34937. };
  34938. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34939. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34940. this._currentRenderTarget = null;
  34941. if (onBeforeUnbind) {
  34942. if (texture._MSAAFramebuffer) {
  34943. this._currentFramebuffer = texture._framebuffer;
  34944. }
  34945. onBeforeUnbind();
  34946. }
  34947. this._currentFramebuffer = null;
  34948. };
  34949. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34950. var vbo = {
  34951. capacity: 1,
  34952. references: 1,
  34953. is32Bits: false
  34954. };
  34955. return vbo;
  34956. };
  34957. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34958. if (premulAlpha === void 0) { premulAlpha = false; }
  34959. };
  34960. NullEngine.prototype.areAllEffectsReady = function () {
  34961. return true;
  34962. };
  34963. /**
  34964. * @hidden
  34965. * Get the current error code of the webGL context
  34966. * @returns the error code
  34967. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34968. */
  34969. NullEngine.prototype.getError = function () {
  34970. return 0;
  34971. };
  34972. /** @hidden */
  34973. NullEngine.prototype._getUnpackAlignement = function () {
  34974. return 1;
  34975. };
  34976. /** @hidden */
  34977. NullEngine.prototype._unpackFlipY = function (value) {
  34978. };
  34979. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34980. if (offset === void 0) { offset = 0; }
  34981. };
  34982. /**
  34983. * Updates a dynamic vertex buffer.
  34984. * @param vertexBuffer the vertex buffer to update
  34985. * @param data the data used to update the vertex buffer
  34986. * @param byteOffset the byte offset of the data (optional)
  34987. * @param byteLength the byte length of the data (optional)
  34988. */
  34989. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34990. };
  34991. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34992. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34993. this._boundTexturesCache[this._activeChannel] = texture;
  34994. return true;
  34995. }
  34996. return false;
  34997. };
  34998. /** @hidden */
  34999. NullEngine.prototype._bindTexture = function (channel, texture) {
  35000. if (channel < 0) {
  35001. return;
  35002. }
  35003. this._bindTextureDirectly(0, texture);
  35004. };
  35005. /** @hidden */
  35006. NullEngine.prototype._releaseBuffer = function (buffer) {
  35007. buffer.references--;
  35008. if (buffer.references === 0) {
  35009. return true;
  35010. }
  35011. return false;
  35012. };
  35013. NullEngine.prototype.releaseEffects = function () {
  35014. };
  35015. NullEngine.prototype.displayLoadingUI = function () {
  35016. };
  35017. NullEngine.prototype.hideLoadingUI = function () {
  35018. };
  35019. /** @hidden */
  35020. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  35021. if (faceIndex === void 0) { faceIndex = 0; }
  35022. if (lod === void 0) { lod = 0; }
  35023. };
  35024. /** @hidden */
  35025. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  35026. if (faceIndex === void 0) { faceIndex = 0; }
  35027. if (lod === void 0) { lod = 0; }
  35028. };
  35029. /** @hidden */
  35030. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  35031. if (faceIndex === void 0) { faceIndex = 0; }
  35032. if (lod === void 0) { lod = 0; }
  35033. };
  35034. /** @hidden */
  35035. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  35036. if (faceIndex === void 0) { faceIndex = 0; }
  35037. if (lod === void 0) { lod = 0; }
  35038. };
  35039. return NullEngine;
  35040. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  35041. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  35042. /***/ }),
  35043. /***/ "./Events/clipboardEvents.ts":
  35044. /*!***********************************!*\
  35045. !*** ./Events/clipboardEvents.ts ***!
  35046. \***********************************/
  35047. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  35048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35049. "use strict";
  35050. __webpack_require__.r(__webpack_exports__);
  35051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  35052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  35053. /**
  35054. * Gather the list of clipboard event types as constants.
  35055. */
  35056. var ClipboardEventTypes = /** @class */ (function () {
  35057. function ClipboardEventTypes() {
  35058. }
  35059. /**
  35060. * The clipboard event is fired when a copy command is active (pressed).
  35061. */
  35062. ClipboardEventTypes.COPY = 0x01; //
  35063. /**
  35064. * The clipboard event is fired when a cut command is active (pressed).
  35065. */
  35066. ClipboardEventTypes.CUT = 0x02;
  35067. /**
  35068. * The clipboard event is fired when a paste command is active (pressed).
  35069. */
  35070. ClipboardEventTypes.PASTE = 0x03;
  35071. return ClipboardEventTypes;
  35072. }());
  35073. /**
  35074. * This class is used to store clipboard related info for the onClipboardObservable event.
  35075. */
  35076. var ClipboardInfo = /** @class */ (function () {
  35077. /**
  35078. *Creates an instance of ClipboardInfo.
  35079. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  35080. * @param event Defines the related dom event
  35081. */
  35082. function ClipboardInfo(
  35083. /**
  35084. * Defines the type of event (BABYLON.ClipboardEventTypes)
  35085. */
  35086. type,
  35087. /**
  35088. * Defines the related dom event
  35089. */
  35090. event) {
  35091. this.type = type;
  35092. this.event = event;
  35093. }
  35094. /**
  35095. * Get the clipboard event's type from the keycode.
  35096. * @param keyCode Defines the keyCode for the current keyboard event.
  35097. * @return {number}
  35098. */
  35099. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  35100. var charCode = keyCode;
  35101. //TODO: add codes for extended ASCII
  35102. switch (charCode) {
  35103. case 67: return ClipboardEventTypes.COPY;
  35104. case 86: return ClipboardEventTypes.PASTE;
  35105. case 88: return ClipboardEventTypes.CUT;
  35106. default: return -1;
  35107. }
  35108. };
  35109. return ClipboardInfo;
  35110. }());
  35111. /***/ }),
  35112. /***/ "./Events/index.ts":
  35113. /*!*************************!*\
  35114. !*** ./Events/index.ts ***!
  35115. \*************************/
  35116. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  35117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35118. "use strict";
  35119. __webpack_require__.r(__webpack_exports__);
  35120. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  35121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  35122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  35123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  35124. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  35125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  35126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  35127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  35128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  35129. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  35130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  35131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  35132. /***/ }),
  35133. /***/ "./Events/keyboardEvents.ts":
  35134. /*!**********************************!*\
  35135. !*** ./Events/keyboardEvents.ts ***!
  35136. \**********************************/
  35137. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  35138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35139. "use strict";
  35140. __webpack_require__.r(__webpack_exports__);
  35141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  35142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  35143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  35144. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35145. /**
  35146. * Gather the list of keyboard event types as constants.
  35147. */
  35148. var KeyboardEventTypes = /** @class */ (function () {
  35149. function KeyboardEventTypes() {
  35150. }
  35151. /**
  35152. * The keydown event is fired when a key becomes active (pressed).
  35153. */
  35154. KeyboardEventTypes.KEYDOWN = 0x01;
  35155. /**
  35156. * The keyup event is fired when a key has been released.
  35157. */
  35158. KeyboardEventTypes.KEYUP = 0x02;
  35159. return KeyboardEventTypes;
  35160. }());
  35161. /**
  35162. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35163. */
  35164. var KeyboardInfo = /** @class */ (function () {
  35165. /**
  35166. * Instantiates a new keyboard info.
  35167. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35168. * @param type Defines the type of event (KeyboardEventTypes)
  35169. * @param event Defines the related dom event
  35170. */
  35171. function KeyboardInfo(
  35172. /**
  35173. * Defines the type of event (KeyboardEventTypes)
  35174. */
  35175. type,
  35176. /**
  35177. * Defines the related dom event
  35178. */
  35179. event) {
  35180. this.type = type;
  35181. this.event = event;
  35182. }
  35183. return KeyboardInfo;
  35184. }());
  35185. /**
  35186. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35187. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  35188. */
  35189. var KeyboardInfoPre = /** @class */ (function (_super) {
  35190. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  35191. /**
  35192. * Instantiates a new keyboard pre info.
  35193. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35194. * @param type Defines the type of event (KeyboardEventTypes)
  35195. * @param event Defines the related dom event
  35196. */
  35197. function KeyboardInfoPre(
  35198. /**
  35199. * Defines the type of event (KeyboardEventTypes)
  35200. */
  35201. type,
  35202. /**
  35203. * Defines the related dom event
  35204. */
  35205. event) {
  35206. var _this = _super.call(this, type, event) || this;
  35207. _this.type = type;
  35208. _this.event = event;
  35209. _this.skipOnPointerObservable = false;
  35210. return _this;
  35211. }
  35212. return KeyboardInfoPre;
  35213. }(KeyboardInfo));
  35214. /***/ }),
  35215. /***/ "./Events/pointerEvents.ts":
  35216. /*!*********************************!*\
  35217. !*** ./Events/pointerEvents.ts ***!
  35218. \*********************************/
  35219. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  35220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35221. "use strict";
  35222. __webpack_require__.r(__webpack_exports__);
  35223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  35224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  35225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  35226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  35227. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35228. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  35229. /**
  35230. * Gather the list of pointer event types as constants.
  35231. */
  35232. var PointerEventTypes = /** @class */ (function () {
  35233. function PointerEventTypes() {
  35234. }
  35235. /**
  35236. * 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.
  35237. */
  35238. PointerEventTypes.POINTERDOWN = 0x01;
  35239. /**
  35240. * The pointerup event is fired when a pointer is no longer active.
  35241. */
  35242. PointerEventTypes.POINTERUP = 0x02;
  35243. /**
  35244. * The pointermove event is fired when a pointer changes coordinates.
  35245. */
  35246. PointerEventTypes.POINTERMOVE = 0x04;
  35247. /**
  35248. * The pointerwheel event is fired when a mouse wheel has been rotated.
  35249. */
  35250. PointerEventTypes.POINTERWHEEL = 0x08;
  35251. /**
  35252. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  35253. */
  35254. PointerEventTypes.POINTERPICK = 0x10;
  35255. /**
  35256. * The pointertap event is fired when a the object has been touched and released without drag.
  35257. */
  35258. PointerEventTypes.POINTERTAP = 0x20;
  35259. /**
  35260. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  35261. */
  35262. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  35263. return PointerEventTypes;
  35264. }());
  35265. /**
  35266. * Base class of pointer info types.
  35267. */
  35268. var PointerInfoBase = /** @class */ (function () {
  35269. /**
  35270. * Instantiates the base class of pointers info.
  35271. * @param type Defines the type of event (PointerEventTypes)
  35272. * @param event Defines the related dom event
  35273. */
  35274. function PointerInfoBase(
  35275. /**
  35276. * Defines the type of event (PointerEventTypes)
  35277. */
  35278. type,
  35279. /**
  35280. * Defines the related dom event
  35281. */
  35282. event) {
  35283. this.type = type;
  35284. this.event = event;
  35285. }
  35286. return PointerInfoBase;
  35287. }());
  35288. /**
  35289. * This class is used to store pointer related info for the onPrePointerObservable event.
  35290. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  35291. */
  35292. var PointerInfoPre = /** @class */ (function (_super) {
  35293. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  35294. /**
  35295. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  35296. * @param type Defines the type of event (PointerEventTypes)
  35297. * @param event Defines the related dom event
  35298. * @param localX Defines the local x coordinates of the pointer when the event occured
  35299. * @param localY Defines the local y coordinates of the pointer when the event occured
  35300. */
  35301. function PointerInfoPre(type, event, localX, localY) {
  35302. var _this = _super.call(this, type, event) || this;
  35303. /**
  35304. * Ray from a pointer if availible (eg. 6dof controller)
  35305. */
  35306. _this.ray = null;
  35307. _this.skipOnPointerObservable = false;
  35308. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  35309. return _this;
  35310. }
  35311. return PointerInfoPre;
  35312. }(PointerInfoBase));
  35313. /**
  35314. * This type contains all the data related to a pointer event in Babylon.js.
  35315. * 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.
  35316. */
  35317. var PointerInfo = /** @class */ (function (_super) {
  35318. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  35319. /**
  35320. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  35321. * @param type Defines the type of event (PointerEventTypes)
  35322. * @param event Defines the related dom event
  35323. * @param pickInfo Defines the picking info associated to the info (if any)\
  35324. */
  35325. function PointerInfo(type, event,
  35326. /**
  35327. * Defines the picking info associated to the info (if any)\
  35328. */
  35329. pickInfo) {
  35330. var _this = _super.call(this, type, event) || this;
  35331. _this.pickInfo = pickInfo;
  35332. return _this;
  35333. }
  35334. return PointerInfo;
  35335. }(PointerInfoBase));
  35336. /***/ }),
  35337. /***/ "./Gamepads/Controllers/daydreamController.ts":
  35338. /*!****************************************************!*\
  35339. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  35340. \****************************************************/
  35341. /*! exports provided: DaydreamController */
  35342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35343. "use strict";
  35344. __webpack_require__.r(__webpack_exports__);
  35345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  35346. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35347. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35348. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35349. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35350. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35351. /**
  35352. * Google Daydream controller
  35353. */
  35354. var DaydreamController = /** @class */ (function (_super) {
  35355. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  35356. /**
  35357. * Creates a new DaydreamController from a gamepad
  35358. * @param vrGamepad the gamepad that the controller should be created from
  35359. */
  35360. function DaydreamController(vrGamepad) {
  35361. var _this = _super.call(this, vrGamepad) || this;
  35362. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  35363. return _this;
  35364. }
  35365. /**
  35366. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35367. * @param scene scene in which to add meshes
  35368. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35369. */
  35370. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35371. var _this = this;
  35372. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  35373. _this._defaultModel = newMeshes[1];
  35374. _this.attachToMesh(_this._defaultModel);
  35375. if (meshLoaded) {
  35376. meshLoaded(_this._defaultModel);
  35377. }
  35378. });
  35379. };
  35380. /**
  35381. * Called once for each button that changed state since the last frame
  35382. * @param buttonIdx Which button index changed
  35383. * @param state New state of the button
  35384. * @param changes Which properties on the state changed since last frame
  35385. */
  35386. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35387. // Daydream controller only has 1 GamepadButton (on the trackpad).
  35388. if (buttonIdx === 0) {
  35389. var observable = this.onTriggerStateChangedObservable;
  35390. if (observable) {
  35391. observable.notifyObservers(state);
  35392. }
  35393. }
  35394. else {
  35395. // If the app or home buttons are ever made available
  35396. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  35397. }
  35398. };
  35399. /**
  35400. * Base Url for the controller model.
  35401. */
  35402. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35403. /**
  35404. * File name for the controller model.
  35405. */
  35406. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  35407. /**
  35408. * Gamepad Id prefix used to identify Daydream Controller.
  35409. */
  35410. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  35411. return DaydreamController;
  35412. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35413. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35414. canCreate: function (gamepadInfo) {
  35415. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  35416. },
  35417. create: function (gamepadInfo) {
  35418. return new DaydreamController(gamepadInfo);
  35419. }
  35420. });
  35421. /***/ }),
  35422. /***/ "./Gamepads/Controllers/gearVRController.ts":
  35423. /*!**************************************************!*\
  35424. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  35425. \**************************************************/
  35426. /*! exports provided: GearVRController */
  35427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35428. "use strict";
  35429. __webpack_require__.r(__webpack_exports__);
  35430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  35431. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35432. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35433. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35434. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35435. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35436. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35437. /**
  35438. * Gear VR Controller
  35439. */
  35440. var GearVRController = /** @class */ (function (_super) {
  35441. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  35442. /**
  35443. * Creates a new GearVRController from a gamepad
  35444. * @param vrGamepad the gamepad that the controller should be created from
  35445. */
  35446. function GearVRController(vrGamepad) {
  35447. var _this = _super.call(this, vrGamepad) || this;
  35448. _this._buttonIndexToObservableNameMap = [
  35449. 'onTrackpadChangedObservable',
  35450. 'onTriggerStateChangedObservable' // Trigger
  35451. ];
  35452. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  35453. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  35454. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  35455. _this._disableTrackPosition(_this._calculatedPosition);
  35456. return _this;
  35457. }
  35458. /**
  35459. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35460. * @param scene scene in which to add meshes
  35461. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35462. */
  35463. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35464. var _this = this;
  35465. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  35466. // Offset the controller so it will rotate around the users wrist
  35467. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  35468. newMeshes[1].parent = mesh;
  35469. newMeshes[1].position.z = -0.15;
  35470. _this._defaultModel = mesh;
  35471. _this.attachToMesh(_this._defaultModel);
  35472. if (meshLoaded) {
  35473. meshLoaded(_this._defaultModel);
  35474. }
  35475. });
  35476. };
  35477. /**
  35478. * Called once for each button that changed state since the last frame
  35479. * @param buttonIdx Which button index changed
  35480. * @param state New state of the button
  35481. * @param changes Which properties on the state changed since last frame
  35482. */
  35483. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35484. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  35485. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  35486. // Only emit events for buttons that we know how to map from index to observable
  35487. var observable = this[observableName];
  35488. if (observable) {
  35489. observable.notifyObservers(state);
  35490. }
  35491. }
  35492. };
  35493. /**
  35494. * Base Url for the controller model.
  35495. */
  35496. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35497. /**
  35498. * File name for the controller model.
  35499. */
  35500. GearVRController.MODEL_FILENAME = 'generic.babylon';
  35501. /**
  35502. * Gamepad Id prefix used to identify this controller.
  35503. */
  35504. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  35505. return GearVRController;
  35506. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  35507. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35508. canCreate: function (gamepadInfo) {
  35509. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  35510. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  35511. },
  35512. create: function (gamepadInfo) {
  35513. return new GearVRController(gamepadInfo);
  35514. }
  35515. });
  35516. /***/ }),
  35517. /***/ "./Gamepads/Controllers/genericController.ts":
  35518. /*!***************************************************!*\
  35519. !*** ./Gamepads/Controllers/genericController.ts ***!
  35520. \***************************************************/
  35521. /*! exports provided: GenericController */
  35522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35523. "use strict";
  35524. __webpack_require__.r(__webpack_exports__);
  35525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  35526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35527. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35528. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35529. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35530. /**
  35531. * Generic Controller
  35532. */
  35533. var GenericController = /** @class */ (function (_super) {
  35534. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  35535. /**
  35536. * Creates a new GenericController from a gamepad
  35537. * @param vrGamepad the gamepad that the controller should be created from
  35538. */
  35539. function GenericController(vrGamepad) {
  35540. return _super.call(this, vrGamepad) || this;
  35541. }
  35542. /**
  35543. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35544. * @param scene scene in which to add meshes
  35545. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35546. */
  35547. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35548. var _this = this;
  35549. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  35550. _this._defaultModel = newMeshes[1];
  35551. _this.attachToMesh(_this._defaultModel);
  35552. if (meshLoaded) {
  35553. meshLoaded(_this._defaultModel);
  35554. }
  35555. });
  35556. };
  35557. /**
  35558. * Called once for each button that changed state since the last frame
  35559. * @param buttonIdx Which button index changed
  35560. * @param state New state of the button
  35561. * @param changes Which properties on the state changed since last frame
  35562. */
  35563. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35564. console.log("Button id: " + buttonIdx + "state: ");
  35565. console.dir(state);
  35566. };
  35567. /**
  35568. * Base Url for the controller model.
  35569. */
  35570. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35571. /**
  35572. * File name for the controller model.
  35573. */
  35574. GenericController.MODEL_FILENAME = 'generic.babylon';
  35575. return GenericController;
  35576. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35577. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  35578. /***/ }),
  35579. /***/ "./Gamepads/Controllers/index.ts":
  35580. /*!***************************************!*\
  35581. !*** ./Gamepads/Controllers/index.ts ***!
  35582. \***************************************/
  35583. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  35584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35585. "use strict";
  35586. __webpack_require__.r(__webpack_exports__);
  35587. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  35588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35589. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  35590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  35591. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  35593. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  35594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  35595. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  35597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  35598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  35599. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  35600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  35601. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  35603. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  35604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  35605. /***/ }),
  35606. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  35607. /*!*******************************************************!*\
  35608. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  35609. \*******************************************************/
  35610. /*! exports provided: OculusTouchController */
  35611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35612. "use strict";
  35613. __webpack_require__.r(__webpack_exports__);
  35614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  35615. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35616. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35617. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35618. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35619. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35620. /**
  35621. * Oculus Touch Controller
  35622. */
  35623. var OculusTouchController = /** @class */ (function (_super) {
  35624. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  35625. /**
  35626. * Creates a new OculusTouchController from a gamepad
  35627. * @param vrGamepad the gamepad that the controller should be created from
  35628. */
  35629. function OculusTouchController(vrGamepad) {
  35630. var _this = _super.call(this, vrGamepad) || this;
  35631. /**
  35632. * Fired when the secondary trigger on this controller is modified
  35633. */
  35634. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35635. /**
  35636. * Fired when the thumb rest on this controller is modified
  35637. */
  35638. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35639. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  35640. return _this;
  35641. }
  35642. /**
  35643. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35644. * @param scene scene in which to add meshes
  35645. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35646. */
  35647. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35648. var _this = this;
  35649. var meshName;
  35650. // Hand
  35651. if (this.hand === 'left') {
  35652. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  35653. }
  35654. else { // Right is the default if no hand is specified
  35655. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  35656. }
  35657. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  35658. /*
  35659. Parent Mesh name: oculus_touch_left
  35660. - body
  35661. - trigger
  35662. - thumbstick
  35663. - grip
  35664. - button_y
  35665. - button_x
  35666. - button_enter
  35667. */
  35668. _this._defaultModel = newMeshes[1];
  35669. _this.attachToMesh(_this._defaultModel);
  35670. if (meshLoaded) {
  35671. meshLoaded(_this._defaultModel);
  35672. }
  35673. });
  35674. };
  35675. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  35676. /**
  35677. * Fired when the A button on this controller is modified
  35678. */
  35679. get: function () {
  35680. if (this.hand === 'right') {
  35681. return this.onMainButtonStateChangedObservable;
  35682. }
  35683. else {
  35684. throw new Error('No A button on left hand');
  35685. }
  35686. },
  35687. enumerable: true,
  35688. configurable: true
  35689. });
  35690. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  35691. /**
  35692. * Fired when the B button on this controller is modified
  35693. */
  35694. get: function () {
  35695. if (this.hand === 'right') {
  35696. return this.onSecondaryButtonStateChangedObservable;
  35697. }
  35698. else {
  35699. throw new Error('No B button on left hand');
  35700. }
  35701. },
  35702. enumerable: true,
  35703. configurable: true
  35704. });
  35705. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  35706. /**
  35707. * Fired when the X button on this controller is modified
  35708. */
  35709. get: function () {
  35710. if (this.hand === 'left') {
  35711. return this.onMainButtonStateChangedObservable;
  35712. }
  35713. else {
  35714. throw new Error('No X button on right hand');
  35715. }
  35716. },
  35717. enumerable: true,
  35718. configurable: true
  35719. });
  35720. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  35721. /**
  35722. * Fired when the Y button on this controller is modified
  35723. */
  35724. get: function () {
  35725. if (this.hand === 'left') {
  35726. return this.onSecondaryButtonStateChangedObservable;
  35727. }
  35728. else {
  35729. throw new Error('No Y button on right hand');
  35730. }
  35731. },
  35732. enumerable: true,
  35733. configurable: true
  35734. });
  35735. /**
  35736. * Called once for each button that changed state since the last frame
  35737. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35738. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35739. * 2) secondary trigger (same)
  35740. * 3) A (right) X (left), touch, pressed = value
  35741. * 4) B / Y
  35742. * 5) thumb rest
  35743. * @param buttonIdx Which button index changed
  35744. * @param state New state of the button
  35745. * @param changes Which properties on the state changed since last frame
  35746. */
  35747. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35748. var notifyObject = state; //{ state: state, changes: changes };
  35749. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35750. switch (buttonIdx) {
  35751. case 0:
  35752. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35753. return;
  35754. case 1: // index trigger
  35755. if (this._defaultModel) {
  35756. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35757. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35758. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35759. }
  35760. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35761. return;
  35762. case 2: // secondary trigger
  35763. if (this._defaultModel) {
  35764. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35765. }
  35766. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35767. return;
  35768. case 3:
  35769. if (this._defaultModel) {
  35770. if (notifyObject.pressed) {
  35771. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35772. }
  35773. else {
  35774. (this._defaultModel.getChildren()[1]).position.y = 0;
  35775. }
  35776. }
  35777. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35778. return;
  35779. case 4:
  35780. if (this._defaultModel) {
  35781. if (notifyObject.pressed) {
  35782. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35783. }
  35784. else {
  35785. (this._defaultModel.getChildren()[2]).position.y = 0;
  35786. }
  35787. }
  35788. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35789. return;
  35790. case 5:
  35791. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35792. return;
  35793. }
  35794. };
  35795. /**
  35796. * Base Url for the controller model.
  35797. */
  35798. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35799. /**
  35800. * File name for the left controller model.
  35801. */
  35802. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35803. /**
  35804. * File name for the right controller model.
  35805. */
  35806. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35807. return OculusTouchController;
  35808. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35809. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35810. canCreate: function (gamepadInfo) {
  35811. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35812. },
  35813. create: function (gamepadInfo) {
  35814. return new OculusTouchController(gamepadInfo);
  35815. }
  35816. });
  35817. /***/ }),
  35818. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35819. /*!*******************************************************!*\
  35820. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35821. \*******************************************************/
  35822. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35824. "use strict";
  35825. __webpack_require__.r(__webpack_exports__);
  35826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35827. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35829. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35830. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35831. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35832. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35833. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35834. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35835. /**
  35836. * Defines the types of pose enabled controllers that are supported
  35837. */
  35838. var PoseEnabledControllerType;
  35839. (function (PoseEnabledControllerType) {
  35840. /**
  35841. * HTC Vive
  35842. */
  35843. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  35844. /**
  35845. * Oculus Rift
  35846. */
  35847. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  35848. /**
  35849. * Windows mixed reality
  35850. */
  35851. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  35852. /**
  35853. * Samsung gear VR
  35854. */
  35855. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  35856. /**
  35857. * Google Daydream
  35858. */
  35859. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  35860. /**
  35861. * Generic
  35862. */
  35863. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  35864. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  35865. /**
  35866. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35867. */
  35868. var PoseEnabledControllerHelper = /** @class */ (function () {
  35869. function PoseEnabledControllerHelper() {
  35870. }
  35871. /**
  35872. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35873. * @param vrGamepad the gamepad to initialized
  35874. * @returns a vr controller of the type the gamepad identified as
  35875. */
  35876. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  35877. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  35878. var factory = _a[_i];
  35879. if (factory.canCreate(vrGamepad)) {
  35880. return factory.create(vrGamepad);
  35881. }
  35882. }
  35883. if (this._DefaultControllerFactory) {
  35884. return this._DefaultControllerFactory(vrGamepad);
  35885. }
  35886. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  35887. };
  35888. /** @hidden */
  35889. PoseEnabledControllerHelper._ControllerFactories = [];
  35890. /** @hidden */
  35891. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  35892. return PoseEnabledControllerHelper;
  35893. }());
  35894. /**
  35895. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35896. */
  35897. var PoseEnabledController = /** @class */ (function (_super) {
  35898. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  35899. /**
  35900. * Creates a new PoseEnabledController from a gamepad
  35901. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35902. */
  35903. function PoseEnabledController(browserGamepad) {
  35904. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  35905. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  35906. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35907. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35908. /**
  35909. * The device position in babylon space
  35910. */
  35911. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35912. /**
  35913. * The device rotation in babylon space
  35914. */
  35915. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35916. /**
  35917. * The scale factor of the device in babylon space
  35918. */
  35919. _this.deviceScaleFactor = 1;
  35920. // Used to convert 6dof controllers to 3dof
  35921. _this._trackPosition = true;
  35922. _this._maxRotationDistFromHeadset = Math.PI / 5;
  35923. _this._draggedRoomRotation = 0;
  35924. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35925. /**
  35926. * Internal, matrix used to convert room space to babylon space
  35927. * @hidden
  35928. */
  35929. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35930. /**
  35931. * Node to be used when casting a ray from the controller
  35932. * @hidden
  35933. */
  35934. _this._pointingPoseNode = null;
  35935. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35936. /**
  35937. * @hidden
  35938. */
  35939. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35940. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35941. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35942. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35943. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35944. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35945. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35946. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35947. return _this;
  35948. }
  35949. /**
  35950. * @hidden
  35951. */
  35952. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35953. if (this._trackPosition) {
  35954. this._calculatedPosition.copyFrom(fixedPosition);
  35955. this._trackPosition = false;
  35956. }
  35957. };
  35958. /**
  35959. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35960. */
  35961. PoseEnabledController.prototype.update = function () {
  35962. _super.prototype.update.call(this);
  35963. this._updatePoseAndMesh();
  35964. };
  35965. /**
  35966. * Updates only the pose device and mesh without doing any button event checking
  35967. */
  35968. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35969. var pose = this.browserGamepad.pose;
  35970. this.updateFromDevice(pose);
  35971. 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) {
  35972. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35973. camera._computeDevicePosition();
  35974. this._deviceToWorld.setTranslation(camera.devicePosition);
  35975. if (camera.deviceRotationQuaternion) {
  35976. var camera = camera;
  35977. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35978. // Find the radian distance away that the headset is from the controllers rotation
  35979. 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));
  35980. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35981. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35982. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35983. this._draggedRoomRotation += rotationAmount;
  35984. // Rotate controller around headset
  35985. var sin = Math.sin(-rotationAmount);
  35986. var cos = Math.cos(-rotationAmount);
  35987. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35988. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35989. }
  35990. }
  35991. }
  35992. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35993. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35994. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35995. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35996. if (this._mesh) {
  35997. this._mesh.position.copyFrom(this.devicePosition);
  35998. if (this._mesh.rotationQuaternion) {
  35999. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  36000. }
  36001. }
  36002. };
  36003. /**
  36004. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  36005. * @param poseData raw pose fromthe device
  36006. */
  36007. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  36008. if (poseData) {
  36009. this.rawPose = poseData;
  36010. if (poseData.position) {
  36011. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  36012. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  36013. this._deviceRoomPosition.z *= -1;
  36014. }
  36015. if (this._trackPosition) {
  36016. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  36017. }
  36018. this._calculatedPosition.addInPlace(this.position);
  36019. }
  36020. var pose = this.rawPose;
  36021. if (poseData.orientation && pose.orientation) {
  36022. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  36023. if (this._mesh) {
  36024. if (this._mesh.getScene().useRightHandedSystem) {
  36025. this._deviceRoomRotationQuaternion.z *= -1;
  36026. this._deviceRoomRotationQuaternion.w *= -1;
  36027. }
  36028. else {
  36029. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  36030. }
  36031. }
  36032. // if the camera is set, rotate to the camera's rotation
  36033. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  36034. }
  36035. }
  36036. };
  36037. /**
  36038. * Attaches a mesh to the controller
  36039. * @param mesh the mesh to be attached
  36040. */
  36041. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  36042. if (this._mesh) {
  36043. this._mesh.parent = null;
  36044. }
  36045. this._mesh = mesh;
  36046. if (this._poseControlledCamera) {
  36047. this._mesh.parent = this._poseControlledCamera;
  36048. }
  36049. if (!this._mesh.rotationQuaternion) {
  36050. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36051. }
  36052. // 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
  36053. this._updatePoseAndMesh();
  36054. if (this._pointingPoseNode) {
  36055. var parents = [];
  36056. var obj = this._pointingPoseNode;
  36057. while (obj.parent) {
  36058. parents.push(obj.parent);
  36059. obj = obj.parent;
  36060. }
  36061. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  36062. }
  36063. this._meshAttachedObservable.notifyObservers(mesh);
  36064. };
  36065. /**
  36066. * Attaches the controllers mesh to a camera
  36067. * @param camera the camera the mesh should be attached to
  36068. */
  36069. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  36070. this._poseControlledCamera = camera;
  36071. if (this._mesh) {
  36072. this._mesh.parent = this._poseControlledCamera;
  36073. }
  36074. };
  36075. /**
  36076. * Disposes of the controller
  36077. */
  36078. PoseEnabledController.prototype.dispose = function () {
  36079. if (this._mesh) {
  36080. this._mesh.dispose();
  36081. }
  36082. this._mesh = null;
  36083. _super.prototype.dispose.call(this);
  36084. };
  36085. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  36086. /**
  36087. * The mesh that is attached to the controller
  36088. */
  36089. get: function () {
  36090. return this._mesh;
  36091. },
  36092. enumerable: true,
  36093. configurable: true
  36094. });
  36095. /**
  36096. * Gets the ray of the controller in the direction the controller is pointing
  36097. * @param length the length the resulting ray should be
  36098. * @returns a ray in the direction the controller is pointing
  36099. */
  36100. PoseEnabledController.prototype.getForwardRay = function (length) {
  36101. if (length === void 0) { length = 100; }
  36102. if (!this.mesh) {
  36103. 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);
  36104. }
  36105. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  36106. var origin = m.getTranslation();
  36107. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  36108. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  36109. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  36110. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  36111. };
  36112. /**
  36113. * Name of the child mesh that can be used to cast a ray from the controller
  36114. */
  36115. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  36116. return PoseEnabledController;
  36117. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  36118. /***/ }),
  36119. /***/ "./Gamepads/Controllers/viveController.ts":
  36120. /*!************************************************!*\
  36121. !*** ./Gamepads/Controllers/viveController.ts ***!
  36122. \************************************************/
  36123. /*! exports provided: ViveController */
  36124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36125. "use strict";
  36126. __webpack_require__.r(__webpack_exports__);
  36127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  36128. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36129. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36130. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36131. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36132. /**
  36133. * Vive Controller
  36134. */
  36135. var ViveController = /** @class */ (function (_super) {
  36136. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  36137. /**
  36138. * Creates a new ViveController from a gamepad
  36139. * @param vrGamepad the gamepad that the controller should be created from
  36140. */
  36141. function ViveController(vrGamepad) {
  36142. var _this = _super.call(this, vrGamepad) || this;
  36143. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  36144. _this._invertLeftStickY = true;
  36145. return _this;
  36146. }
  36147. /**
  36148. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36149. * @param scene scene in which to add meshes
  36150. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36151. */
  36152. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  36153. var _this = this;
  36154. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  36155. /*
  36156. Parent Mesh name: ViveWand
  36157. - body
  36158. - r_gripper
  36159. - l_gripper
  36160. - menu_button
  36161. - system_button
  36162. - trackpad
  36163. - trigger
  36164. - LED
  36165. */
  36166. _this._defaultModel = newMeshes[1];
  36167. _this.attachToMesh(_this._defaultModel);
  36168. if (meshLoaded) {
  36169. meshLoaded(_this._defaultModel);
  36170. }
  36171. });
  36172. };
  36173. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  36174. /**
  36175. * Fired when the left button on this controller is modified
  36176. */
  36177. get: function () {
  36178. return this.onMainButtonStateChangedObservable;
  36179. },
  36180. enumerable: true,
  36181. configurable: true
  36182. });
  36183. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  36184. /**
  36185. * Fired when the right button on this controller is modified
  36186. */
  36187. get: function () {
  36188. return this.onMainButtonStateChangedObservable;
  36189. },
  36190. enumerable: true,
  36191. configurable: true
  36192. });
  36193. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  36194. /**
  36195. * Fired when the menu button on this controller is modified
  36196. */
  36197. get: function () {
  36198. return this.onSecondaryButtonStateChangedObservable;
  36199. },
  36200. enumerable: true,
  36201. configurable: true
  36202. });
  36203. /**
  36204. * Called once for each button that changed state since the last frame
  36205. * Vive mapping:
  36206. * 0: touchpad
  36207. * 1: trigger
  36208. * 2: left AND right buttons
  36209. * 3: menu button
  36210. * @param buttonIdx Which button index changed
  36211. * @param state New state of the button
  36212. * @param changes Which properties on the state changed since last frame
  36213. */
  36214. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36215. var notifyObject = state; //{ state: state, changes: changes };
  36216. switch (buttonIdx) {
  36217. case 0:
  36218. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  36219. return;
  36220. case 1: // index trigger
  36221. if (this._defaultModel) {
  36222. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  36223. }
  36224. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  36225. return;
  36226. case 2: // left AND right button
  36227. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  36228. return;
  36229. case 3:
  36230. if (this._defaultModel) {
  36231. if (notifyObject.pressed) {
  36232. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36233. }
  36234. else {
  36235. (this._defaultModel.getChildren()[2]).position.y = 0;
  36236. }
  36237. }
  36238. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36239. return;
  36240. }
  36241. };
  36242. /**
  36243. * Base Url for the controller model.
  36244. */
  36245. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  36246. /**
  36247. * File name for the controller model.
  36248. */
  36249. ViveController.MODEL_FILENAME = 'wand.babylon';
  36250. return ViveController;
  36251. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  36252. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36253. canCreate: function (gamepadInfo) {
  36254. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  36255. },
  36256. create: function (gamepadInfo) {
  36257. return new ViveController(gamepadInfo);
  36258. }
  36259. });
  36260. /***/ }),
  36261. /***/ "./Gamepads/Controllers/webVRController.ts":
  36262. /*!*************************************************!*\
  36263. !*** ./Gamepads/Controllers/webVRController.ts ***!
  36264. \*************************************************/
  36265. /*! exports provided: WebVRController */
  36266. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36267. "use strict";
  36268. __webpack_require__.r(__webpack_exports__);
  36269. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  36270. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36271. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36272. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36273. /**
  36274. * Defines the WebVRController object that represents controllers tracked in 3D space
  36275. */
  36276. var WebVRController = /** @class */ (function (_super) {
  36277. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  36278. /**
  36279. * Creates a new WebVRController from a gamepad
  36280. * @param vrGamepad the gamepad that the WebVRController should be created from
  36281. */
  36282. function WebVRController(vrGamepad) {
  36283. var _this = _super.call(this, vrGamepad) || this;
  36284. // Observables
  36285. /**
  36286. * Fired when the trigger state has changed
  36287. */
  36288. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36289. /**
  36290. * Fired when the main button state has changed
  36291. */
  36292. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36293. /**
  36294. * Fired when the secondary button state has changed
  36295. */
  36296. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36297. /**
  36298. * Fired when the pad state has changed
  36299. */
  36300. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36301. /**
  36302. * Fired when controllers stick values have changed
  36303. */
  36304. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36305. /**
  36306. * X and Y axis corrisponding to the controllers joystick
  36307. */
  36308. _this.pad = { x: 0, y: 0 };
  36309. // avoid GC, store state in a tmp object
  36310. _this._changes = {
  36311. pressChanged: false,
  36312. touchChanged: false,
  36313. valueChanged: false,
  36314. changed: false
  36315. };
  36316. _this._buttons = new Array(vrGamepad.buttons.length);
  36317. _this.hand = vrGamepad.hand;
  36318. return _this;
  36319. }
  36320. /**
  36321. * Fired when a controller button's state has changed
  36322. * @param callback the callback containing the button that was modified
  36323. */
  36324. WebVRController.prototype.onButtonStateChange = function (callback) {
  36325. this._onButtonStateChange = callback;
  36326. };
  36327. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  36328. /**
  36329. * The default controller model for the controller
  36330. */
  36331. get: function () {
  36332. return this._defaultModel;
  36333. },
  36334. enumerable: true,
  36335. configurable: true
  36336. });
  36337. /**
  36338. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  36339. */
  36340. WebVRController.prototype.update = function () {
  36341. _super.prototype.update.call(this);
  36342. for (var index = 0; index < this._buttons.length; index++) {
  36343. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  36344. }
  36345. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  36346. this.pad.x = this.leftStick.x;
  36347. this.pad.y = this.leftStick.y;
  36348. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  36349. }
  36350. };
  36351. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  36352. if (!newState) {
  36353. newState = {
  36354. pressed: false,
  36355. touched: false,
  36356. value: 0
  36357. };
  36358. }
  36359. if (!currentState) {
  36360. this._buttons[buttonIndex] = {
  36361. pressed: newState.pressed,
  36362. touched: newState.touched,
  36363. value: newState.value
  36364. };
  36365. return;
  36366. }
  36367. this._checkChanges(newState, currentState);
  36368. if (this._changes.changed) {
  36369. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  36370. this._handleButtonChange(buttonIndex, newState, this._changes);
  36371. }
  36372. this._buttons[buttonIndex].pressed = newState.pressed;
  36373. this._buttons[buttonIndex].touched = newState.touched;
  36374. // oculus triggers are never 0, thou not touched.
  36375. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  36376. };
  36377. WebVRController.prototype._checkChanges = function (newState, currentState) {
  36378. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  36379. this._changes.touchChanged = newState.touched !== currentState.touched;
  36380. this._changes.valueChanged = newState.value !== currentState.value;
  36381. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  36382. return this._changes;
  36383. };
  36384. /**
  36385. * Disposes of th webVRCOntroller
  36386. */
  36387. WebVRController.prototype.dispose = function () {
  36388. _super.prototype.dispose.call(this);
  36389. this.onTriggerStateChangedObservable.clear();
  36390. this.onMainButtonStateChangedObservable.clear();
  36391. this.onSecondaryButtonStateChangedObservable.clear();
  36392. this.onPadStateChangedObservable.clear();
  36393. this.onPadValuesChangedObservable.clear();
  36394. };
  36395. return WebVRController;
  36396. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  36397. /***/ }),
  36398. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  36399. /*!*********************************************************!*\
  36400. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  36401. \*********************************************************/
  36402. /*! exports provided: WindowsMotionController */
  36403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36404. "use strict";
  36405. __webpack_require__.r(__webpack_exports__);
  36406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  36407. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36408. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  36409. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36410. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36411. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  36412. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36413. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36414. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36415. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  36416. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36417. /**
  36418. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  36419. */
  36420. var LoadedMeshInfo = /** @class */ (function () {
  36421. function LoadedMeshInfo() {
  36422. /**
  36423. * Map of the button meshes contained in the controller
  36424. */
  36425. this.buttonMeshes = {};
  36426. /**
  36427. * Map of the axis meshes contained in the controller
  36428. */
  36429. this.axisMeshes = {};
  36430. }
  36431. return LoadedMeshInfo;
  36432. }());
  36433. /**
  36434. * Defines the WindowsMotionController object that the state of the windows motion controller
  36435. */
  36436. var WindowsMotionController = /** @class */ (function (_super) {
  36437. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  36438. /**
  36439. * Creates a new WindowsMotionController from a gamepad
  36440. * @param vrGamepad the gamepad that the controller should be created from
  36441. */
  36442. function WindowsMotionController(vrGamepad) {
  36443. var _this = _super.call(this, vrGamepad) || this;
  36444. _this._mapping = {
  36445. // Semantic button names
  36446. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  36447. // A mapping of the button name to glTF model node name
  36448. // that should be transformed by button value.
  36449. buttonMeshNames: {
  36450. 'trigger': 'SELECT',
  36451. 'menu': 'MENU',
  36452. 'grip': 'GRASP',
  36453. 'thumbstick': 'THUMBSTICK_PRESS',
  36454. 'trackpad': 'TOUCHPAD_PRESS'
  36455. },
  36456. // This mapping is used to translate from the Motion Controller to Babylon semantics
  36457. buttonObservableNames: {
  36458. 'trigger': 'onTriggerStateChangedObservable',
  36459. 'menu': 'onSecondaryButtonStateChangedObservable',
  36460. 'grip': 'onMainButtonStateChangedObservable',
  36461. 'thumbstick': 'onPadStateChangedObservable',
  36462. 'trackpad': 'onTrackpadChangedObservable'
  36463. },
  36464. // A mapping of the axis name to glTF model node name
  36465. // that should be transformed by axis value.
  36466. // This array mirrors the browserGamepad.axes array, such that
  36467. // the mesh corresponding to axis 0 is in this array index 0.
  36468. axisMeshNames: [
  36469. 'THUMBSTICK_X',
  36470. 'THUMBSTICK_Y',
  36471. 'TOUCHPAD_TOUCH_X',
  36472. 'TOUCHPAD_TOUCH_Y'
  36473. ],
  36474. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  36475. };
  36476. /**
  36477. * Fired when the trackpad on this controller is clicked
  36478. */
  36479. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36480. /**
  36481. * Fired when the trackpad on this controller is modified
  36482. */
  36483. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36484. /**
  36485. * The current x and y values of this controller's trackpad
  36486. */
  36487. _this.trackpad = { x: 0, y: 0 };
  36488. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  36489. _this._loadedMeshInfo = null;
  36490. return _this;
  36491. }
  36492. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  36493. /**
  36494. * Fired when the trigger on this controller is modified
  36495. */
  36496. get: function () {
  36497. return this.onTriggerStateChangedObservable;
  36498. },
  36499. enumerable: true,
  36500. configurable: true
  36501. });
  36502. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  36503. /**
  36504. * Fired when the menu button on this controller is modified
  36505. */
  36506. get: function () {
  36507. return this.onSecondaryButtonStateChangedObservable;
  36508. },
  36509. enumerable: true,
  36510. configurable: true
  36511. });
  36512. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  36513. /**
  36514. * Fired when the grip button on this controller is modified
  36515. */
  36516. get: function () {
  36517. return this.onMainButtonStateChangedObservable;
  36518. },
  36519. enumerable: true,
  36520. configurable: true
  36521. });
  36522. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  36523. /**
  36524. * Fired when the thumbstick button on this controller is modified
  36525. */
  36526. get: function () {
  36527. return this.onPadStateChangedObservable;
  36528. },
  36529. enumerable: true,
  36530. configurable: true
  36531. });
  36532. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  36533. /**
  36534. * Fired when the touchpad button on this controller is modified
  36535. */
  36536. get: function () {
  36537. return this.onTrackpadChangedObservable;
  36538. },
  36539. enumerable: true,
  36540. configurable: true
  36541. });
  36542. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  36543. /**
  36544. * Fired when the touchpad values on this controller are modified
  36545. */
  36546. get: function () {
  36547. return this.onTrackpadValuesChangedObservable;
  36548. },
  36549. enumerable: true,
  36550. configurable: true
  36551. });
  36552. WindowsMotionController.prototype._updateTrackpad = function () {
  36553. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  36554. this.trackpad.x = this.browserGamepad["axes"][2];
  36555. this.trackpad.y = this.browserGamepad["axes"][3];
  36556. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  36557. }
  36558. };
  36559. /**
  36560. * Called once per frame by the engine.
  36561. */
  36562. WindowsMotionController.prototype.update = function () {
  36563. _super.prototype.update.call(this);
  36564. if (this.browserGamepad.axes) {
  36565. this._updateTrackpad();
  36566. // Only need to animate axes if there is a loaded mesh
  36567. if (this._loadedMeshInfo) {
  36568. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  36569. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  36570. }
  36571. }
  36572. }
  36573. };
  36574. /**
  36575. * Called once for each button that changed state since the last frame
  36576. * @param buttonIdx Which button index changed
  36577. * @param state New state of the button
  36578. * @param changes Which properties on the state changed since last frame
  36579. */
  36580. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36581. var buttonName = this._mapping.buttons[buttonIdx];
  36582. if (!buttonName) {
  36583. return;
  36584. }
  36585. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  36586. this._updateTrackpad();
  36587. // Only emit events for buttons that we know how to map from index to name
  36588. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  36589. if (observable) {
  36590. observable.notifyObservers(state);
  36591. }
  36592. this._lerpButtonTransform(buttonName, state.value);
  36593. };
  36594. /**
  36595. * Moves the buttons on the controller mesh based on their current state
  36596. * @param buttonName the name of the button to move
  36597. * @param buttonValue the value of the button which determines the buttons new position
  36598. */
  36599. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  36600. // If there is no loaded mesh, there is nothing to transform.
  36601. if (!this._loadedMeshInfo) {
  36602. return;
  36603. }
  36604. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  36605. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36606. return;
  36607. }
  36608. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  36609. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  36610. };
  36611. /**
  36612. * Moves the axis on the controller mesh based on its current state
  36613. * @param axis the index of the axis
  36614. * @param axisValue the value of the axis which determines the meshes new position
  36615. * @hidden
  36616. */
  36617. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  36618. if (!this._loadedMeshInfo) {
  36619. return;
  36620. }
  36621. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  36622. if (!meshInfo) {
  36623. return;
  36624. }
  36625. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36626. return;
  36627. }
  36628. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  36629. var lerpValue = axisValue * 0.5 + 0.5;
  36630. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  36631. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  36632. };
  36633. /**
  36634. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36635. * @param scene scene in which to add meshes
  36636. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36637. */
  36638. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  36639. var _this = this;
  36640. if (forceDefault === void 0) { forceDefault = false; }
  36641. var path;
  36642. var filename;
  36643. // Checking if GLB loader is present
  36644. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  36645. // Determine the device specific folder based on the ID suffix
  36646. var device = 'default';
  36647. if (this.id && !forceDefault) {
  36648. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  36649. device = ((match && match[0]) || device);
  36650. }
  36651. // Hand
  36652. if (this.hand === 'left') {
  36653. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  36654. }
  36655. else { // Right is the default if no hand is specified
  36656. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  36657. }
  36658. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  36659. }
  36660. else {
  36661. _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");
  36662. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  36663. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  36664. }
  36665. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  36666. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  36667. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  36668. if (!_this._loadedMeshInfo) {
  36669. return;
  36670. }
  36671. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  36672. _this.attachToMesh(_this._defaultModel);
  36673. if (meshLoaded) {
  36674. meshLoaded(_this._defaultModel);
  36675. }
  36676. }, null, function (scene, message) {
  36677. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  36678. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  36679. if (!forceDefault) {
  36680. _this.initControllerMesh(scene, meshLoaded, true);
  36681. }
  36682. });
  36683. };
  36684. /**
  36685. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  36686. * can be transformed by button presses and axes values, based on this._mapping.
  36687. *
  36688. * @param scene scene in which the meshes exist
  36689. * @param meshes list of meshes that make up the controller model to process
  36690. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  36691. */
  36692. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  36693. var loadedMeshInfo = null;
  36694. // Create a new mesh to contain the glTF hierarchy
  36695. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  36696. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  36697. var childMesh = null;
  36698. for (var i = 0; i < meshes.length; i++) {
  36699. var mesh = meshes[i];
  36700. if (!mesh.parent) {
  36701. // Exclude controller meshes from picking results
  36702. mesh.isPickable = false;
  36703. // Handle root node, attach to the new parentMesh
  36704. childMesh = mesh;
  36705. break;
  36706. }
  36707. }
  36708. if (childMesh) {
  36709. childMesh.setParent(parentMesh);
  36710. // Create our mesh info. Note that this method will always return non-null.
  36711. loadedMeshInfo = this.createMeshInfo(parentMesh);
  36712. }
  36713. else {
  36714. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  36715. }
  36716. return loadedMeshInfo;
  36717. };
  36718. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  36719. var loadedMeshInfo = new LoadedMeshInfo();
  36720. var i;
  36721. loadedMeshInfo.rootNode = rootNode;
  36722. // Reset the caches
  36723. loadedMeshInfo.buttonMeshes = {};
  36724. loadedMeshInfo.axisMeshes = {};
  36725. // Button Meshes
  36726. for (i = 0; i < this._mapping.buttons.length; i++) {
  36727. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36728. if (!buttonMeshName) {
  36729. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36730. continue;
  36731. }
  36732. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36733. if (!buttonMesh) {
  36734. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36735. continue;
  36736. }
  36737. var buttonMeshInfo = {
  36738. index: i,
  36739. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36740. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36741. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36742. };
  36743. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36744. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36745. }
  36746. else {
  36747. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36748. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36749. '(VALUE: ' + !!buttonMeshInfo.value +
  36750. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36751. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36752. ')');
  36753. }
  36754. }
  36755. // Axis Meshes
  36756. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36757. var axisMeshName = this._mapping.axisMeshNames[i];
  36758. if (!axisMeshName) {
  36759. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36760. continue;
  36761. }
  36762. var axisMesh = getChildByName(rootNode, axisMeshName);
  36763. if (!axisMesh) {
  36764. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36765. continue;
  36766. }
  36767. var axisMeshInfo = {
  36768. index: i,
  36769. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36770. min: getImmediateChildByName(axisMesh, 'MIN'),
  36771. max: getImmediateChildByName(axisMesh, 'MAX')
  36772. };
  36773. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36774. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36775. }
  36776. else {
  36777. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36778. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36779. '(VALUE: ' + !!axisMeshInfo.value +
  36780. ', MIN: ' + !!axisMeshInfo.min +
  36781. ', MAX:' + !!axisMeshInfo.max +
  36782. ')');
  36783. }
  36784. }
  36785. // Pointing Ray
  36786. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36787. if (!loadedMeshInfo.pointingPoseNode) {
  36788. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36789. }
  36790. else {
  36791. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36792. }
  36793. return loadedMeshInfo;
  36794. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36795. function getChildByName(node, name) {
  36796. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36797. }
  36798. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36799. function getImmediateChildByName(node, name) {
  36800. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36801. }
  36802. };
  36803. /**
  36804. * Gets the ray of the controller in the direction the controller is pointing
  36805. * @param length the length the resulting ray should be
  36806. * @returns a ray in the direction the controller is pointing
  36807. */
  36808. WindowsMotionController.prototype.getForwardRay = function (length) {
  36809. if (length === void 0) { length = 100; }
  36810. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36811. return _super.prototype.getForwardRay.call(this, length);
  36812. }
  36813. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36814. var origin = m.getTranslation();
  36815. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36816. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36817. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36818. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36819. };
  36820. /**
  36821. * Disposes of the controller
  36822. */
  36823. WindowsMotionController.prototype.dispose = function () {
  36824. _super.prototype.dispose.call(this);
  36825. this.onTrackpadChangedObservable.clear();
  36826. };
  36827. /**
  36828. * The base url used to load the left and right controller models
  36829. */
  36830. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36831. /**
  36832. * The name of the left controller model file
  36833. */
  36834. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36835. /**
  36836. * The name of the right controller model file
  36837. */
  36838. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36839. /**
  36840. * The controller name prefix for this controller type
  36841. */
  36842. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  36843. /**
  36844. * The controller id pattern for this controller type
  36845. */
  36846. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  36847. return WindowsMotionController;
  36848. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  36849. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36850. canCreate: function (gamepadInfo) {
  36851. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  36852. },
  36853. create: function (gamepadInfo) {
  36854. return new WindowsMotionController(gamepadInfo);
  36855. }
  36856. });
  36857. /***/ }),
  36858. /***/ "./Gamepads/gamepad.ts":
  36859. /*!*****************************!*\
  36860. !*** ./Gamepads/gamepad.ts ***!
  36861. \*****************************/
  36862. /*! exports provided: StickValues, Gamepad, GenericPad */
  36863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36864. "use strict";
  36865. __webpack_require__.r(__webpack_exports__);
  36866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  36867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  36868. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  36869. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36870. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36871. /**
  36872. * Represents a gamepad control stick position
  36873. */
  36874. var StickValues = /** @class */ (function () {
  36875. /**
  36876. * Initializes the gamepad x and y control stick values
  36877. * @param x The x component of the gamepad control stick value
  36878. * @param y The y component of the gamepad control stick value
  36879. */
  36880. function StickValues(
  36881. /**
  36882. * The x component of the control stick
  36883. */
  36884. x,
  36885. /**
  36886. * The y component of the control stick
  36887. */
  36888. y) {
  36889. this.x = x;
  36890. this.y = y;
  36891. }
  36892. return StickValues;
  36893. }());
  36894. /**
  36895. * Represents a gamepad
  36896. */
  36897. var Gamepad = /** @class */ (function () {
  36898. /**
  36899. * Initializes the gamepad
  36900. * @param id The id of the gamepad
  36901. * @param index The index of the gamepad
  36902. * @param browserGamepad The browser gamepad
  36903. * @param leftStickX The x component of the left joystick
  36904. * @param leftStickY The y component of the left joystick
  36905. * @param rightStickX The x component of the right joystick
  36906. * @param rightStickY The y component of the right joystick
  36907. */
  36908. function Gamepad(
  36909. /**
  36910. * The id of the gamepad
  36911. */
  36912. id,
  36913. /**
  36914. * The index of the gamepad
  36915. */
  36916. index,
  36917. /**
  36918. * The browser gamepad
  36919. */
  36920. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  36921. if (leftStickX === void 0) { leftStickX = 0; }
  36922. if (leftStickY === void 0) { leftStickY = 1; }
  36923. if (rightStickX === void 0) { rightStickX = 2; }
  36924. if (rightStickY === void 0) { rightStickY = 3; }
  36925. this.id = id;
  36926. this.index = index;
  36927. this.browserGamepad = browserGamepad;
  36928. this._leftStick = { x: 0, y: 0 };
  36929. this._rightStick = { x: 0, y: 0 };
  36930. /** @hidden */
  36931. this._isConnected = true;
  36932. /**
  36933. * Specifies whether the left control stick should be Y-inverted
  36934. */
  36935. this._invertLeftStickY = false;
  36936. this.type = Gamepad.GAMEPAD;
  36937. this._leftStickAxisX = leftStickX;
  36938. this._leftStickAxisY = leftStickY;
  36939. this._rightStickAxisX = rightStickX;
  36940. this._rightStickAxisY = rightStickY;
  36941. if (this.browserGamepad.axes.length >= 2) {
  36942. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36943. }
  36944. if (this.browserGamepad.axes.length >= 4) {
  36945. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36946. }
  36947. }
  36948. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36949. /**
  36950. * Specifies if the gamepad has been connected
  36951. */
  36952. get: function () {
  36953. return this._isConnected;
  36954. },
  36955. enumerable: true,
  36956. configurable: true
  36957. });
  36958. /**
  36959. * Callback triggered when the left joystick has changed
  36960. * @param callback
  36961. */
  36962. Gamepad.prototype.onleftstickchanged = function (callback) {
  36963. this._onleftstickchanged = callback;
  36964. };
  36965. /**
  36966. * Callback triggered when the right joystick has changed
  36967. * @param callback
  36968. */
  36969. Gamepad.prototype.onrightstickchanged = function (callback) {
  36970. this._onrightstickchanged = callback;
  36971. };
  36972. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36973. /**
  36974. * Gets the left joystick
  36975. */
  36976. get: function () {
  36977. return this._leftStick;
  36978. },
  36979. /**
  36980. * Sets the left joystick values
  36981. */
  36982. set: function (newValues) {
  36983. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36984. this._onleftstickchanged(newValues);
  36985. }
  36986. this._leftStick = newValues;
  36987. },
  36988. enumerable: true,
  36989. configurable: true
  36990. });
  36991. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36992. /**
  36993. * Gets the right joystick
  36994. */
  36995. get: function () {
  36996. return this._rightStick;
  36997. },
  36998. /**
  36999. * Sets the right joystick value
  37000. */
  37001. set: function (newValues) {
  37002. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  37003. this._onrightstickchanged(newValues);
  37004. }
  37005. this._rightStick = newValues;
  37006. },
  37007. enumerable: true,
  37008. configurable: true
  37009. });
  37010. /**
  37011. * Updates the gamepad joystick positions
  37012. */
  37013. Gamepad.prototype.update = function () {
  37014. if (this._leftStick) {
  37015. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37016. if (this._invertLeftStickY) {
  37017. this.leftStick.y *= -1;
  37018. }
  37019. }
  37020. if (this._rightStick) {
  37021. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37022. }
  37023. };
  37024. /**
  37025. * Disposes the gamepad
  37026. */
  37027. Gamepad.prototype.dispose = function () {
  37028. };
  37029. /**
  37030. * Represents a gamepad controller
  37031. */
  37032. Gamepad.GAMEPAD = 0;
  37033. /**
  37034. * Represents a generic controller
  37035. */
  37036. Gamepad.GENERIC = 1;
  37037. /**
  37038. * Represents an XBox controller
  37039. */
  37040. Gamepad.XBOX = 2;
  37041. /**
  37042. * Represents a pose-enabled controller
  37043. */
  37044. Gamepad.POSE_ENABLED = 3;
  37045. return Gamepad;
  37046. }());
  37047. /**
  37048. * Represents a generic gamepad
  37049. */
  37050. var GenericPad = /** @class */ (function (_super) {
  37051. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  37052. /**
  37053. * Initializes the generic gamepad
  37054. * @param id The id of the generic gamepad
  37055. * @param index The index of the generic gamepad
  37056. * @param browserGamepad The browser gamepad
  37057. */
  37058. function GenericPad(id, index, browserGamepad) {
  37059. var _this = _super.call(this, id, index, browserGamepad) || this;
  37060. /**
  37061. * Observable triggered when a button has been pressed
  37062. */
  37063. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37064. /**
  37065. * Observable triggered when a button has been released
  37066. */
  37067. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37068. _this.type = Gamepad.GENERIC;
  37069. _this._buttons = new Array(browserGamepad.buttons.length);
  37070. return _this;
  37071. }
  37072. /**
  37073. * Callback triggered when a button has been pressed
  37074. * @param callback Called when a button has been pressed
  37075. */
  37076. GenericPad.prototype.onbuttondown = function (callback) {
  37077. this._onbuttondown = callback;
  37078. };
  37079. /**
  37080. * Callback triggered when a button has been released
  37081. * @param callback Called when a button has been released
  37082. */
  37083. GenericPad.prototype.onbuttonup = function (callback) {
  37084. this._onbuttonup = callback;
  37085. };
  37086. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  37087. if (newValue !== currentValue) {
  37088. if (newValue === 1) {
  37089. if (this._onbuttondown) {
  37090. this._onbuttondown(buttonIndex);
  37091. }
  37092. this.onButtonDownObservable.notifyObservers(buttonIndex);
  37093. }
  37094. if (newValue === 0) {
  37095. if (this._onbuttonup) {
  37096. this._onbuttonup(buttonIndex);
  37097. }
  37098. this.onButtonUpObservable.notifyObservers(buttonIndex);
  37099. }
  37100. }
  37101. return newValue;
  37102. };
  37103. /**
  37104. * Updates the generic gamepad
  37105. */
  37106. GenericPad.prototype.update = function () {
  37107. _super.prototype.update.call(this);
  37108. for (var index = 0; index < this._buttons.length; index++) {
  37109. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  37110. }
  37111. };
  37112. /**
  37113. * Disposes the generic gamepad
  37114. */
  37115. GenericPad.prototype.dispose = function () {
  37116. _super.prototype.dispose.call(this);
  37117. this.onButtonDownObservable.clear();
  37118. this.onButtonUpObservable.clear();
  37119. };
  37120. return GenericPad;
  37121. }(Gamepad));
  37122. /***/ }),
  37123. /***/ "./Gamepads/gamepadManager.ts":
  37124. /*!************************************!*\
  37125. !*** ./Gamepads/gamepadManager.ts ***!
  37126. \************************************/
  37127. /*! exports provided: GamepadManager */
  37128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37129. "use strict";
  37130. __webpack_require__.r(__webpack_exports__);
  37131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  37132. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  37133. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37134. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  37135. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37136. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37137. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37138. /**
  37139. * Manager for handling gamepads
  37140. */
  37141. var GamepadManager = /** @class */ (function () {
  37142. /**
  37143. * Initializes the gamepad manager
  37144. * @param _scene BabylonJS scene
  37145. */
  37146. function GamepadManager(_scene) {
  37147. var _this = this;
  37148. this._scene = _scene;
  37149. this._babylonGamepads = [];
  37150. this._oneGamepadConnected = false;
  37151. /** @hidden */
  37152. this._isMonitoring = false;
  37153. /**
  37154. * observable to be triggered when the gamepad controller has been disconnected
  37155. */
  37156. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37157. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  37158. this._gamepadEventSupported = false;
  37159. }
  37160. else {
  37161. this._gamepadEventSupported = 'GamepadEvent' in window;
  37162. this._gamepadSupport = (navigator.getGamepads ||
  37163. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  37164. }
  37165. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  37166. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  37167. for (var i in _this._babylonGamepads) {
  37168. var gamepad = _this._babylonGamepads[i];
  37169. if (gamepad && gamepad._isConnected) {
  37170. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  37171. }
  37172. }
  37173. });
  37174. this._onGamepadConnectedEvent = function (evt) {
  37175. var gamepad = evt.gamepad;
  37176. if (gamepad.index in _this._babylonGamepads) {
  37177. if (_this._babylonGamepads[gamepad.index].isConnected) {
  37178. return;
  37179. }
  37180. }
  37181. var newGamepad;
  37182. if (_this._babylonGamepads[gamepad.index]) {
  37183. newGamepad = _this._babylonGamepads[gamepad.index];
  37184. newGamepad.browserGamepad = gamepad;
  37185. newGamepad._isConnected = true;
  37186. }
  37187. else {
  37188. newGamepad = _this._addNewGamepad(gamepad);
  37189. }
  37190. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37191. _this._startMonitoringGamepads();
  37192. };
  37193. this._onGamepadDisconnectedEvent = function (evt) {
  37194. var gamepad = evt.gamepad;
  37195. // Remove the gamepad from the list of gamepads to monitor.
  37196. for (var i in _this._babylonGamepads) {
  37197. if (_this._babylonGamepads[i].index === gamepad.index) {
  37198. var disconnectedGamepad = _this._babylonGamepads[i];
  37199. disconnectedGamepad._isConnected = false;
  37200. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  37201. break;
  37202. }
  37203. }
  37204. };
  37205. if (this._gamepadSupport) {
  37206. //first add already-connected gamepads
  37207. this._updateGamepadObjects();
  37208. if (this._babylonGamepads.length) {
  37209. this._startMonitoringGamepads();
  37210. }
  37211. // Checking if the gamepad connected event is supported (like in Firefox)
  37212. if (this._gamepadEventSupported) {
  37213. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  37214. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  37215. }
  37216. else {
  37217. this._startMonitoringGamepads();
  37218. }
  37219. }
  37220. }
  37221. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  37222. /**
  37223. * The gamepads in the game pad manager
  37224. */
  37225. get: function () {
  37226. return this._babylonGamepads;
  37227. },
  37228. enumerable: true,
  37229. configurable: true
  37230. });
  37231. /**
  37232. * Get the gamepad controllers based on type
  37233. * @param type The type of gamepad controller
  37234. * @returns Nullable gamepad
  37235. */
  37236. GamepadManager.prototype.getGamepadByType = function (type) {
  37237. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  37238. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  37239. var gamepad = _a[_i];
  37240. if (gamepad && gamepad.type === type) {
  37241. return gamepad;
  37242. }
  37243. }
  37244. return null;
  37245. };
  37246. /**
  37247. * Disposes the gamepad manager
  37248. */
  37249. GamepadManager.prototype.dispose = function () {
  37250. if (this._gamepadEventSupported) {
  37251. if (this._onGamepadConnectedEvent) {
  37252. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  37253. }
  37254. if (this._onGamepadDisconnectedEvent) {
  37255. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  37256. }
  37257. this._onGamepadConnectedEvent = null;
  37258. this._onGamepadDisconnectedEvent = null;
  37259. }
  37260. this._babylonGamepads.forEach(function (gamepad) {
  37261. gamepad.dispose();
  37262. });
  37263. this.onGamepadConnectedObservable.clear();
  37264. this.onGamepadDisconnectedObservable.clear();
  37265. this._oneGamepadConnected = false;
  37266. this._stopMonitoringGamepads();
  37267. this._babylonGamepads = [];
  37268. };
  37269. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  37270. if (!this._oneGamepadConnected) {
  37271. this._oneGamepadConnected = true;
  37272. }
  37273. var newGamepad;
  37274. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  37275. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  37276. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  37277. }
  37278. // if pose is supported, use the (WebVR) pose enabled controller
  37279. else if (gamepad.pose) {
  37280. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  37281. }
  37282. else {
  37283. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  37284. }
  37285. this._babylonGamepads[newGamepad.index] = newGamepad;
  37286. return newGamepad;
  37287. };
  37288. GamepadManager.prototype._startMonitoringGamepads = function () {
  37289. if (!this._isMonitoring) {
  37290. this._isMonitoring = true;
  37291. //back-comp
  37292. if (!this._scene) {
  37293. this._checkGamepadsStatus();
  37294. }
  37295. }
  37296. };
  37297. GamepadManager.prototype._stopMonitoringGamepads = function () {
  37298. this._isMonitoring = false;
  37299. };
  37300. /** @hidden */
  37301. GamepadManager.prototype._checkGamepadsStatus = function () {
  37302. var _this = this;
  37303. // Hack to be compatible Chrome
  37304. this._updateGamepadObjects();
  37305. for (var i in this._babylonGamepads) {
  37306. var gamepad = this._babylonGamepads[i];
  37307. if (!gamepad || !gamepad.isConnected) {
  37308. continue;
  37309. }
  37310. gamepad.update();
  37311. }
  37312. if (this._isMonitoring && !this._scene) {
  37313. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  37314. }
  37315. };
  37316. // This function is called only on Chrome, which does not properly support
  37317. // connection/disconnection events and forces you to recopy again the gamepad object
  37318. GamepadManager.prototype._updateGamepadObjects = function () {
  37319. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  37320. for (var i = 0; i < gamepads.length; i++) {
  37321. var gamepad = gamepads[i];
  37322. if (gamepad) {
  37323. if (!this._babylonGamepads[gamepad.index]) {
  37324. var newGamepad = this._addNewGamepad(gamepad);
  37325. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37326. }
  37327. else {
  37328. // Forced to copy again this object for Chrome for unknown reason
  37329. this._babylonGamepads[i].browserGamepad = gamepad;
  37330. if (!this._babylonGamepads[i].isConnected) {
  37331. this._babylonGamepads[i]._isConnected = true;
  37332. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  37333. }
  37334. }
  37335. }
  37336. }
  37337. };
  37338. return GamepadManager;
  37339. }());
  37340. /***/ }),
  37341. /***/ "./Gamepads/gamepadSceneComponent.ts":
  37342. /*!*******************************************!*\
  37343. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  37344. \*******************************************/
  37345. /*! exports provided: GamepadSystemSceneComponent */
  37346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37347. "use strict";
  37348. __webpack_require__.r(__webpack_exports__);
  37349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  37350. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  37351. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  37352. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37353. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  37354. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  37355. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  37356. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  37357. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  37358. get: function () {
  37359. if (!this._gamepadManager) {
  37360. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  37361. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  37362. if (!component) {
  37363. component = new GamepadSystemSceneComponent(this);
  37364. this._addComponent(component);
  37365. }
  37366. }
  37367. return this._gamepadManager;
  37368. },
  37369. enumerable: true,
  37370. configurable: true
  37371. });
  37372. /**
  37373. * Adds a gamepad to the free camera inputs manager
  37374. */
  37375. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  37376. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  37377. return this;
  37378. };
  37379. /**
  37380. * Adds a gamepad to the arc rotate camera inputs manager
  37381. */
  37382. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  37383. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  37384. return this;
  37385. };
  37386. /**
  37387. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37388. */
  37389. var GamepadSystemSceneComponent = /** @class */ (function () {
  37390. /**
  37391. * Creates a new instance of the component for the given scene
  37392. * @param scene Defines the scene to register the component in
  37393. */
  37394. function GamepadSystemSceneComponent(scene) {
  37395. /**
  37396. * The component name helpfull to identify the component in the list of scene components.
  37397. */
  37398. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  37399. this.scene = scene;
  37400. }
  37401. /**
  37402. * Registers the component in a given scene
  37403. */
  37404. GamepadSystemSceneComponent.prototype.register = function () {
  37405. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  37406. };
  37407. /**
  37408. * Rebuilds the elements related to this component in case of
  37409. * context lost for instance.
  37410. */
  37411. GamepadSystemSceneComponent.prototype.rebuild = function () {
  37412. // Nothing to do for gamepads
  37413. };
  37414. /**
  37415. * Disposes the component and the associated ressources
  37416. */
  37417. GamepadSystemSceneComponent.prototype.dispose = function () {
  37418. var gamepadManager = this.scene._gamepadManager;
  37419. if (gamepadManager) {
  37420. gamepadManager.dispose();
  37421. this.scene._gamepadManager = null;
  37422. }
  37423. };
  37424. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  37425. var gamepadManager = this.scene._gamepadManager;
  37426. if (gamepadManager && gamepadManager._isMonitoring) {
  37427. gamepadManager._checkGamepadsStatus();
  37428. }
  37429. };
  37430. return GamepadSystemSceneComponent;
  37431. }());
  37432. /***/ }),
  37433. /***/ "./Gamepads/index.ts":
  37434. /*!***************************!*\
  37435. !*** ./Gamepads/index.ts ***!
  37436. \***************************/
  37437. /*! exports provided: StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  37438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37439. "use strict";
  37440. __webpack_require__.r(__webpack_exports__);
  37441. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  37442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  37444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  37445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  37446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  37447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  37448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  37449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  37450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  37451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  37452. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  37454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  37455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  37456. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  37458. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  37459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  37460. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  37462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  37463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  37464. /***/ }),
  37465. /***/ "./Gamepads/xboxGamepad.ts":
  37466. /*!*********************************!*\
  37467. !*** ./Gamepads/xboxGamepad.ts ***!
  37468. \*********************************/
  37469. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37471. "use strict";
  37472. __webpack_require__.r(__webpack_exports__);
  37473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  37474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  37475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  37476. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37477. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37478. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37479. /**
  37480. * Defines supported buttons for XBox360 compatible gamepads
  37481. */
  37482. var Xbox360Button;
  37483. (function (Xbox360Button) {
  37484. /** A */
  37485. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  37486. /** B */
  37487. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  37488. /** X */
  37489. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  37490. /** Y */
  37491. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  37492. /** Start */
  37493. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  37494. /** Back */
  37495. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  37496. /** Left button */
  37497. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  37498. /** Right button */
  37499. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  37500. /** Left stick */
  37501. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  37502. /** Right stick */
  37503. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  37504. })(Xbox360Button || (Xbox360Button = {}));
  37505. /** Defines values for XBox360 DPad */
  37506. var Xbox360Dpad;
  37507. (function (Xbox360Dpad) {
  37508. /** Up */
  37509. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  37510. /** Down */
  37511. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  37512. /** Left */
  37513. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  37514. /** Right */
  37515. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  37516. })(Xbox360Dpad || (Xbox360Dpad = {}));
  37517. /**
  37518. * Defines a XBox360 gamepad
  37519. */
  37520. var Xbox360Pad = /** @class */ (function (_super) {
  37521. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  37522. /**
  37523. * Creates a new XBox360 gamepad object
  37524. * @param id defines the id of this gamepad
  37525. * @param index defines its index
  37526. * @param gamepad defines the internal HTML gamepad object
  37527. * @param xboxOne defines if it is a XBox One gamepad
  37528. */
  37529. function Xbox360Pad(id, index, gamepad, xboxOne) {
  37530. if (xboxOne === void 0) { xboxOne = false; }
  37531. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  37532. _this._leftTrigger = 0;
  37533. _this._rightTrigger = 0;
  37534. /** Observable raised when a button is pressed */
  37535. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37536. /** Observable raised when a button is released */
  37537. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37538. /** Observable raised when a pad is pressed */
  37539. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37540. /** Observable raised when a pad is released */
  37541. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37542. _this._buttonA = 0;
  37543. _this._buttonB = 0;
  37544. _this._buttonX = 0;
  37545. _this._buttonY = 0;
  37546. _this._buttonBack = 0;
  37547. _this._buttonStart = 0;
  37548. _this._buttonLB = 0;
  37549. _this._buttonRB = 0;
  37550. _this._buttonLeftStick = 0;
  37551. _this._buttonRightStick = 0;
  37552. _this._dPadUp = 0;
  37553. _this._dPadDown = 0;
  37554. _this._dPadLeft = 0;
  37555. _this._dPadRight = 0;
  37556. _this._isXboxOnePad = false;
  37557. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  37558. _this._isXboxOnePad = xboxOne;
  37559. return _this;
  37560. }
  37561. /**
  37562. * Defines the callback to call when left trigger is pressed
  37563. * @param callback defines the callback to use
  37564. */
  37565. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  37566. this._onlefttriggerchanged = callback;
  37567. };
  37568. /**
  37569. * Defines the callback to call when right trigger is pressed
  37570. * @param callback defines the callback to use
  37571. */
  37572. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  37573. this._onrighttriggerchanged = callback;
  37574. };
  37575. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  37576. /**
  37577. * Gets the left trigger value
  37578. */
  37579. get: function () {
  37580. return this._leftTrigger;
  37581. },
  37582. /**
  37583. * Sets the left trigger value
  37584. */
  37585. set: function (newValue) {
  37586. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  37587. this._onlefttriggerchanged(newValue);
  37588. }
  37589. this._leftTrigger = newValue;
  37590. },
  37591. enumerable: true,
  37592. configurable: true
  37593. });
  37594. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  37595. /**
  37596. * Gets the right trigger value
  37597. */
  37598. get: function () {
  37599. return this._rightTrigger;
  37600. },
  37601. /**
  37602. * Sets the right trigger value
  37603. */
  37604. set: function (newValue) {
  37605. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  37606. this._onrighttriggerchanged(newValue);
  37607. }
  37608. this._rightTrigger = newValue;
  37609. },
  37610. enumerable: true,
  37611. configurable: true
  37612. });
  37613. /**
  37614. * Defines the callback to call when a button is pressed
  37615. * @param callback defines the callback to use
  37616. */
  37617. Xbox360Pad.prototype.onbuttondown = function (callback) {
  37618. this._onbuttondown = callback;
  37619. };
  37620. /**
  37621. * Defines the callback to call when a button is released
  37622. * @param callback defines the callback to use
  37623. */
  37624. Xbox360Pad.prototype.onbuttonup = function (callback) {
  37625. this._onbuttonup = callback;
  37626. };
  37627. /**
  37628. * Defines the callback to call when a pad is pressed
  37629. * @param callback defines the callback to use
  37630. */
  37631. Xbox360Pad.prototype.ondpaddown = function (callback) {
  37632. this._ondpaddown = callback;
  37633. };
  37634. /**
  37635. * Defines the callback to call when a pad is released
  37636. * @param callback defines the callback to use
  37637. */
  37638. Xbox360Pad.prototype.ondpadup = function (callback) {
  37639. this._ondpadup = callback;
  37640. };
  37641. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  37642. if (newValue !== currentValue) {
  37643. if (newValue === 1) {
  37644. if (this._onbuttondown) {
  37645. this._onbuttondown(buttonType);
  37646. }
  37647. this.onButtonDownObservable.notifyObservers(buttonType);
  37648. }
  37649. if (newValue === 0) {
  37650. if (this._onbuttonup) {
  37651. this._onbuttonup(buttonType);
  37652. }
  37653. this.onButtonUpObservable.notifyObservers(buttonType);
  37654. }
  37655. }
  37656. return newValue;
  37657. };
  37658. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  37659. if (newValue !== currentValue) {
  37660. if (newValue === 1) {
  37661. if (this._ondpaddown) {
  37662. this._ondpaddown(buttonType);
  37663. }
  37664. this.onPadDownObservable.notifyObservers(buttonType);
  37665. }
  37666. if (newValue === 0) {
  37667. if (this._ondpadup) {
  37668. this._ondpadup(buttonType);
  37669. }
  37670. this.onPadUpObservable.notifyObservers(buttonType);
  37671. }
  37672. }
  37673. return newValue;
  37674. };
  37675. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  37676. /**
  37677. * Gets the value of the `A` button
  37678. */
  37679. get: function () {
  37680. return this._buttonA;
  37681. },
  37682. /**
  37683. * Sets the value of the `A` button
  37684. */
  37685. set: function (value) {
  37686. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  37687. },
  37688. enumerable: true,
  37689. configurable: true
  37690. });
  37691. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  37692. /**
  37693. * Gets the value of the `B` button
  37694. */
  37695. get: function () {
  37696. return this._buttonB;
  37697. },
  37698. /**
  37699. * Sets the value of the `B` button
  37700. */
  37701. set: function (value) {
  37702. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  37703. },
  37704. enumerable: true,
  37705. configurable: true
  37706. });
  37707. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  37708. /**
  37709. * Gets the value of the `X` button
  37710. */
  37711. get: function () {
  37712. return this._buttonX;
  37713. },
  37714. /**
  37715. * Sets the value of the `X` button
  37716. */
  37717. set: function (value) {
  37718. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  37719. },
  37720. enumerable: true,
  37721. configurable: true
  37722. });
  37723. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37724. /**
  37725. * Gets the value of the `Y` button
  37726. */
  37727. get: function () {
  37728. return this._buttonY;
  37729. },
  37730. /**
  37731. * Sets the value of the `Y` button
  37732. */
  37733. set: function (value) {
  37734. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37735. },
  37736. enumerable: true,
  37737. configurable: true
  37738. });
  37739. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37740. /**
  37741. * Gets the value of the `Start` button
  37742. */
  37743. get: function () {
  37744. return this._buttonStart;
  37745. },
  37746. /**
  37747. * Sets the value of the `Start` button
  37748. */
  37749. set: function (value) {
  37750. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37751. },
  37752. enumerable: true,
  37753. configurable: true
  37754. });
  37755. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37756. /**
  37757. * Gets the value of the `Back` button
  37758. */
  37759. get: function () {
  37760. return this._buttonBack;
  37761. },
  37762. /**
  37763. * Sets the value of the `Back` button
  37764. */
  37765. set: function (value) {
  37766. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37767. },
  37768. enumerable: true,
  37769. configurable: true
  37770. });
  37771. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37772. /**
  37773. * Gets the value of the `Left` button
  37774. */
  37775. get: function () {
  37776. return this._buttonLB;
  37777. },
  37778. /**
  37779. * Sets the value of the `Left` button
  37780. */
  37781. set: function (value) {
  37782. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37783. },
  37784. enumerable: true,
  37785. configurable: true
  37786. });
  37787. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37788. /**
  37789. * Gets the value of the `Right` button
  37790. */
  37791. get: function () {
  37792. return this._buttonRB;
  37793. },
  37794. /**
  37795. * Sets the value of the `Right` button
  37796. */
  37797. set: function (value) {
  37798. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37799. },
  37800. enumerable: true,
  37801. configurable: true
  37802. });
  37803. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37804. /**
  37805. * Gets the value of the Left joystick
  37806. */
  37807. get: function () {
  37808. return this._buttonLeftStick;
  37809. },
  37810. /**
  37811. * Sets the value of the Left joystick
  37812. */
  37813. set: function (value) {
  37814. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37815. },
  37816. enumerable: true,
  37817. configurable: true
  37818. });
  37819. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37820. /**
  37821. * Gets the value of the Right joystick
  37822. */
  37823. get: function () {
  37824. return this._buttonRightStick;
  37825. },
  37826. /**
  37827. * Sets the value of the Right joystick
  37828. */
  37829. set: function (value) {
  37830. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37831. },
  37832. enumerable: true,
  37833. configurable: true
  37834. });
  37835. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37836. /**
  37837. * Gets the value of D-pad up
  37838. */
  37839. get: function () {
  37840. return this._dPadUp;
  37841. },
  37842. /**
  37843. * Sets the value of D-pad up
  37844. */
  37845. set: function (value) {
  37846. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  37847. },
  37848. enumerable: true,
  37849. configurable: true
  37850. });
  37851. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  37852. /**
  37853. * Gets the value of D-pad down
  37854. */
  37855. get: function () {
  37856. return this._dPadDown;
  37857. },
  37858. /**
  37859. * Sets the value of D-pad down
  37860. */
  37861. set: function (value) {
  37862. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  37863. },
  37864. enumerable: true,
  37865. configurable: true
  37866. });
  37867. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  37868. /**
  37869. * Gets the value of D-pad left
  37870. */
  37871. get: function () {
  37872. return this._dPadLeft;
  37873. },
  37874. /**
  37875. * Sets the value of D-pad left
  37876. */
  37877. set: function (value) {
  37878. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  37879. },
  37880. enumerable: true,
  37881. configurable: true
  37882. });
  37883. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  37884. /**
  37885. * Gets the value of D-pad right
  37886. */
  37887. get: function () {
  37888. return this._dPadRight;
  37889. },
  37890. /**
  37891. * Sets the value of D-pad right
  37892. */
  37893. set: function (value) {
  37894. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  37895. },
  37896. enumerable: true,
  37897. configurable: true
  37898. });
  37899. /**
  37900. * Force the gamepad to synchronize with device values
  37901. */
  37902. Xbox360Pad.prototype.update = function () {
  37903. _super.prototype.update.call(this);
  37904. if (this._isXboxOnePad) {
  37905. this.buttonA = this.browserGamepad.buttons[0].value;
  37906. this.buttonB = this.browserGamepad.buttons[1].value;
  37907. this.buttonX = this.browserGamepad.buttons[2].value;
  37908. this.buttonY = this.browserGamepad.buttons[3].value;
  37909. this.buttonLB = this.browserGamepad.buttons[4].value;
  37910. this.buttonRB = this.browserGamepad.buttons[5].value;
  37911. this.leftTrigger = this.browserGamepad.axes[2];
  37912. this.rightTrigger = this.browserGamepad.axes[5];
  37913. this.buttonBack = this.browserGamepad.buttons[9].value;
  37914. this.buttonStart = this.browserGamepad.buttons[8].value;
  37915. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  37916. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  37917. this.dPadUp = this.browserGamepad.buttons[11].value;
  37918. this.dPadDown = this.browserGamepad.buttons[12].value;
  37919. this.dPadLeft = this.browserGamepad.buttons[13].value;
  37920. this.dPadRight = this.browserGamepad.buttons[14].value;
  37921. }
  37922. else {
  37923. this.buttonA = this.browserGamepad.buttons[0].value;
  37924. this.buttonB = this.browserGamepad.buttons[1].value;
  37925. this.buttonX = this.browserGamepad.buttons[2].value;
  37926. this.buttonY = this.browserGamepad.buttons[3].value;
  37927. this.buttonLB = this.browserGamepad.buttons[4].value;
  37928. this.buttonRB = this.browserGamepad.buttons[5].value;
  37929. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37930. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37931. this.buttonBack = this.browserGamepad.buttons[8].value;
  37932. this.buttonStart = this.browserGamepad.buttons[9].value;
  37933. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37934. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37935. this.dPadUp = this.browserGamepad.buttons[12].value;
  37936. this.dPadDown = this.browserGamepad.buttons[13].value;
  37937. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37938. this.dPadRight = this.browserGamepad.buttons[15].value;
  37939. }
  37940. };
  37941. /**
  37942. * Disposes the gamepad
  37943. */
  37944. Xbox360Pad.prototype.dispose = function () {
  37945. _super.prototype.dispose.call(this);
  37946. this.onButtonDownObservable.clear();
  37947. this.onButtonUpObservable.clear();
  37948. this.onPadDownObservable.clear();
  37949. this.onPadUpObservable.clear();
  37950. };
  37951. return Xbox360Pad;
  37952. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37953. /***/ }),
  37954. /***/ "./Gizmos/axisDragGizmo.ts":
  37955. /*!*********************************!*\
  37956. !*** ./Gizmos/axisDragGizmo.ts ***!
  37957. \*********************************/
  37958. /*! exports provided: AxisDragGizmo */
  37959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37960. "use strict";
  37961. __webpack_require__.r(__webpack_exports__);
  37962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37963. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37964. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37965. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37966. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37967. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37968. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37969. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37970. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37971. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37972. /**
  37973. * Single axis drag gizmo
  37974. */
  37975. var AxisDragGizmo = /** @class */ (function (_super) {
  37976. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37977. /**
  37978. * Creates an AxisDragGizmo
  37979. * @param gizmoLayer The utility layer the gizmo will be added to
  37980. * @param dragAxis The axis which the gizmo will be able to drag on
  37981. * @param color The color of the gizmo
  37982. */
  37983. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37984. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37985. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultGizmoUtilityLayer; }
  37986. var _this = _super.call(this, gizmoLayer) || this;
  37987. _this._pointerObserver = null;
  37988. /**
  37989. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37990. */
  37991. _this.snapDistance = 0;
  37992. /**
  37993. * Event that fires each time the gizmo snaps to a new location.
  37994. * * snapDistance is the the change in distance
  37995. */
  37996. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37997. // Create Material
  37998. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37999. coloredMaterial.diffuseColor = color;
  38000. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38001. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38002. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38003. // Build mesh on root node
  38004. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  38005. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38006. arrow.scaling.scaleInPlace(1 / 3);
  38007. arrow.parent = _this._rootMesh;
  38008. var currentSnapDragDistance = 0;
  38009. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38010. var tmpSnapEvent = { snapDistance: 0 };
  38011. // Add drag behavior to handle events when the gizmo is dragged
  38012. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38013. _this.dragBehavior.moveAttached = false;
  38014. _this._rootMesh.addBehavior(_this.dragBehavior);
  38015. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38016. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38017. _this.dragBehavior.onDragObservable.add(function (event) {
  38018. if (_this.attachedMesh) {
  38019. // Convert delta to local translation if it has a parent
  38020. if (_this.attachedMesh.parent) {
  38021. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38022. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  38023. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  38024. }
  38025. else {
  38026. localDelta.copyFrom(event.delta);
  38027. }
  38028. // Snapping logic
  38029. if (_this.snapDistance == 0) {
  38030. _this.attachedMesh.position.addInPlace(localDelta);
  38031. }
  38032. else {
  38033. currentSnapDragDistance += event.dragDistance;
  38034. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38035. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38036. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38037. localDelta.normalizeToRef(tmpVector);
  38038. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  38039. _this.attachedMesh.position.addInPlace(tmpVector);
  38040. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38041. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38042. }
  38043. }
  38044. }
  38045. });
  38046. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38047. if (_this._customMeshSet) {
  38048. return;
  38049. }
  38050. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38051. var material = isHovered ? hoverMaterial : coloredMaterial;
  38052. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38053. m.material = material;
  38054. if (m.color) {
  38055. m.color = material.diffuseColor;
  38056. }
  38057. });
  38058. });
  38059. return _this;
  38060. }
  38061. /** @hidden */
  38062. AxisDragGizmo._CreateArrow = function (scene, material) {
  38063. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38064. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375, tessellation: 96 }, scene);
  38065. var line = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, scene);
  38066. line.material = material;
  38067. cylinder.parent = arrow;
  38068. line.parent = arrow;
  38069. // Position arrow pointing in its drag axis
  38070. cylinder.material = material;
  38071. cylinder.rotation.x = Math.PI / 2;
  38072. cylinder.position.z += 0.3;
  38073. line.position.z += 0.275 / 2;
  38074. line.rotation.x = Math.PI / 2;
  38075. return arrow;
  38076. };
  38077. /** @hidden */
  38078. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  38079. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38080. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  38081. var mesh = _a[_i];
  38082. var childInstance = mesh.createInstance(mesh.name);
  38083. childInstance.parent = instance;
  38084. }
  38085. return instance;
  38086. };
  38087. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  38088. if (this.dragBehavior) {
  38089. this.dragBehavior.enabled = value ? true : false;
  38090. }
  38091. };
  38092. /**
  38093. * Disposes of the gizmo
  38094. */
  38095. AxisDragGizmo.prototype.dispose = function () {
  38096. this.onSnapObservable.clear();
  38097. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38098. this.dragBehavior.detach();
  38099. _super.prototype.dispose.call(this);
  38100. };
  38101. return AxisDragGizmo;
  38102. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38103. /***/ }),
  38104. /***/ "./Gizmos/axisScaleGizmo.ts":
  38105. /*!**********************************!*\
  38106. !*** ./Gizmos/axisScaleGizmo.ts ***!
  38107. \**********************************/
  38108. /*! exports provided: AxisScaleGizmo */
  38109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38110. "use strict";
  38111. __webpack_require__.r(__webpack_exports__);
  38112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  38113. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38114. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38115. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38116. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38117. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38118. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38119. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38120. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38121. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38122. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38123. /**
  38124. * Single axis scale gizmo
  38125. */
  38126. var AxisScaleGizmo = /** @class */ (function (_super) {
  38127. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  38128. /**
  38129. * Creates an AxisScaleGizmo
  38130. * @param gizmoLayer The utility layer the gizmo will be added to
  38131. * @param dragAxis The axis which the gizmo will be able to scale on
  38132. * @param color The color of the gizmo
  38133. */
  38134. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  38135. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38136. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultGizmoUtilityLayer; }
  38137. var _this = _super.call(this, gizmoLayer) || this;
  38138. _this._pointerObserver = null;
  38139. /**
  38140. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38141. */
  38142. _this.snapDistance = 0;
  38143. /**
  38144. * Event that fires each time the gizmo snaps to a new location.
  38145. * * snapDistance is the the change in distance
  38146. */
  38147. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38148. /**
  38149. * If the scaling operation should be done on all axis (default: false)
  38150. */
  38151. _this.uniformScaling = false;
  38152. // Create Material
  38153. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38154. _this._coloredMaterial.diffuseColor = color;
  38155. _this._coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38156. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38157. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38158. // Build mesh on root node
  38159. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38160. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  38161. var arrowTail = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, gizmoLayer.utilityLayerScene);
  38162. arrow.addChild(arrowMesh);
  38163. arrow.addChild(arrowTail);
  38164. // Position arrow pointing in its drag axis
  38165. arrowMesh.scaling.scaleInPlace(0.1);
  38166. arrowMesh.material = _this._coloredMaterial;
  38167. arrowMesh.rotation.x = Math.PI / 2;
  38168. arrowMesh.position.z += 0.3;
  38169. arrowTail.position.z += 0.275 / 2;
  38170. arrowTail.rotation.x = Math.PI / 2;
  38171. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38172. _this._rootMesh.addChild(arrow);
  38173. arrow.scaling.scaleInPlace(1 / 3);
  38174. // Add drag behavior to handle events when the gizmo is dragged
  38175. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38176. _this.dragBehavior.moveAttached = false;
  38177. _this._rootMesh.addBehavior(_this.dragBehavior);
  38178. var currentSnapDragDistance = 0;
  38179. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38180. var tmpSnapEvent = { snapDistance: 0 };
  38181. _this.dragBehavior.onDragObservable.add(function (event) {
  38182. if (_this.attachedMesh) {
  38183. // Snapping logic
  38184. var snapped = false;
  38185. var dragSteps = 0;
  38186. if (_this.uniformScaling) {
  38187. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  38188. if (tmpVector.y < 0) {
  38189. tmpVector.scaleInPlace(-1);
  38190. }
  38191. }
  38192. else {
  38193. tmpVector.copyFrom(dragAxis);
  38194. }
  38195. if (_this.snapDistance == 0) {
  38196. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  38197. }
  38198. else {
  38199. currentSnapDragDistance += event.dragDistance;
  38200. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38201. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38202. if (currentSnapDragDistance < 0) {
  38203. dragSteps *= -1;
  38204. }
  38205. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38206. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  38207. snapped = true;
  38208. }
  38209. else {
  38210. tmpVector.scaleInPlace(0);
  38211. }
  38212. }
  38213. _this.attachedMesh.scaling.addInPlace(tmpVector);
  38214. if (snapped) {
  38215. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38216. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38217. }
  38218. }
  38219. });
  38220. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38221. if (_this._customMeshSet) {
  38222. return;
  38223. }
  38224. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38225. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  38226. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38227. m.material = material;
  38228. if (m.color) {
  38229. m.color = material.diffuseColor;
  38230. }
  38231. });
  38232. });
  38233. return _this;
  38234. }
  38235. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  38236. if (this.dragBehavior) {
  38237. this.dragBehavior.enabled = value ? true : false;
  38238. }
  38239. };
  38240. /**
  38241. * Disposes of the gizmo
  38242. */
  38243. AxisScaleGizmo.prototype.dispose = function () {
  38244. this.onSnapObservable.clear();
  38245. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38246. this.dragBehavior.detach();
  38247. _super.prototype.dispose.call(this);
  38248. };
  38249. /**
  38250. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38251. * @param mesh The mesh to replace the default mesh of the gizmo
  38252. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  38253. */
  38254. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  38255. var _this = this;
  38256. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  38257. _super.prototype.setCustomMesh.call(this, mesh);
  38258. if (useGizmoMaterial) {
  38259. this._rootMesh.getChildMeshes().forEach(function (m) {
  38260. m.material = _this._coloredMaterial;
  38261. if (m.color) {
  38262. m.color = _this._coloredMaterial.diffuseColor;
  38263. }
  38264. });
  38265. this._customMeshSet = false;
  38266. }
  38267. };
  38268. return AxisScaleGizmo;
  38269. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  38270. /***/ }),
  38271. /***/ "./Gizmos/boundingBoxGizmo.ts":
  38272. /*!************************************!*\
  38273. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  38274. \************************************/
  38275. /*! exports provided: BoundingBoxGizmo */
  38276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38277. "use strict";
  38278. __webpack_require__.r(__webpack_exports__);
  38279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  38280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38281. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38282. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38283. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38284. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38285. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38286. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  38287. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38288. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38289. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38290. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38291. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38292. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38293. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  38294. /**
  38295. * Bounding box gizmo
  38296. */
  38297. var BoundingBoxGizmo = /** @class */ (function (_super) {
  38298. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  38299. /**
  38300. * Creates an BoundingBoxGizmo
  38301. * @param gizmoLayer The utility layer the gizmo will be added to
  38302. * @param color The color of the gizmo
  38303. */
  38304. function BoundingBoxGizmo(color, gizmoLayer) {
  38305. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  38306. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  38307. var _this = _super.call(this, gizmoLayer) || this;
  38308. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  38309. _this._renderObserver = null;
  38310. _this._pointerObserver = null;
  38311. _this._scaleDragSpeed = 0.2;
  38312. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38313. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  38314. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  38315. /**
  38316. * 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)
  38317. */
  38318. _this.ignoreChildren = false;
  38319. /**
  38320. * 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)
  38321. */
  38322. _this.includeChildPredicate = null;
  38323. /**
  38324. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38325. */
  38326. _this.rotationSphereSize = 0.1;
  38327. /**
  38328. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38329. */
  38330. _this.scaleBoxSize = 0.1;
  38331. /**
  38332. * 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)
  38333. */
  38334. _this.fixedDragMeshScreenSize = false;
  38335. /**
  38336. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38337. */
  38338. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  38339. /**
  38340. * Fired when a rotation sphere or scale box is dragged
  38341. */
  38342. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38343. /**
  38344. * Fired when a scale box is dragged
  38345. */
  38346. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38347. /**
  38348. * Fired when a scale box drag is ended
  38349. */
  38350. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38351. /**
  38352. * Fired when a rotation sphere is dragged
  38353. */
  38354. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38355. /**
  38356. * Fired when a rotation sphere drag is ended
  38357. */
  38358. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38359. /**
  38360. * 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)
  38361. */
  38362. _this.scalePivot = null;
  38363. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  38364. // Dragging
  38365. _this._dragMesh = null;
  38366. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  38367. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  38368. _this._updateScale = false;
  38369. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  38370. // Create Materials
  38371. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38372. _this.coloredMaterial.disableLighting = true;
  38373. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38374. _this.hoverColoredMaterial.disableLighting = true;
  38375. // Build bounding box out of lines
  38376. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38377. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38378. var lines = [];
  38379. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0)] }, gizmoLayer.utilityLayerScene));
  38380. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  38381. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38382. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  38383. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38384. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  38385. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38386. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38387. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38388. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38389. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38390. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  38391. lines.forEach(function (l) {
  38392. l.color = color;
  38393. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  38394. l.isPickable = false;
  38395. _this._lineBoundingBox.addChild(l);
  38396. });
  38397. _this._rootMesh.addChild(_this._lineBoundingBox);
  38398. _this.setColor(color);
  38399. // Create rotation spheres
  38400. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38401. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38402. var _loop_1 = function (i_1) {
  38403. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  38404. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38405. sphere.material = this_1.coloredMaterial;
  38406. // Drag behavior
  38407. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  38408. _dragBehavior.moveAttached = false;
  38409. _dragBehavior.updateDragPlane = false;
  38410. sphere.addBehavior(_dragBehavior);
  38411. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  38412. var totalTurnAmountOfDrag = 0;
  38413. _dragBehavior.onDragStartObservable.add(function () {
  38414. startingTurnDirection.copyFrom(sphere.forward);
  38415. totalTurnAmountOfDrag = 0;
  38416. });
  38417. _dragBehavior.onDragObservable.add(function (event) {
  38418. _this.onRotationSphereDragObservable.notifyObservers({});
  38419. if (_this.attachedMesh) {
  38420. var originalParent = _this.attachedMesh.parent;
  38421. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38422. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38423. return;
  38424. }
  38425. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38426. var worldDragDirection = startingTurnDirection;
  38427. // Project the world right on to the drag plane
  38428. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  38429. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  38430. // project drag delta on to the resulting drag axis and rotate based on that
  38431. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  38432. // Make rotation relative to size of mesh.
  38433. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38434. // Rotate based on axis
  38435. if (!_this.attachedMesh.rotationQuaternion) {
  38436. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38437. }
  38438. if (!_this._anchorMesh.rotationQuaternion) {
  38439. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  38440. }
  38441. // Do not allow the object to turn more than a full circle
  38442. totalTurnAmountOfDrag += projectDist;
  38443. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  38444. if (i_1 >= 8) {
  38445. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  38446. }
  38447. else if (i_1 >= 4) {
  38448. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  38449. }
  38450. else {
  38451. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  38452. }
  38453. // Rotate around center of bounding box
  38454. _this._anchorMesh.addChild(_this.attachedMesh);
  38455. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  38456. _this._anchorMesh.removeChild(_this.attachedMesh);
  38457. _this.attachedMesh.setParent(originalParent);
  38458. }
  38459. _this.updateBoundingBox();
  38460. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38461. }
  38462. _this._updateDummy();
  38463. });
  38464. // Selection/deselection
  38465. _dragBehavior.onDragStartObservable.add(function () {
  38466. _this.onDragStartObservable.notifyObservers({});
  38467. _this._selectNode(sphere);
  38468. });
  38469. _dragBehavior.onDragEndObservable.add(function () {
  38470. _this.onRotationSphereDragEndObservable.notifyObservers({});
  38471. _this._selectNode(null);
  38472. _this._updateDummy();
  38473. });
  38474. this_1._rotateSpheresParent.addChild(sphere);
  38475. };
  38476. var this_1 = this, _dragBehavior;
  38477. for (var i_1 = 0; i_1 < 12; i_1++) {
  38478. _loop_1(i_1);
  38479. }
  38480. _this._rootMesh.addChild(_this._rotateSpheresParent);
  38481. // Create scale cubes
  38482. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38483. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38484. for (var i = 0; i < 2; i++) {
  38485. for (var j = 0; j < 2; j++) {
  38486. var _loop_2 = function () {
  38487. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  38488. box.material = this_2.coloredMaterial;
  38489. // Dragging logic
  38490. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  38491. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38492. _dragBehavior.moveAttached = false;
  38493. box.addBehavior(_dragBehavior);
  38494. _dragBehavior.onDragObservable.add(function (event) {
  38495. _this.onScaleBoxDragObservable.notifyObservers({});
  38496. if (_this.attachedMesh) {
  38497. var originalParent = _this.attachedMesh.parent;
  38498. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38499. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38500. return;
  38501. }
  38502. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38503. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38504. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  38505. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  38506. _this.updateBoundingBox();
  38507. if (_this.scalePivot) {
  38508. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  38509. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  38510. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  38511. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38512. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38513. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  38514. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38515. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  38516. }
  38517. else {
  38518. // Scale from the position of the opposite corner
  38519. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  38520. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38521. }
  38522. _this._anchorMesh.addChild(_this.attachedMesh);
  38523. _this._anchorMesh.scaling.addInPlace(deltaScale);
  38524. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  38525. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  38526. }
  38527. _this._anchorMesh.removeChild(_this.attachedMesh);
  38528. _this.attachedMesh.setParent(originalParent);
  38529. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38530. }
  38531. _this._updateDummy();
  38532. });
  38533. // Selection/deselection
  38534. _dragBehavior.onDragStartObservable.add(function () {
  38535. _this.onDragStartObservable.notifyObservers({});
  38536. _this._selectNode(box);
  38537. });
  38538. _dragBehavior.onDragEndObservable.add(function () {
  38539. _this.onScaleBoxDragEndObservable.notifyObservers({});
  38540. _this._selectNode(null);
  38541. _this._updateDummy();
  38542. });
  38543. this_2._scaleBoxesParent.addChild(box);
  38544. };
  38545. var this_2 = this, _dragBehavior;
  38546. for (var k = 0; k < 2; k++) {
  38547. _loop_2();
  38548. }
  38549. }
  38550. }
  38551. _this._rootMesh.addChild(_this._scaleBoxesParent);
  38552. // Hover color change
  38553. var pointerIds = new Array();
  38554. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38555. if (!pointerIds[pointerInfo.event.pointerId]) {
  38556. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  38557. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  38558. pointerIds[pointerInfo.event.pointerId] = mesh;
  38559. mesh.material = _this.hoverColoredMaterial;
  38560. }
  38561. });
  38562. }
  38563. else {
  38564. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  38565. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  38566. delete pointerIds[pointerInfo.event.pointerId];
  38567. }
  38568. }
  38569. });
  38570. // Update bounding box positions
  38571. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  38572. // Only update the bouding box if scaling has changed
  38573. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  38574. _this.updateBoundingBox();
  38575. }
  38576. else if (_this.fixedDragMeshScreenSize) {
  38577. _this._updateRotationSpheres();
  38578. _this._updateScaleBoxes();
  38579. }
  38580. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  38581. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  38582. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  38583. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  38584. }
  38585. });
  38586. _this.updateBoundingBox();
  38587. return _this;
  38588. }
  38589. /**
  38590. * Sets the color of the bounding box gizmo
  38591. * @param color the color to set
  38592. */
  38593. BoundingBoxGizmo.prototype.setColor = function (color) {
  38594. this.coloredMaterial.emissiveColor = color;
  38595. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  38596. this._lineBoundingBox.getChildren().forEach(function (l) {
  38597. if (l.color) {
  38598. l.color = color;
  38599. }
  38600. });
  38601. };
  38602. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  38603. var _this = this;
  38604. if (value) {
  38605. // Reset anchor mesh to match attached mesh's scale
  38606. // This is needed to avoid invalid box/sphere position on first drag
  38607. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  38608. var originalParent = value.parent;
  38609. this._anchorMesh.addChild(value);
  38610. this._anchorMesh.removeChild(value);
  38611. value.setParent(originalParent);
  38612. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  38613. this.updateBoundingBox();
  38614. value.getChildMeshes(false).forEach(function (m) {
  38615. m.markAsDirty("scaling");
  38616. });
  38617. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  38618. _this._updateDummy();
  38619. });
  38620. }
  38621. };
  38622. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  38623. this._rotateSpheresParent.getChildMeshes()
  38624. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  38625. m.isVisible = (!selectedMesh || m == selectedMesh);
  38626. });
  38627. };
  38628. /**
  38629. * Updates the bounding box information for the Gizmo
  38630. */
  38631. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  38632. if (this.attachedMesh) {
  38633. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  38634. var originalParent = this.attachedMesh.parent;
  38635. this.attachedMesh.setParent(null);
  38636. this._update();
  38637. // Rotate based on axis
  38638. if (!this.attachedMesh.rotationQuaternion) {
  38639. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  38640. }
  38641. if (!this._anchorMesh.rotationQuaternion) {
  38642. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  38643. }
  38644. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38645. // Store original position and reset mesh to origin before computing the bounding box
  38646. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38647. this._tmpVector.copyFrom(this.attachedMesh.position);
  38648. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  38649. this.attachedMesh.position.set(0, 0, 0);
  38650. // Update bounding dimensions/positions
  38651. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  38652. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  38653. // Update gizmo to match bounding box scaling and rotation
  38654. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  38655. 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);
  38656. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  38657. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  38658. this._lineBoundingBox.computeWorldMatrix();
  38659. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  38660. // restore position/rotation values
  38661. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  38662. this.attachedMesh.position.copyFrom(this._tmpVector);
  38663. this.attachedMesh.setParent(originalParent);
  38664. }
  38665. this._updateRotationSpheres();
  38666. this._updateScaleBoxes();
  38667. if (this.attachedMesh) {
  38668. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  38669. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  38670. }
  38671. };
  38672. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  38673. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  38674. for (var i = 0; i < 3; i++) {
  38675. for (var j = 0; j < 2; j++) {
  38676. for (var k = 0; k < 2; k++) {
  38677. var index = ((i * 4) + (j * 2)) + k;
  38678. if (i == 0) {
  38679. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38680. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38681. 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));
  38682. }
  38683. if (i == 1) {
  38684. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  38685. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38686. 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));
  38687. }
  38688. if (i == 2) {
  38689. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  38690. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38691. 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));
  38692. }
  38693. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38694. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38695. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38696. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38697. }
  38698. else {
  38699. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  38700. }
  38701. }
  38702. }
  38703. }
  38704. };
  38705. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  38706. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  38707. for (var i = 0; i < 2; i++) {
  38708. for (var j = 0; j < 2; j++) {
  38709. for (var k = 0; k < 2; k++) {
  38710. var index = ((i * 4) + (j * 2)) + k;
  38711. if (scaleBoxes[index]) {
  38712. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38713. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38714. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38715. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38716. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38717. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38718. }
  38719. else {
  38720. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  38721. }
  38722. }
  38723. }
  38724. }
  38725. }
  38726. };
  38727. /**
  38728. * Enables rotation on the specified axis and disables rotation on the others
  38729. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38730. */
  38731. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38732. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38733. if (i < 4) {
  38734. m.setEnabled(axis.indexOf("x") != -1);
  38735. }
  38736. else if (i < 8) {
  38737. m.setEnabled(axis.indexOf("y") != -1);
  38738. }
  38739. else {
  38740. m.setEnabled(axis.indexOf("z") != -1);
  38741. }
  38742. });
  38743. };
  38744. /**
  38745. * Enables/disables scaling
  38746. * @param enable if scaling should be enabled
  38747. */
  38748. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38749. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38750. m.setEnabled(enable);
  38751. });
  38752. };
  38753. BoundingBoxGizmo.prototype._updateDummy = function () {
  38754. if (this._dragMesh) {
  38755. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38756. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38757. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38758. }
  38759. };
  38760. /**
  38761. * Enables a pointer drag behavior on the bounding box of the gizmo
  38762. */
  38763. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38764. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38765. this._dragMesh.visibility = 0;
  38766. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38767. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38768. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38769. };
  38770. /**
  38771. * Disposes of the gizmo
  38772. */
  38773. BoundingBoxGizmo.prototype.dispose = function () {
  38774. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38775. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38776. this._lineBoundingBox.dispose();
  38777. this._rotateSpheresParent.dispose();
  38778. this._scaleBoxesParent.dispose();
  38779. if (this._dragMesh) {
  38780. this._dragMesh.dispose();
  38781. }
  38782. _super.prototype.dispose.call(this);
  38783. };
  38784. /**
  38785. * 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)
  38786. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38787. * @returns the bounding box mesh with the passed in mesh as a child
  38788. */
  38789. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38790. var makeNotPickable = function (root) {
  38791. root.isPickable = false;
  38792. root.getChildMeshes().forEach(function (c) {
  38793. makeNotPickable(c);
  38794. });
  38795. };
  38796. makeNotPickable(mesh);
  38797. // Reset position to get boudning box from origin with no rotation
  38798. if (!mesh.rotationQuaternion) {
  38799. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38800. }
  38801. var oldPos = mesh.position.clone();
  38802. var oldRot = mesh.rotationQuaternion.clone();
  38803. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38804. mesh.position.set(0, 0, 0);
  38805. // Update bounding dimensions/positions
  38806. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38807. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38808. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38809. // Adjust scale to avoid undefined behavior when adding child
  38810. if (box.scaling.y === 0) {
  38811. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38812. }
  38813. if (box.scaling.x === 0) {
  38814. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38815. }
  38816. if (box.scaling.z === 0) {
  38817. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38818. }
  38819. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38820. // Restore original positions
  38821. mesh.addChild(box);
  38822. mesh.rotationQuaternion.copyFrom(oldRot);
  38823. mesh.position.copyFrom(oldPos);
  38824. // Reverse parenting
  38825. mesh.removeChild(box);
  38826. box.addChild(mesh);
  38827. box.visibility = 0;
  38828. return box;
  38829. };
  38830. /**
  38831. * CustomMeshes are not supported by this gizmo
  38832. * @param mesh The mesh to replace the default mesh of the gizmo
  38833. */
  38834. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38835. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38836. };
  38837. return BoundingBoxGizmo;
  38838. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  38839. /***/ }),
  38840. /***/ "./Gizmos/gizmo.ts":
  38841. /*!*************************!*\
  38842. !*** ./Gizmos/gizmo.ts ***!
  38843. \*************************/
  38844. /*! exports provided: Gizmo */
  38845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38846. "use strict";
  38847. __webpack_require__.r(__webpack_exports__);
  38848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  38849. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38850. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38851. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38852. /**
  38853. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38854. */
  38855. var Gizmo = /** @class */ (function () {
  38856. /**
  38857. * Creates a gizmo
  38858. * @param gizmoLayer The utility layer the gizmo will be added to
  38859. */
  38860. function Gizmo(
  38861. /** The utility layer the gizmo will be added to */
  38862. gizmoLayer) {
  38863. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultGizmoUtilityLayer; }
  38864. var _this = this;
  38865. this.gizmoLayer = gizmoLayer;
  38866. /**
  38867. * Ratio for the scale of the gizmo (Default: 1)
  38868. */
  38869. this.scaleRatio = 1;
  38870. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  38871. /**
  38872. * If a custom mesh has been set (Default: false)
  38873. */
  38874. this._customMeshSet = false;
  38875. /**
  38876. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38877. */
  38878. this.updateGizmoRotationToMatchAttachedMesh = true;
  38879. /**
  38880. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38881. */
  38882. this.updateGizmoPositionToMatchAttachedMesh = true;
  38883. /**
  38884. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38885. */
  38886. this._updateScale = true;
  38887. this._interactionsEnabled = true;
  38888. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  38889. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  38890. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  38891. _this._update();
  38892. });
  38893. this.attachedMesh = null;
  38894. }
  38895. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  38896. /**
  38897. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38898. * * When set, interactions will be enabled
  38899. */
  38900. get: function () {
  38901. return this._attachedMesh;
  38902. },
  38903. set: function (value) {
  38904. this._attachedMesh = value;
  38905. this._rootMesh.setEnabled(value ? true : false);
  38906. this._attachedMeshChanged(value);
  38907. },
  38908. enumerable: true,
  38909. configurable: true
  38910. });
  38911. /**
  38912. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38913. * @param mesh The mesh to replace the default mesh of the gizmo
  38914. */
  38915. Gizmo.prototype.setCustomMesh = function (mesh) {
  38916. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  38917. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  38918. }
  38919. this._rootMesh.getChildMeshes().forEach(function (c) {
  38920. c.dispose();
  38921. });
  38922. mesh.parent = this._rootMesh;
  38923. this._customMeshSet = true;
  38924. };
  38925. Gizmo.prototype._attachedMeshChanged = function (value) {
  38926. };
  38927. /**
  38928. * @hidden
  38929. * Updates the gizmo to match the attached mesh's position/rotation
  38930. */
  38931. Gizmo.prototype._update = function () {
  38932. if (this.attachedMesh) {
  38933. var effectiveMesh = this.attachedMesh._effectiveMesh || this.attachedMesh;
  38934. if (this.updateGizmoRotationToMatchAttachedMesh) {
  38935. if (!this._rootMesh.rotationQuaternion) {
  38936. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38937. }
  38938. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38939. this._tempVector.copyFrom(effectiveMesh.scaling);
  38940. if (effectiveMesh.scaling.x < 0) {
  38941. effectiveMesh.scaling.x *= -1;
  38942. }
  38943. if (effectiveMesh.scaling.y < 0) {
  38944. effectiveMesh.scaling.y *= -1;
  38945. }
  38946. if (effectiveMesh.scaling.z < 0) {
  38947. effectiveMesh.scaling.z *= -1;
  38948. }
  38949. effectiveMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38950. effectiveMesh.scaling.copyFrom(this._tempVector);
  38951. effectiveMesh.computeWorldMatrix();
  38952. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38953. }
  38954. else if (this._rootMesh.rotationQuaternion) {
  38955. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38956. }
  38957. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38958. this._rootMesh.position.copyFrom(effectiveMesh.absolutePosition);
  38959. }
  38960. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38961. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38962. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38963. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38964. }
  38965. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38966. var dist = this._tempVector.length() * this.scaleRatio;
  38967. this._rootMesh.scaling.set(dist, dist, dist);
  38968. }
  38969. }
  38970. };
  38971. /**
  38972. * Disposes of the gizmo
  38973. */
  38974. Gizmo.prototype.dispose = function () {
  38975. this._rootMesh.dispose();
  38976. if (this._beforeRenderObserver) {
  38977. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38978. }
  38979. };
  38980. return Gizmo;
  38981. }());
  38982. /***/ }),
  38983. /***/ "./Gizmos/gizmoManager.ts":
  38984. /*!********************************!*\
  38985. !*** ./Gizmos/gizmoManager.ts ***!
  38986. \********************************/
  38987. /*! exports provided: GizmoManager */
  38988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38989. "use strict";
  38990. __webpack_require__.r(__webpack_exports__);
  38991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  38992. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38993. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38994. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38995. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38996. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38997. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38998. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38999. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39000. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39001. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39002. /**
  39003. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  39004. */
  39005. var GizmoManager = /** @class */ (function () {
  39006. /**
  39007. * Instatiates a gizmo manager
  39008. * @param scene the scene to overlay the gizmos on top of
  39009. */
  39010. function GizmoManager(scene) {
  39011. var _this = this;
  39012. this.scene = scene;
  39013. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  39014. this.clearGizmoOnEmptyPointerEvent = false;
  39015. /** Fires an event when the manager is attached to a mesh */
  39016. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  39017. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  39018. this._pointerObserver = null;
  39019. this._attachedMesh = null;
  39020. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  39021. /**
  39022. * When bounding box gizmo is enabled, this can be used to track drag/end events
  39023. */
  39024. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  39025. /**
  39026. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  39027. */
  39028. this.attachableMeshes = null;
  39029. /**
  39030. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  39031. */
  39032. this.usePointerToAttachGizmos = true;
  39033. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  39034. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  39035. this._defaultUtilityLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"].DefaultGizmoUtilityLayer;
  39036. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  39037. // Instatiate/dispose gizmos based on pointer actions
  39038. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  39039. if (!_this.usePointerToAttachGizmos) {
  39040. return;
  39041. }
  39042. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  39043. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  39044. var node = pointerInfo.pickInfo.pickedMesh;
  39045. if (_this.attachableMeshes == null) {
  39046. // Attach to the most parent node
  39047. while (node && node.parent != null) {
  39048. node = node.parent;
  39049. }
  39050. }
  39051. else {
  39052. // Attach to the parent node that is an attachableMesh
  39053. var found = false;
  39054. _this.attachableMeshes.forEach(function (mesh) {
  39055. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  39056. node = mesh;
  39057. found = true;
  39058. }
  39059. });
  39060. if (!found) {
  39061. node = null;
  39062. }
  39063. }
  39064. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  39065. if (_this._attachedMesh != node) {
  39066. _this.attachToMesh(node);
  39067. }
  39068. }
  39069. else {
  39070. if (_this.clearGizmoOnEmptyPointerEvent) {
  39071. _this.attachToMesh(null);
  39072. }
  39073. }
  39074. }
  39075. else {
  39076. if (_this.clearGizmoOnEmptyPointerEvent) {
  39077. _this.attachToMesh(null);
  39078. }
  39079. }
  39080. }
  39081. });
  39082. }
  39083. /**
  39084. * Attaches a set of gizmos to the specified mesh
  39085. * @param mesh The mesh the gizmo's should be attached to
  39086. */
  39087. GizmoManager.prototype.attachToMesh = function (mesh) {
  39088. if (this._attachedMesh) {
  39089. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39090. }
  39091. this._attachedMesh = mesh;
  39092. for (var key in this.gizmos) {
  39093. var gizmo = (this.gizmos[key]);
  39094. if (gizmo && this._gizmosEnabled[key]) {
  39095. gizmo.attachedMesh = mesh;
  39096. }
  39097. }
  39098. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  39099. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39100. }
  39101. this.onAttachedToMeshObservable.notifyObservers(mesh);
  39102. };
  39103. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  39104. get: function () {
  39105. return this._gizmosEnabled.positionGizmo;
  39106. },
  39107. /**
  39108. * If the position gizmo is enabled
  39109. */
  39110. set: function (value) {
  39111. if (value) {
  39112. if (!this.gizmos.positionGizmo) {
  39113. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  39114. }
  39115. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  39116. }
  39117. else if (this.gizmos.positionGizmo) {
  39118. this.gizmos.positionGizmo.attachedMesh = null;
  39119. }
  39120. this._gizmosEnabled.positionGizmo = value;
  39121. },
  39122. enumerable: true,
  39123. configurable: true
  39124. });
  39125. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  39126. get: function () {
  39127. return this._gizmosEnabled.rotationGizmo;
  39128. },
  39129. /**
  39130. * If the rotation gizmo is enabled
  39131. */
  39132. set: function (value) {
  39133. if (value) {
  39134. if (!this.gizmos.rotationGizmo) {
  39135. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  39136. }
  39137. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  39138. }
  39139. else if (this.gizmos.rotationGizmo) {
  39140. this.gizmos.rotationGizmo.attachedMesh = null;
  39141. }
  39142. this._gizmosEnabled.rotationGizmo = value;
  39143. },
  39144. enumerable: true,
  39145. configurable: true
  39146. });
  39147. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  39148. get: function () {
  39149. return this._gizmosEnabled.scaleGizmo;
  39150. },
  39151. /**
  39152. * If the scale gizmo is enabled
  39153. */
  39154. set: function (value) {
  39155. if (value) {
  39156. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  39157. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  39158. }
  39159. else if (this.gizmos.scaleGizmo) {
  39160. this.gizmos.scaleGizmo.attachedMesh = null;
  39161. }
  39162. this._gizmosEnabled.scaleGizmo = value;
  39163. },
  39164. enumerable: true,
  39165. configurable: true
  39166. });
  39167. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  39168. get: function () {
  39169. return this._gizmosEnabled.boundingBoxGizmo;
  39170. },
  39171. /**
  39172. * If the boundingBox gizmo is enabled
  39173. */
  39174. set: function (value) {
  39175. if (value) {
  39176. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  39177. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  39178. if (this._attachedMesh) {
  39179. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39180. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39181. }
  39182. }
  39183. else if (this.gizmos.boundingBoxGizmo) {
  39184. if (this._attachedMesh) {
  39185. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39186. }
  39187. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  39188. }
  39189. this._gizmosEnabled.boundingBoxGizmo = value;
  39190. },
  39191. enumerable: true,
  39192. configurable: true
  39193. });
  39194. /**
  39195. * Disposes of the gizmo manager
  39196. */
  39197. GizmoManager.prototype.dispose = function () {
  39198. this.scene.onPointerObservable.remove(this._pointerObserver);
  39199. for (var key in this.gizmos) {
  39200. var gizmo = (this.gizmos[key]);
  39201. if (gizmo) {
  39202. gizmo.dispose();
  39203. }
  39204. }
  39205. this._defaultKeepDepthUtilityLayer.dispose();
  39206. this.boundingBoxDragBehavior.detach();
  39207. this.onAttachedToMeshObservable.clear();
  39208. };
  39209. return GizmoManager;
  39210. }());
  39211. /***/ }),
  39212. /***/ "./Gizmos/index.ts":
  39213. /*!*************************!*\
  39214. !*** ./Gizmos/index.ts ***!
  39215. \*************************/
  39216. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  39217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39218. "use strict";
  39219. __webpack_require__.r(__webpack_exports__);
  39220. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  39222. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  39224. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  39226. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  39228. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  39229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  39230. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  39232. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  39234. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  39236. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  39238. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  39239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  39240. /***/ }),
  39241. /***/ "./Gizmos/lightGizmo.ts":
  39242. /*!******************************!*\
  39243. !*** ./Gizmos/lightGizmo.ts ***!
  39244. \******************************/
  39245. /*! exports provided: LightGizmo */
  39246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39247. "use strict";
  39248. __webpack_require__.r(__webpack_exports__);
  39249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  39250. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39251. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39252. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39253. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39254. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39255. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39256. /**
  39257. * Gizmo that enables viewing a light
  39258. */
  39259. var LightGizmo = /** @class */ (function (_super) {
  39260. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  39261. /**
  39262. * Creates a LightGizmo
  39263. * @param gizmoLayer The utility layer the gizmo will be added to
  39264. */
  39265. function LightGizmo(gizmoLayer) {
  39266. var _this = _super.call(this, gizmoLayer) || this;
  39267. _this._light = null;
  39268. _this._box = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("light", 0.02, 0, 0.02, 16, 1, _this.gizmoLayer.utilityLayerScene);
  39269. _this._box.rotation.x = -Math.PI / 2;
  39270. _this._box.bakeCurrentTransformIntoVertices();
  39271. _this._box.material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", _this.gizmoLayer.utilityLayerScene);
  39272. _this._box.material.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Yellow();
  39273. _this._rootMesh.addChild(_this._box);
  39274. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  39275. return _this;
  39276. }
  39277. Object.defineProperty(LightGizmo.prototype, "light", {
  39278. get: function () {
  39279. return this._light;
  39280. },
  39281. /**
  39282. * The light that the gizmo is attached to
  39283. */
  39284. set: function (light) {
  39285. this._light = light;
  39286. if (light.position) {
  39287. this.attachedMesh.position.copyFrom(light.position);
  39288. }
  39289. if (light.direction) {
  39290. this._box.setDirection(light.direction);
  39291. }
  39292. },
  39293. enumerable: true,
  39294. configurable: true
  39295. });
  39296. /**
  39297. * @hidden
  39298. * Updates the gizmo to match the attached mesh's position/rotation
  39299. */
  39300. LightGizmo.prototype._update = function () {
  39301. _super.prototype._update.call(this);
  39302. if (!this._light) {
  39303. return;
  39304. }
  39305. if (this._light.position) {
  39306. this._light.position.copyFrom(this.attachedMesh.position);
  39307. }
  39308. if (this._light.direction) {
  39309. this._light.direction.copyFrom(this._box.forward);
  39310. }
  39311. if (!this._light.isEnabled()) {
  39312. this._box.material.emissiveColor.set(0, 0, 0);
  39313. }
  39314. else {
  39315. this._box.material.emissiveColor.set(1, 1, 1);
  39316. }
  39317. };
  39318. return LightGizmo;
  39319. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39320. /***/ }),
  39321. /***/ "./Gizmos/planeRotationGizmo.ts":
  39322. /*!**************************************!*\
  39323. !*** ./Gizmos/planeRotationGizmo.ts ***!
  39324. \**************************************/
  39325. /*! exports provided: PlaneRotationGizmo */
  39326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39327. "use strict";
  39328. __webpack_require__.r(__webpack_exports__);
  39329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  39330. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39331. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39332. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39333. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39334. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39335. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  39336. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39337. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39338. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39339. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  39340. /**
  39341. * Single plane rotation gizmo
  39342. */
  39343. var PlaneRotationGizmo = /** @class */ (function (_super) {
  39344. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  39345. /**
  39346. * Creates a PlaneRotationGizmo
  39347. * @param gizmoLayer The utility layer the gizmo will be added to
  39348. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  39349. * @param color The color of the gizmo
  39350. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39351. */
  39352. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  39353. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  39354. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultGizmoUtilityLayer; }
  39355. if (tessellation === void 0) { tessellation = 32; }
  39356. var _this = _super.call(this, gizmoLayer) || this;
  39357. _this._pointerObserver = null;
  39358. /**
  39359. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  39360. */
  39361. _this.snapDistance = 0;
  39362. /**
  39363. * Event that fires each time the gizmo snaps to a new location.
  39364. * * snapDistance is the the change in distance
  39365. */
  39366. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39367. // Create Material
  39368. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39369. coloredMaterial.diffuseColor = color;
  39370. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  39371. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39372. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  39373. // Build mesh on root node
  39374. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  39375. var drag = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.03, tessellation, gizmoLayer.utilityLayerScene);
  39376. drag.visibility = 0;
  39377. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.005, tessellation, gizmoLayer.utilityLayerScene);
  39378. rotationMesh.material = coloredMaterial;
  39379. // Position arrow pointing in its drag axis
  39380. rotationMesh.rotation.x = Math.PI / 2;
  39381. drag.rotation.x = Math.PI / 2;
  39382. parentMesh.addChild(rotationMesh);
  39383. parentMesh.addChild(drag);
  39384. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  39385. _this._rootMesh.addChild(parentMesh);
  39386. parentMesh.scaling.scaleInPlace(1 / 3);
  39387. // Add drag behavior to handle events when the gizmo is dragged
  39388. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  39389. _this.dragBehavior.moveAttached = false;
  39390. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  39391. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  39392. _this._rootMesh.addBehavior(_this.dragBehavior);
  39393. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39394. _this.dragBehavior.onDragStartObservable.add(function (e) {
  39395. if (_this.attachedMesh) {
  39396. lastDragPosition.copyFrom(e.dragPlanePoint);
  39397. }
  39398. });
  39399. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39400. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39401. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39402. var tmpSnapEvent = { snapDistance: 0 };
  39403. var currentSnapDragDistance = 0;
  39404. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39405. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39406. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  39407. _this.dragBehavior.onDragObservable.add(function (event) {
  39408. if (_this.attachedMesh) {
  39409. if (!_this.attachedMesh.rotationQuaternion) {
  39410. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  39411. }
  39412. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  39413. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  39414. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  39415. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  39416. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  39417. var angle = Math.atan2(cross.length(), dot);
  39418. planeNormalTowardsCamera.copyFrom(planeNormal);
  39419. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  39420. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39421. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  39422. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  39423. }
  39424. // Flip up vector depending on which side the camera is on
  39425. if (gizmoLayer.utilityLayerScene.activeCamera) {
  39426. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  39427. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  39428. planeNormalTowardsCamera.scaleInPlace(-1);
  39429. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  39430. }
  39431. }
  39432. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  39433. if (halfCircleSide) {
  39434. angle = -angle;
  39435. }
  39436. // Snapping logic
  39437. var snapped = false;
  39438. if (_this.snapDistance != 0) {
  39439. currentSnapDragDistance += angle;
  39440. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  39441. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  39442. if (currentSnapDragDistance < 0) {
  39443. dragSteps *= -1;
  39444. }
  39445. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  39446. angle = _this.snapDistance * dragSteps;
  39447. snapped = true;
  39448. }
  39449. else {
  39450. angle = 0;
  39451. }
  39452. }
  39453. // If the mesh has a parent, convert needed world rotation to local rotation
  39454. tmpMatrix.reset();
  39455. if (_this.attachedMesh.parent) {
  39456. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  39457. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  39458. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  39459. }
  39460. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  39461. var quaternionCoefficient = Math.sin(angle / 2);
  39462. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  39463. // 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
  39464. if (tmpMatrix.determinant() > 0) {
  39465. amountToRotate.toEulerAnglesToRef(tmpVector);
  39466. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  39467. }
  39468. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39469. // Rotate selected mesh quaternion over fixed axis
  39470. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  39471. }
  39472. else {
  39473. // Rotate selected mesh quaternion over rotated axis
  39474. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  39475. }
  39476. lastDragPosition.copyFrom(event.dragPlanePoint);
  39477. if (snapped) {
  39478. tmpSnapEvent.snapDistance = angle;
  39479. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  39480. }
  39481. }
  39482. });
  39483. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  39484. if (_this._customMeshSet) {
  39485. return;
  39486. }
  39487. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  39488. var material = isHovered ? hoverMaterial : coloredMaterial;
  39489. _this._rootMesh.getChildMeshes().forEach(function (m) {
  39490. m.material = material;
  39491. if (m.color) {
  39492. m.color = material.diffuseColor;
  39493. }
  39494. });
  39495. });
  39496. return _this;
  39497. }
  39498. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  39499. if (this.dragBehavior) {
  39500. this.dragBehavior.enabled = value ? true : false;
  39501. }
  39502. };
  39503. /**
  39504. * Disposes of the gizmo
  39505. */
  39506. PlaneRotationGizmo.prototype.dispose = function () {
  39507. this.onSnapObservable.clear();
  39508. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  39509. this.dragBehavior.detach();
  39510. _super.prototype.dispose.call(this);
  39511. };
  39512. return PlaneRotationGizmo;
  39513. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  39514. /***/ }),
  39515. /***/ "./Gizmos/positionGizmo.ts":
  39516. /*!*********************************!*\
  39517. !*** ./Gizmos/positionGizmo.ts ***!
  39518. \*********************************/
  39519. /*! exports provided: PositionGizmo */
  39520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39521. "use strict";
  39522. __webpack_require__.r(__webpack_exports__);
  39523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  39524. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39525. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39526. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39527. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39528. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39529. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39530. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39531. /**
  39532. * Gizmo that enables dragging a mesh along 3 axis
  39533. */
  39534. var PositionGizmo = /** @class */ (function (_super) {
  39535. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  39536. /**
  39537. * Creates a PositionGizmo
  39538. * @param gizmoLayer The utility layer the gizmo will be added to
  39539. */
  39540. function PositionGizmo(gizmoLayer) {
  39541. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultGizmoUtilityLayer; }
  39542. var _this = _super.call(this, gizmoLayer) || this;
  39543. /** Fires an event when any of it's sub gizmos are dragged */
  39544. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39545. /** Fires an event when any of it's sub gizmos are released from dragging */
  39546. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39547. _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);
  39548. _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);
  39549. _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);
  39550. // Relay drag events
  39551. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39552. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39553. _this.onDragStartObservable.notifyObservers({});
  39554. });
  39555. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39556. _this.onDragEndObservable.notifyObservers({});
  39557. });
  39558. });
  39559. _this.attachedMesh = null;
  39560. return _this;
  39561. }
  39562. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  39563. get: function () {
  39564. return this.xGizmo.attachedMesh;
  39565. },
  39566. set: function (mesh) {
  39567. if (this.xGizmo) {
  39568. this.xGizmo.attachedMesh = mesh;
  39569. this.yGizmo.attachedMesh = mesh;
  39570. this.zGizmo.attachedMesh = mesh;
  39571. }
  39572. },
  39573. enumerable: true,
  39574. configurable: true
  39575. });
  39576. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39577. get: function () {
  39578. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39579. },
  39580. set: function (value) {
  39581. if (this.xGizmo) {
  39582. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39583. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39584. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39585. }
  39586. },
  39587. enumerable: true,
  39588. configurable: true
  39589. });
  39590. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  39591. get: function () {
  39592. return this.xGizmo.snapDistance;
  39593. },
  39594. /**
  39595. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39596. */
  39597. set: function (value) {
  39598. if (this.xGizmo) {
  39599. this.xGizmo.snapDistance = value;
  39600. this.yGizmo.snapDistance = value;
  39601. this.zGizmo.snapDistance = value;
  39602. }
  39603. },
  39604. enumerable: true,
  39605. configurable: true
  39606. });
  39607. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  39608. get: function () {
  39609. return this.xGizmo.scaleRatio;
  39610. },
  39611. /**
  39612. * Ratio for the scale of the gizmo (Default: 1)
  39613. */
  39614. set: function (value) {
  39615. if (this.xGizmo) {
  39616. this.xGizmo.scaleRatio = value;
  39617. this.yGizmo.scaleRatio = value;
  39618. this.zGizmo.scaleRatio = value;
  39619. }
  39620. },
  39621. enumerable: true,
  39622. configurable: true
  39623. });
  39624. /**
  39625. * Disposes of the gizmo
  39626. */
  39627. PositionGizmo.prototype.dispose = function () {
  39628. this.xGizmo.dispose();
  39629. this.yGizmo.dispose();
  39630. this.zGizmo.dispose();
  39631. this.onDragStartObservable.clear();
  39632. this.onDragEndObservable.clear();
  39633. };
  39634. /**
  39635. * CustomMeshes are not supported by this gizmo
  39636. * @param mesh The mesh to replace the default mesh of the gizmo
  39637. */
  39638. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  39639. _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)");
  39640. };
  39641. return PositionGizmo;
  39642. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39643. /***/ }),
  39644. /***/ "./Gizmos/rotationGizmo.ts":
  39645. /*!*********************************!*\
  39646. !*** ./Gizmos/rotationGizmo.ts ***!
  39647. \*********************************/
  39648. /*! exports provided: RotationGizmo */
  39649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39650. "use strict";
  39651. __webpack_require__.r(__webpack_exports__);
  39652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  39653. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39654. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39655. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39656. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39657. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39658. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39659. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39660. /**
  39661. * Gizmo that enables rotating a mesh along 3 axis
  39662. */
  39663. var RotationGizmo = /** @class */ (function (_super) {
  39664. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  39665. /**
  39666. * Creates a RotationGizmo
  39667. * @param gizmoLayer The utility layer the gizmo will be added to
  39668. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39669. */
  39670. function RotationGizmo(gizmoLayer, tessellation) {
  39671. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultGizmoUtilityLayer; }
  39672. if (tessellation === void 0) { tessellation = 32; }
  39673. var _this = _super.call(this, gizmoLayer) || this;
  39674. /** Fires an event when any of it's sub gizmos are dragged */
  39675. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39676. /** Fires an event when any of it's sub gizmos are released from dragging */
  39677. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39678. _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);
  39679. _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);
  39680. _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);
  39681. // Relay drag events
  39682. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39683. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39684. _this.onDragStartObservable.notifyObservers({});
  39685. });
  39686. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39687. _this.onDragEndObservable.notifyObservers({});
  39688. });
  39689. });
  39690. _this.attachedMesh = null;
  39691. return _this;
  39692. }
  39693. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  39694. get: function () {
  39695. return this.xGizmo.attachedMesh;
  39696. },
  39697. set: function (mesh) {
  39698. if (this.xGizmo) {
  39699. this.xGizmo.attachedMesh = mesh;
  39700. this.yGizmo.attachedMesh = mesh;
  39701. this.zGizmo.attachedMesh = mesh;
  39702. }
  39703. },
  39704. enumerable: true,
  39705. configurable: true
  39706. });
  39707. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39708. get: function () {
  39709. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39710. },
  39711. set: function (value) {
  39712. if (this.xGizmo) {
  39713. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39714. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39715. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39716. }
  39717. },
  39718. enumerable: true,
  39719. configurable: true
  39720. });
  39721. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  39722. get: function () {
  39723. return this.xGizmo.snapDistance;
  39724. },
  39725. /**
  39726. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39727. */
  39728. set: function (value) {
  39729. if (this.xGizmo) {
  39730. this.xGizmo.snapDistance = value;
  39731. this.yGizmo.snapDistance = value;
  39732. this.zGizmo.snapDistance = value;
  39733. }
  39734. },
  39735. enumerable: true,
  39736. configurable: true
  39737. });
  39738. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  39739. get: function () {
  39740. return this.xGizmo.scaleRatio;
  39741. },
  39742. /**
  39743. * Ratio for the scale of the gizmo (Default: 1)
  39744. */
  39745. set: function (value) {
  39746. if (this.xGizmo) {
  39747. this.xGizmo.scaleRatio = value;
  39748. this.yGizmo.scaleRatio = value;
  39749. this.zGizmo.scaleRatio = value;
  39750. }
  39751. },
  39752. enumerable: true,
  39753. configurable: true
  39754. });
  39755. /**
  39756. * Disposes of the gizmo
  39757. */
  39758. RotationGizmo.prototype.dispose = function () {
  39759. this.xGizmo.dispose();
  39760. this.yGizmo.dispose();
  39761. this.zGizmo.dispose();
  39762. this.onDragStartObservable.clear();
  39763. this.onDragEndObservable.clear();
  39764. };
  39765. /**
  39766. * CustomMeshes are not supported by this gizmo
  39767. * @param mesh The mesh to replace the default mesh of the gizmo
  39768. */
  39769. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  39770. _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)");
  39771. };
  39772. return RotationGizmo;
  39773. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39774. /***/ }),
  39775. /***/ "./Gizmos/scaleGizmo.ts":
  39776. /*!******************************!*\
  39777. !*** ./Gizmos/scaleGizmo.ts ***!
  39778. \******************************/
  39779. /*! exports provided: ScaleGizmo */
  39780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39781. "use strict";
  39782. __webpack_require__.r(__webpack_exports__);
  39783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  39784. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39785. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39786. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39787. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39788. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  39789. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39790. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39791. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39792. /**
  39793. * Gizmo that enables scaling a mesh along 3 axis
  39794. */
  39795. var ScaleGizmo = /** @class */ (function (_super) {
  39796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  39797. /**
  39798. * Creates a ScaleGizmo
  39799. * @param gizmoLayer The utility layer the gizmo will be added to
  39800. */
  39801. function ScaleGizmo(gizmoLayer) {
  39802. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultGizmoUtilityLayer; }
  39803. var _this = _super.call(this, gizmoLayer) || this;
  39804. /** Fires an event when any of it's sub gizmos are dragged */
  39805. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39806. /** Fires an event when any of it's sub gizmos are released from dragging */
  39807. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39808. _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);
  39809. _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);
  39810. _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);
  39811. // Create uniform scale gizmo
  39812. _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);
  39813. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  39814. _this.uniformScaleGizmo.uniformScaling = true;
  39815. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39816. uniformScalingMesh.scaling.scaleInPlace(0.02);
  39817. uniformScalingMesh.visibility = 0;
  39818. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39819. octahedron.scaling.scaleInPlace(0.007);
  39820. uniformScalingMesh.addChild(octahedron);
  39821. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  39822. // Relay drag events
  39823. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  39824. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39825. _this.onDragStartObservable.notifyObservers({});
  39826. });
  39827. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39828. _this.onDragEndObservable.notifyObservers({});
  39829. });
  39830. });
  39831. _this.attachedMesh = null;
  39832. return _this;
  39833. }
  39834. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  39835. get: function () {
  39836. return this.xGizmo.attachedMesh;
  39837. },
  39838. set: function (mesh) {
  39839. if (this.xGizmo) {
  39840. this.xGizmo.attachedMesh = mesh;
  39841. this.yGizmo.attachedMesh = mesh;
  39842. this.zGizmo.attachedMesh = mesh;
  39843. this.uniformScaleGizmo.attachedMesh = mesh;
  39844. }
  39845. },
  39846. enumerable: true,
  39847. configurable: true
  39848. });
  39849. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39850. get: function () {
  39851. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39852. },
  39853. set: function (value) {
  39854. if (!value) {
  39855. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  39856. }
  39857. if (this.xGizmo) {
  39858. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39859. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39860. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39861. }
  39862. },
  39863. enumerable: true,
  39864. configurable: true
  39865. });
  39866. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  39867. get: function () {
  39868. return this.xGizmo.snapDistance;
  39869. },
  39870. /**
  39871. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39872. */
  39873. set: function (value) {
  39874. if (this.xGizmo) {
  39875. this.xGizmo.snapDistance = value;
  39876. this.yGizmo.snapDistance = value;
  39877. this.zGizmo.snapDistance = value;
  39878. this.uniformScaleGizmo.snapDistance = value;
  39879. }
  39880. },
  39881. enumerable: true,
  39882. configurable: true
  39883. });
  39884. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  39885. get: function () {
  39886. return this.xGizmo.scaleRatio;
  39887. },
  39888. /**
  39889. * Ratio for the scale of the gizmo (Default: 1)
  39890. */
  39891. set: function (value) {
  39892. if (this.xGizmo) {
  39893. this.xGizmo.scaleRatio = value;
  39894. this.yGizmo.scaleRatio = value;
  39895. this.zGizmo.scaleRatio = value;
  39896. this.uniformScaleGizmo.scaleRatio = value;
  39897. }
  39898. },
  39899. enumerable: true,
  39900. configurable: true
  39901. });
  39902. /**
  39903. * Disposes of the gizmo
  39904. */
  39905. ScaleGizmo.prototype.dispose = function () {
  39906. this.xGizmo.dispose();
  39907. this.yGizmo.dispose();
  39908. this.zGizmo.dispose();
  39909. this.uniformScaleGizmo.dispose();
  39910. this.onDragStartObservable.clear();
  39911. this.onDragEndObservable.clear();
  39912. };
  39913. return ScaleGizmo;
  39914. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  39915. /***/ }),
  39916. /***/ "./Helpers/environmentHelper.ts":
  39917. /*!**************************************!*\
  39918. !*** ./Helpers/environmentHelper.ts ***!
  39919. \**************************************/
  39920. /*! exports provided: EnvironmentHelper */
  39921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39922. "use strict";
  39923. __webpack_require__.r(__webpack_exports__);
  39924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  39925. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39926. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39927. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39928. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39929. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39930. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  39931. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39932. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  39933. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  39934. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39935. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39936. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  39937. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39938. /**
  39939. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  39940. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  39941. * It also helps with the default setup of your imageProcessing configuration.
  39942. */
  39943. var EnvironmentHelper = /** @class */ (function () {
  39944. /**
  39945. * constructor
  39946. * @param options Defines the options we want to customize the helper
  39947. * @param scene The scene to add the material to
  39948. */
  39949. function EnvironmentHelper(options, scene) {
  39950. var _this = this;
  39951. this._errorHandler = function (message, exception) {
  39952. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  39953. };
  39954. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  39955. this._scene = scene;
  39956. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39957. this._setupBackground();
  39958. this._setupImageProcessing();
  39959. }
  39960. /**
  39961. * Creates the default options for the helper.
  39962. */
  39963. EnvironmentHelper._getDefaultOptions = function () {
  39964. return {
  39965. createGround: true,
  39966. groundSize: 15,
  39967. groundTexture: this._groundTextureCDNUrl,
  39968. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39969. groundOpacity: 0.9,
  39970. enableGroundShadow: true,
  39971. groundShadowLevel: 0.5,
  39972. enableGroundMirror: false,
  39973. groundMirrorSizeRatio: 0.3,
  39974. groundMirrorBlurKernel: 64,
  39975. groundMirrorAmount: 1,
  39976. groundMirrorFresnelWeight: 1,
  39977. groundMirrorFallOffDistance: 0,
  39978. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  39979. groundYBias: 0.00001,
  39980. createSkybox: true,
  39981. skyboxSize: 20,
  39982. skyboxTexture: this._skyboxTextureCDNUrl,
  39983. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39984. backgroundYRotation: 0,
  39985. sizeAuto: true,
  39986. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  39987. setupImageProcessing: true,
  39988. environmentTexture: this._environmentTextureCDNUrl,
  39989. cameraExposure: 0.8,
  39990. cameraContrast: 1.2,
  39991. toneMappingEnabled: true,
  39992. };
  39993. };
  39994. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  39995. /**
  39996. * Gets the root mesh created by the helper.
  39997. */
  39998. get: function () {
  39999. return this._rootMesh;
  40000. },
  40001. enumerable: true,
  40002. configurable: true
  40003. });
  40004. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  40005. /**
  40006. * Gets the skybox created by the helper.
  40007. */
  40008. get: function () {
  40009. return this._skybox;
  40010. },
  40011. enumerable: true,
  40012. configurable: true
  40013. });
  40014. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  40015. /**
  40016. * Gets the skybox texture created by the helper.
  40017. */
  40018. get: function () {
  40019. return this._skyboxTexture;
  40020. },
  40021. enumerable: true,
  40022. configurable: true
  40023. });
  40024. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  40025. /**
  40026. * Gets the skybox material created by the helper.
  40027. */
  40028. get: function () {
  40029. return this._skyboxMaterial;
  40030. },
  40031. enumerable: true,
  40032. configurable: true
  40033. });
  40034. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  40035. /**
  40036. * Gets the ground mesh created by the helper.
  40037. */
  40038. get: function () {
  40039. return this._ground;
  40040. },
  40041. enumerable: true,
  40042. configurable: true
  40043. });
  40044. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  40045. /**
  40046. * Gets the ground texture created by the helper.
  40047. */
  40048. get: function () {
  40049. return this._groundTexture;
  40050. },
  40051. enumerable: true,
  40052. configurable: true
  40053. });
  40054. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  40055. /**
  40056. * Gets the ground mirror created by the helper.
  40057. */
  40058. get: function () {
  40059. return this._groundMirror;
  40060. },
  40061. enumerable: true,
  40062. configurable: true
  40063. });
  40064. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  40065. /**
  40066. * Gets the ground mirror render list to helps pushing the meshes
  40067. * you wish in the ground reflection.
  40068. */
  40069. get: function () {
  40070. if (this._groundMirror) {
  40071. return this._groundMirror.renderList;
  40072. }
  40073. return null;
  40074. },
  40075. enumerable: true,
  40076. configurable: true
  40077. });
  40078. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  40079. /**
  40080. * Gets the ground material created by the helper.
  40081. */
  40082. get: function () {
  40083. return this._groundMaterial;
  40084. },
  40085. enumerable: true,
  40086. configurable: true
  40087. });
  40088. /**
  40089. * Updates the background according to the new options
  40090. * @param options
  40091. */
  40092. EnvironmentHelper.prototype.updateOptions = function (options) {
  40093. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  40094. if (this._ground && !newOptions.createGround) {
  40095. this._ground.dispose();
  40096. this._ground = null;
  40097. }
  40098. if (this._groundMaterial && !newOptions.createGround) {
  40099. this._groundMaterial.dispose();
  40100. this._groundMaterial = null;
  40101. }
  40102. if (this._groundTexture) {
  40103. if (this._options.groundTexture != newOptions.groundTexture) {
  40104. this._groundTexture.dispose();
  40105. this._groundTexture = null;
  40106. }
  40107. }
  40108. if (this._skybox && !newOptions.createSkybox) {
  40109. this._skybox.dispose();
  40110. this._skybox = null;
  40111. }
  40112. if (this._skyboxMaterial && !newOptions.createSkybox) {
  40113. this._skyboxMaterial.dispose();
  40114. this._skyboxMaterial = null;
  40115. }
  40116. if (this._skyboxTexture) {
  40117. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  40118. this._skyboxTexture.dispose();
  40119. this._skyboxTexture = null;
  40120. }
  40121. }
  40122. if (this._groundMirror && !newOptions.enableGroundMirror) {
  40123. this._groundMirror.dispose();
  40124. this._groundMirror = null;
  40125. }
  40126. if (this._scene.environmentTexture) {
  40127. if (this._options.environmentTexture != newOptions.environmentTexture) {
  40128. this._scene.environmentTexture.dispose();
  40129. }
  40130. }
  40131. this._options = newOptions;
  40132. this._setupBackground();
  40133. this._setupImageProcessing();
  40134. };
  40135. /**
  40136. * Sets the primary color of all the available elements.
  40137. * @param color the main color to affect to the ground and the background
  40138. */
  40139. EnvironmentHelper.prototype.setMainColor = function (color) {
  40140. if (this.groundMaterial) {
  40141. this.groundMaterial.primaryColor = color;
  40142. }
  40143. if (this.skyboxMaterial) {
  40144. this.skyboxMaterial.primaryColor = color;
  40145. }
  40146. if (this.groundMirror) {
  40147. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  40148. }
  40149. };
  40150. /**
  40151. * Setup the image processing according to the specified options.
  40152. */
  40153. EnvironmentHelper.prototype._setupImageProcessing = function () {
  40154. if (this._options.setupImageProcessing) {
  40155. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  40156. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  40157. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  40158. this._setupEnvironmentTexture();
  40159. }
  40160. };
  40161. /**
  40162. * Setup the environment texture according to the specified options.
  40163. */
  40164. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  40165. if (this._scene.environmentTexture) {
  40166. return;
  40167. }
  40168. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40169. this._scene.environmentTexture = this._options.environmentTexture;
  40170. return;
  40171. }
  40172. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  40173. this._scene.environmentTexture = environmentTexture;
  40174. };
  40175. /**
  40176. * Setup the background according to the specified options.
  40177. */
  40178. EnvironmentHelper.prototype._setupBackground = function () {
  40179. if (!this._rootMesh) {
  40180. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  40181. }
  40182. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  40183. var sceneSize = this._getSceneSize();
  40184. if (this._options.createGround) {
  40185. this._setupGround(sceneSize);
  40186. this._setupGroundMaterial();
  40187. this._setupGroundDiffuseTexture();
  40188. if (this._options.enableGroundMirror) {
  40189. this._setupGroundMirrorTexture(sceneSize);
  40190. }
  40191. this._setupMirrorInGroundMaterial();
  40192. }
  40193. if (this._options.createSkybox) {
  40194. this._setupSkybox(sceneSize);
  40195. this._setupSkyboxMaterial();
  40196. this._setupSkyboxReflectionTexture();
  40197. }
  40198. this._rootMesh.position.x = sceneSize.rootPosition.x;
  40199. this._rootMesh.position.z = sceneSize.rootPosition.z;
  40200. this._rootMesh.position.y = sceneSize.rootPosition.y;
  40201. };
  40202. /**
  40203. * Get the scene sizes according to the setup.
  40204. */
  40205. EnvironmentHelper.prototype._getSceneSize = function () {
  40206. var _this = this;
  40207. var groundSize = this._options.groundSize;
  40208. var skyboxSize = this._options.skyboxSize;
  40209. var rootPosition = this._options.rootPosition;
  40210. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  40211. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40212. }
  40213. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  40214. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  40215. });
  40216. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  40217. if (this._options.sizeAuto) {
  40218. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  40219. this._scene.activeCamera.upperRadiusLimit) {
  40220. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  40221. skyboxSize = groundSize;
  40222. }
  40223. var sceneDiagonalLenght = sceneDiagonal.length();
  40224. if (sceneDiagonalLenght > groundSize) {
  40225. groundSize = sceneDiagonalLenght * 2;
  40226. skyboxSize = groundSize;
  40227. }
  40228. // 10 % bigger.
  40229. groundSize *= 1.1;
  40230. skyboxSize *= 1.5;
  40231. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  40232. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  40233. }
  40234. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40235. };
  40236. /**
  40237. * Setup the ground according to the specified options.
  40238. */
  40239. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  40240. var _this = this;
  40241. if (!this._ground || this._ground.isDisposed()) {
  40242. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  40243. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  40244. this._ground.parent = this._rootMesh;
  40245. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  40246. }
  40247. this._ground.receiveShadows = this._options.enableGroundShadow;
  40248. };
  40249. /**
  40250. * Setup the ground material according to the specified options.
  40251. */
  40252. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  40253. if (!this._groundMaterial) {
  40254. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  40255. }
  40256. this._groundMaterial.alpha = this._options.groundOpacity;
  40257. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  40258. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  40259. this._groundMaterial.primaryColor = this._options.groundColor;
  40260. this._groundMaterial.useRGBColor = false;
  40261. this._groundMaterial.enableNoise = true;
  40262. if (this._ground) {
  40263. this._ground.material = this._groundMaterial;
  40264. }
  40265. };
  40266. /**
  40267. * Setup the ground diffuse texture according to the specified options.
  40268. */
  40269. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  40270. if (!this._groundMaterial) {
  40271. return;
  40272. }
  40273. if (this._groundTexture) {
  40274. return;
  40275. }
  40276. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40277. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  40278. return;
  40279. }
  40280. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40281. diffuseTexture.gammaSpace = false;
  40282. diffuseTexture.hasAlpha = true;
  40283. this._groundMaterial.diffuseTexture = diffuseTexture;
  40284. };
  40285. /**
  40286. * Setup the ground mirror texture according to the specified options.
  40287. */
  40288. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  40289. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  40290. if (!this._groundMirror) {
  40291. 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);
  40292. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  40293. this._groundMirror.anisotropicFilteringLevel = 1;
  40294. this._groundMirror.wrapU = wrapping;
  40295. this._groundMirror.wrapV = wrapping;
  40296. this._groundMirror.gammaSpace = false;
  40297. if (this._groundMirror.renderList) {
  40298. for (var i = 0; i < this._scene.meshes.length; i++) {
  40299. var mesh = this._scene.meshes[i];
  40300. if (mesh !== this._ground &&
  40301. mesh !== this._skybox &&
  40302. mesh !== this._rootMesh) {
  40303. this._groundMirror.renderList.push(mesh);
  40304. }
  40305. }
  40306. }
  40307. }
  40308. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  40309. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  40310. };
  40311. /**
  40312. * Setup the ground to receive the mirror texture.
  40313. */
  40314. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  40315. if (this._groundMaterial) {
  40316. this._groundMaterial.reflectionTexture = this._groundMirror;
  40317. this._groundMaterial.reflectionFresnel = true;
  40318. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  40319. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  40320. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  40321. }
  40322. };
  40323. /**
  40324. * Setup the skybox according to the specified options.
  40325. */
  40326. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  40327. var _this = this;
  40328. if (!this._skybox || this._skybox.isDisposed()) {
  40329. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  40330. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  40331. }
  40332. this._skybox.parent = this._rootMesh;
  40333. };
  40334. /**
  40335. * Setup the skybox material according to the specified options.
  40336. */
  40337. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  40338. if (!this._skybox) {
  40339. return;
  40340. }
  40341. if (!this._skyboxMaterial) {
  40342. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  40343. }
  40344. this._skyboxMaterial.useRGBColor = false;
  40345. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  40346. this._skyboxMaterial.enableNoise = true;
  40347. this._skybox.material = this._skyboxMaterial;
  40348. };
  40349. /**
  40350. * Setup the skybox reflection texture according to the specified options.
  40351. */
  40352. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  40353. if (!this._skyboxMaterial) {
  40354. return;
  40355. }
  40356. if (this._skyboxTexture) {
  40357. return;
  40358. }
  40359. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40360. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  40361. return;
  40362. }
  40363. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40364. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  40365. this._skyboxTexture.gammaSpace = false;
  40366. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  40367. };
  40368. /**
  40369. * Dispose all the elements created by the Helper.
  40370. */
  40371. EnvironmentHelper.prototype.dispose = function () {
  40372. if (this._groundMaterial) {
  40373. this._groundMaterial.dispose(true, true);
  40374. }
  40375. if (this._skyboxMaterial) {
  40376. this._skyboxMaterial.dispose(true, true);
  40377. }
  40378. this._rootMesh.dispose(false);
  40379. };
  40380. /**
  40381. * Default ground texture URL.
  40382. */
  40383. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  40384. /**
  40385. * Default skybox texture URL.
  40386. */
  40387. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  40388. /**
  40389. * Default environment texture URL.
  40390. */
  40391. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  40392. return EnvironmentHelper;
  40393. }());
  40394. /***/ }),
  40395. /***/ "./Helpers/index.ts":
  40396. /*!**************************!*\
  40397. !*** ./Helpers/index.ts ***!
  40398. \**************************/
  40399. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  40400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40401. "use strict";
  40402. __webpack_require__.r(__webpack_exports__);
  40403. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  40405. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  40406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  40407. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  40408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  40409. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  40410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  40411. /***/ }),
  40412. /***/ "./Helpers/photoDome.ts":
  40413. /*!******************************!*\
  40414. !*** ./Helpers/photoDome.ts ***!
  40415. \******************************/
  40416. /*! exports provided: PhotoDome */
  40417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40418. "use strict";
  40419. __webpack_require__.r(__webpack_exports__);
  40420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  40421. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40422. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40423. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40424. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40425. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40426. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40427. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40428. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40429. /**
  40430. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  40431. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  40432. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  40433. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40434. */
  40435. var PhotoDome = /** @class */ (function (_super) {
  40436. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  40437. /**
  40438. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  40439. * @param name Element's name, child elements will append suffixes for their own names.
  40440. * @param urlsOfPhoto defines the url of the photo to display
  40441. * @param options defines an object containing optional or exposed sub element properties
  40442. * @param onError defines a callback called when an error occured while loading the texture
  40443. */
  40444. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  40445. if (onError === void 0) { onError = null; }
  40446. var _this = _super.call(this, name, scene) || this;
  40447. _this._useDirectMapping = false;
  40448. /**
  40449. * Observable raised when an error occured while loading the 360 image
  40450. */
  40451. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40452. // set defaults and manage values
  40453. name = name || "photoDome";
  40454. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40455. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40456. if (options.useDirectMapping === undefined) {
  40457. _this._useDirectMapping = true;
  40458. }
  40459. else {
  40460. _this._useDirectMapping = options.useDirectMapping;
  40461. }
  40462. if (options.faceForward === undefined) {
  40463. options.faceForward = true;
  40464. }
  40465. _this._setReady(false);
  40466. // create
  40467. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40468. _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);
  40469. // configure material
  40470. material.opacityFresnel = false;
  40471. material.useEquirectangularFOV = true;
  40472. material.fovMultiplier = 1.0;
  40473. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  40474. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  40475. if (onError) {
  40476. onError(message, exception);
  40477. }
  40478. });
  40479. _this.photoTexture.onLoadObservable.addOnce(function () {
  40480. _this._setReady(true);
  40481. });
  40482. // configure mesh
  40483. _this._mesh.material = material;
  40484. _this._mesh.parent = _this;
  40485. // Initial rotation
  40486. if (options.faceForward && scene.activeCamera) {
  40487. var camera = scene.activeCamera;
  40488. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  40489. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  40490. direction.normalize();
  40491. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  40492. }
  40493. return _this;
  40494. }
  40495. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  40496. /**
  40497. * Gets or sets the texture being displayed on the sphere
  40498. */
  40499. get: function () {
  40500. return this._photoTexture;
  40501. },
  40502. set: function (value) {
  40503. if (this._photoTexture === value) {
  40504. return;
  40505. }
  40506. this._photoTexture = value;
  40507. if (this._useDirectMapping) {
  40508. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40509. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40510. this._material.diffuseTexture = this._photoTexture;
  40511. }
  40512. else {
  40513. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40514. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40515. this._material.reflectionTexture = this._photoTexture;
  40516. }
  40517. },
  40518. enumerable: true,
  40519. configurable: true
  40520. });
  40521. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  40522. /**
  40523. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40524. * Also see the options.resolution property.
  40525. */
  40526. get: function () {
  40527. return this._material.fovMultiplier;
  40528. },
  40529. set: function (value) {
  40530. this._material.fovMultiplier = value;
  40531. },
  40532. enumerable: true,
  40533. configurable: true
  40534. });
  40535. /**
  40536. * Releases resources associated with this node.
  40537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40539. */
  40540. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40541. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40542. this._photoTexture.dispose();
  40543. this._mesh.dispose();
  40544. this._material.dispose();
  40545. this.onLoadErrorObservable.clear();
  40546. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40547. };
  40548. return PhotoDome;
  40549. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  40550. /***/ }),
  40551. /***/ "./Helpers/sceneHelpers.ts":
  40552. /*!*********************************!*\
  40553. !*** ./Helpers/sceneHelpers.ts ***!
  40554. \*********************************/
  40555. /*! exports provided: _forceSceneHelpersToBundle */
  40556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40557. "use strict";
  40558. __webpack_require__.r(__webpack_exports__);
  40559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  40560. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40561. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  40562. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40563. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40564. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40565. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40566. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  40567. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  40568. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40569. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  40570. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40571. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  40572. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  40573. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  40574. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  40575. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  40576. /* harmony import */ var _Materials_Textures_Loaders_ddsTextureLoader__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  40577. /* harmony import */ var _Materials_Textures_Loaders_envTextureLoader__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/Loaders/envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  40578. /* harmony import */ var _Materials_Textures_Loaders_ktxTextureLoader__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  40579. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40580. /** @hidden */
  40581. var _forceSceneHelpersToBundle = true;
  40582. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  40583. if (replace === void 0) { replace = false; }
  40584. // Dispose existing light in replace mode.
  40585. if (replace) {
  40586. if (this.lights) {
  40587. for (var i = 0; i < this.lights.length; i++) {
  40588. this.lights[i].dispose();
  40589. }
  40590. }
  40591. }
  40592. // Light
  40593. if (this.lights.length === 0) {
  40594. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  40595. }
  40596. };
  40597. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  40598. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40599. if (replace === void 0) { replace = false; }
  40600. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40601. // Dispose existing camera in replace mode.
  40602. if (replace) {
  40603. if (this.activeCamera) {
  40604. this.activeCamera.dispose();
  40605. this.activeCamera = null;
  40606. }
  40607. }
  40608. // Camera
  40609. if (!this.activeCamera) {
  40610. var worldExtends = this.getWorldExtends();
  40611. var worldSize = worldExtends.max.subtract(worldExtends.min);
  40612. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  40613. var camera;
  40614. var radius = worldSize.length() * 1.5;
  40615. // empty scene scenario!
  40616. if (!isFinite(radius)) {
  40617. radius = 1;
  40618. worldCenter.copyFromFloats(0, 0, 0);
  40619. }
  40620. if (createArcRotateCamera) {
  40621. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  40622. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  40623. arcRotateCamera.wheelPrecision = 100 / radius;
  40624. camera = arcRotateCamera;
  40625. }
  40626. else {
  40627. 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);
  40628. freeCamera.setTarget(worldCenter);
  40629. camera = freeCamera;
  40630. }
  40631. camera.minZ = radius * 0.01;
  40632. camera.maxZ = radius * 1000;
  40633. camera.speed = radius * 0.2;
  40634. this.activeCamera = camera;
  40635. var canvas = this.getEngine().getRenderingCanvas();
  40636. if (attachCameraControls && canvas) {
  40637. camera.attachControl(canvas);
  40638. }
  40639. }
  40640. };
  40641. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  40642. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40643. if (replace === void 0) { replace = false; }
  40644. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40645. this.createDefaultLight(replace);
  40646. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  40647. };
  40648. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  40649. if (pbr === void 0) { pbr = false; }
  40650. if (scale === void 0) { scale = 1000; }
  40651. if (blur === void 0) { blur = 0; }
  40652. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  40653. if (!environmentTexture) {
  40654. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  40655. return null;
  40656. }
  40657. if (setGlobalEnvTexture) {
  40658. if (environmentTexture) {
  40659. this.environmentTexture = environmentTexture;
  40660. }
  40661. }
  40662. // Skybox
  40663. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  40664. if (pbr) {
  40665. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  40666. hdrSkyboxMaterial.backFaceCulling = false;
  40667. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  40668. if (hdrSkyboxMaterial.reflectionTexture) {
  40669. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40670. }
  40671. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  40672. hdrSkyboxMaterial.disableLighting = true;
  40673. hdrSkyboxMaterial.twoSidedLighting = true;
  40674. hdrSkybox.infiniteDistance = true;
  40675. hdrSkybox.material = hdrSkyboxMaterial;
  40676. }
  40677. else {
  40678. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  40679. skyboxMaterial.backFaceCulling = false;
  40680. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  40681. if (skyboxMaterial.reflectionTexture) {
  40682. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40683. }
  40684. skyboxMaterial.disableLighting = true;
  40685. hdrSkybox.infiniteDistance = true;
  40686. hdrSkybox.material = skyboxMaterial;
  40687. }
  40688. hdrSkybox.isPickable = false;
  40689. return hdrSkybox;
  40690. };
  40691. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  40692. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  40693. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  40694. }
  40695. return null;
  40696. };
  40697. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  40698. if (webVROptions === void 0) { webVROptions = {}; }
  40699. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  40700. };
  40701. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  40702. var _this = this;
  40703. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  40704. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  40705. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  40706. .then(function (ui) {
  40707. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  40708. return helper;
  40709. });
  40710. });
  40711. };
  40712. /***/ }),
  40713. /***/ "./Helpers/videoDome.ts":
  40714. /*!******************************!*\
  40715. !*** ./Helpers/videoDome.ts ***!
  40716. \******************************/
  40717. /*! exports provided: VideoDome */
  40718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40719. "use strict";
  40720. __webpack_require__.r(__webpack_exports__);
  40721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  40722. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40723. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40724. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40725. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40726. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  40727. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40728. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40729. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40730. /**
  40731. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  40732. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  40733. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  40734. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40735. */
  40736. var VideoDome = /** @class */ (function (_super) {
  40737. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  40738. /**
  40739. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  40740. * @param name Element's name, child elements will append suffixes for their own names.
  40741. * @param urlsOrVideo defines the url(s) or the video element to use
  40742. * @param options An object containing optional or exposed sub element properties
  40743. */
  40744. function VideoDome(name, urlsOrVideo, options, scene) {
  40745. var _this = _super.call(this, name, scene) || this;
  40746. _this._useDirectMapping = false;
  40747. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  40748. /**
  40749. * Oberserver used in Stereoscopic VR Mode.
  40750. */
  40751. _this._onBeforeCameraRenderObserver = null;
  40752. scene = _this.getScene();
  40753. // set defaults and manage values
  40754. name = name || "videoDome";
  40755. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40756. options.clickToPlay = Boolean(options.clickToPlay);
  40757. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  40758. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  40759. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40760. if (options.useDirectMapping === undefined) {
  40761. _this._useDirectMapping = true;
  40762. }
  40763. else {
  40764. _this._useDirectMapping = options.useDirectMapping;
  40765. }
  40766. if (options.faceForward === undefined) {
  40767. options.faceForward = true;
  40768. }
  40769. _this._setReady(false);
  40770. // create
  40771. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  40772. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40773. 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);
  40774. _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);
  40775. texture.onLoadObservable.addOnce(function () {
  40776. _this._setReady(true);
  40777. });
  40778. // configure material
  40779. material.useEquirectangularFOV = true;
  40780. material.fovMultiplier = 1.0;
  40781. material.opacityFresnel = false;
  40782. if (_this._useDirectMapping) {
  40783. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40784. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40785. material.diffuseTexture = texture;
  40786. }
  40787. else {
  40788. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40789. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40790. material.reflectionTexture = texture;
  40791. }
  40792. // configure mesh
  40793. _this._mesh.material = material;
  40794. _this._mesh.parent = _this;
  40795. // optional configuration
  40796. if (options.clickToPlay) {
  40797. scene.onPointerUp = function () {
  40798. _this._videoTexture.video.play();
  40799. };
  40800. }
  40801. // Initial rotation
  40802. if (options.faceForward && scene.activeCamera) {
  40803. var camera = scene.activeCamera;
  40804. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  40805. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  40806. direction.normalize();
  40807. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  40808. }
  40809. return _this;
  40810. }
  40811. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  40812. /**
  40813. * Gets the video texture being displayed on the sphere
  40814. */
  40815. get: function () {
  40816. return this._videoTexture;
  40817. },
  40818. enumerable: true,
  40819. configurable: true
  40820. });
  40821. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  40822. /**
  40823. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40824. * Also see the options.resolution property.
  40825. */
  40826. get: function () {
  40827. return this._material.fovMultiplier;
  40828. },
  40829. set: function (value) {
  40830. this._material.fovMultiplier = value;
  40831. },
  40832. enumerable: true,
  40833. configurable: true
  40834. });
  40835. Object.defineProperty(VideoDome.prototype, "videoMode", {
  40836. /**
  40837. * Gets or set the current video mode for the video. It can be:
  40838. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  40839. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  40840. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  40841. */
  40842. get: function () {
  40843. return this._videoMode;
  40844. },
  40845. set: function (value) {
  40846. if (this._videoMode === value) {
  40847. return;
  40848. }
  40849. this._changeVideoMode(value);
  40850. },
  40851. enumerable: true,
  40852. configurable: true
  40853. });
  40854. VideoDome.prototype._changeVideoMode = function (value) {
  40855. var _this = this;
  40856. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40857. this._videoMode = value;
  40858. // Default Setup and Reset.
  40859. this._videoTexture.uScale = 1;
  40860. this._videoTexture.vScale = 1;
  40861. this._videoTexture.uOffset = 0;
  40862. this._videoTexture.vOffset = 0;
  40863. switch (value) {
  40864. case VideoDome.MODE_SIDEBYSIDE:
  40865. this._videoTexture.uScale = 0.5;
  40866. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  40867. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  40868. });
  40869. break;
  40870. case VideoDome.MODE_TOPBOTTOM:
  40871. this._videoTexture.vScale = 0.5;
  40872. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  40873. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  40874. });
  40875. break;
  40876. }
  40877. };
  40878. /**
  40879. * Releases resources associated with this node.
  40880. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40881. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40882. */
  40883. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40884. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40885. this._videoTexture.dispose();
  40886. this._mesh.dispose();
  40887. this._material.dispose();
  40888. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40889. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40890. };
  40891. /**
  40892. * Define the video source as a Monoscopic panoramic 360 video.
  40893. */
  40894. VideoDome.MODE_MONOSCOPIC = 0;
  40895. /**
  40896. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  40897. */
  40898. VideoDome.MODE_TOPBOTTOM = 1;
  40899. /**
  40900. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  40901. */
  40902. VideoDome.MODE_SIDEBYSIDE = 2;
  40903. return VideoDome;
  40904. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  40905. /***/ }),
  40906. /***/ "./Instrumentation/engineInstrumentation.ts":
  40907. /*!**************************************************!*\
  40908. !*** ./Instrumentation/engineInstrumentation.ts ***!
  40909. \**************************************************/
  40910. /*! exports provided: EngineInstrumentation */
  40911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40912. "use strict";
  40913. __webpack_require__.r(__webpack_exports__);
  40914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  40915. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40916. /**
  40917. * This class can be used to get instrumentation data from a Babylon engine
  40918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40919. */
  40920. var EngineInstrumentation = /** @class */ (function () {
  40921. /**
  40922. * Instantiates a new engine instrumentation.
  40923. * This class can be used to get instrumentation data from a Babylon engine
  40924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40925. * @param engine Defines the engine to instrument
  40926. */
  40927. function EngineInstrumentation(
  40928. /**
  40929. * Define the instrumented engine.
  40930. */
  40931. engine) {
  40932. this.engine = engine;
  40933. this._captureGPUFrameTime = false;
  40934. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40935. this._captureShaderCompilationTime = false;
  40936. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40937. // Observers
  40938. this._onBeginFrameObserver = null;
  40939. this._onEndFrameObserver = null;
  40940. this._onBeforeShaderCompilationObserver = null;
  40941. this._onAfterShaderCompilationObserver = null;
  40942. }
  40943. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  40944. // Properties
  40945. /**
  40946. * Gets the perf counter used for GPU frame time
  40947. */
  40948. get: function () {
  40949. return this._gpuFrameTime;
  40950. },
  40951. enumerable: true,
  40952. configurable: true
  40953. });
  40954. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  40955. /**
  40956. * Gets the GPU frame time capture status
  40957. */
  40958. get: function () {
  40959. return this._captureGPUFrameTime;
  40960. },
  40961. /**
  40962. * Enable or disable the GPU frame time capture
  40963. */
  40964. set: function (value) {
  40965. var _this = this;
  40966. if (value === this._captureGPUFrameTime) {
  40967. return;
  40968. }
  40969. this._captureGPUFrameTime = value;
  40970. if (value) {
  40971. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  40972. if (!_this._gpuFrameTimeToken) {
  40973. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  40974. }
  40975. });
  40976. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  40977. if (!_this._gpuFrameTimeToken) {
  40978. return;
  40979. }
  40980. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  40981. if (time > -1) {
  40982. _this._gpuFrameTimeToken = null;
  40983. _this._gpuFrameTime.fetchNewFrame();
  40984. _this._gpuFrameTime.addCount(time, true);
  40985. }
  40986. });
  40987. }
  40988. else {
  40989. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40990. this._onBeginFrameObserver = null;
  40991. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40992. this._onEndFrameObserver = null;
  40993. }
  40994. },
  40995. enumerable: true,
  40996. configurable: true
  40997. });
  40998. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  40999. /**
  41000. * Gets the perf counter used for shader compilation time
  41001. */
  41002. get: function () {
  41003. return this._shaderCompilationTime;
  41004. },
  41005. enumerable: true,
  41006. configurable: true
  41007. });
  41008. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  41009. /**
  41010. * Gets the shader compilation time capture status
  41011. */
  41012. get: function () {
  41013. return this._captureShaderCompilationTime;
  41014. },
  41015. /**
  41016. * Enable or disable the shader compilation time capture
  41017. */
  41018. set: function (value) {
  41019. var _this = this;
  41020. if (value === this._captureShaderCompilationTime) {
  41021. return;
  41022. }
  41023. this._captureShaderCompilationTime = value;
  41024. if (value) {
  41025. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  41026. _this._shaderCompilationTime.fetchNewFrame();
  41027. _this._shaderCompilationTime.beginMonitoring();
  41028. });
  41029. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  41030. _this._shaderCompilationTime.endMonitoring();
  41031. });
  41032. }
  41033. else {
  41034. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41035. this._onBeforeShaderCompilationObserver = null;
  41036. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41037. this._onAfterShaderCompilationObserver = null;
  41038. }
  41039. },
  41040. enumerable: true,
  41041. configurable: true
  41042. });
  41043. /**
  41044. * Dispose and release associated resources.
  41045. */
  41046. EngineInstrumentation.prototype.dispose = function () {
  41047. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  41048. this._onBeginFrameObserver = null;
  41049. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  41050. this._onEndFrameObserver = null;
  41051. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41052. this._onBeforeShaderCompilationObserver = null;
  41053. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41054. this._onAfterShaderCompilationObserver = null;
  41055. this.engine = null;
  41056. };
  41057. return EngineInstrumentation;
  41058. }());
  41059. /***/ }),
  41060. /***/ "./Instrumentation/index.ts":
  41061. /*!**********************************!*\
  41062. !*** ./Instrumentation/index.ts ***!
  41063. \**********************************/
  41064. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  41065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41066. "use strict";
  41067. __webpack_require__.r(__webpack_exports__);
  41068. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  41069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  41070. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  41071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  41072. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  41073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  41074. /***/ }),
  41075. /***/ "./Instrumentation/sceneInstrumentation.ts":
  41076. /*!*************************************************!*\
  41077. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  41078. \*************************************************/
  41079. /*! exports provided: SceneInstrumentation */
  41080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41081. "use strict";
  41082. __webpack_require__.r(__webpack_exports__);
  41083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  41084. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41085. /**
  41086. * This class can be used to get instrumentation data from a Babylon engine
  41087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41088. */
  41089. var SceneInstrumentation = /** @class */ (function () {
  41090. /**
  41091. * Instantiates a new scene instrumentation.
  41092. * This class can be used to get instrumentation data from a Babylon engine
  41093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41094. * @param scene Defines the scene to instrument
  41095. */
  41096. function SceneInstrumentation(
  41097. /**
  41098. * Defines the scene to instrument
  41099. */
  41100. scene) {
  41101. var _this = this;
  41102. this.scene = scene;
  41103. this._captureActiveMeshesEvaluationTime = false;
  41104. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41105. this._captureRenderTargetsRenderTime = false;
  41106. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41107. this._captureFrameTime = false;
  41108. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41109. this._captureRenderTime = false;
  41110. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41111. this._captureInterFrameTime = false;
  41112. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41113. this._captureParticlesRenderTime = false;
  41114. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41115. this._captureSpritesRenderTime = false;
  41116. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41117. this._capturePhysicsTime = false;
  41118. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41119. this._captureAnimationsTime = false;
  41120. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41121. this._captureCameraRenderTime = false;
  41122. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41123. // Observers
  41124. this._onBeforeActiveMeshesEvaluationObserver = null;
  41125. this._onAfterActiveMeshesEvaluationObserver = null;
  41126. this._onBeforeRenderTargetsRenderObserver = null;
  41127. this._onAfterRenderTargetsRenderObserver = null;
  41128. this._onAfterRenderObserver = null;
  41129. this._onBeforeDrawPhaseObserver = null;
  41130. this._onAfterDrawPhaseObserver = null;
  41131. this._onBeforeAnimationsObserver = null;
  41132. this._onBeforeParticlesRenderingObserver = null;
  41133. this._onAfterParticlesRenderingObserver = null;
  41134. this._onBeforeSpritesRenderingObserver = null;
  41135. this._onAfterSpritesRenderingObserver = null;
  41136. this._onBeforePhysicsObserver = null;
  41137. this._onAfterPhysicsObserver = null;
  41138. this._onAfterAnimationsObserver = null;
  41139. this._onBeforeCameraRenderObserver = null;
  41140. this._onAfterCameraRenderObserver = null;
  41141. // Before render
  41142. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  41143. if (_this._captureActiveMeshesEvaluationTime) {
  41144. _this._activeMeshesEvaluationTime.fetchNewFrame();
  41145. }
  41146. if (_this._captureRenderTargetsRenderTime) {
  41147. _this._renderTargetsRenderTime.fetchNewFrame();
  41148. }
  41149. if (_this._captureFrameTime) {
  41150. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  41151. _this._frameTime.beginMonitoring();
  41152. }
  41153. if (_this._captureInterFrameTime) {
  41154. _this._interFrameTime.endMonitoring();
  41155. }
  41156. if (_this._captureParticlesRenderTime) {
  41157. _this._particlesRenderTime.fetchNewFrame();
  41158. }
  41159. if (_this._captureSpritesRenderTime) {
  41160. _this._spritesRenderTime.fetchNewFrame();
  41161. }
  41162. if (_this._captureAnimationsTime) {
  41163. _this._animationsTime.beginMonitoring();
  41164. }
  41165. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  41166. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  41167. });
  41168. // After render
  41169. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  41170. if (_this._captureFrameTime) {
  41171. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  41172. _this._frameTime.endMonitoring();
  41173. }
  41174. if (_this._captureRenderTime) {
  41175. _this._renderTime.endMonitoring(false);
  41176. }
  41177. if (_this._captureInterFrameTime) {
  41178. _this._interFrameTime.beginMonitoring();
  41179. }
  41180. });
  41181. }
  41182. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  41183. // Properties
  41184. /**
  41185. * Gets the perf counter used for active meshes evaluation time
  41186. */
  41187. get: function () {
  41188. return this._activeMeshesEvaluationTime;
  41189. },
  41190. enumerable: true,
  41191. configurable: true
  41192. });
  41193. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  41194. /**
  41195. * Gets the active meshes evaluation time capture status
  41196. */
  41197. get: function () {
  41198. return this._captureActiveMeshesEvaluationTime;
  41199. },
  41200. /**
  41201. * Enable or disable the active meshes evaluation time capture
  41202. */
  41203. set: function (value) {
  41204. var _this = this;
  41205. if (value === this._captureActiveMeshesEvaluationTime) {
  41206. return;
  41207. }
  41208. this._captureActiveMeshesEvaluationTime = value;
  41209. if (value) {
  41210. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  41211. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  41212. _this._activeMeshesEvaluationTime.beginMonitoring();
  41213. });
  41214. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  41215. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  41216. _this._activeMeshesEvaluationTime.endMonitoring();
  41217. });
  41218. }
  41219. else {
  41220. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41221. this._onBeforeActiveMeshesEvaluationObserver = null;
  41222. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41223. this._onAfterActiveMeshesEvaluationObserver = null;
  41224. }
  41225. },
  41226. enumerable: true,
  41227. configurable: true
  41228. });
  41229. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  41230. /**
  41231. * Gets the perf counter used for render targets render time
  41232. */
  41233. get: function () {
  41234. return this._renderTargetsRenderTime;
  41235. },
  41236. enumerable: true,
  41237. configurable: true
  41238. });
  41239. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  41240. /**
  41241. * Gets the render targets render time capture status
  41242. */
  41243. get: function () {
  41244. return this._captureRenderTargetsRenderTime;
  41245. },
  41246. /**
  41247. * Enable or disable the render targets render time capture
  41248. */
  41249. set: function (value) {
  41250. var _this = this;
  41251. if (value === this._captureRenderTargetsRenderTime) {
  41252. return;
  41253. }
  41254. this._captureRenderTargetsRenderTime = value;
  41255. if (value) {
  41256. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  41257. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  41258. _this._renderTargetsRenderTime.beginMonitoring();
  41259. });
  41260. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  41261. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  41262. _this._renderTargetsRenderTime.endMonitoring(false);
  41263. });
  41264. }
  41265. else {
  41266. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41267. this._onBeforeRenderTargetsRenderObserver = null;
  41268. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41269. this._onAfterRenderTargetsRenderObserver = null;
  41270. }
  41271. },
  41272. enumerable: true,
  41273. configurable: true
  41274. });
  41275. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  41276. /**
  41277. * Gets the perf counter used for particles render time
  41278. */
  41279. get: function () {
  41280. return this._particlesRenderTime;
  41281. },
  41282. enumerable: true,
  41283. configurable: true
  41284. });
  41285. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  41286. /**
  41287. * Gets the particles render time capture status
  41288. */
  41289. get: function () {
  41290. return this._captureParticlesRenderTime;
  41291. },
  41292. /**
  41293. * Enable or disable the particles render time capture
  41294. */
  41295. set: function (value) {
  41296. var _this = this;
  41297. if (value === this._captureParticlesRenderTime) {
  41298. return;
  41299. }
  41300. this._captureParticlesRenderTime = value;
  41301. if (value) {
  41302. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  41303. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  41304. _this._particlesRenderTime.beginMonitoring();
  41305. });
  41306. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  41307. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  41308. _this._particlesRenderTime.endMonitoring(false);
  41309. });
  41310. }
  41311. else {
  41312. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41313. this._onBeforeParticlesRenderingObserver = null;
  41314. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41315. this._onAfterParticlesRenderingObserver = null;
  41316. }
  41317. },
  41318. enumerable: true,
  41319. configurable: true
  41320. });
  41321. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  41322. /**
  41323. * Gets the perf counter used for sprites render time
  41324. */
  41325. get: function () {
  41326. return this._spritesRenderTime;
  41327. },
  41328. enumerable: true,
  41329. configurable: true
  41330. });
  41331. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  41332. /**
  41333. * Gets the sprites render time capture status
  41334. */
  41335. get: function () {
  41336. return this._captureSpritesRenderTime;
  41337. },
  41338. /**
  41339. * Enable or disable the sprites render time capture
  41340. */
  41341. set: function (value) {
  41342. var _this = this;
  41343. if (value === this._captureSpritesRenderTime) {
  41344. return;
  41345. }
  41346. this._captureSpritesRenderTime = value;
  41347. if (!this.scene.spriteManagers) {
  41348. return;
  41349. }
  41350. if (value) {
  41351. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  41352. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  41353. _this._spritesRenderTime.beginMonitoring();
  41354. });
  41355. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  41356. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  41357. _this._spritesRenderTime.endMonitoring(false);
  41358. });
  41359. }
  41360. else {
  41361. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41362. this._onBeforeSpritesRenderingObserver = null;
  41363. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41364. this._onAfterSpritesRenderingObserver = null;
  41365. }
  41366. },
  41367. enumerable: true,
  41368. configurable: true
  41369. });
  41370. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  41371. /**
  41372. * Gets the perf counter used for physics time
  41373. */
  41374. get: function () {
  41375. return this._physicsTime;
  41376. },
  41377. enumerable: true,
  41378. configurable: true
  41379. });
  41380. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  41381. /**
  41382. * Gets the physics time capture status
  41383. */
  41384. get: function () {
  41385. return this._capturePhysicsTime;
  41386. },
  41387. /**
  41388. * Enable or disable the physics time capture
  41389. */
  41390. set: function (value) {
  41391. var _this = this;
  41392. if (value === this._capturePhysicsTime) {
  41393. return;
  41394. }
  41395. if (!this.scene.onBeforePhysicsObservable) {
  41396. return;
  41397. }
  41398. this._capturePhysicsTime = value;
  41399. if (value) {
  41400. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  41401. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  41402. _this._physicsTime.beginMonitoring();
  41403. });
  41404. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  41405. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  41406. _this._physicsTime.endMonitoring();
  41407. });
  41408. }
  41409. else {
  41410. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41411. this._onBeforePhysicsObserver = null;
  41412. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41413. this._onAfterPhysicsObserver = null;
  41414. }
  41415. },
  41416. enumerable: true,
  41417. configurable: true
  41418. });
  41419. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  41420. /**
  41421. * Gets the perf counter used for animations time
  41422. */
  41423. get: function () {
  41424. return this._animationsTime;
  41425. },
  41426. enumerable: true,
  41427. configurable: true
  41428. });
  41429. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  41430. /**
  41431. * Gets the animations time capture status
  41432. */
  41433. get: function () {
  41434. return this._captureAnimationsTime;
  41435. },
  41436. /**
  41437. * Enable or disable the animations time capture
  41438. */
  41439. set: function (value) {
  41440. var _this = this;
  41441. if (value === this._captureAnimationsTime) {
  41442. return;
  41443. }
  41444. this._captureAnimationsTime = value;
  41445. if (value) {
  41446. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  41447. _this._animationsTime.endMonitoring();
  41448. });
  41449. }
  41450. else {
  41451. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41452. this._onAfterAnimationsObserver = null;
  41453. }
  41454. },
  41455. enumerable: true,
  41456. configurable: true
  41457. });
  41458. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  41459. /**
  41460. * Gets the perf counter used for frame time capture
  41461. */
  41462. get: function () {
  41463. return this._frameTime;
  41464. },
  41465. enumerable: true,
  41466. configurable: true
  41467. });
  41468. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  41469. /**
  41470. * Gets the frame time capture status
  41471. */
  41472. get: function () {
  41473. return this._captureFrameTime;
  41474. },
  41475. /**
  41476. * Enable or disable the frame time capture
  41477. */
  41478. set: function (value) {
  41479. this._captureFrameTime = value;
  41480. },
  41481. enumerable: true,
  41482. configurable: true
  41483. });
  41484. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  41485. /**
  41486. * Gets the perf counter used for inter-frames time capture
  41487. */
  41488. get: function () {
  41489. return this._interFrameTime;
  41490. },
  41491. enumerable: true,
  41492. configurable: true
  41493. });
  41494. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  41495. /**
  41496. * Gets the inter-frames time capture status
  41497. */
  41498. get: function () {
  41499. return this._captureInterFrameTime;
  41500. },
  41501. /**
  41502. * Enable or disable the inter-frames time capture
  41503. */
  41504. set: function (value) {
  41505. this._captureInterFrameTime = value;
  41506. },
  41507. enumerable: true,
  41508. configurable: true
  41509. });
  41510. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  41511. /**
  41512. * Gets the perf counter used for render time capture
  41513. */
  41514. get: function () {
  41515. return this._renderTime;
  41516. },
  41517. enumerable: true,
  41518. configurable: true
  41519. });
  41520. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  41521. /**
  41522. * Gets the render time capture status
  41523. */
  41524. get: function () {
  41525. return this._captureRenderTime;
  41526. },
  41527. /**
  41528. * Enable or disable the render time capture
  41529. */
  41530. set: function (value) {
  41531. var _this = this;
  41532. if (value === this._captureRenderTime) {
  41533. return;
  41534. }
  41535. this._captureRenderTime = value;
  41536. if (value) {
  41537. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  41538. _this._renderTime.beginMonitoring();
  41539. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  41540. });
  41541. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  41542. _this._renderTime.endMonitoring(false);
  41543. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  41544. });
  41545. }
  41546. else {
  41547. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41548. this._onBeforeDrawPhaseObserver = null;
  41549. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41550. this._onAfterDrawPhaseObserver = null;
  41551. }
  41552. },
  41553. enumerable: true,
  41554. configurable: true
  41555. });
  41556. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  41557. /**
  41558. * Gets the perf counter used for camera render time capture
  41559. */
  41560. get: function () {
  41561. return this._cameraRenderTime;
  41562. },
  41563. enumerable: true,
  41564. configurable: true
  41565. });
  41566. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  41567. /**
  41568. * Gets the camera render time capture status
  41569. */
  41570. get: function () {
  41571. return this._captureCameraRenderTime;
  41572. },
  41573. /**
  41574. * Enable or disable the camera render time capture
  41575. */
  41576. set: function (value) {
  41577. var _this = this;
  41578. if (value === this._captureCameraRenderTime) {
  41579. return;
  41580. }
  41581. this._captureCameraRenderTime = value;
  41582. if (value) {
  41583. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  41584. _this._cameraRenderTime.beginMonitoring();
  41585. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  41586. });
  41587. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  41588. _this._cameraRenderTime.endMonitoring(false);
  41589. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  41590. });
  41591. }
  41592. else {
  41593. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41594. this._onBeforeCameraRenderObserver = null;
  41595. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41596. this._onAfterCameraRenderObserver = null;
  41597. }
  41598. },
  41599. enumerable: true,
  41600. configurable: true
  41601. });
  41602. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  41603. /**
  41604. * Gets the perf counter used for draw calls
  41605. */
  41606. get: function () {
  41607. return this.scene.getEngine()._drawCalls;
  41608. },
  41609. enumerable: true,
  41610. configurable: true
  41611. });
  41612. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  41613. /**
  41614. * Gets the perf counter used for texture collisions
  41615. */
  41616. get: function () {
  41617. return this.scene.getEngine()._textureCollisions;
  41618. },
  41619. enumerable: true,
  41620. configurable: true
  41621. });
  41622. /**
  41623. * Dispose and release associated resources.
  41624. */
  41625. SceneInstrumentation.prototype.dispose = function () {
  41626. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41627. this._onAfterRenderObserver = null;
  41628. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41629. this._onBeforeActiveMeshesEvaluationObserver = null;
  41630. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41631. this._onAfterActiveMeshesEvaluationObserver = null;
  41632. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41633. this._onBeforeRenderTargetsRenderObserver = null;
  41634. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41635. this._onAfterRenderTargetsRenderObserver = null;
  41636. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  41637. this._onBeforeAnimationsObserver = null;
  41638. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41639. this._onBeforeParticlesRenderingObserver = null;
  41640. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41641. this._onAfterParticlesRenderingObserver = null;
  41642. if (this._onBeforeSpritesRenderingObserver) {
  41643. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41644. this._onBeforeSpritesRenderingObserver = null;
  41645. }
  41646. if (this._onAfterSpritesRenderingObserver) {
  41647. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41648. this._onAfterSpritesRenderingObserver = null;
  41649. }
  41650. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41651. this._onBeforeDrawPhaseObserver = null;
  41652. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41653. this._onAfterDrawPhaseObserver = null;
  41654. if (this._onBeforePhysicsObserver) {
  41655. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41656. this._onBeforePhysicsObserver = null;
  41657. }
  41658. if (this._onAfterPhysicsObserver) {
  41659. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41660. this._onAfterPhysicsObserver = null;
  41661. }
  41662. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41663. this._onAfterAnimationsObserver = null;
  41664. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41665. this._onBeforeCameraRenderObserver = null;
  41666. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41667. this._onAfterCameraRenderObserver = null;
  41668. this.scene = null;
  41669. };
  41670. return SceneInstrumentation;
  41671. }());
  41672. /***/ }),
  41673. /***/ "./Instrumentation/timeToken.ts":
  41674. /*!**************************************!*\
  41675. !*** ./Instrumentation/timeToken.ts ***!
  41676. \**************************************/
  41677. /*! exports provided: _TimeToken */
  41678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41679. "use strict";
  41680. __webpack_require__.r(__webpack_exports__);
  41681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  41682. /**
  41683. * @hidden
  41684. **/
  41685. var _TimeToken = /** @class */ (function () {
  41686. function _TimeToken() {
  41687. this._timeElapsedQueryEnded = false;
  41688. }
  41689. return _TimeToken;
  41690. }());
  41691. /***/ }),
  41692. /***/ "./Layers/effectLayer.ts":
  41693. /*!*******************************!*\
  41694. !*** ./Layers/effectLayer.ts ***!
  41695. \*******************************/
  41696. /*! exports provided: EffectLayer */
  41697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41698. "use strict";
  41699. __webpack_require__.r(__webpack_exports__);
  41700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  41701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41702. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41703. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41704. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41705. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41706. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  41707. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41708. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41709. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41710. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41711. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  41712. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41713. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  41714. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  41715. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  41716. /**
  41717. * The effect layer Helps adding post process effect blended with the main pass.
  41718. *
  41719. * This can be for instance use to generate glow or higlight effects on the scene.
  41720. *
  41721. * The effect layer class can not be used directly and is intented to inherited from to be
  41722. * customized per effects.
  41723. */
  41724. var EffectLayer = /** @class */ (function () {
  41725. /**
  41726. * Instantiates a new effect Layer and references it in the scene.
  41727. * @param name The name of the layer
  41728. * @param scene The scene to use the layer in
  41729. */
  41730. function EffectLayer(
  41731. /** The Friendly of the effect in the scene */
  41732. name, scene) {
  41733. this._vertexBuffers = {};
  41734. this._maxSize = 0;
  41735. this._mainTextureDesiredSize = { width: 0, height: 0 };
  41736. this._shouldRender = true;
  41737. this._postProcesses = [];
  41738. this._textures = [];
  41739. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  41740. /**
  41741. * The clear color of the texture used to generate the glow map.
  41742. */
  41743. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  41744. /**
  41745. * Specifies wether the highlight layer is enabled or not.
  41746. */
  41747. this.isEnabled = true;
  41748. /**
  41749. * An event triggered when the effect layer has been disposed.
  41750. */
  41751. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41752. /**
  41753. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  41754. */
  41755. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41756. /**
  41757. * An event triggered when the generated texture is being merged in the scene.
  41758. */
  41759. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41760. /**
  41761. * An event triggered when the generated texture has been merged in the scene.
  41762. */
  41763. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41764. /**
  41765. * An event triggered when the efffect layer changes its size.
  41766. */
  41767. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41768. this.name = name;
  41769. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  41770. EffectLayer._SceneComponentInitialization(this._scene);
  41771. this._engine = this._scene.getEngine();
  41772. this._maxSize = this._engine.getCaps().maxTextureSize;
  41773. this._scene.effectLayers.push(this);
  41774. // Generate Buffers
  41775. this._generateIndexBuffer();
  41776. this._genrateVertexBuffer();
  41777. }
  41778. Object.defineProperty(EffectLayer.prototype, "camera", {
  41779. /**
  41780. * Gets the camera attached to the layer.
  41781. */
  41782. get: function () {
  41783. return this._effectLayerOptions.camera;
  41784. },
  41785. enumerable: true,
  41786. configurable: true
  41787. });
  41788. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  41789. /**
  41790. * Gets the rendering group id the layer should render in.
  41791. */
  41792. get: function () {
  41793. return this._effectLayerOptions.renderingGroupId;
  41794. },
  41795. enumerable: true,
  41796. configurable: true
  41797. });
  41798. /**
  41799. * Initializes the effect layer with the required options.
  41800. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  41801. */
  41802. EffectLayer.prototype._init = function (options) {
  41803. // Adapt options
  41804. 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);
  41805. this._setMainTextureSize();
  41806. this._createMainTexture();
  41807. this._createTextureAndPostProcesses();
  41808. this._mergeEffect = this._createMergeEffect();
  41809. };
  41810. /**
  41811. * Generates the index buffer of the full screen quad blending to the main canvas.
  41812. */
  41813. EffectLayer.prototype._generateIndexBuffer = function () {
  41814. // Indices
  41815. var indices = [];
  41816. indices.push(0);
  41817. indices.push(1);
  41818. indices.push(2);
  41819. indices.push(0);
  41820. indices.push(2);
  41821. indices.push(3);
  41822. this._indexBuffer = this._engine.createIndexBuffer(indices);
  41823. };
  41824. /**
  41825. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  41826. */
  41827. EffectLayer.prototype._genrateVertexBuffer = function () {
  41828. // VBO
  41829. var vertices = [];
  41830. vertices.push(1, 1);
  41831. vertices.push(-1, 1);
  41832. vertices.push(-1, -1);
  41833. vertices.push(1, -1);
  41834. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  41835. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  41836. };
  41837. /**
  41838. * Sets the main texture desired size which is the closest power of two
  41839. * of the engine canvas size.
  41840. */
  41841. EffectLayer.prototype._setMainTextureSize = function () {
  41842. if (this._effectLayerOptions.mainTextureFixedSize) {
  41843. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  41844. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  41845. }
  41846. else {
  41847. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  41848. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  41849. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  41850. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  41851. }
  41852. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  41853. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  41854. };
  41855. /**
  41856. * Creates the main texture for the effect layer.
  41857. */
  41858. EffectLayer.prototype._createMainTexture = function () {
  41859. var _this = this;
  41860. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  41861. width: this._mainTextureDesiredSize.width,
  41862. height: this._mainTextureDesiredSize.height
  41863. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  41864. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  41865. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41866. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41867. this._mainTexture.anisotropicFilteringLevel = 1;
  41868. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  41869. this._mainTexture.renderParticles = false;
  41870. this._mainTexture.renderList = null;
  41871. this._mainTexture.ignoreCameraViewport = true;
  41872. // Custom render function
  41873. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  41874. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  41875. var index;
  41876. var engine = _this._scene.getEngine();
  41877. if (depthOnlySubMeshes.length) {
  41878. engine.setColorWrite(false);
  41879. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  41880. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  41881. }
  41882. engine.setColorWrite(true);
  41883. }
  41884. for (index = 0; index < opaqueSubMeshes.length; index++) {
  41885. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  41886. }
  41887. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  41888. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  41889. }
  41890. for (index = 0; index < transparentSubMeshes.length; index++) {
  41891. _this._renderSubMesh(transparentSubMeshes.data[index]);
  41892. }
  41893. };
  41894. this._mainTexture.onClearObservable.add(function (engine) {
  41895. engine.clear(_this.neutralColor, true, true, true);
  41896. });
  41897. };
  41898. /**
  41899. * Adds specific effects defines.
  41900. * @param defines The defines to add specifics to.
  41901. */
  41902. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  41903. // Nothing to add by default.
  41904. };
  41905. /**
  41906. * Checks for the readiness of the element composing the layer.
  41907. * @param subMesh the mesh to check for
  41908. * @param useInstances specify wether or not to use instances to render the mesh
  41909. * @param emissiveTexture the associated emissive texture used to generate the glow
  41910. * @return true if ready otherwise, false
  41911. */
  41912. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  41913. var material = subMesh.getMaterial();
  41914. if (!material) {
  41915. return false;
  41916. }
  41917. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  41918. return false;
  41919. }
  41920. var defines = [];
  41921. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41922. var mesh = subMesh.getMesh();
  41923. var uv1 = false;
  41924. var uv2 = false;
  41925. // Diffuse
  41926. if (material) {
  41927. var needAlphaTest = material.needAlphaTesting();
  41928. var diffuseTexture = material.getAlphaTestTexture();
  41929. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41930. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41931. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41932. defines.push("#define DIFFUSE");
  41933. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41934. diffuseTexture.coordinatesIndex === 1) {
  41935. defines.push("#define DIFFUSEUV2");
  41936. uv2 = true;
  41937. }
  41938. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41939. defines.push("#define DIFFUSEUV1");
  41940. uv1 = true;
  41941. }
  41942. if (needAlphaTest) {
  41943. defines.push("#define ALPHATEST");
  41944. defines.push("#define ALPHATESTVALUE 0.4");
  41945. }
  41946. }
  41947. var opacityTexture = material.opacityTexture;
  41948. if (opacityTexture) {
  41949. defines.push("#define OPACITY");
  41950. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41951. opacityTexture.coordinatesIndex === 1) {
  41952. defines.push("#define OPACITYUV2");
  41953. uv2 = true;
  41954. }
  41955. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41956. defines.push("#define OPACITYUV1");
  41957. uv1 = true;
  41958. }
  41959. }
  41960. }
  41961. // Emissive
  41962. if (emissiveTexture) {
  41963. defines.push("#define EMISSIVE");
  41964. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41965. emissiveTexture.coordinatesIndex === 1) {
  41966. defines.push("#define EMISSIVEUV2");
  41967. uv2 = true;
  41968. }
  41969. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41970. defines.push("#define EMISSIVEUV1");
  41971. uv1 = true;
  41972. }
  41973. }
  41974. // Vertex
  41975. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  41976. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  41977. defines.push("#define VERTEXALPHA");
  41978. }
  41979. if (uv1) {
  41980. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  41981. defines.push("#define UV1");
  41982. }
  41983. if (uv2) {
  41984. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  41985. defines.push("#define UV2");
  41986. }
  41987. // Bones
  41988. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  41989. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  41990. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  41991. if (mesh.numBoneInfluencers > 4) {
  41992. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  41993. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  41994. }
  41995. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  41996. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  41997. }
  41998. else {
  41999. defines.push("#define NUM_BONE_INFLUENCERS 0");
  42000. }
  42001. // Morph targets
  42002. var manager = mesh.morphTargetManager;
  42003. var morphInfluencers = 0;
  42004. if (manager) {
  42005. if (manager.numInfluencers > 0) {
  42006. defines.push("#define MORPHTARGETS");
  42007. morphInfluencers = manager.numInfluencers;
  42008. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  42009. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  42010. }
  42011. }
  42012. // Instances
  42013. if (useInstances) {
  42014. defines.push("#define INSTANCES");
  42015. attribs.push("world0");
  42016. attribs.push("world1");
  42017. attribs.push("world2");
  42018. attribs.push("world3");
  42019. }
  42020. this._addCustomEffectDefines(defines);
  42021. // Get correct effect
  42022. var join = defines.join("\n");
  42023. if (this._cachedDefines !== join) {
  42024. this._cachedDefines = join;
  42025. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  42026. "color", "morphTargetInfluences",
  42027. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  42028. }
  42029. return this._effectLayerMapGenerationEffect.isReady();
  42030. };
  42031. /**
  42032. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  42033. */
  42034. EffectLayer.prototype.render = function () {
  42035. var currentEffect = this._mergeEffect;
  42036. // Check
  42037. if (!currentEffect.isReady()) {
  42038. return;
  42039. }
  42040. for (var i = 0; i < this._postProcesses.length; i++) {
  42041. if (!this._postProcesses[i].isReady()) {
  42042. return;
  42043. }
  42044. }
  42045. var engine = this._scene.getEngine();
  42046. this.onBeforeComposeObservable.notifyObservers(this);
  42047. // Render
  42048. engine.enableEffect(currentEffect);
  42049. engine.setState(false);
  42050. // VBOs
  42051. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42052. // Cache
  42053. var previousAlphaMode = engine.getAlphaMode();
  42054. // Go Blend.
  42055. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  42056. // Blends the map on the main canvas.
  42057. this._internalRender(currentEffect);
  42058. // Restore Alpha
  42059. engine.setAlphaMode(previousAlphaMode);
  42060. this.onAfterComposeObservable.notifyObservers(this);
  42061. // Handle size changes.
  42062. var size = this._mainTexture.getSize();
  42063. this._setMainTextureSize();
  42064. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  42065. // Recreate RTT and post processes on size change.
  42066. this.onSizeChangedObservable.notifyObservers(this);
  42067. this._disposeTextureAndPostProcesses();
  42068. this._createMainTexture();
  42069. this._createTextureAndPostProcesses();
  42070. }
  42071. };
  42072. /**
  42073. * Determine if a given mesh will be used in the current effect.
  42074. * @param mesh mesh to test
  42075. * @returns true if the mesh will be used
  42076. */
  42077. EffectLayer.prototype.hasMesh = function (mesh) {
  42078. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  42079. return true;
  42080. }
  42081. return false;
  42082. };
  42083. /**
  42084. * Returns true if the layer contains information to display, otherwise false.
  42085. * @returns true if the glow layer should be rendered
  42086. */
  42087. EffectLayer.prototype.shouldRender = function () {
  42088. return this.isEnabled && this._shouldRender;
  42089. };
  42090. /**
  42091. * Returns true if the mesh should render, otherwise false.
  42092. * @param mesh The mesh to render
  42093. * @returns true if it should render otherwise false
  42094. */
  42095. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  42096. return true;
  42097. };
  42098. /**
  42099. * Returns true if the mesh can be rendered, otherwise false.
  42100. * @param mesh The mesh to render
  42101. * @param material The material used on the mesh
  42102. * @returns true if it can be rendered otherwise false
  42103. */
  42104. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  42105. return !material.needAlphaBlendingForMesh(mesh);
  42106. };
  42107. /**
  42108. * Returns true if the mesh should render, otherwise false.
  42109. * @param mesh The mesh to render
  42110. * @returns true if it should render otherwise false
  42111. */
  42112. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  42113. return true;
  42114. };
  42115. /**
  42116. * Renders the submesh passed in parameter to the generation map.
  42117. */
  42118. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  42119. var _this = this;
  42120. if (!this.shouldRender()) {
  42121. return;
  42122. }
  42123. var material = subMesh.getMaterial();
  42124. var mesh = subMesh.getRenderingMesh();
  42125. var scene = this._scene;
  42126. var engine = scene.getEngine();
  42127. if (!material) {
  42128. return;
  42129. }
  42130. // Do not block in blend mode.
  42131. if (!this._canRenderMesh(mesh, material)) {
  42132. return;
  42133. }
  42134. // Culling
  42135. engine.setState(material.backFaceCulling);
  42136. // Managing instances
  42137. var batch = mesh._getInstancesRenderList(subMesh._id);
  42138. if (batch.mustReturn) {
  42139. return;
  42140. }
  42141. // Early Exit per mesh
  42142. if (!this._shouldRenderMesh(mesh)) {
  42143. return;
  42144. }
  42145. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  42146. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  42147. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  42148. engine.enableEffect(this._effectLayerMapGenerationEffect);
  42149. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  42150. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  42151. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  42152. var needAlphaTest = material.needAlphaTesting();
  42153. var diffuseTexture = material.getAlphaTestTexture();
  42154. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42155. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42156. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42157. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  42158. var textureMatrix = diffuseTexture.getTextureMatrix();
  42159. if (textureMatrix) {
  42160. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  42161. }
  42162. }
  42163. var opacityTexture = material.opacityTexture;
  42164. if (opacityTexture) {
  42165. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  42166. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  42167. var textureMatrix = opacityTexture.getTextureMatrix();
  42168. if (textureMatrix) {
  42169. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  42170. }
  42171. }
  42172. // Glow emissive only
  42173. if (this._emissiveTextureAndColor.texture) {
  42174. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  42175. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  42176. }
  42177. // Bones
  42178. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  42179. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  42180. }
  42181. // Morph targets
  42182. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  42183. // Draw
  42184. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  42185. }
  42186. else {
  42187. // Need to reset refresh rate of the main map
  42188. this._mainTexture.resetRefreshCounter();
  42189. }
  42190. };
  42191. /**
  42192. * Rebuild the required buffers.
  42193. * @hidden Internal use only.
  42194. */
  42195. EffectLayer.prototype._rebuild = function () {
  42196. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42197. if (vb) {
  42198. vb._rebuild();
  42199. }
  42200. this._generateIndexBuffer();
  42201. };
  42202. /**
  42203. * Dispose only the render target textures and post process.
  42204. */
  42205. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  42206. this._mainTexture.dispose();
  42207. for (var i = 0; i < this._postProcesses.length; i++) {
  42208. if (this._postProcesses[i]) {
  42209. this._postProcesses[i].dispose();
  42210. }
  42211. }
  42212. this._postProcesses = [];
  42213. for (var i = 0; i < this._textures.length; i++) {
  42214. if (this._textures[i]) {
  42215. this._textures[i].dispose();
  42216. }
  42217. }
  42218. this._textures = [];
  42219. };
  42220. /**
  42221. * Dispose the highlight layer and free resources.
  42222. */
  42223. EffectLayer.prototype.dispose = function () {
  42224. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42225. if (vertexBuffer) {
  42226. vertexBuffer.dispose();
  42227. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  42228. }
  42229. if (this._indexBuffer) {
  42230. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42231. this._indexBuffer = null;
  42232. }
  42233. // Clean textures and post processes
  42234. this._disposeTextureAndPostProcesses();
  42235. // Remove from scene
  42236. var index = this._scene.effectLayers.indexOf(this, 0);
  42237. if (index > -1) {
  42238. this._scene.effectLayers.splice(index, 1);
  42239. }
  42240. // Callback
  42241. this.onDisposeObservable.notifyObservers(this);
  42242. this.onDisposeObservable.clear();
  42243. this.onBeforeRenderMainTextureObservable.clear();
  42244. this.onBeforeComposeObservable.clear();
  42245. this.onAfterComposeObservable.clear();
  42246. this.onSizeChangedObservable.clear();
  42247. };
  42248. /**
  42249. * Gets the class name of the effect layer
  42250. * @returns the string with the class name of the effect layer
  42251. */
  42252. EffectLayer.prototype.getClassName = function () {
  42253. return "EffectLayer";
  42254. };
  42255. /**
  42256. * Creates an effect layer from parsed effect layer data
  42257. * @param parsedEffectLayer defines effect layer data
  42258. * @param scene defines the current scene
  42259. * @param rootUrl defines the root URL containing the effect layer information
  42260. * @returns a parsed effect Layer
  42261. */
  42262. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  42263. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  42264. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  42265. };
  42266. /** @hidden */
  42267. EffectLayer._SceneComponentInitialization = function (_) {
  42268. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  42269. };
  42270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42272. ], EffectLayer.prototype, "name", void 0);
  42273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  42275. ], EffectLayer.prototype, "neutralColor", void 0);
  42276. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42278. ], EffectLayer.prototype, "isEnabled", void 0);
  42279. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  42281. ], EffectLayer.prototype, "camera", null);
  42282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42284. ], EffectLayer.prototype, "renderingGroupId", null);
  42285. return EffectLayer;
  42286. }());
  42287. /***/ }),
  42288. /***/ "./Layers/effectLayerSceneComponent.ts":
  42289. /*!*********************************************!*\
  42290. !*** ./Layers/effectLayerSceneComponent.ts ***!
  42291. \*********************************************/
  42292. /*! exports provided: EffectLayerSceneComponent */
  42293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42294. "use strict";
  42295. __webpack_require__.r(__webpack_exports__);
  42296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  42297. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  42298. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42299. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42300. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42301. // Adds the parser to the scene parsers.
  42302. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  42303. if (parsedData.effectLayers) {
  42304. if (!container.effectLayers) {
  42305. container.effectLayers = new Array();
  42306. }
  42307. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  42308. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  42309. container.effectLayers.push(effectLayer);
  42310. }
  42311. }
  42312. });
  42313. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  42314. var index = this.effectLayers.indexOf(toRemove);
  42315. if (index !== -1) {
  42316. this.effectLayers.splice(index, 1);
  42317. }
  42318. return index;
  42319. };
  42320. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  42321. this.effectLayers.push(newEffectLayer);
  42322. };
  42323. /**
  42324. * Defines the layer scene component responsible to manage any effect layers
  42325. * in a given scene.
  42326. */
  42327. var EffectLayerSceneComponent = /** @class */ (function () {
  42328. /**
  42329. * Creates a new instance of the component for the given scene
  42330. * @param scene Defines the scene to register the component in
  42331. */
  42332. function EffectLayerSceneComponent(scene) {
  42333. /**
  42334. * The component name helpfull to identify the component in the list of scene components.
  42335. */
  42336. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  42337. this._renderEffects = false;
  42338. this._needStencil = false;
  42339. this._previousStencilState = false;
  42340. this.scene = scene;
  42341. this._engine = scene.getEngine();
  42342. scene.effectLayers = new Array();
  42343. }
  42344. /**
  42345. * Registers the component in a given scene
  42346. */
  42347. EffectLayerSceneComponent.prototype.register = function () {
  42348. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  42349. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  42350. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  42351. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  42352. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  42353. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  42354. };
  42355. /**
  42356. * Rebuilds the elements related to this component in case of
  42357. * context lost for instance.
  42358. */
  42359. EffectLayerSceneComponent.prototype.rebuild = function () {
  42360. var layers = this.scene.effectLayers;
  42361. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42362. var effectLayer = layers_1[_i];
  42363. effectLayer._rebuild();
  42364. }
  42365. };
  42366. /**
  42367. * Serializes the component data to the specified json object
  42368. * @param serializationObject The object to serialize to
  42369. */
  42370. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  42371. // Effect layers
  42372. serializationObject.effectLayers = [];
  42373. var layers = this.scene.effectLayers;
  42374. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42375. var effectLayer = layers_2[_i];
  42376. if (effectLayer.serialize) {
  42377. serializationObject.effectLayers.push(effectLayer.serialize());
  42378. }
  42379. }
  42380. };
  42381. /**
  42382. * Adds all the element from the container to the scene
  42383. * @param container the container holding the elements
  42384. */
  42385. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  42386. var _this = this;
  42387. if (!container.effectLayers) {
  42388. return;
  42389. }
  42390. container.effectLayers.forEach(function (o) {
  42391. _this.scene.addEffectLayer(o);
  42392. });
  42393. };
  42394. /**
  42395. * Removes all the elements in the container from the scene
  42396. * @param container contains the elements to remove
  42397. * @param dispose if the removed element should be disposed (default: false)
  42398. */
  42399. EffectLayerSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  42400. var _this = this;
  42401. if (!container.effectLayers) {
  42402. return;
  42403. }
  42404. container.effectLayers.forEach(function (o) {
  42405. _this.scene.removeEffectLayer(o);
  42406. if (dispose) {
  42407. o.dispose();
  42408. }
  42409. });
  42410. };
  42411. /**
  42412. * Disposes the component and the associated ressources.
  42413. */
  42414. EffectLayerSceneComponent.prototype.dispose = function () {
  42415. var layers = this.scene.effectLayers;
  42416. while (layers.length) {
  42417. layers[0].dispose();
  42418. }
  42419. };
  42420. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  42421. var layers = this.scene.effectLayers;
  42422. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  42423. var layer = layers_3[_i];
  42424. if (!layer.hasMesh(mesh)) {
  42425. continue;
  42426. }
  42427. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  42428. var subMesh = _b[_a];
  42429. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  42430. return false;
  42431. }
  42432. }
  42433. }
  42434. return true;
  42435. };
  42436. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  42437. this._renderEffects = false;
  42438. this._needStencil = false;
  42439. var layers = this.scene.effectLayers;
  42440. if (layers && layers.length > 0) {
  42441. this._previousStencilState = this._engine.getStencilBuffer();
  42442. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  42443. var effectLayer = layers_4[_i];
  42444. if (effectLayer.shouldRender() &&
  42445. (!effectLayer.camera ||
  42446. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  42447. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  42448. this._renderEffects = true;
  42449. this._needStencil = this._needStencil || effectLayer.needStencil();
  42450. var renderTarget = effectLayer._mainTexture;
  42451. if (renderTarget._shouldRender()) {
  42452. this.scene.incrementRenderId();
  42453. renderTarget.render(false, false);
  42454. }
  42455. }
  42456. }
  42457. this.scene.incrementRenderId();
  42458. }
  42459. };
  42460. EffectLayerSceneComponent.prototype._setStencil = function () {
  42461. // Activate effect Layer stencil
  42462. if (this._needStencil) {
  42463. this._engine.setStencilBuffer(true);
  42464. }
  42465. };
  42466. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  42467. // Restore effect Layer stencil
  42468. if (this._needStencil) {
  42469. this._engine.setStencilBuffer(this._previousStencilState);
  42470. }
  42471. };
  42472. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  42473. if (this._renderEffects) {
  42474. this._engine.setDepthBuffer(false);
  42475. var layers = this.scene.effectLayers;
  42476. for (var i = 0; i < layers.length; i++) {
  42477. var effectLayer = layers[i];
  42478. if (effectLayer.renderingGroupId === renderingGroupId) {
  42479. if (effectLayer.shouldRender()) {
  42480. effectLayer.render();
  42481. }
  42482. }
  42483. }
  42484. this._engine.setDepthBuffer(true);
  42485. }
  42486. };
  42487. EffectLayerSceneComponent.prototype._drawCamera = function () {
  42488. if (this._renderEffects) {
  42489. this._draw(-1);
  42490. }
  42491. };
  42492. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  42493. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  42494. this._draw(index);
  42495. }
  42496. };
  42497. return EffectLayerSceneComponent;
  42498. }());
  42499. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  42500. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  42501. if (!component) {
  42502. component = new EffectLayerSceneComponent(scene);
  42503. scene._addComponent(component);
  42504. }
  42505. };
  42506. /***/ }),
  42507. /***/ "./Layers/glowLayer.ts":
  42508. /*!*****************************!*\
  42509. !*** ./Layers/glowLayer.ts ***!
  42510. \*****************************/
  42511. /*! exports provided: GlowLayer */
  42512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42513. "use strict";
  42514. __webpack_require__.r(__webpack_exports__);
  42515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  42516. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42517. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42518. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42519. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42520. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42521. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42522. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42523. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42524. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42525. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42526. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42527. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42528. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42529. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42530. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42531. /* harmony import */ var _Layers_effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Layers/effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42532. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  42533. for (var index = 0; index < this.effectLayers.length; index++) {
  42534. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  42535. return this.effectLayers[index];
  42536. }
  42537. }
  42538. return null;
  42539. };
  42540. /**
  42541. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  42542. *
  42543. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42544. * glowy meshes to your scene.
  42545. *
  42546. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  42547. */
  42548. var GlowLayer = /** @class */ (function (_super) {
  42549. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  42550. /**
  42551. * Instantiates a new glow Layer and references it to the scene.
  42552. * @param name The name of the layer
  42553. * @param scene The scene to use the layer in
  42554. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  42555. */
  42556. function GlowLayer(name, scene, options) {
  42557. var _this = _super.call(this, name, scene) || this;
  42558. _this._intensity = 1.0;
  42559. _this._includedOnlyMeshes = [];
  42560. _this._excludedMeshes = [];
  42561. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  42562. // Adapt options
  42563. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  42564. // Initialize the layer
  42565. _this._init({
  42566. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  42567. camera: _this._options.camera,
  42568. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42569. mainTextureRatio: _this._options.mainTextureRatio,
  42570. renderingGroupId: _this._options.renderingGroupId
  42571. });
  42572. return _this;
  42573. }
  42574. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  42575. /**
  42576. * Gets the kernel size of the blur.
  42577. */
  42578. get: function () {
  42579. return this._horizontalBlurPostprocess1.kernel;
  42580. },
  42581. /**
  42582. * Sets the kernel size of the blur.
  42583. */
  42584. set: function (value) {
  42585. this._horizontalBlurPostprocess1.kernel = value;
  42586. this._verticalBlurPostprocess1.kernel = value;
  42587. this._horizontalBlurPostprocess2.kernel = value;
  42588. this._verticalBlurPostprocess2.kernel = value;
  42589. },
  42590. enumerable: true,
  42591. configurable: true
  42592. });
  42593. Object.defineProperty(GlowLayer.prototype, "intensity", {
  42594. /**
  42595. * Gets the glow intensity.
  42596. */
  42597. get: function () {
  42598. return this._intensity;
  42599. },
  42600. /**
  42601. * Sets the glow intensity.
  42602. */
  42603. set: function (value) {
  42604. this._intensity = value;
  42605. },
  42606. enumerable: true,
  42607. configurable: true
  42608. });
  42609. /**
  42610. * Get the effect name of the layer.
  42611. * @return The effect name
  42612. */
  42613. GlowLayer.prototype.getEffectName = function () {
  42614. return GlowLayer.EffectName;
  42615. };
  42616. /**
  42617. * Create the merge effect. This is the shader use to blit the information back
  42618. * to the main canvas at the end of the scene rendering.
  42619. */
  42620. GlowLayer.prototype._createMergeEffect = function () {
  42621. // Effect
  42622. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  42623. };
  42624. /**
  42625. * Creates the render target textures and post processes used in the glow layer.
  42626. */
  42627. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  42628. var _this = this;
  42629. var blurTextureWidth = this._mainTextureDesiredSize.width;
  42630. var blurTextureHeight = this._mainTextureDesiredSize.height;
  42631. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42632. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42633. var textureType = 0;
  42634. if (this._engine.getCaps().textureHalfFloatRender) {
  42635. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42636. }
  42637. else {
  42638. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42639. }
  42640. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  42641. width: blurTextureWidth,
  42642. height: blurTextureHeight
  42643. }, this._scene, false, true, textureType);
  42644. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42645. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42646. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42647. this._blurTexture1.renderParticles = false;
  42648. this._blurTexture1.ignoreCameraViewport = true;
  42649. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  42650. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  42651. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  42652. width: blurTextureWidth2,
  42653. height: blurTextureHeight2
  42654. }, this._scene, false, true, textureType);
  42655. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42656. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42657. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42658. this._blurTexture2.renderParticles = false;
  42659. this._blurTexture2.ignoreCameraViewport = true;
  42660. this._textures = [this._blurTexture1, this._blurTexture2];
  42661. 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, {
  42662. width: blurTextureWidth,
  42663. height: blurTextureHeight
  42664. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42665. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  42666. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  42667. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  42668. effect.setTexture("textureSampler", _this._mainTexture);
  42669. });
  42670. 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, {
  42671. width: blurTextureWidth,
  42672. height: blurTextureHeight
  42673. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42674. 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, {
  42675. width: blurTextureWidth2,
  42676. height: blurTextureHeight2
  42677. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42678. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  42679. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  42680. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  42681. effect.setTexture("textureSampler", _this._blurTexture1);
  42682. });
  42683. 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, {
  42684. width: blurTextureWidth2,
  42685. height: blurTextureHeight2
  42686. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42687. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  42688. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  42689. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  42690. this._mainTexture.samples = this._options.mainTextureSamples;
  42691. this._mainTexture.onAfterUnbindObservable.add(function () {
  42692. var internalTexture = _this._blurTexture1.getInternalTexture();
  42693. if (internalTexture) {
  42694. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  42695. internalTexture = _this._blurTexture2.getInternalTexture();
  42696. if (internalTexture) {
  42697. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  42698. }
  42699. }
  42700. });
  42701. // Prevent autoClear.
  42702. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42703. };
  42704. /**
  42705. * Checks for the readiness of the element composing the layer.
  42706. * @param subMesh the mesh to check for
  42707. * @param useInstances specify wether or not to use instances to render the mesh
  42708. * @param emissiveTexture the associated emissive texture used to generate the glow
  42709. * @return true if ready otherwise, false
  42710. */
  42711. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  42712. var material = subMesh.getMaterial();
  42713. var mesh = subMesh.getRenderingMesh();
  42714. if (!material || !mesh) {
  42715. return false;
  42716. }
  42717. var emissiveTexture = material.emissiveTexture;
  42718. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42719. };
  42720. /**
  42721. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42722. */
  42723. GlowLayer.prototype.needStencil = function () {
  42724. return false;
  42725. };
  42726. /**
  42727. * Returns true if the mesh can be rendered, otherwise false.
  42728. * @param mesh The mesh to render
  42729. * @param material The material used on the mesh
  42730. * @returns true if it can be rendered otherwise false
  42731. */
  42732. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  42733. return true;
  42734. };
  42735. /**
  42736. * Implementation specific of rendering the generating effect on the main canvas.
  42737. * @param effect The effect used to render through
  42738. */
  42739. GlowLayer.prototype._internalRender = function (effect) {
  42740. // Texture
  42741. effect.setTexture("textureSampler", this._blurTexture1);
  42742. effect.setTexture("textureSampler2", this._blurTexture2);
  42743. effect.setFloat("offset", this._intensity);
  42744. // Cache
  42745. var engine = this._engine;
  42746. var previousStencilBuffer = engine.getStencilBuffer();
  42747. // Draw order
  42748. engine.setStencilBuffer(false);
  42749. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  42750. // Draw order
  42751. engine.setStencilBuffer(previousStencilBuffer);
  42752. };
  42753. /**
  42754. * Sets the required values for both the emissive texture and and the main color.
  42755. */
  42756. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42757. var textureLevel = 1.0;
  42758. if (this.customEmissiveTextureSelector) {
  42759. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  42760. }
  42761. else {
  42762. if (material) {
  42763. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42764. if (this._emissiveTextureAndColor.texture) {
  42765. textureLevel = this._emissiveTextureAndColor.texture.level;
  42766. }
  42767. }
  42768. else {
  42769. this._emissiveTextureAndColor.texture = null;
  42770. }
  42771. }
  42772. if (this.customEmissiveColorSelector) {
  42773. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  42774. }
  42775. else {
  42776. if (material.emissiveColor) {
  42777. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  42778. }
  42779. else {
  42780. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42781. }
  42782. }
  42783. };
  42784. /**
  42785. * Returns true if the mesh should render, otherwise false.
  42786. * @param mesh The mesh to render
  42787. * @returns true if it should render otherwise false
  42788. */
  42789. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  42790. return this.hasMesh(mesh);
  42791. };
  42792. /**
  42793. * Adds specific effects defines.
  42794. * @param defines The defines to add specifics to.
  42795. */
  42796. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  42797. defines.push("#define GLOW");
  42798. };
  42799. /**
  42800. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  42801. * @param mesh The mesh to exclude from the glow layer
  42802. */
  42803. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  42804. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  42805. this._excludedMeshes.push(mesh.uniqueId);
  42806. }
  42807. };
  42808. /**
  42809. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  42810. * @param mesh The mesh to remove
  42811. */
  42812. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  42813. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  42814. if (index !== -1) {
  42815. this._excludedMeshes.splice(index, 1);
  42816. }
  42817. };
  42818. /**
  42819. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  42820. * @param mesh The mesh to include in the glow layer
  42821. */
  42822. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  42823. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  42824. this._includedOnlyMeshes.push(mesh.uniqueId);
  42825. }
  42826. };
  42827. /**
  42828. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  42829. * @param mesh The mesh to remove
  42830. */
  42831. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  42832. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  42833. if (index !== -1) {
  42834. this._includedOnlyMeshes.splice(index, 1);
  42835. }
  42836. };
  42837. /**
  42838. * Determine if a given mesh will be used in the glow layer
  42839. * @param mesh The mesh to test
  42840. * @returns true if the mesh will be highlighted by the current glow layer
  42841. */
  42842. GlowLayer.prototype.hasMesh = function (mesh) {
  42843. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42844. return false;
  42845. }
  42846. // Included Mesh
  42847. if (this._includedOnlyMeshes.length) {
  42848. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  42849. }
  42850. // Excluded Mesh
  42851. if (this._excludedMeshes.length) {
  42852. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  42853. }
  42854. return true;
  42855. };
  42856. /**
  42857. * Free any resources and references associated to a mesh.
  42858. * Internal use
  42859. * @param mesh The mesh to free.
  42860. * @hidden
  42861. */
  42862. GlowLayer.prototype._disposeMesh = function (mesh) {
  42863. this.removeIncludedOnlyMesh(mesh);
  42864. this.removeExcludedMesh(mesh);
  42865. };
  42866. /**
  42867. * Gets the class name of the effect layer
  42868. * @returns the string with the class name of the effect layer
  42869. */
  42870. GlowLayer.prototype.getClassName = function () {
  42871. return "GlowLayer";
  42872. };
  42873. /**
  42874. * Serializes this glow layer
  42875. * @returns a serialized glow layer object
  42876. */
  42877. GlowLayer.prototype.serialize = function () {
  42878. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42879. serializationObject.customType = "BABYLON.GlowLayer";
  42880. var index;
  42881. // Included meshes
  42882. serializationObject.includedMeshes = [];
  42883. if (this._includedOnlyMeshes.length) {
  42884. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  42885. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  42886. if (mesh) {
  42887. serializationObject.includedMeshes.push(mesh.id);
  42888. }
  42889. }
  42890. }
  42891. // Excluded meshes
  42892. serializationObject.excludedMeshes = [];
  42893. if (this._excludedMeshes.length) {
  42894. for (index = 0; index < this._excludedMeshes.length; index++) {
  42895. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  42896. if (mesh) {
  42897. serializationObject.excludedMeshes.push(mesh.id);
  42898. }
  42899. }
  42900. }
  42901. return serializationObject;
  42902. };
  42903. /**
  42904. * Creates a Glow Layer from parsed glow layer data
  42905. * @param parsedGlowLayer defines glow layer data
  42906. * @param scene defines the current scene
  42907. * @param rootUrl defines the root URL containing the glow layer information
  42908. * @returns a parsed Glow Layer
  42909. */
  42910. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  42911. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  42912. var index;
  42913. // Excluded meshes
  42914. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  42915. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  42916. if (mesh) {
  42917. gl.addExcludedMesh(mesh);
  42918. }
  42919. }
  42920. // Included meshes
  42921. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  42922. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  42923. if (mesh) {
  42924. gl.addIncludedOnlyMesh(mesh);
  42925. }
  42926. }
  42927. return gl;
  42928. };
  42929. /**
  42930. * Effect Name of the layer.
  42931. */
  42932. GlowLayer.EffectName = "GlowLayer";
  42933. /**
  42934. * The default blur kernel size used for the glow.
  42935. */
  42936. GlowLayer.DefaultBlurKernelSize = 32;
  42937. /**
  42938. * The default texture size ratio used for the glow.
  42939. */
  42940. GlowLayer.DefaultTextureRatio = 0.5;
  42941. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42943. ], GlowLayer.prototype, "blurKernelSize", null);
  42944. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42945. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42946. ], GlowLayer.prototype, "intensity", null);
  42947. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42948. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42949. ], GlowLayer.prototype, "_options", void 0);
  42950. return GlowLayer;
  42951. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  42952. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  42953. /***/ }),
  42954. /***/ "./Layers/highlightLayer.ts":
  42955. /*!**********************************!*\
  42956. !*** ./Layers/highlightLayer.ts ***!
  42957. \**********************************/
  42958. /*! exports provided: HighlightLayer */
  42959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42960. "use strict";
  42961. __webpack_require__.r(__webpack_exports__);
  42962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  42963. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42964. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42965. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42966. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42967. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42968. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42969. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42970. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42971. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42972. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  42973. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  42974. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42975. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42976. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42977. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42978. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42979. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42980. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42981. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42982. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  42983. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  42984. for (var index = 0; index < this.effectLayers.length; index++) {
  42985. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  42986. return this.effectLayers[index];
  42987. }
  42988. }
  42989. return null;
  42990. };
  42991. /**
  42992. * Special Glow Blur post process only blurring the alpha channel
  42993. * It enforces keeping the most luminous color in the color channel.
  42994. */
  42995. var GlowBlurPostProcess = /** @class */ (function (_super) {
  42996. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  42997. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  42998. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  42999. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  43000. _this.direction = direction;
  43001. _this.kernel = kernel;
  43002. _this.onApplyObservable.add(function (effect) {
  43003. effect.setFloat2("screenSize", _this.width, _this.height);
  43004. effect.setVector2("direction", _this.direction);
  43005. effect.setFloat("blurWidth", _this.kernel);
  43006. });
  43007. return _this;
  43008. }
  43009. return GlowBlurPostProcess;
  43010. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  43011. /**
  43012. * The highlight layer Helps adding a glow effect around a mesh.
  43013. *
  43014. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43015. * glowy meshes to your scene.
  43016. *
  43017. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  43018. */
  43019. var HighlightLayer = /** @class */ (function (_super) {
  43020. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  43021. /**
  43022. * Instantiates a new highlight Layer and references it to the scene..
  43023. * @param name The name of the layer
  43024. * @param scene The scene to use the layer in
  43025. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  43026. */
  43027. function HighlightLayer(name, scene, options) {
  43028. var _this = _super.call(this, name, scene) || this;
  43029. _this.name = name;
  43030. /**
  43031. * Specifies whether or not the inner glow is ACTIVE in the layer.
  43032. */
  43033. _this.innerGlow = true;
  43034. /**
  43035. * Specifies whether or not the outer glow is ACTIVE in the layer.
  43036. */
  43037. _this.outerGlow = true;
  43038. /**
  43039. * An event triggered when the highlight layer is being blurred.
  43040. */
  43041. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43042. /**
  43043. * An event triggered when the highlight layer has been blurred.
  43044. */
  43045. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43046. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  43047. _this._meshes = {};
  43048. _this._excludedMeshes = {};
  43049. _this.neutralColor = HighlightLayer.NeutralColor;
  43050. // Warn on stencil
  43051. if (!_this._engine.isStencilEnable) {
  43052. _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 }");
  43053. }
  43054. // Adapt options
  43055. _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);
  43056. // Initialize the layer
  43057. _this._init({
  43058. alphaBlendingMode: _this._options.alphaBlendingMode,
  43059. camera: _this._options.camera,
  43060. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  43061. mainTextureRatio: _this._options.mainTextureRatio,
  43062. renderingGroupId: _this._options.renderingGroupId
  43063. });
  43064. // Do not render as long as no meshes have been added
  43065. _this._shouldRender = false;
  43066. return _this;
  43067. }
  43068. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  43069. /**
  43070. * Gets the horizontal size of the blur.
  43071. */
  43072. get: function () {
  43073. return this._horizontalBlurPostprocess.kernel;
  43074. },
  43075. /**
  43076. * Specifies the horizontal size of the blur.
  43077. */
  43078. set: function (value) {
  43079. this._horizontalBlurPostprocess.kernel = value;
  43080. },
  43081. enumerable: true,
  43082. configurable: true
  43083. });
  43084. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  43085. /**
  43086. * Gets the vertical size of the blur.
  43087. */
  43088. get: function () {
  43089. return this._verticalBlurPostprocess.kernel;
  43090. },
  43091. /**
  43092. * Specifies the vertical size of the blur.
  43093. */
  43094. set: function (value) {
  43095. this._verticalBlurPostprocess.kernel = value;
  43096. },
  43097. enumerable: true,
  43098. configurable: true
  43099. });
  43100. /**
  43101. * Get the effect name of the layer.
  43102. * @return The effect name
  43103. */
  43104. HighlightLayer.prototype.getEffectName = function () {
  43105. return HighlightLayer.EffectName;
  43106. };
  43107. /**
  43108. * Create the merge effect. This is the shader use to blit the information back
  43109. * to the main canvas at the end of the scene rendering.
  43110. */
  43111. HighlightLayer.prototype._createMergeEffect = function () {
  43112. // Effect
  43113. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  43114. };
  43115. /**
  43116. * Creates the render target textures and post processes used in the highlight layer.
  43117. */
  43118. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  43119. var _this = this;
  43120. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  43121. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  43122. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  43123. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  43124. var textureType = 0;
  43125. if (this._engine.getCaps().textureHalfFloatRender) {
  43126. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43127. }
  43128. else {
  43129. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43130. }
  43131. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  43132. width: blurTextureWidth,
  43133. height: blurTextureHeight
  43134. }, this._scene, false, true, textureType);
  43135. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43136. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43137. this._blurTexture.anisotropicFilteringLevel = 16;
  43138. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  43139. this._blurTexture.renderParticles = false;
  43140. this._blurTexture.ignoreCameraViewport = true;
  43141. this._textures = [this._blurTexture];
  43142. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  43143. 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());
  43144. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  43145. effect.setTexture("textureSampler", _this._mainTexture);
  43146. });
  43147. 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());
  43148. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43149. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43150. });
  43151. 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());
  43152. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  43153. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43154. });
  43155. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43156. }
  43157. else {
  43158. 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, {
  43159. width: blurTextureWidth,
  43160. height: blurTextureHeight
  43161. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43162. this._horizontalBlurPostprocess.width = blurTextureWidth;
  43163. this._horizontalBlurPostprocess.height = blurTextureHeight;
  43164. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43165. effect.setTexture("textureSampler", _this._mainTexture);
  43166. });
  43167. 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, {
  43168. width: blurTextureWidth,
  43169. height: blurTextureHeight
  43170. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43171. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43172. }
  43173. this._mainTexture.onAfterUnbindObservable.add(function () {
  43174. _this.onBeforeBlurObservable.notifyObservers(_this);
  43175. var internalTexture = _this._blurTexture.getInternalTexture();
  43176. if (internalTexture) {
  43177. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  43178. }
  43179. _this.onAfterBlurObservable.notifyObservers(_this);
  43180. });
  43181. // Prevent autoClear.
  43182. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43183. };
  43184. /**
  43185. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43186. */
  43187. HighlightLayer.prototype.needStencil = function () {
  43188. return true;
  43189. };
  43190. /**
  43191. * Checks for the readiness of the element composing the layer.
  43192. * @param subMesh the mesh to check for
  43193. * @param useInstances specify wether or not to use instances to render the mesh
  43194. * @param emissiveTexture the associated emissive texture used to generate the glow
  43195. * @return true if ready otherwise, false
  43196. */
  43197. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  43198. var material = subMesh.getMaterial();
  43199. var mesh = subMesh.getRenderingMesh();
  43200. if (!material || !mesh || !this._meshes) {
  43201. return false;
  43202. }
  43203. var emissiveTexture = null;
  43204. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43205. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43206. emissiveTexture = material.emissiveTexture;
  43207. }
  43208. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43209. };
  43210. /**
  43211. * Implementation specific of rendering the generating effect on the main canvas.
  43212. * @param effect The effect used to render through
  43213. */
  43214. HighlightLayer.prototype._internalRender = function (effect) {
  43215. // Texture
  43216. effect.setTexture("textureSampler", this._blurTexture);
  43217. // Cache
  43218. var engine = this._engine;
  43219. engine.cacheStencilState();
  43220. // Stencil operations
  43221. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  43222. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43223. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43224. // Draw order
  43225. engine.setStencilMask(0x00);
  43226. engine.setStencilBuffer(true);
  43227. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  43228. // 2 passes inner outer
  43229. if (this.outerGlow) {
  43230. effect.setFloat("offset", 0);
  43231. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  43232. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43233. }
  43234. if (this.innerGlow) {
  43235. effect.setFloat("offset", 1);
  43236. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  43237. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43238. }
  43239. // Restore Cache
  43240. engine.restoreStencilState();
  43241. };
  43242. /**
  43243. * Returns true if the layer contains information to display, otherwise false.
  43244. */
  43245. HighlightLayer.prototype.shouldRender = function () {
  43246. if (_super.prototype.shouldRender.call(this)) {
  43247. return this._meshes ? true : false;
  43248. }
  43249. return false;
  43250. };
  43251. /**
  43252. * Returns true if the mesh should render, otherwise false.
  43253. * @param mesh The mesh to render
  43254. * @returns true if it should render otherwise false
  43255. */
  43256. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  43257. // Excluded Mesh
  43258. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  43259. return false;
  43260. }
  43261. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43262. return false;
  43263. }
  43264. return true;
  43265. };
  43266. /**
  43267. * Sets the required values for both the emissive texture and and the main color.
  43268. */
  43269. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43270. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43271. if (highlightLayerMesh) {
  43272. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  43273. }
  43274. else {
  43275. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43276. }
  43277. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43278. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43279. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  43280. }
  43281. else {
  43282. this._emissiveTextureAndColor.texture = null;
  43283. }
  43284. };
  43285. /**
  43286. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43287. * @param mesh The mesh to exclude from the highlight layer
  43288. */
  43289. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  43290. if (!this._excludedMeshes) {
  43291. return;
  43292. }
  43293. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43294. if (!meshExcluded) {
  43295. this._excludedMeshes[mesh.uniqueId] = {
  43296. mesh: mesh,
  43297. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  43298. mesh.getEngine().setStencilBuffer(false);
  43299. }),
  43300. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  43301. mesh.getEngine().setStencilBuffer(true);
  43302. }),
  43303. };
  43304. }
  43305. };
  43306. /**
  43307. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43308. * @param mesh The mesh to highlight
  43309. */
  43310. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  43311. if (!this._excludedMeshes) {
  43312. return;
  43313. }
  43314. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43315. if (meshExcluded) {
  43316. if (meshExcluded.beforeBind) {
  43317. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  43318. }
  43319. if (meshExcluded.afterRender) {
  43320. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  43321. }
  43322. }
  43323. this._excludedMeshes[mesh.uniqueId] = null;
  43324. };
  43325. /**
  43326. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43327. * @param mesh mesh to test
  43328. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43329. */
  43330. HighlightLayer.prototype.hasMesh = function (mesh) {
  43331. if (!this._meshes) {
  43332. return false;
  43333. }
  43334. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43335. return false;
  43336. }
  43337. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  43338. };
  43339. /**
  43340. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43341. * @param mesh The mesh to highlight
  43342. * @param color The color of the highlight
  43343. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43344. */
  43345. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  43346. var _this = this;
  43347. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  43348. if (!this._meshes) {
  43349. return;
  43350. }
  43351. var meshHighlight = this._meshes[mesh.uniqueId];
  43352. if (meshHighlight) {
  43353. meshHighlight.color = color;
  43354. }
  43355. else {
  43356. this._meshes[mesh.uniqueId] = {
  43357. mesh: mesh,
  43358. color: color,
  43359. // Lambda required for capture due to Observable this context
  43360. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  43361. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  43362. _this._defaultStencilReference(mesh);
  43363. }
  43364. else {
  43365. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  43366. }
  43367. }),
  43368. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  43369. glowEmissiveOnly: glowEmissiveOnly
  43370. };
  43371. mesh.onDisposeObservable.add(function () {
  43372. _this._disposeMesh(mesh);
  43373. });
  43374. }
  43375. this._shouldRender = true;
  43376. };
  43377. /**
  43378. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43379. * @param mesh The mesh to highlight
  43380. */
  43381. HighlightLayer.prototype.removeMesh = function (mesh) {
  43382. if (!this._meshes) {
  43383. return;
  43384. }
  43385. var meshHighlight = this._meshes[mesh.uniqueId];
  43386. if (meshHighlight) {
  43387. if (meshHighlight.observerHighlight) {
  43388. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43389. }
  43390. if (meshHighlight.observerDefault) {
  43391. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43392. }
  43393. delete this._meshes[mesh.uniqueId];
  43394. }
  43395. this._shouldRender = false;
  43396. for (var meshHighlightToCheck in this._meshes) {
  43397. if (this._meshes[meshHighlightToCheck]) {
  43398. this._shouldRender = true;
  43399. break;
  43400. }
  43401. }
  43402. };
  43403. /**
  43404. * Force the stencil to the normal expected value for none glowing parts
  43405. */
  43406. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  43407. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  43408. };
  43409. /**
  43410. * Free any resources and references associated to a mesh.
  43411. * Internal use
  43412. * @param mesh The mesh to free.
  43413. * @hidden
  43414. */
  43415. HighlightLayer.prototype._disposeMesh = function (mesh) {
  43416. this.removeMesh(mesh);
  43417. this.removeExcludedMesh(mesh);
  43418. };
  43419. /**
  43420. * Dispose the highlight layer and free resources.
  43421. */
  43422. HighlightLayer.prototype.dispose = function () {
  43423. if (this._meshes) {
  43424. // Clean mesh references
  43425. for (var id in this._meshes) {
  43426. var meshHighlight = this._meshes[id];
  43427. if (meshHighlight && meshHighlight.mesh) {
  43428. if (meshHighlight.observerHighlight) {
  43429. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43430. }
  43431. if (meshHighlight.observerDefault) {
  43432. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43433. }
  43434. }
  43435. }
  43436. this._meshes = null;
  43437. }
  43438. if (this._excludedMeshes) {
  43439. for (var id in this._excludedMeshes) {
  43440. var meshHighlight = this._excludedMeshes[id];
  43441. if (meshHighlight) {
  43442. if (meshHighlight.beforeBind) {
  43443. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  43444. }
  43445. if (meshHighlight.afterRender) {
  43446. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  43447. }
  43448. }
  43449. }
  43450. this._excludedMeshes = null;
  43451. }
  43452. _super.prototype.dispose.call(this);
  43453. };
  43454. /**
  43455. * Gets the class name of the effect layer
  43456. * @returns the string with the class name of the effect layer
  43457. */
  43458. HighlightLayer.prototype.getClassName = function () {
  43459. return "HighlightLayer";
  43460. };
  43461. /**
  43462. * Serializes this Highlight layer
  43463. * @returns a serialized Highlight layer object
  43464. */
  43465. HighlightLayer.prototype.serialize = function () {
  43466. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43467. serializationObject.customType = "BABYLON.HighlightLayer";
  43468. // Highlighted meshes
  43469. serializationObject.meshes = [];
  43470. if (this._meshes) {
  43471. for (var m in this._meshes) {
  43472. var mesh = this._meshes[m];
  43473. if (mesh) {
  43474. serializationObject.meshes.push({
  43475. glowEmissiveOnly: mesh.glowEmissiveOnly,
  43476. color: mesh.color.asArray(),
  43477. meshId: mesh.mesh.id
  43478. });
  43479. }
  43480. }
  43481. }
  43482. // Excluded meshes
  43483. serializationObject.excludedMeshes = [];
  43484. if (this._excludedMeshes) {
  43485. for (var e in this._excludedMeshes) {
  43486. var excludedMesh = this._excludedMeshes[e];
  43487. if (excludedMesh) {
  43488. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  43489. }
  43490. }
  43491. }
  43492. return serializationObject;
  43493. };
  43494. /**
  43495. * Creates a Highlight layer from parsed Highlight layer data
  43496. * @param parsedHightlightLayer defines the Highlight layer data
  43497. * @param scene defines the current scene
  43498. * @param rootUrl defines the root URL containing the Highlight layer information
  43499. * @returns a parsed Highlight layer
  43500. */
  43501. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  43502. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  43503. var index;
  43504. // Excluded meshes
  43505. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  43506. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  43507. if (mesh) {
  43508. hl.addExcludedMesh(mesh);
  43509. }
  43510. }
  43511. // Included meshes
  43512. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  43513. var highlightedMesh = parsedHightlightLayer.meshes[index];
  43514. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  43515. if (mesh) {
  43516. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  43517. }
  43518. }
  43519. return hl;
  43520. };
  43521. /**
  43522. * Effect Name of the highlight layer.
  43523. */
  43524. HighlightLayer.EffectName = "HighlightLayer";
  43525. /**
  43526. * The neutral color used during the preparation of the glow effect.
  43527. * This is black by default as the blend operation is a blend operation.
  43528. */
  43529. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  43530. /**
  43531. * Stencil value used for glowing meshes.
  43532. */
  43533. HighlightLayer.GlowingMeshStencilReference = 0x02;
  43534. /**
  43535. * Stencil value used for the other meshes in the scene.
  43536. */
  43537. HighlightLayer.NormalMeshStencilReference = 0x01;
  43538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43540. ], HighlightLayer.prototype, "innerGlow", void 0);
  43541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43543. ], HighlightLayer.prototype, "outerGlow", void 0);
  43544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43546. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  43547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43549. ], HighlightLayer.prototype, "blurVerticalSize", null);
  43550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43552. ], HighlightLayer.prototype, "_options", void 0);
  43553. return HighlightLayer;
  43554. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  43555. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  43556. /***/ }),
  43557. /***/ "./Layers/index.ts":
  43558. /*!*************************!*\
  43559. !*** ./Layers/index.ts ***!
  43560. \*************************/
  43561. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  43562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43563. "use strict";
  43564. __webpack_require__.r(__webpack_exports__);
  43565. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43567. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  43568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  43569. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  43570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  43571. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  43572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  43573. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  43574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  43575. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  43577. /***/ }),
  43578. /***/ "./Layers/layer.ts":
  43579. /*!*************************!*\
  43580. !*** ./Layers/layer.ts ***!
  43581. \*************************/
  43582. /*! exports provided: Layer */
  43583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43584. "use strict";
  43585. __webpack_require__.r(__webpack_exports__);
  43586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  43587. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43588. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43589. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43590. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43591. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43592. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43593. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43594. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43595. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43596. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  43597. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  43598. /**
  43599. * This represents a full screen 2d layer.
  43600. * This can be useful to display a picture in the background of your scene for instance.
  43601. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43602. */
  43603. var Layer = /** @class */ (function () {
  43604. /**
  43605. * Instantiates a new layer.
  43606. * This represents a full screen 2d layer.
  43607. * This can be useful to display a picture in the background of your scene for instance.
  43608. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43609. * @param name Define the name of the layer in the scene
  43610. * @param imgUrl Define the url of the texture to display in the layer
  43611. * @param scene Define the scene the layer belongs to
  43612. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  43613. * @param color Defines a color for the layer
  43614. */
  43615. function Layer(
  43616. /**
  43617. * Define the name of the layer.
  43618. */
  43619. name, imgUrl, scene, isBackground, color) {
  43620. this.name = name;
  43621. /**
  43622. * Define the scale of the layer in order to zoom in out of the texture.
  43623. */
  43624. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  43625. /**
  43626. * Define an offset for the layer in order to shift the texture.
  43627. */
  43628. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  43629. /**
  43630. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  43631. */
  43632. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  43633. /**
  43634. * Define a mask to restrict the layer to only some of the scene cameras.
  43635. */
  43636. this.layerMask = 0x0FFFFFFF;
  43637. /**
  43638. * Define the list of render target the layer is visible into.
  43639. */
  43640. this.renderTargetTextures = [];
  43641. /**
  43642. * Define if the layer is only used in renderTarget or if it also
  43643. * renders in the main frame buffer of the canvas.
  43644. */
  43645. this.renderOnlyInRenderTargetTextures = false;
  43646. this._vertexBuffers = {};
  43647. /**
  43648. * An event triggered when the layer is disposed.
  43649. */
  43650. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43651. /**
  43652. * An event triggered before rendering the scene
  43653. */
  43654. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43655. /**
  43656. * An event triggered after rendering the scene
  43657. */
  43658. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43659. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  43660. this.isBackground = isBackground === undefined ? true : isBackground;
  43661. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  43662. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  43663. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  43664. if (!layerComponent) {
  43665. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  43666. this._scene._addComponent(layerComponent);
  43667. }
  43668. this._scene.layers.push(this);
  43669. var engine = this._scene.getEngine();
  43670. // VBO
  43671. var vertices = [];
  43672. vertices.push(1, 1);
  43673. vertices.push(-1, 1);
  43674. vertices.push(-1, -1);
  43675. vertices.push(1, -1);
  43676. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  43677. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  43678. this._createIndexBuffer();
  43679. // Effects
  43680. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  43681. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  43682. }
  43683. Object.defineProperty(Layer.prototype, "onDispose", {
  43684. /**
  43685. * Back compatibility with callback before the onDisposeObservable existed.
  43686. * The set callback will be triggered when the layer has been disposed.
  43687. */
  43688. set: function (callback) {
  43689. if (this._onDisposeObserver) {
  43690. this.onDisposeObservable.remove(this._onDisposeObserver);
  43691. }
  43692. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  43693. },
  43694. enumerable: true,
  43695. configurable: true
  43696. });
  43697. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  43698. /**
  43699. * Back compatibility with callback before the onBeforeRenderObservable existed.
  43700. * The set callback will be triggered just before rendering the layer.
  43701. */
  43702. set: function (callback) {
  43703. if (this._onBeforeRenderObserver) {
  43704. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  43705. }
  43706. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  43707. },
  43708. enumerable: true,
  43709. configurable: true
  43710. });
  43711. Object.defineProperty(Layer.prototype, "onAfterRender", {
  43712. /**
  43713. * Back compatibility with callback before the onAfterRenderObservable existed.
  43714. * The set callback will be triggered just after rendering the layer.
  43715. */
  43716. set: function (callback) {
  43717. if (this._onAfterRenderObserver) {
  43718. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  43719. }
  43720. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  43721. },
  43722. enumerable: true,
  43723. configurable: true
  43724. });
  43725. Layer.prototype._createIndexBuffer = function () {
  43726. var engine = this._scene.getEngine();
  43727. // Indices
  43728. var indices = [];
  43729. indices.push(0);
  43730. indices.push(1);
  43731. indices.push(2);
  43732. indices.push(0);
  43733. indices.push(2);
  43734. indices.push(3);
  43735. this._indexBuffer = engine.createIndexBuffer(indices);
  43736. };
  43737. /** @hidden */
  43738. Layer.prototype._rebuild = function () {
  43739. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  43740. if (vb) {
  43741. vb._rebuild();
  43742. }
  43743. this._createIndexBuffer();
  43744. };
  43745. /**
  43746. * Renders the layer in the scene.
  43747. */
  43748. Layer.prototype.render = function () {
  43749. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  43750. // Check
  43751. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  43752. return;
  43753. }
  43754. var engine = this._scene.getEngine();
  43755. this.onBeforeRenderObservable.notifyObservers(this);
  43756. // Render
  43757. engine.enableEffect(currentEffect);
  43758. engine.setState(false);
  43759. // Texture
  43760. currentEffect.setTexture("textureSampler", this.texture);
  43761. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  43762. // Color
  43763. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  43764. // Scale / offset
  43765. currentEffect.setVector2("offset", this.offset);
  43766. currentEffect.setVector2("scale", this.scale);
  43767. // VBOs
  43768. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  43769. // Draw order
  43770. if (!this.alphaTest) {
  43771. engine.setAlphaMode(this.alphaBlendingMode);
  43772. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  43773. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  43774. }
  43775. else {
  43776. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  43777. }
  43778. this.onAfterRenderObservable.notifyObservers(this);
  43779. };
  43780. /**
  43781. * Disposes and releases the associated ressources.
  43782. */
  43783. Layer.prototype.dispose = function () {
  43784. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  43785. if (vertexBuffer) {
  43786. vertexBuffer.dispose();
  43787. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  43788. }
  43789. if (this._indexBuffer) {
  43790. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43791. this._indexBuffer = null;
  43792. }
  43793. if (this.texture) {
  43794. this.texture.dispose();
  43795. this.texture = null;
  43796. }
  43797. // Clean RTT list
  43798. this.renderTargetTextures = [];
  43799. // Remove from scene
  43800. var index = this._scene.layers.indexOf(this);
  43801. this._scene.layers.splice(index, 1);
  43802. // Callback
  43803. this.onDisposeObservable.notifyObservers(this);
  43804. this.onDisposeObservable.clear();
  43805. this.onAfterRenderObservable.clear();
  43806. this.onBeforeRenderObservable.clear();
  43807. };
  43808. return Layer;
  43809. }());
  43810. /***/ }),
  43811. /***/ "./Layers/layerSceneComponent.ts":
  43812. /*!***************************************!*\
  43813. !*** ./Layers/layerSceneComponent.ts ***!
  43814. \***************************************/
  43815. /*! exports provided: LayerSceneComponent */
  43816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43817. "use strict";
  43818. __webpack_require__.r(__webpack_exports__);
  43819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  43820. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43821. /**
  43822. * Defines the layer scene component responsible to manage any layers
  43823. * in a given scene.
  43824. */
  43825. var LayerSceneComponent = /** @class */ (function () {
  43826. /**
  43827. * Creates a new instance of the component for the given scene
  43828. * @param scene Defines the scene to register the component in
  43829. */
  43830. function LayerSceneComponent(scene) {
  43831. /**
  43832. * The component name helpfull to identify the component in the list of scene components.
  43833. */
  43834. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  43835. this.scene = scene;
  43836. this._engine = scene.getEngine();
  43837. scene.layers = new Array();
  43838. }
  43839. /**
  43840. * Registers the component in a given scene
  43841. */
  43842. LayerSceneComponent.prototype.register = function () {
  43843. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  43844. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  43845. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  43846. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  43847. };
  43848. /**
  43849. * Rebuilds the elements related to this component in case of
  43850. * context lost for instance.
  43851. */
  43852. LayerSceneComponent.prototype.rebuild = function () {
  43853. var layers = this.scene.layers;
  43854. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  43855. var layer = layers_1[_i];
  43856. layer._rebuild();
  43857. }
  43858. };
  43859. /**
  43860. * Disposes the component and the associated ressources.
  43861. */
  43862. LayerSceneComponent.prototype.dispose = function () {
  43863. var layers = this.scene.layers;
  43864. while (layers.length) {
  43865. layers[0].dispose();
  43866. }
  43867. };
  43868. LayerSceneComponent.prototype._draw = function (predicate) {
  43869. var layers = this.scene.layers;
  43870. if (layers.length) {
  43871. this._engine.setDepthBuffer(false);
  43872. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  43873. var layer = layers_2[_i];
  43874. if (predicate(layer)) {
  43875. layer.render();
  43876. }
  43877. }
  43878. this._engine.setDepthBuffer(true);
  43879. }
  43880. };
  43881. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  43882. return !layer.renderOnlyInRenderTargetTextures &&
  43883. layer.isBackground === isBackground &&
  43884. ((layer.layerMask & cameraLayerMask) !== 0);
  43885. };
  43886. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  43887. var _this = this;
  43888. this._draw(function (layer) {
  43889. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  43890. });
  43891. };
  43892. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  43893. var _this = this;
  43894. this._draw(function (layer) {
  43895. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  43896. });
  43897. };
  43898. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  43899. return (layer.renderTargetTextures.length > 0) &&
  43900. layer.isBackground === isBackground &&
  43901. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  43902. ((layer.layerMask & cameraLayerMask) !== 0);
  43903. };
  43904. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  43905. var _this = this;
  43906. this._draw(function (layer) {
  43907. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  43908. });
  43909. };
  43910. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  43911. var _this = this;
  43912. this._draw(function (layer) {
  43913. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  43914. });
  43915. };
  43916. return LayerSceneComponent;
  43917. }());
  43918. /***/ }),
  43919. /***/ "./Legacy/legacy.ts":
  43920. /*!**************************!*\
  43921. !*** ./Legacy/legacy.ts ***!
  43922. \**************************/
  43923. /*! exports provided: Debug, AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, MultiviewRenderTarget, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleview, 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, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, CubeMapToSphericalPolynomialTools, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, EquiRectangularCubeTexture, HDRCubeTexture, DummyInternalTextureTracker, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  43924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43925. "use strict";
  43926. __webpack_require__.r(__webpack_exports__);
  43927. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  43928. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  43929. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  43930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  43931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  43932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  43933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  43934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  43935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  43936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  43937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  43938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  43939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  43940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  43941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  43942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  43943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  43944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  43945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  43946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  43947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  43948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  43949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  43950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  43951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  43952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  43953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  43954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  43955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  43956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  43957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  43958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  43959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  43960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  43961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  43962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  43963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  43964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  43965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  43966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  43967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  43968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  43969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  43970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  43971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  43972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  43973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  43974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  43975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  43976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  43977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  43978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  43979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  43980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  43981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  43982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  43983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  43984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  43985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  43986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  43987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  43988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  43989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  43990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  43991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  43992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  43993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  43994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  43995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  43996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  43997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  43998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  43999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  44000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  44001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  44002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  44003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  44004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  44005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  44006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  44007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  44008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  44009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  44010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  44011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  44012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  44013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  44014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  44015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  44016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  44017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  44018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  44019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  44020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  44021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  44022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  44023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  44024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  44025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  44026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  44027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  44028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  44029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  44030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  44031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  44032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  44033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  44034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  44035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  44036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  44037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  44038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  44039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  44040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  44041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  44042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  44043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  44044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  44045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  44046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  44047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  44048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  44049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  44050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  44051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  44052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  44053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  44054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  44055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  44056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  44057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  44058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  44059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  44060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  44061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  44062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  44063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  44064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  44065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  44066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  44067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  44068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  44070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  44071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  44072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  44073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  44074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  44075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  44076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  44077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  44078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  44079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  44080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  44081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  44082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  44083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  44084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  44085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  44086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  44087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  44088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  44089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  44090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  44091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  44092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  44093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  44094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  44095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  44096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  44097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  44098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  44099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  44100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  44101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  44102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiviewRenderTarget"]; });
  44103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  44104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  44105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  44106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  44107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  44108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  44109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  44110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  44111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  44112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  44113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  44114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  44115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  44116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  44117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  44118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  44119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  44120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  44121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  44122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  44123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  44124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  44125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  44126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  44127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  44128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  44129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  44130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  44131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  44132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  44133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  44134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  44135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  44136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  44137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  44138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  44139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  44140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  44141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  44142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  44143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  44144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  44145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  44146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  44147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  44148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  44149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  44150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  44151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  44152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  44153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  44154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  44155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  44156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  44157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  44158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  44159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  44160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  44161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  44162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  44163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  44164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  44165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  44166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  44167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  44168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  44169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  44170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  44171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  44172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  44173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  44174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  44175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  44176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  44177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  44178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  44179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  44180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  44181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  44182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  44183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  44184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEventOptions"]; });
  44185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEventOptions"]; });
  44186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEventOptions"]; });
  44187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  44188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  44189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  44190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  44191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  44192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  44193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  44194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  44195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  44196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  44197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  44198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  44199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  44200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  44201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  44202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  44203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  44204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  44205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  44206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  44207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  44208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  44209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  44210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  44211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  44212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  44213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  44214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  44215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  44216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  44217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  44218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  44219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  44220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  44221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  44222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  44223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  44224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  44225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  44226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  44227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  44228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleview", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRMultiviewToSingleview"]; });
  44229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  44230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  44231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  44232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  44233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  44234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  44235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  44236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  44237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  44238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  44239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  44240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  44241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  44242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  44243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  44244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  44245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  44246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  44247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  44248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  44249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  44250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  44251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  44252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  44253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  44254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  44255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  44256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  44257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  44258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  44259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  44260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  44261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  44262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  44263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  44264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  44265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  44266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  44267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  44268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  44269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  44270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  44271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  44272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  44273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMatrix"]; });
  44274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  44275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  44276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  44277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  44278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshExploder"]; });
  44279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  44280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  44281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  44282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  44283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  44284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  44285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  44286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  44287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  44288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  44289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  44290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  44291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  44292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  44293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  44294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  44295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  44296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  44297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  44298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  44299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  44300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  44301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  44302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  44303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  44304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  44305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  44306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  44307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  44308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  44309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  44310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  44311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  44312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  44313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  44314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  44315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  44316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  44317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  44318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  44319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  44320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  44321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  44322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  44323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  44324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  44325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  44326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  44327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  44328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]; });
  44329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InspectableType"]; });
  44330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  44331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  44332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  44333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  44334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  44335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  44336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  44337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  44338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  44339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  44340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  44341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  44342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  44343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  44344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  44345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  44346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  44347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  44348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  44349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  44350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  44351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  44352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  44353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  44354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  44355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  44356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  44357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  44358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  44359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  44360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  44361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  44362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  44363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  44364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  44365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  44366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  44367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  44368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  44369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  44370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  44371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  44372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  44373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  44374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  44375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  44376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  44377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  44378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  44379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  44380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  44381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  44382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  44383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  44384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  44385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  44386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  44387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  44388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  44389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  44390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  44391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  44392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  44393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  44394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  44396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  44397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  44398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  44399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  44400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  44401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  44402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  44403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  44404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  44405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTexture"]; });
  44406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  44407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  44408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  44409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  44410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  44411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  44412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  44413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  44414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  44415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  44416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  44417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  44418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  44419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  44420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  44421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  44422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  44423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  44424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  44425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  44426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  44427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  44428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  44429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  44430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  44431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  44432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  44433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  44434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  44435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  44436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  44437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  44438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  44439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  44440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  44441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  44442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  44443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  44444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  44445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  44446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  44447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  44448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  44449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  44450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  44451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  44452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  44453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  44454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  44455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  44456. /**
  44457. * Legacy support, defining window.BABYLON (global variable).
  44458. *
  44459. * This is the entry point for the UMD module.
  44460. * The entry point for a future ESM package should be index.ts
  44461. */
  44462. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  44463. if (typeof globalObject !== "undefined") {
  44464. globalObject.BABYLON = BABYLON;
  44465. globalObject.BABYLON = globalObject.BABYLON || {};
  44466. var BABYLON = globalObject.BABYLON;
  44467. BABYLON.Debug = BABYLON.Debug || {};
  44468. var keys = [];
  44469. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  44470. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  44471. keys.push(key);
  44472. }
  44473. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  44474. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  44475. }
  44476. }
  44477. var Debug = {
  44478. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  44479. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  44480. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  44481. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  44482. };
  44483. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  44484. /***/ }),
  44485. /***/ "./LensFlares/index.ts":
  44486. /*!*****************************!*\
  44487. !*** ./LensFlares/index.ts ***!
  44488. \*****************************/
  44489. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  44490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44491. "use strict";
  44492. __webpack_require__.r(__webpack_exports__);
  44493. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44495. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  44497. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  44498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  44499. /***/ }),
  44500. /***/ "./LensFlares/lensFlare.ts":
  44501. /*!*********************************!*\
  44502. !*** ./LensFlares/lensFlare.ts ***!
  44503. \*********************************/
  44504. /*! exports provided: LensFlare */
  44505. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44506. "use strict";
  44507. __webpack_require__.r(__webpack_exports__);
  44508. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  44509. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44510. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44511. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44512. /**
  44513. * This represents one of the lens effect in a `lensFlareSystem`.
  44514. * It controls one of the indiviual texture used in the effect.
  44515. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44516. */
  44517. var LensFlare = /** @class */ (function () {
  44518. /**
  44519. * Instantiates a new Lens Flare.
  44520. * This represents one of the lens effect in a `lensFlareSystem`.
  44521. * It controls one of the indiviual texture used in the effect.
  44522. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44523. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44524. * @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.
  44525. * @param color Define the lens color
  44526. * @param imgUrl Define the lens texture url
  44527. * @param system Define the `lensFlareSystem` this flare is part of
  44528. */
  44529. function LensFlare(
  44530. /**
  44531. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44532. */
  44533. size,
  44534. /**
  44535. * 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.
  44536. */
  44537. position, color, imgUrl, system) {
  44538. this.size = size;
  44539. this.position = position;
  44540. /**
  44541. * Define the alpha mode to render this particular lens.
  44542. */
  44543. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  44544. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  44545. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  44546. this._system = system;
  44547. system.lensFlares.push(this);
  44548. }
  44549. /**
  44550. * Creates a new Lens Flare.
  44551. * This represents one of the lens effect in a `lensFlareSystem`.
  44552. * It controls one of the indiviual texture used in the effect.
  44553. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44554. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44555. * @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.
  44556. * @param color Define the lens color
  44557. * @param imgUrl Define the lens texture url
  44558. * @param system Define the `lensFlareSystem` this flare is part of
  44559. * @returns The newly created Lens Flare
  44560. */
  44561. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  44562. return new LensFlare(size, position, color, imgUrl, system);
  44563. };
  44564. /**
  44565. * Dispose and release the lens flare with its associated resources.
  44566. */
  44567. LensFlare.prototype.dispose = function () {
  44568. if (this.texture) {
  44569. this.texture.dispose();
  44570. }
  44571. // Remove from scene
  44572. var index = this._system.lensFlares.indexOf(this);
  44573. this._system.lensFlares.splice(index, 1);
  44574. };
  44575. return LensFlare;
  44576. }());
  44577. /***/ }),
  44578. /***/ "./LensFlares/lensFlareSystem.ts":
  44579. /*!***************************************!*\
  44580. !*** ./LensFlares/lensFlareSystem.ts ***!
  44581. \***************************************/
  44582. /*! exports provided: LensFlareSystem */
  44583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44584. "use strict";
  44585. __webpack_require__.r(__webpack_exports__);
  44586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  44587. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44588. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44589. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  44590. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  44591. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44592. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  44593. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44594. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44595. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44596. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  44597. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  44598. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  44599. /**
  44600. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44601. * It is usually composed of several `lensFlare`.
  44602. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44603. */
  44604. var LensFlareSystem = /** @class */ (function () {
  44605. /**
  44606. * Instantiates a lens flare system.
  44607. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44608. * It is usually composed of several `lensFlare`.
  44609. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44610. * @param name Define the name of the lens flare system in the scene
  44611. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44612. * @param scene Define the scene the lens flare system belongs to
  44613. */
  44614. function LensFlareSystem(
  44615. /**
  44616. * Define the name of the lens flare system
  44617. */
  44618. name, emitter, scene) {
  44619. this.name = name;
  44620. /**
  44621. * List of lens flares used in this system.
  44622. */
  44623. this.lensFlares = new Array();
  44624. /**
  44625. * Define a limit from the border the lens flare can be visible.
  44626. */
  44627. this.borderLimit = 300;
  44628. /**
  44629. * Define a viewport border we do not want to see the lens flare in.
  44630. */
  44631. this.viewportBorder = 0;
  44632. /**
  44633. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44634. */
  44635. this.layerMask = 0x0FFFFFFF;
  44636. this._vertexBuffers = {};
  44637. this._isEnabled = true;
  44638. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  44639. LensFlareSystem._SceneComponentInitialization(this._scene);
  44640. this._emitter = emitter;
  44641. this.id = name;
  44642. scene.lensFlareSystems.push(this);
  44643. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  44644. var engine = scene.getEngine();
  44645. // VBO
  44646. var vertices = [];
  44647. vertices.push(1, 1);
  44648. vertices.push(-1, 1);
  44649. vertices.push(-1, -1);
  44650. vertices.push(1, -1);
  44651. 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);
  44652. // Indices
  44653. var indices = [];
  44654. indices.push(0);
  44655. indices.push(1);
  44656. indices.push(2);
  44657. indices.push(0);
  44658. indices.push(2);
  44659. indices.push(3);
  44660. this._indexBuffer = engine.createIndexBuffer(indices);
  44661. // Effects
  44662. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  44663. }
  44664. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  44665. /**
  44666. * Define if the lens flare system is enabled.
  44667. */
  44668. get: function () {
  44669. return this._isEnabled;
  44670. },
  44671. set: function (value) {
  44672. this._isEnabled = value;
  44673. },
  44674. enumerable: true,
  44675. configurable: true
  44676. });
  44677. /**
  44678. * Get the scene the effects belongs to.
  44679. * @returns the scene holding the lens flare system
  44680. */
  44681. LensFlareSystem.prototype.getScene = function () {
  44682. return this._scene;
  44683. };
  44684. /**
  44685. * Get the emitter of the lens flare system.
  44686. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44687. * @returns the emitter of the lens flare system
  44688. */
  44689. LensFlareSystem.prototype.getEmitter = function () {
  44690. return this._emitter;
  44691. };
  44692. /**
  44693. * Set the emitter of the lens flare system.
  44694. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44695. * @param newEmitter Define the new emitter of the system
  44696. */
  44697. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  44698. this._emitter = newEmitter;
  44699. };
  44700. /**
  44701. * Get the lens flare system emitter position.
  44702. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  44703. * @returns the position
  44704. */
  44705. LensFlareSystem.prototype.getEmitterPosition = function () {
  44706. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  44707. };
  44708. /**
  44709. * @hidden
  44710. */
  44711. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  44712. var position = this.getEmitterPosition();
  44713. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  44714. this._positionX = position.x;
  44715. this._positionY = position.y;
  44716. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  44717. if (this.viewportBorder > 0) {
  44718. globalViewport.x -= this.viewportBorder;
  44719. globalViewport.y -= this.viewportBorder;
  44720. globalViewport.width += this.viewportBorder * 2;
  44721. globalViewport.height += this.viewportBorder * 2;
  44722. position.x += this.viewportBorder;
  44723. position.y += this.viewportBorder;
  44724. this._positionX += this.viewportBorder;
  44725. this._positionY += this.viewportBorder;
  44726. }
  44727. if (position.z > 0) {
  44728. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  44729. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  44730. return true;
  44731. }
  44732. }
  44733. return true;
  44734. }
  44735. return false;
  44736. };
  44737. /** @hidden */
  44738. LensFlareSystem.prototype._isVisible = function () {
  44739. if (!this._isEnabled || !this._scene.activeCamera) {
  44740. return false;
  44741. }
  44742. var emitterPosition = this.getEmitterPosition();
  44743. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  44744. var distance = direction.length();
  44745. direction.normalize();
  44746. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  44747. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  44748. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  44749. };
  44750. /**
  44751. * @hidden
  44752. */
  44753. LensFlareSystem.prototype.render = function () {
  44754. if (!this._effect.isReady() || !this._scene.activeCamera) {
  44755. return false;
  44756. }
  44757. var engine = this._scene.getEngine();
  44758. var viewport = this._scene.activeCamera.viewport;
  44759. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  44760. // Position
  44761. if (!this.computeEffectivePosition(globalViewport)) {
  44762. return false;
  44763. }
  44764. // Visibility
  44765. if (!this._isVisible()) {
  44766. return false;
  44767. }
  44768. // Intensity
  44769. var awayX;
  44770. var awayY;
  44771. if (this._positionX < this.borderLimit + globalViewport.x) {
  44772. awayX = this.borderLimit + globalViewport.x - this._positionX;
  44773. }
  44774. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  44775. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  44776. }
  44777. else {
  44778. awayX = 0;
  44779. }
  44780. if (this._positionY < this.borderLimit + globalViewport.y) {
  44781. awayY = this.borderLimit + globalViewport.y - this._positionY;
  44782. }
  44783. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  44784. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  44785. }
  44786. else {
  44787. awayY = 0;
  44788. }
  44789. var away = (awayX > awayY) ? awayX : awayY;
  44790. away -= this.viewportBorder;
  44791. if (away > this.borderLimit) {
  44792. away = this.borderLimit;
  44793. }
  44794. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  44795. if (intensity < 0) {
  44796. return false;
  44797. }
  44798. if (intensity > 1.0) {
  44799. intensity = 1.0;
  44800. }
  44801. if (this.viewportBorder > 0) {
  44802. globalViewport.x += this.viewportBorder;
  44803. globalViewport.y += this.viewportBorder;
  44804. globalViewport.width -= this.viewportBorder * 2;
  44805. globalViewport.height -= this.viewportBorder * 2;
  44806. this._positionX -= this.viewportBorder;
  44807. this._positionY -= this.viewportBorder;
  44808. }
  44809. // Position
  44810. var centerX = globalViewport.x + globalViewport.width / 2;
  44811. var centerY = globalViewport.y + globalViewport.height / 2;
  44812. var distX = centerX - this._positionX;
  44813. var distY = centerY - this._positionY;
  44814. // Effects
  44815. engine.enableEffect(this._effect);
  44816. engine.setState(false);
  44817. engine.setDepthBuffer(false);
  44818. // VBOs
  44819. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  44820. // Flares
  44821. for (var index = 0; index < this.lensFlares.length; index++) {
  44822. var flare = this.lensFlares[index];
  44823. engine.setAlphaMode(flare.alphaMode);
  44824. var x = centerX - (distX * flare.position);
  44825. var y = centerY - (distY * flare.position);
  44826. var cw = flare.size;
  44827. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  44828. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  44829. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  44830. 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);
  44831. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  44832. // Texture
  44833. this._effect.setTexture("textureSampler", flare.texture);
  44834. // Color
  44835. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  44836. // Draw order
  44837. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44838. }
  44839. engine.setDepthBuffer(true);
  44840. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44841. return true;
  44842. };
  44843. /**
  44844. * Dispose and release the lens flare with its associated resources.
  44845. */
  44846. LensFlareSystem.prototype.dispose = function () {
  44847. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  44848. if (vertexBuffer) {
  44849. vertexBuffer.dispose();
  44850. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  44851. }
  44852. if (this._indexBuffer) {
  44853. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44854. this._indexBuffer = null;
  44855. }
  44856. while (this.lensFlares.length) {
  44857. this.lensFlares[0].dispose();
  44858. }
  44859. // Remove from scene
  44860. var index = this._scene.lensFlareSystems.indexOf(this);
  44861. this._scene.lensFlareSystems.splice(index, 1);
  44862. };
  44863. /**
  44864. * Parse a lens flare system from a JSON repressentation
  44865. * @param parsedLensFlareSystem Define the JSON to parse
  44866. * @param scene Define the scene the parsed system should be instantiated in
  44867. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44868. * @returns the parsed system
  44869. */
  44870. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  44871. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  44872. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  44873. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  44874. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  44875. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  44876. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  44877. var parsedFlare = parsedLensFlareSystem.flares[index];
  44878. _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);
  44879. }
  44880. return lensFlareSystem;
  44881. };
  44882. /**
  44883. * Serialize the current Lens Flare System into a JSON representation.
  44884. * @returns the serialized JSON
  44885. */
  44886. LensFlareSystem.prototype.serialize = function () {
  44887. var serializationObject = {};
  44888. serializationObject.id = this.id;
  44889. serializationObject.name = this.name;
  44890. serializationObject.emitterId = this.getEmitter().id;
  44891. serializationObject.borderLimit = this.borderLimit;
  44892. serializationObject.flares = [];
  44893. for (var index = 0; index < this.lensFlares.length; index++) {
  44894. var flare = this.lensFlares[index];
  44895. serializationObject.flares.push({
  44896. size: flare.size,
  44897. position: flare.position,
  44898. color: flare.color.asArray(),
  44899. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  44900. });
  44901. }
  44902. return serializationObject;
  44903. };
  44904. /** @hidden */
  44905. LensFlareSystem._SceneComponentInitialization = function (_) {
  44906. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  44907. };
  44908. return LensFlareSystem;
  44909. }());
  44910. /***/ }),
  44911. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  44912. /*!*****************************************************!*\
  44913. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  44914. \*****************************************************/
  44915. /*! exports provided: LensFlareSystemSceneComponent */
  44916. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44917. "use strict";
  44918. __webpack_require__.r(__webpack_exports__);
  44919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  44920. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44921. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44922. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  44923. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44924. // Adds the parser to the scene parsers.
  44925. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  44926. // Lens flares
  44927. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  44928. if (!container.lensFlareSystems) {
  44929. container.lensFlareSystems = new Array();
  44930. }
  44931. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  44932. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  44933. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  44934. container.lensFlareSystems.push(lf);
  44935. }
  44936. }
  44937. });
  44938. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  44939. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44940. if (this.lensFlareSystems[index].name === name) {
  44941. return this.lensFlareSystems[index];
  44942. }
  44943. }
  44944. return null;
  44945. };
  44946. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  44947. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44948. if (this.lensFlareSystems[index].id === id) {
  44949. return this.lensFlareSystems[index];
  44950. }
  44951. }
  44952. return null;
  44953. };
  44954. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  44955. var index = this.lensFlareSystems.indexOf(toRemove);
  44956. if (index !== -1) {
  44957. this.lensFlareSystems.splice(index, 1);
  44958. }
  44959. return index;
  44960. };
  44961. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  44962. this.lensFlareSystems.push(newLensFlareSystem);
  44963. };
  44964. /**
  44965. * Defines the lens flare scene component responsible to manage any lens flares
  44966. * in a given scene.
  44967. */
  44968. var LensFlareSystemSceneComponent = /** @class */ (function () {
  44969. /**
  44970. * Creates a new instance of the component for the given scene
  44971. * @param scene Defines the scene to register the component in
  44972. */
  44973. function LensFlareSystemSceneComponent(scene) {
  44974. /**
  44975. * The component name helpfull to identify the component in the list of scene components.
  44976. */
  44977. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  44978. this.scene = scene;
  44979. scene.lensFlareSystems = new Array();
  44980. }
  44981. /**
  44982. * Registers the component in a given scene
  44983. */
  44984. LensFlareSystemSceneComponent.prototype.register = function () {
  44985. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  44986. };
  44987. /**
  44988. * Rebuilds the elements related to this component in case of
  44989. * context lost for instance.
  44990. */
  44991. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  44992. // Nothing to do for lens flare
  44993. };
  44994. /**
  44995. * Adds all the element from the container to the scene
  44996. * @param container the container holding the elements
  44997. */
  44998. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  44999. var _this = this;
  45000. if (!container.lensFlareSystems) {
  45001. return;
  45002. }
  45003. container.lensFlareSystems.forEach(function (o) {
  45004. _this.scene.addLensFlareSystem(o);
  45005. });
  45006. };
  45007. /**
  45008. * Removes all the elements in the container from the scene
  45009. * @param container contains the elements to remove
  45010. * @param dispose if the removed element should be disposed (default: false)
  45011. */
  45012. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  45013. var _this = this;
  45014. if (!container.lensFlareSystems) {
  45015. return;
  45016. }
  45017. container.lensFlareSystems.forEach(function (o) {
  45018. _this.scene.removeLensFlareSystem(o);
  45019. if (dispose) {
  45020. o.dispose();
  45021. }
  45022. });
  45023. };
  45024. /**
  45025. * Serializes the component data to the specified json object
  45026. * @param serializationObject The object to serialize to
  45027. */
  45028. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  45029. // Lens flares
  45030. serializationObject.lensFlareSystems = [];
  45031. var lensFlareSystems = this.scene.lensFlareSystems;
  45032. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  45033. var lensFlareSystem = lensFlareSystems_1[_i];
  45034. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  45035. }
  45036. };
  45037. /**
  45038. * Disposes the component and the associated ressources.
  45039. */
  45040. LensFlareSystemSceneComponent.prototype.dispose = function () {
  45041. var lensFlareSystems = this.scene.lensFlareSystems;
  45042. while (lensFlareSystems.length) {
  45043. lensFlareSystems[0].dispose();
  45044. }
  45045. };
  45046. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  45047. // Lens flares
  45048. if (this.scene.lensFlaresEnabled) {
  45049. var lensFlareSystems = this.scene.lensFlareSystems;
  45050. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45051. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  45052. var lensFlareSystem = lensFlareSystems_2[_i];
  45053. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  45054. lensFlareSystem.render();
  45055. }
  45056. }
  45057. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45058. }
  45059. };
  45060. return LensFlareSystemSceneComponent;
  45061. }());
  45062. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  45063. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  45064. if (!component) {
  45065. component = new LensFlareSystemSceneComponent(scene);
  45066. scene._addComponent(component);
  45067. }
  45068. };
  45069. /***/ }),
  45070. /***/ "./Lights/Shadows/index.ts":
  45071. /*!*********************************!*\
  45072. !*** ./Lights/Shadows/index.ts ***!
  45073. \*********************************/
  45074. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  45075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45076. "use strict";
  45077. __webpack_require__.r(__webpack_exports__);
  45078. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  45080. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  45081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  45082. /***/ }),
  45083. /***/ "./Lights/Shadows/shadowGenerator.ts":
  45084. /*!*******************************************!*\
  45085. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  45086. \*******************************************/
  45087. /*! exports provided: ShadowGenerator */
  45088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45089. "use strict";
  45090. __webpack_require__.r(__webpack_exports__);
  45091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  45092. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45093. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  45094. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  45095. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  45096. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  45097. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  45098. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  45099. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  45100. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  45101. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  45102. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  45103. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  45104. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  45105. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  45106. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  45107. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  45108. /**
  45109. * Default implementation IShadowGenerator.
  45110. * This is the main object responsible of generating shadows in the framework.
  45111. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  45112. */
  45113. var ShadowGenerator = /** @class */ (function () {
  45114. /**
  45115. * Creates a ShadowGenerator object.
  45116. * A ShadowGenerator is the required tool to use the shadows.
  45117. * Each light casting shadows needs to use its own ShadowGenerator.
  45118. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  45119. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  45120. * @param light The light object generating the shadows.
  45121. * @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.
  45122. */
  45123. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  45124. /**
  45125. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  45126. */
  45127. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45128. /**
  45129. * Observable triggered before a mesh is rendered in the shadow map.
  45130. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  45131. */
  45132. this.onBeforeShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45133. this._bias = 0.00005;
  45134. this._normalBias = 0;
  45135. this._blurBoxOffset = 1;
  45136. this._blurScale = 2;
  45137. this._blurKernel = 1;
  45138. this._useKernelBlur = false;
  45139. this._filter = ShadowGenerator.FILTER_NONE;
  45140. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  45141. this._contactHardeningLightSizeUVRatio = 0.1;
  45142. this._darkness = 0;
  45143. this._transparencyShadow = false;
  45144. /**
  45145. * Controls the extent to which the shadows fade out at the edge of the frustum
  45146. * Used only by directionals and spots
  45147. */
  45148. this.frustumEdgeFalloff = 0;
  45149. /**
  45150. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  45151. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  45152. * It might on the other hand introduce peter panning.
  45153. */
  45154. this.forceBackFacesOnly = false;
  45155. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  45156. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45157. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45158. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45159. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45160. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45161. this._currentFaceIndex = 0;
  45162. this._currentFaceIndexCache = 0;
  45163. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  45164. this._mapSize = mapSize;
  45165. this._light = light;
  45166. this._scene = light.getScene();
  45167. light._shadowGenerator = this;
  45168. ShadowGenerator._SceneComponentInitialization(this._scene);
  45169. // Texture type fallback from float to int if not supported.
  45170. var caps = this._scene.getEngine().getCaps();
  45171. if (!usefulFloatFirst) {
  45172. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45173. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45174. }
  45175. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45176. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45177. }
  45178. else {
  45179. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45180. }
  45181. }
  45182. else {
  45183. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45184. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45185. }
  45186. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45187. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45188. }
  45189. else {
  45190. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45191. }
  45192. }
  45193. this._initializeGenerator();
  45194. this._applyFilterValues();
  45195. }
  45196. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  45197. /**
  45198. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  45199. */
  45200. get: function () {
  45201. return this._bias;
  45202. },
  45203. /**
  45204. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  45205. */
  45206. set: function (bias) {
  45207. this._bias = bias;
  45208. },
  45209. enumerable: true,
  45210. configurable: true
  45211. });
  45212. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  45213. /**
  45214. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45215. */
  45216. get: function () {
  45217. return this._normalBias;
  45218. },
  45219. /**
  45220. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45221. */
  45222. set: function (normalBias) {
  45223. this._normalBias = normalBias;
  45224. },
  45225. enumerable: true,
  45226. configurable: true
  45227. });
  45228. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  45229. /**
  45230. * Gets the blur box offset: offset applied during the blur pass.
  45231. * Only useful if useKernelBlur = false
  45232. */
  45233. get: function () {
  45234. return this._blurBoxOffset;
  45235. },
  45236. /**
  45237. * Sets the blur box offset: offset applied during the blur pass.
  45238. * Only useful if useKernelBlur = false
  45239. */
  45240. set: function (value) {
  45241. if (this._blurBoxOffset === value) {
  45242. return;
  45243. }
  45244. this._blurBoxOffset = value;
  45245. this._disposeBlurPostProcesses();
  45246. },
  45247. enumerable: true,
  45248. configurable: true
  45249. });
  45250. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  45251. /**
  45252. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  45253. * 2 means half of the size.
  45254. */
  45255. get: function () {
  45256. return this._blurScale;
  45257. },
  45258. /**
  45259. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  45260. * 2 means half of the size.
  45261. */
  45262. set: function (value) {
  45263. if (this._blurScale === value) {
  45264. return;
  45265. }
  45266. this._blurScale = value;
  45267. this._disposeBlurPostProcesses();
  45268. },
  45269. enumerable: true,
  45270. configurable: true
  45271. });
  45272. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  45273. /**
  45274. * Gets the blur kernel: kernel size of the blur pass.
  45275. * Only useful if useKernelBlur = true
  45276. */
  45277. get: function () {
  45278. return this._blurKernel;
  45279. },
  45280. /**
  45281. * Sets the blur kernel: kernel size of the blur pass.
  45282. * Only useful if useKernelBlur = true
  45283. */
  45284. set: function (value) {
  45285. if (this._blurKernel === value) {
  45286. return;
  45287. }
  45288. this._blurKernel = value;
  45289. this._disposeBlurPostProcesses();
  45290. },
  45291. enumerable: true,
  45292. configurable: true
  45293. });
  45294. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  45295. /**
  45296. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  45297. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45298. */
  45299. get: function () {
  45300. return this._useKernelBlur;
  45301. },
  45302. /**
  45303. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  45304. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45305. */
  45306. set: function (value) {
  45307. if (this._useKernelBlur === value) {
  45308. return;
  45309. }
  45310. this._useKernelBlur = value;
  45311. this._disposeBlurPostProcesses();
  45312. },
  45313. enumerable: true,
  45314. configurable: true
  45315. });
  45316. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  45317. /**
  45318. * Gets the depth scale used in ESM mode.
  45319. */
  45320. get: function () {
  45321. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  45322. },
  45323. /**
  45324. * Sets the depth scale used in ESM mode.
  45325. * This can override the scale stored on the light.
  45326. */
  45327. set: function (value) {
  45328. this._depthScale = value;
  45329. },
  45330. enumerable: true,
  45331. configurable: true
  45332. });
  45333. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  45334. /**
  45335. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  45336. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45337. */
  45338. get: function () {
  45339. return this._filter;
  45340. },
  45341. /**
  45342. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  45343. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45344. */
  45345. set: function (value) {
  45346. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  45347. if (this._light.needCube()) {
  45348. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45349. this.useExponentialShadowMap = true;
  45350. return;
  45351. }
  45352. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45353. this.useCloseExponentialShadowMap = true;
  45354. return;
  45355. }
  45356. // PCF on cubemap would also be expensive
  45357. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45358. this.usePoissonSampling = true;
  45359. return;
  45360. }
  45361. }
  45362. // Weblg1 fallback for PCF.
  45363. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45364. if (this._scene.getEngine().webGLVersion === 1) {
  45365. this.usePoissonSampling = true;
  45366. return;
  45367. }
  45368. }
  45369. if (this._filter === value) {
  45370. return;
  45371. }
  45372. this._filter = value;
  45373. this._disposeBlurPostProcesses();
  45374. this._applyFilterValues();
  45375. this._light._markMeshesAsLightDirty();
  45376. },
  45377. enumerable: true,
  45378. configurable: true
  45379. });
  45380. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  45381. /**
  45382. * Gets if the current filter is set to Poisson Sampling.
  45383. */
  45384. get: function () {
  45385. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  45386. },
  45387. /**
  45388. * Sets the current filter to Poisson Sampling.
  45389. */
  45390. set: function (value) {
  45391. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  45392. return;
  45393. }
  45394. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  45395. },
  45396. enumerable: true,
  45397. configurable: true
  45398. });
  45399. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  45400. /**
  45401. * Gets if the current filter is set to ESM.
  45402. */
  45403. get: function () {
  45404. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  45405. },
  45406. /**
  45407. * Sets the current filter is to ESM.
  45408. */
  45409. set: function (value) {
  45410. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  45411. return;
  45412. }
  45413. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45414. },
  45415. enumerable: true,
  45416. configurable: true
  45417. });
  45418. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  45419. /**
  45420. * Gets if the current filter is set to filtered ESM.
  45421. */
  45422. get: function () {
  45423. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  45424. },
  45425. /**
  45426. * Gets if the current filter is set to filtered ESM.
  45427. */
  45428. set: function (value) {
  45429. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45430. return;
  45431. }
  45432. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45433. },
  45434. enumerable: true,
  45435. configurable: true
  45436. });
  45437. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  45438. /**
  45439. * Gets if the current filter is set to "close ESM" (using the inverse of the
  45440. * exponential to prevent steep falloff artifacts).
  45441. */
  45442. get: function () {
  45443. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  45444. },
  45445. /**
  45446. * Sets the current filter to "close ESM" (using the inverse of the
  45447. * exponential to prevent steep falloff artifacts).
  45448. */
  45449. set: function (value) {
  45450. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  45451. return;
  45452. }
  45453. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45454. },
  45455. enumerable: true,
  45456. configurable: true
  45457. });
  45458. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  45459. /**
  45460. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  45461. * exponential to prevent steep falloff artifacts).
  45462. */
  45463. get: function () {
  45464. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  45465. },
  45466. /**
  45467. * Sets the current filter to filtered "close ESM" (using the inverse of the
  45468. * exponential to prevent steep falloff artifacts).
  45469. */
  45470. set: function (value) {
  45471. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45472. return;
  45473. }
  45474. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45475. },
  45476. enumerable: true,
  45477. configurable: true
  45478. });
  45479. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  45480. /**
  45481. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  45482. */
  45483. get: function () {
  45484. return this.filter === ShadowGenerator.FILTER_PCF;
  45485. },
  45486. /**
  45487. * Sets the current filter to "PCF" (percentage closer filtering).
  45488. */
  45489. set: function (value) {
  45490. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  45491. return;
  45492. }
  45493. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  45494. },
  45495. enumerable: true,
  45496. configurable: true
  45497. });
  45498. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  45499. /**
  45500. * Gets the PCF or PCSS Quality.
  45501. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45502. */
  45503. get: function () {
  45504. return this._filteringQuality;
  45505. },
  45506. /**
  45507. * Sets the PCF or PCSS Quality.
  45508. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45509. */
  45510. set: function (filteringQuality) {
  45511. this._filteringQuality = filteringQuality;
  45512. },
  45513. enumerable: true,
  45514. configurable: true
  45515. });
  45516. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  45517. /**
  45518. * Gets if the current filter is set to "PCSS" (contact hardening).
  45519. */
  45520. get: function () {
  45521. return this.filter === ShadowGenerator.FILTER_PCSS;
  45522. },
  45523. /**
  45524. * Sets the current filter to "PCSS" (contact hardening).
  45525. */
  45526. set: function (value) {
  45527. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  45528. return;
  45529. }
  45530. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  45531. },
  45532. enumerable: true,
  45533. configurable: true
  45534. });
  45535. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  45536. /**
  45537. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45538. * Using a ratio helps keeping shape stability independently of the map size.
  45539. *
  45540. * It does not account for the light projection as it was having too much
  45541. * instability during the light setup or during light position changes.
  45542. *
  45543. * Only valid if useContactHardeningShadow is true.
  45544. */
  45545. get: function () {
  45546. return this._contactHardeningLightSizeUVRatio;
  45547. },
  45548. /**
  45549. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45550. * Using a ratio helps keeping shape stability independently of the map size.
  45551. *
  45552. * It does not account for the light projection as it was having too much
  45553. * instability during the light setup or during light position changes.
  45554. *
  45555. * Only valid if useContactHardeningShadow is true.
  45556. */
  45557. set: function (contactHardeningLightSizeUVRatio) {
  45558. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  45559. },
  45560. enumerable: true,
  45561. configurable: true
  45562. });
  45563. /**
  45564. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  45565. * 0 means strongest and 1 would means no shadow.
  45566. * @returns the darkness.
  45567. */
  45568. ShadowGenerator.prototype.getDarkness = function () {
  45569. return this._darkness;
  45570. };
  45571. /**
  45572. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  45573. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  45574. * @returns the shadow generator allowing fluent coding.
  45575. */
  45576. ShadowGenerator.prototype.setDarkness = function (darkness) {
  45577. if (darkness >= 1.0) {
  45578. this._darkness = 1.0;
  45579. }
  45580. else if (darkness <= 0.0) {
  45581. this._darkness = 0.0;
  45582. }
  45583. else {
  45584. this._darkness = darkness;
  45585. }
  45586. return this;
  45587. };
  45588. /**
  45589. * Sets the ability to have transparent shadow (boolean).
  45590. * @param transparent True if transparent else False
  45591. * @returns the shadow generator allowing fluent coding
  45592. */
  45593. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  45594. this._transparencyShadow = transparent;
  45595. return this;
  45596. };
  45597. /**
  45598. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  45599. * @returns The render target texture if present otherwise, null
  45600. */
  45601. ShadowGenerator.prototype.getShadowMap = function () {
  45602. return this._shadowMap;
  45603. };
  45604. /**
  45605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  45606. * @returns The render target texture if the shadow map is present otherwise, null
  45607. */
  45608. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  45609. if (this._shadowMap2) {
  45610. return this._shadowMap2;
  45611. }
  45612. return this._shadowMap;
  45613. };
  45614. /**
  45615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  45616. * @param mesh Mesh to add
  45617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  45618. * @returns the Shadow Generator itself
  45619. */
  45620. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  45621. if (includeDescendants === void 0) { includeDescendants = true; }
  45622. var _a;
  45623. if (!this._shadowMap) {
  45624. return this;
  45625. }
  45626. if (!this._shadowMap.renderList) {
  45627. this._shadowMap.renderList = [];
  45628. }
  45629. this._shadowMap.renderList.push(mesh);
  45630. if (includeDescendants) {
  45631. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  45632. }
  45633. return this;
  45634. };
  45635. /**
  45636. * Helper function to remove a mesh and its descendants from the list of shadow casters
  45637. * @param mesh Mesh to remove
  45638. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  45639. * @returns the Shadow Generator itself
  45640. */
  45641. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  45642. if (includeDescendants === void 0) { includeDescendants = true; }
  45643. if (!this._shadowMap || !this._shadowMap.renderList) {
  45644. return this;
  45645. }
  45646. var index = this._shadowMap.renderList.indexOf(mesh);
  45647. if (index !== -1) {
  45648. this._shadowMap.renderList.splice(index, 1);
  45649. }
  45650. if (includeDescendants) {
  45651. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  45652. var child = _a[_i];
  45653. this.removeShadowCaster(child);
  45654. }
  45655. }
  45656. return this;
  45657. };
  45658. /**
  45659. * Returns the associated light object.
  45660. * @returns the light generating the shadow
  45661. */
  45662. ShadowGenerator.prototype.getLight = function () {
  45663. return this._light;
  45664. };
  45665. ShadowGenerator.prototype._initializeGenerator = function () {
  45666. this._light._markMeshesAsLightDirty();
  45667. this._initializeShadowMap();
  45668. };
  45669. ShadowGenerator.prototype._initializeShadowMap = function () {
  45670. var _this = this;
  45671. // Render target
  45672. var engine = this._scene.getEngine();
  45673. if (engine.webGLVersion > 1) {
  45674. 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);
  45675. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  45676. }
  45677. else {
  45678. 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());
  45679. }
  45680. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45681. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45682. this._shadowMap.anisotropicFilteringLevel = 1;
  45683. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45684. this._shadowMap.renderParticles = false;
  45685. this._shadowMap.ignoreCameraViewport = true;
  45686. // Record Face Index before render.
  45687. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  45688. _this._currentFaceIndex = faceIndex;
  45689. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45690. engine.setColorWrite(false);
  45691. }
  45692. });
  45693. // Custom render function.
  45694. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  45695. // Blur if required afer render.
  45696. this._shadowMap.onAfterUnbindObservable.add(function () {
  45697. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45698. engine.setColorWrite(true);
  45699. }
  45700. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  45701. return;
  45702. }
  45703. var shadowMap = _this.getShadowMapForRendering();
  45704. if (shadowMap) {
  45705. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  45706. }
  45707. });
  45708. // Clear according to the chosen filter.
  45709. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  45710. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  45711. this._shadowMap.onClearObservable.add(function (engine) {
  45712. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45713. engine.clear(clearOne, false, true, false);
  45714. }
  45715. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  45716. engine.clear(clearZero, true, true, false);
  45717. }
  45718. else {
  45719. engine.clear(clearOne, true, true, false);
  45720. }
  45721. });
  45722. };
  45723. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  45724. var _this = this;
  45725. var engine = this._scene.getEngine();
  45726. var targetSize = this._mapSize / this.blurScale;
  45727. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  45728. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  45729. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45730. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45731. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45732. }
  45733. if (this.useKernelBlur) {
  45734. 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);
  45735. this._kernelBlurXPostprocess.width = targetSize;
  45736. this._kernelBlurXPostprocess.height = targetSize;
  45737. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  45738. effect.setTexture("textureSampler", _this._shadowMap);
  45739. });
  45740. 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);
  45741. this._kernelBlurXPostprocess.autoClear = false;
  45742. this._kernelBlurYPostprocess.autoClear = false;
  45743. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45744. this._kernelBlurXPostprocess.packedFloat = true;
  45745. this._kernelBlurYPostprocess.packedFloat = true;
  45746. }
  45747. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  45748. }
  45749. else {
  45750. 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);
  45751. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  45752. effect.setFloat2("screenSize", targetSize, targetSize);
  45753. effect.setTexture("textureSampler", _this._shadowMap);
  45754. });
  45755. this._boxBlurPostprocess.autoClear = false;
  45756. this._blurPostProcesses = [this._boxBlurPostprocess];
  45757. }
  45758. };
  45759. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  45760. var index;
  45761. var engine = this._scene.getEngine();
  45762. if (depthOnlySubMeshes.length) {
  45763. engine.setColorWrite(false);
  45764. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  45765. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  45766. }
  45767. engine.setColorWrite(true);
  45768. }
  45769. for (index = 0; index < opaqueSubMeshes.length; index++) {
  45770. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  45771. }
  45772. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  45773. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  45774. }
  45775. if (this._transparencyShadow) {
  45776. for (index = 0; index < transparentSubMeshes.length; index++) {
  45777. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  45778. }
  45779. }
  45780. };
  45781. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  45782. var _this = this;
  45783. var mesh = subMesh.getRenderingMesh();
  45784. var scene = this._scene;
  45785. var engine = scene.getEngine();
  45786. var material = subMesh.getMaterial();
  45787. if (!material || subMesh.verticesCount === 0) {
  45788. return;
  45789. }
  45790. // Culling
  45791. engine.setState(material.backFaceCulling);
  45792. // Managing instances
  45793. var batch = mesh._getInstancesRenderList(subMesh._id);
  45794. if (batch.mustReturn) {
  45795. return;
  45796. }
  45797. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  45798. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  45799. engine.enableEffect(this._effect);
  45800. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  45801. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  45802. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  45803. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45804. this._effect.setVector3("lightData", this._cachedDirection);
  45805. }
  45806. else {
  45807. this._effect.setVector3("lightData", this._cachedPosition);
  45808. }
  45809. if (scene.activeCamera) {
  45810. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  45811. }
  45812. // Alpha test
  45813. if (material && material.needAlphaTesting()) {
  45814. var alphaTexture = material.getAlphaTestTexture();
  45815. if (alphaTexture) {
  45816. this._effect.setTexture("diffuseSampler", alphaTexture);
  45817. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  45818. }
  45819. }
  45820. // Bones
  45821. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45822. var skeleton = mesh.skeleton;
  45823. if (skeleton.isUsingTextureForMatrices) {
  45824. var boneTexture = skeleton.getTransformMatrixTexture();
  45825. if (!boneTexture) {
  45826. return;
  45827. }
  45828. this._effect.setTexture("boneSampler", boneTexture);
  45829. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  45830. }
  45831. else {
  45832. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  45833. }
  45834. }
  45835. // Morph targets
  45836. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  45837. if (this.forceBackFacesOnly) {
  45838. engine.setState(true, 0, false, true);
  45839. }
  45840. // Observables
  45841. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(mesh);
  45842. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  45843. // Draw
  45844. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  45845. if (this.forceBackFacesOnly) {
  45846. engine.setState(true, 0, false, false);
  45847. }
  45848. }
  45849. else {
  45850. // Need to reset refresh rate of the shadowMap
  45851. if (this._shadowMap) {
  45852. this._shadowMap.resetRefreshCounter();
  45853. }
  45854. }
  45855. };
  45856. ShadowGenerator.prototype._applyFilterValues = function () {
  45857. if (!this._shadowMap) {
  45858. return;
  45859. }
  45860. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  45861. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  45862. }
  45863. else {
  45864. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45865. }
  45866. };
  45867. /**
  45868. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45869. * @param onCompiled Callback triggered at the and of the effects compilation
  45870. * @param options Sets of optional options forcing the compilation with different modes
  45871. */
  45872. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  45873. var _this = this;
  45874. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  45875. var shadowMap = this.getShadowMap();
  45876. if (!shadowMap) {
  45877. if (onCompiled) {
  45878. onCompiled(this);
  45879. }
  45880. return;
  45881. }
  45882. var renderList = shadowMap.renderList;
  45883. if (!renderList) {
  45884. if (onCompiled) {
  45885. onCompiled(this);
  45886. }
  45887. return;
  45888. }
  45889. var subMeshes = new Array();
  45890. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  45891. var mesh = renderList_1[_i];
  45892. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  45893. }
  45894. if (subMeshes.length === 0) {
  45895. if (onCompiled) {
  45896. onCompiled(this);
  45897. }
  45898. return;
  45899. }
  45900. var currentIndex = 0;
  45901. var checkReady = function () {
  45902. if (!_this._scene || !_this._scene.getEngine()) {
  45903. return;
  45904. }
  45905. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  45906. currentIndex++;
  45907. if (currentIndex >= subMeshes.length) {
  45908. if (onCompiled) {
  45909. onCompiled(_this);
  45910. }
  45911. return;
  45912. }
  45913. }
  45914. setTimeout(checkReady, 16);
  45915. };
  45916. checkReady();
  45917. };
  45918. /**
  45919. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45920. * @param options Sets of optional options forcing the compilation with different modes
  45921. * @returns A promise that resolves when the compilation completes
  45922. */
  45923. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  45924. var _this = this;
  45925. return new Promise(function (resolve) {
  45926. _this.forceCompilation(function () {
  45927. resolve();
  45928. }, options);
  45929. });
  45930. };
  45931. /**
  45932. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  45933. * @param subMesh The submesh we want to render in the shadow map
  45934. * @param useInstances Defines wether will draw in the map using instances
  45935. * @returns true if ready otherwise, false
  45936. */
  45937. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  45938. var defines = [];
  45939. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45940. defines.push("#define FLOAT");
  45941. }
  45942. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45943. defines.push("#define ESM");
  45944. }
  45945. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  45946. defines.push("#define DEPTHTEXTURE");
  45947. }
  45948. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  45949. var mesh = subMesh.getMesh();
  45950. var material = subMesh.getMaterial();
  45951. // Normal bias.
  45952. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  45953. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  45954. defines.push("#define NORMAL");
  45955. if (mesh.nonUniformScaling) {
  45956. defines.push("#define NONUNIFORMSCALING");
  45957. }
  45958. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45959. defines.push("#define DIRECTIONINLIGHTDATA");
  45960. }
  45961. }
  45962. // Alpha test
  45963. if (material && material.needAlphaTesting()) {
  45964. var alphaTexture = material.getAlphaTestTexture();
  45965. if (alphaTexture) {
  45966. defines.push("#define ALPHATEST");
  45967. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  45968. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  45969. defines.push("#define UV1");
  45970. }
  45971. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  45972. if (alphaTexture.coordinatesIndex === 1) {
  45973. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  45974. defines.push("#define UV2");
  45975. }
  45976. }
  45977. }
  45978. }
  45979. // Bones
  45980. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45981. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  45982. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  45983. if (mesh.numBoneInfluencers > 4) {
  45984. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  45985. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  45986. }
  45987. var skeleton = mesh.skeleton;
  45988. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45989. if (skeleton.isUsingTextureForMatrices) {
  45990. defines.push("#define BONETEXTURE");
  45991. }
  45992. else {
  45993. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  45994. }
  45995. }
  45996. else {
  45997. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45998. }
  45999. // Morph targets
  46000. var manager = mesh.morphTargetManager;
  46001. var morphInfluencers = 0;
  46002. if (manager) {
  46003. if (manager.numInfluencers > 0) {
  46004. defines.push("#define MORPHTARGETS");
  46005. morphInfluencers = manager.numInfluencers;
  46006. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  46007. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  46008. }
  46009. }
  46010. // Instances
  46011. if (useInstances) {
  46012. defines.push("#define INSTANCES");
  46013. attribs.push("world0");
  46014. attribs.push("world1");
  46015. attribs.push("world2");
  46016. attribs.push("world3");
  46017. }
  46018. if (this.customShaderOptions) {
  46019. if (this.customShaderOptions.defines) {
  46020. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  46021. var define = _a[_i];
  46022. if (defines.indexOf(define) === -1) {
  46023. defines.push(define);
  46024. }
  46025. }
  46026. }
  46027. }
  46028. // Get correct effect
  46029. var join = defines.join("\n");
  46030. if (this._cachedDefines !== join) {
  46031. this._cachedDefines = join;
  46032. var shaderName = "shadowMap";
  46033. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  46034. var samplers = ["diffuseSampler", "boneSampler"];
  46035. // Custom shader?
  46036. if (this.customShaderOptions) {
  46037. shaderName = this.customShaderOptions.shaderName;
  46038. if (this.customShaderOptions.attributes) {
  46039. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  46040. var attrib = _c[_b];
  46041. if (attribs.indexOf(attrib) === -1) {
  46042. attribs.push(attrib);
  46043. }
  46044. }
  46045. }
  46046. if (this.customShaderOptions.uniforms) {
  46047. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  46048. var uniform = _e[_d];
  46049. if (uniforms.indexOf(uniform) === -1) {
  46050. uniforms.push(uniform);
  46051. }
  46052. }
  46053. }
  46054. if (this.customShaderOptions.samplers) {
  46055. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  46056. var sampler = _g[_f];
  46057. if (samplers.indexOf(sampler) === -1) {
  46058. samplers.push(sampler);
  46059. }
  46060. }
  46061. }
  46062. }
  46063. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  46064. }
  46065. if (!this._effect.isReady()) {
  46066. return false;
  46067. }
  46068. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46069. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  46070. this._initializeBlurRTTAndPostProcesses();
  46071. }
  46072. }
  46073. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  46074. return false;
  46075. }
  46076. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  46077. return false;
  46078. }
  46079. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  46080. return false;
  46081. }
  46082. return true;
  46083. };
  46084. /**
  46085. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  46086. * @param defines Defines of the material we want to update
  46087. * @param lightIndex Index of the light in the enabled light list of the material
  46088. */
  46089. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  46090. var scene = this._scene;
  46091. var light = this._light;
  46092. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46093. return;
  46094. }
  46095. defines["SHADOW" + lightIndex] = true;
  46096. if (this.useContactHardeningShadow) {
  46097. defines["SHADOWPCSS" + lightIndex] = true;
  46098. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46099. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46100. }
  46101. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46102. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46103. }
  46104. // else default to high.
  46105. }
  46106. if (this.usePercentageCloserFiltering) {
  46107. defines["SHADOWPCF" + lightIndex] = true;
  46108. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46109. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46110. }
  46111. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46112. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46113. }
  46114. // else default to high.
  46115. }
  46116. else if (this.usePoissonSampling) {
  46117. defines["SHADOWPOISSON" + lightIndex] = true;
  46118. }
  46119. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  46120. defines["SHADOWESM" + lightIndex] = true;
  46121. }
  46122. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46123. defines["SHADOWCLOSEESM" + lightIndex] = true;
  46124. }
  46125. if (light.needCube()) {
  46126. defines["SHADOWCUBE" + lightIndex] = true;
  46127. }
  46128. };
  46129. /**
  46130. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  46131. * defined in the generator but impacting the effect).
  46132. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  46133. * @param effect The effect we are binfing the information for
  46134. */
  46135. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  46136. var light = this._light;
  46137. var scene = this._scene;
  46138. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46139. return;
  46140. }
  46141. var camera = scene.activeCamera;
  46142. if (!camera) {
  46143. return;
  46144. }
  46145. var shadowMap = this.getShadowMap();
  46146. if (!shadowMap) {
  46147. return;
  46148. }
  46149. if (!light.needCube()) {
  46150. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  46151. }
  46152. // Only PCF uses depth stencil texture.
  46153. if (this._filter === ShadowGenerator.FILTER_PCF) {
  46154. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46155. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46156. }
  46157. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  46158. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46159. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  46160. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46161. }
  46162. else {
  46163. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46164. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  46165. }
  46166. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  46167. };
  46168. /**
  46169. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  46170. * (eq to shadow prjection matrix * light transform matrix)
  46171. * @returns The transform matrix used to create the shadow map
  46172. */
  46173. ShadowGenerator.prototype.getTransformMatrix = function () {
  46174. var scene = this._scene;
  46175. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  46176. return this._transformMatrix;
  46177. }
  46178. this._currentRenderID = scene.getRenderId();
  46179. this._currentFaceIndexCache = this._currentFaceIndex;
  46180. var lightPosition = this._light.position;
  46181. if (this._light.computeTransformedInformation()) {
  46182. lightPosition = this._light.transformedPosition;
  46183. }
  46184. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  46185. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  46186. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  46187. }
  46188. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  46189. this._cachedPosition.copyFrom(lightPosition);
  46190. this._cachedDirection.copyFrom(this._lightDirection);
  46191. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  46192. var shadowMap = this.getShadowMap();
  46193. if (shadowMap) {
  46194. var renderList = shadowMap.renderList;
  46195. if (renderList) {
  46196. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  46197. }
  46198. }
  46199. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  46200. }
  46201. return this._transformMatrix;
  46202. };
  46203. /**
  46204. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  46205. * Cube and 2D textures for instance.
  46206. */
  46207. ShadowGenerator.prototype.recreateShadowMap = function () {
  46208. var shadowMap = this._shadowMap;
  46209. if (!shadowMap) {
  46210. return;
  46211. }
  46212. // Track render list.
  46213. var renderList = shadowMap.renderList;
  46214. // Clean up existing data.
  46215. this._disposeRTTandPostProcesses();
  46216. // Reinitializes.
  46217. this._initializeGenerator();
  46218. // Reaffect the filter to ensure a correct fallback if necessary.
  46219. this.filter = this.filter;
  46220. // Reaffect the filter.
  46221. this._applyFilterValues();
  46222. // Reaffect Render List.
  46223. this._shadowMap.renderList = renderList;
  46224. };
  46225. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  46226. if (this._shadowMap2) {
  46227. this._shadowMap2.dispose();
  46228. this._shadowMap2 = null;
  46229. }
  46230. if (this._boxBlurPostprocess) {
  46231. this._boxBlurPostprocess.dispose();
  46232. this._boxBlurPostprocess = null;
  46233. }
  46234. if (this._kernelBlurXPostprocess) {
  46235. this._kernelBlurXPostprocess.dispose();
  46236. this._kernelBlurXPostprocess = null;
  46237. }
  46238. if (this._kernelBlurYPostprocess) {
  46239. this._kernelBlurYPostprocess.dispose();
  46240. this._kernelBlurYPostprocess = null;
  46241. }
  46242. this._blurPostProcesses = [];
  46243. };
  46244. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  46245. if (this._shadowMap) {
  46246. this._shadowMap.dispose();
  46247. this._shadowMap = null;
  46248. }
  46249. this._disposeBlurPostProcesses();
  46250. };
  46251. /**
  46252. * Disposes the ShadowGenerator.
  46253. * Returns nothing.
  46254. */
  46255. ShadowGenerator.prototype.dispose = function () {
  46256. this._disposeRTTandPostProcesses();
  46257. if (this._light) {
  46258. this._light._shadowGenerator = null;
  46259. this._light._markMeshesAsLightDirty();
  46260. }
  46261. };
  46262. /**
  46263. * Serializes the shadow generator setup to a json object.
  46264. * @returns The serialized JSON object
  46265. */
  46266. ShadowGenerator.prototype.serialize = function () {
  46267. var serializationObject = {};
  46268. var shadowMap = this.getShadowMap();
  46269. if (!shadowMap) {
  46270. return serializationObject;
  46271. }
  46272. serializationObject.lightId = this._light.id;
  46273. serializationObject.mapSize = shadowMap.getRenderSize();
  46274. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  46275. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  46276. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46277. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46278. serializationObject.usePoissonSampling = this.usePoissonSampling;
  46279. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  46280. serializationObject.depthScale = this.depthScale;
  46281. serializationObject.darkness = this.getDarkness();
  46282. serializationObject.blurBoxOffset = this.blurBoxOffset;
  46283. serializationObject.blurKernel = this.blurKernel;
  46284. serializationObject.blurScale = this.blurScale;
  46285. serializationObject.useKernelBlur = this.useKernelBlur;
  46286. serializationObject.transparencyShadow = this._transparencyShadow;
  46287. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  46288. serializationObject.bias = this.bias;
  46289. serializationObject.normalBias = this.normalBias;
  46290. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  46291. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  46292. serializationObject.filteringQuality = this.filteringQuality;
  46293. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  46294. serializationObject.renderList = [];
  46295. if (shadowMap.renderList) {
  46296. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  46297. var mesh = shadowMap.renderList[meshIndex];
  46298. serializationObject.renderList.push(mesh.id);
  46299. }
  46300. }
  46301. return serializationObject;
  46302. };
  46303. /**
  46304. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  46305. * @param parsedShadowGenerator The JSON object to parse
  46306. * @param scene The scene to create the shadow map for
  46307. * @returns The parsed shadow generator
  46308. */
  46309. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  46310. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  46311. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  46312. var shadowMap = shadowGenerator.getShadowMap();
  46313. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  46314. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  46315. meshes.forEach(function (mesh) {
  46316. if (!shadowMap) {
  46317. return;
  46318. }
  46319. if (!shadowMap.renderList) {
  46320. shadowMap.renderList = [];
  46321. }
  46322. shadowMap.renderList.push(mesh);
  46323. });
  46324. }
  46325. if (parsedShadowGenerator.usePoissonSampling) {
  46326. shadowGenerator.usePoissonSampling = true;
  46327. }
  46328. else if (parsedShadowGenerator.useExponentialShadowMap) {
  46329. shadowGenerator.useExponentialShadowMap = true;
  46330. }
  46331. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  46332. shadowGenerator.useBlurExponentialShadowMap = true;
  46333. }
  46334. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  46335. shadowGenerator.useCloseExponentialShadowMap = true;
  46336. }
  46337. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  46338. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  46339. }
  46340. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  46341. shadowGenerator.usePercentageCloserFiltering = true;
  46342. }
  46343. else if (parsedShadowGenerator.useContactHardeningShadow) {
  46344. shadowGenerator.useContactHardeningShadow = true;
  46345. }
  46346. if (parsedShadowGenerator.filteringQuality) {
  46347. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  46348. }
  46349. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  46350. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  46351. }
  46352. // Backward compat
  46353. else if (parsedShadowGenerator.useVarianceShadowMap) {
  46354. shadowGenerator.useExponentialShadowMap = true;
  46355. }
  46356. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  46357. shadowGenerator.useBlurExponentialShadowMap = true;
  46358. }
  46359. if (parsedShadowGenerator.depthScale) {
  46360. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  46361. }
  46362. if (parsedShadowGenerator.blurScale) {
  46363. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  46364. }
  46365. if (parsedShadowGenerator.blurBoxOffset) {
  46366. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  46367. }
  46368. if (parsedShadowGenerator.useKernelBlur) {
  46369. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  46370. }
  46371. if (parsedShadowGenerator.blurKernel) {
  46372. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  46373. }
  46374. if (parsedShadowGenerator.bias !== undefined) {
  46375. shadowGenerator.bias = parsedShadowGenerator.bias;
  46376. }
  46377. if (parsedShadowGenerator.normalBias !== undefined) {
  46378. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  46379. }
  46380. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  46381. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  46382. }
  46383. if (parsedShadowGenerator.darkness) {
  46384. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  46385. }
  46386. if (parsedShadowGenerator.transparencyShadow) {
  46387. shadowGenerator.setTransparencyShadow(true);
  46388. }
  46389. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  46390. return shadowGenerator;
  46391. };
  46392. /**
  46393. * Shadow generator mode None: no filtering applied.
  46394. */
  46395. ShadowGenerator.FILTER_NONE = 0;
  46396. /**
  46397. * Shadow generator mode ESM: Exponential Shadow Mapping.
  46398. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46399. */
  46400. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  46401. /**
  46402. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  46403. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  46404. */
  46405. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  46406. /**
  46407. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  46408. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46409. */
  46410. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  46411. /**
  46412. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  46413. * edge artifacts on steep falloff.
  46414. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46415. */
  46416. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  46417. /**
  46418. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  46419. * edge artifacts on steep falloff.
  46420. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46421. */
  46422. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  46423. /**
  46424. * Shadow generator mode PCF: Percentage Closer Filtering
  46425. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46426. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  46427. */
  46428. ShadowGenerator.FILTER_PCF = 6;
  46429. /**
  46430. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  46431. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46432. * Contact Hardening
  46433. */
  46434. ShadowGenerator.FILTER_PCSS = 7;
  46435. /**
  46436. * Reserved for PCF and PCSS
  46437. * Highest Quality.
  46438. *
  46439. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  46440. *
  46441. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  46442. */
  46443. ShadowGenerator.QUALITY_HIGH = 0;
  46444. /**
  46445. * Reserved for PCF and PCSS
  46446. * Good tradeoff for quality/perf cross devices
  46447. *
  46448. * Execute PCF on a 3*3 kernel.
  46449. *
  46450. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  46451. */
  46452. ShadowGenerator.QUALITY_MEDIUM = 1;
  46453. /**
  46454. * Reserved for PCF and PCSS
  46455. * The lowest quality but the fastest.
  46456. *
  46457. * Execute PCF on a 1*1 kernel.
  46458. *
  46459. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  46460. */
  46461. ShadowGenerator.QUALITY_LOW = 2;
  46462. /** @hidden */
  46463. ShadowGenerator._SceneComponentInitialization = function (_) {
  46464. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  46465. };
  46466. return ShadowGenerator;
  46467. }());
  46468. /***/ }),
  46469. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  46470. /*!*********************************************************!*\
  46471. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  46472. \*********************************************************/
  46473. /*! exports provided: ShadowGeneratorSceneComponent */
  46474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46475. "use strict";
  46476. __webpack_require__.r(__webpack_exports__);
  46477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  46478. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  46479. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46480. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46481. // Adds the parser to the scene parsers.
  46482. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  46483. // Shadows
  46484. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  46485. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  46486. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  46487. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  46488. // SG would be available on their associated lights
  46489. }
  46490. }
  46491. });
  46492. /**
  46493. * Defines the shadow generator component responsible to manage any shadow generators
  46494. * in a given scene.
  46495. */
  46496. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  46497. /**
  46498. * Creates a new instance of the component for the given scene
  46499. * @param scene Defines the scene to register the component in
  46500. */
  46501. function ShadowGeneratorSceneComponent(scene) {
  46502. /**
  46503. * The component name helpfull to identify the component in the list of scene components.
  46504. */
  46505. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  46506. this.scene = scene;
  46507. }
  46508. /**
  46509. * Registers the component in a given scene
  46510. */
  46511. ShadowGeneratorSceneComponent.prototype.register = function () {
  46512. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  46513. };
  46514. /**
  46515. * Rebuilds the elements related to this component in case of
  46516. * context lost for instance.
  46517. */
  46518. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  46519. // Nothing To Do Here.
  46520. };
  46521. /**
  46522. * Serializes the component data to the specified json object
  46523. * @param serializationObject The object to serialize to
  46524. */
  46525. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  46526. // Shadows
  46527. serializationObject.shadowGenerators = [];
  46528. var lights = this.scene.lights;
  46529. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  46530. var light = lights_1[_i];
  46531. var shadowGenerator = light.getShadowGenerator();
  46532. if (shadowGenerator) {
  46533. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  46534. }
  46535. }
  46536. };
  46537. /**
  46538. * Adds all the element from the container to the scene
  46539. * @param container the container holding the elements
  46540. */
  46541. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  46542. // Nothing To Do Here. (directly attached to a light)
  46543. };
  46544. /**
  46545. * Removes all the elements in the container from the scene
  46546. * @param container contains the elements to remove
  46547. * @param dispose if the removed element should be disposed (default: false)
  46548. */
  46549. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  46550. // Nothing To Do Here. (directly attached to a light)
  46551. };
  46552. /**
  46553. * Rebuilds the elements related to this component in case of
  46554. * context lost for instance.
  46555. */
  46556. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  46557. // Nothing To Do Here.
  46558. };
  46559. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  46560. // Shadows
  46561. var scene = this.scene;
  46562. if (this.scene.shadowsEnabled) {
  46563. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  46564. var light = scene.lights[lightIndex];
  46565. var shadowGenerator = light.getShadowGenerator();
  46566. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  46567. var shadowMap = (shadowGenerator.getShadowMap());
  46568. if (scene.textures.indexOf(shadowMap) !== -1) {
  46569. renderTargets.push(shadowMap);
  46570. }
  46571. }
  46572. }
  46573. }
  46574. };
  46575. return ShadowGeneratorSceneComponent;
  46576. }());
  46577. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  46578. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  46579. if (!component) {
  46580. component = new ShadowGeneratorSceneComponent(scene);
  46581. scene._addComponent(component);
  46582. }
  46583. };
  46584. /***/ }),
  46585. /***/ "./Lights/directionalLight.ts":
  46586. /*!************************************!*\
  46587. !*** ./Lights/directionalLight.ts ***!
  46588. \************************************/
  46589. /*! exports provided: DirectionalLight */
  46590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46591. "use strict";
  46592. __webpack_require__.r(__webpack_exports__);
  46593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  46594. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46595. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46596. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46597. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46598. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46599. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46600. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  46601. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46602. });
  46603. /**
  46604. * A directional light is defined by a direction (what a surprise!).
  46605. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46606. * 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.
  46607. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46608. */
  46609. var DirectionalLight = /** @class */ (function (_super) {
  46610. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  46611. /**
  46612. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46613. * The directional light is emitted from everywhere in the given direction.
  46614. * It can cast shadows.
  46615. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46616. * @param name The friendly name of the light
  46617. * @param direction The direction of the light
  46618. * @param scene The scene the light belongs to
  46619. */
  46620. function DirectionalLight(name, direction, scene) {
  46621. var _this = _super.call(this, name, scene) || this;
  46622. _this._shadowFrustumSize = 0;
  46623. _this._shadowOrthoScale = 0.1;
  46624. /**
  46625. * Automatically compute the projection matrix to best fit (including all the casters)
  46626. * on each frame.
  46627. */
  46628. _this.autoUpdateExtends = true;
  46629. // Cache
  46630. _this._orthoLeft = Number.MAX_VALUE;
  46631. _this._orthoRight = Number.MIN_VALUE;
  46632. _this._orthoTop = Number.MIN_VALUE;
  46633. _this._orthoBottom = Number.MAX_VALUE;
  46634. _this.position = direction.scale(-1.0);
  46635. _this.direction = direction;
  46636. return _this;
  46637. }
  46638. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  46639. /**
  46640. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46641. */
  46642. get: function () {
  46643. return this._shadowFrustumSize;
  46644. },
  46645. /**
  46646. * Specifies a fix frustum size for the shadow generation.
  46647. */
  46648. set: function (value) {
  46649. this._shadowFrustumSize = value;
  46650. this.forceProjectionMatrixCompute();
  46651. },
  46652. enumerable: true,
  46653. configurable: true
  46654. });
  46655. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  46656. /**
  46657. * Gets the shadow projection scale against the optimal computed one.
  46658. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46659. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46660. */
  46661. get: function () {
  46662. return this._shadowOrthoScale;
  46663. },
  46664. /**
  46665. * Sets the shadow projection scale against the optimal computed one.
  46666. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46667. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46668. */
  46669. set: function (value) {
  46670. this._shadowOrthoScale = value;
  46671. this.forceProjectionMatrixCompute();
  46672. },
  46673. enumerable: true,
  46674. configurable: true
  46675. });
  46676. /**
  46677. * Returns the string "DirectionalLight".
  46678. * @return The class name
  46679. */
  46680. DirectionalLight.prototype.getClassName = function () {
  46681. return "DirectionalLight";
  46682. };
  46683. /**
  46684. * Returns the integer 1.
  46685. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46686. */
  46687. DirectionalLight.prototype.getTypeID = function () {
  46688. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  46689. };
  46690. /**
  46691. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46692. * Returns the DirectionalLight Shadow projection matrix.
  46693. */
  46694. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46695. if (this.shadowFrustumSize > 0) {
  46696. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  46697. }
  46698. else {
  46699. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  46700. }
  46701. };
  46702. /**
  46703. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46704. * Returns the DirectionalLight Shadow projection matrix.
  46705. */
  46706. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  46707. var activeCamera = this.getScene().activeCamera;
  46708. if (!activeCamera) {
  46709. return;
  46710. }
  46711. _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);
  46712. };
  46713. /**
  46714. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46715. * Returns the DirectionalLight Shadow projection matrix.
  46716. */
  46717. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46718. var activeCamera = this.getScene().activeCamera;
  46719. if (!activeCamera) {
  46720. return;
  46721. }
  46722. // Check extends
  46723. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  46724. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46725. this._orthoLeft = Number.MAX_VALUE;
  46726. this._orthoRight = Number.MIN_VALUE;
  46727. this._orthoTop = Number.MIN_VALUE;
  46728. this._orthoBottom = Number.MAX_VALUE;
  46729. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  46730. var mesh = renderList[meshIndex];
  46731. if (!mesh) {
  46732. continue;
  46733. }
  46734. var boundingInfo = mesh.getBoundingInfo();
  46735. var boundingBox = boundingInfo.boundingBox;
  46736. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  46737. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  46738. if (tempVector3.x < this._orthoLeft) {
  46739. this._orthoLeft = tempVector3.x;
  46740. }
  46741. if (tempVector3.y < this._orthoBottom) {
  46742. this._orthoBottom = tempVector3.y;
  46743. }
  46744. if (tempVector3.x > this._orthoRight) {
  46745. this._orthoRight = tempVector3.x;
  46746. }
  46747. if (tempVector3.y > this._orthoTop) {
  46748. this._orthoTop = tempVector3.y;
  46749. }
  46750. }
  46751. }
  46752. }
  46753. var xOffset = this._orthoRight - this._orthoLeft;
  46754. var yOffset = this._orthoTop - this._orthoBottom;
  46755. _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);
  46756. };
  46757. DirectionalLight.prototype._buildUniformLayout = function () {
  46758. this._uniformBuffer.addUniform("vLightData", 4);
  46759. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46760. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46761. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46762. this._uniformBuffer.addUniform("depthValues", 2);
  46763. this._uniformBuffer.create();
  46764. };
  46765. /**
  46766. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46767. * @param effect The effect to update
  46768. * @param lightIndex The index of the light in the effect to update
  46769. * @returns The directional light
  46770. */
  46771. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  46772. if (this.computeTransformedInformation()) {
  46773. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  46774. return this;
  46775. }
  46776. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  46777. return this;
  46778. };
  46779. /**
  46780. * Gets the minZ used for shadow according to both the scene and the light.
  46781. *
  46782. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46783. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46784. * @param activeCamera The camera we are returning the min for
  46785. * @returns the depth min z
  46786. */
  46787. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  46788. return 1;
  46789. };
  46790. /**
  46791. * Gets the maxZ used for shadow according to both the scene and the light.
  46792. *
  46793. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46794. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46795. * @param activeCamera The camera we are returning the max for
  46796. * @returns the depth max z
  46797. */
  46798. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  46799. return 1;
  46800. };
  46801. /**
  46802. * Prepares the list of defines specific to the light type.
  46803. * @param defines the list of defines
  46804. * @param lightIndex defines the index of the light for the effect
  46805. */
  46806. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46807. defines["DIRLIGHT" + lightIndex] = true;
  46808. };
  46809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46811. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  46812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46814. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  46815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46817. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  46818. return DirectionalLight;
  46819. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46820. /***/ }),
  46821. /***/ "./Lights/hemisphericLight.ts":
  46822. /*!************************************!*\
  46823. !*** ./Lights/hemisphericLight.ts ***!
  46824. \************************************/
  46825. /*! exports provided: HemisphericLight */
  46826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46827. "use strict";
  46828. __webpack_require__.r(__webpack_exports__);
  46829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  46830. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46831. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46832. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46833. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46834. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46835. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  46836. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46837. });
  46838. /**
  46839. * The HemisphericLight simulates the ambient environment light,
  46840. * so the passed direction is the light reflection direction, not the incoming direction.
  46841. */
  46842. var HemisphericLight = /** @class */ (function (_super) {
  46843. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  46844. /**
  46845. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  46846. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  46847. * The HemisphericLight can't cast shadows.
  46848. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46849. * @param name The friendly name of the light
  46850. * @param direction The direction of the light reflection
  46851. * @param scene The scene the light belongs to
  46852. */
  46853. function HemisphericLight(name, direction, scene) {
  46854. var _this = _super.call(this, name, scene) || this;
  46855. /**
  46856. * The groundColor is the light in the opposite direction to the one specified during creation.
  46857. * 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.
  46858. */
  46859. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  46860. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46861. return _this;
  46862. }
  46863. HemisphericLight.prototype._buildUniformLayout = function () {
  46864. this._uniformBuffer.addUniform("vLightData", 4);
  46865. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46866. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46867. this._uniformBuffer.addUniform("vLightGround", 3);
  46868. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46869. this._uniformBuffer.addUniform("depthValues", 2);
  46870. this._uniformBuffer.create();
  46871. };
  46872. /**
  46873. * Returns the string "HemisphericLight".
  46874. * @return The class name
  46875. */
  46876. HemisphericLight.prototype.getClassName = function () {
  46877. return "HemisphericLight";
  46878. };
  46879. /**
  46880. * Sets the HemisphericLight direction towards the passed target (Vector3).
  46881. * Returns the updated direction.
  46882. * @param target The target the direction should point to
  46883. * @return The computed direction
  46884. */
  46885. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  46886. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  46887. return this.direction;
  46888. };
  46889. /**
  46890. * Returns the shadow generator associated to the light.
  46891. * @returns Always null for hemispheric lights because it does not support shadows.
  46892. */
  46893. HemisphericLight.prototype.getShadowGenerator = function () {
  46894. return null;
  46895. };
  46896. /**
  46897. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  46898. * @param effect The effect to update
  46899. * @param lightIndex The index of the light in the effect to update
  46900. * @returns The hemispheric light
  46901. */
  46902. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  46903. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46904. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  46905. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  46906. return this;
  46907. };
  46908. /**
  46909. * Computes the world matrix of the node
  46910. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46911. * @param useWasUpdatedFlag defines a reserved property
  46912. * @returns the world matrix
  46913. */
  46914. HemisphericLight.prototype.computeWorldMatrix = function () {
  46915. if (!this._worldMatrix) {
  46916. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46917. }
  46918. return this._worldMatrix;
  46919. };
  46920. /**
  46921. * Returns the integer 3.
  46922. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46923. */
  46924. HemisphericLight.prototype.getTypeID = function () {
  46925. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  46926. };
  46927. /**
  46928. * Prepares the list of defines specific to the light type.
  46929. * @param defines the list of defines
  46930. * @param lightIndex defines the index of the light for the effect
  46931. */
  46932. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46933. defines["HEMILIGHT" + lightIndex] = true;
  46934. };
  46935. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46936. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46937. ], HemisphericLight.prototype, "groundColor", void 0);
  46938. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46940. ], HemisphericLight.prototype, "direction", void 0);
  46941. return HemisphericLight;
  46942. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  46943. /***/ }),
  46944. /***/ "./Lights/index.ts":
  46945. /*!*************************!*\
  46946. !*** ./Lights/index.ts ***!
  46947. \*************************/
  46948. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  46949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46950. "use strict";
  46951. __webpack_require__.r(__webpack_exports__);
  46952. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  46954. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  46956. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  46957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  46958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  46959. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  46960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  46961. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  46962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  46963. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  46964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  46965. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  46966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  46967. /***/ }),
  46968. /***/ "./Lights/light.ts":
  46969. /*!*************************!*\
  46970. !*** ./Lights/light.ts ***!
  46971. \*************************/
  46972. /*! exports provided: Light */
  46973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46974. "use strict";
  46975. __webpack_require__.r(__webpack_exports__);
  46976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  46977. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46978. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46980. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46981. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  46982. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46983. /**
  46984. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  46985. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  46986. * 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.
  46987. */
  46988. var Light = /** @class */ (function (_super) {
  46989. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  46990. /**
  46991. * Creates a Light object in the scene.
  46992. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46993. * @param name The firendly name of the light
  46994. * @param scene The scene the light belongs too
  46995. */
  46996. function Light(name, scene) {
  46997. var _this = _super.call(this, name, scene) || this;
  46998. /**
  46999. * Diffuse gives the basic color to an object.
  47000. */
  47001. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47002. /**
  47003. * Specular produces a highlight color on an object.
  47004. * Note: This is note affecting PBR materials.
  47005. */
  47006. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47007. /**
  47008. * Defines the falloff type for this light. This lets overrriding how punctual light are
  47009. * falling off base on range or angle.
  47010. * This can be set to any values in Light.FALLOFF_x.
  47011. *
  47012. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  47013. * other types of materials.
  47014. */
  47015. _this.falloffType = Light.FALLOFF_DEFAULT;
  47016. /**
  47017. * Strength of the light.
  47018. * Note: By default it is define in the framework own unit.
  47019. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  47020. */
  47021. _this.intensity = 1.0;
  47022. _this._range = Number.MAX_VALUE;
  47023. _this._inverseSquaredRange = 0;
  47024. /**
  47025. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  47026. * of light.
  47027. */
  47028. _this._photometricScale = 1.0;
  47029. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  47030. _this._radius = 0.00001;
  47031. /**
  47032. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  47033. * exceeding the number allowed of the materials.
  47034. */
  47035. _this.renderPriority = 0;
  47036. _this._shadowEnabled = true;
  47037. _this._excludeWithLayerMask = 0;
  47038. _this._includeOnlyWithLayerMask = 0;
  47039. _this._lightmapMode = 0;
  47040. /**
  47041. * @hidden Internal use only.
  47042. */
  47043. _this._excludedMeshesIds = new Array();
  47044. /**
  47045. * @hidden Internal use only.
  47046. */
  47047. _this._includedOnlyMeshesIds = new Array();
  47048. /** @hidden */
  47049. _this._isLight = true;
  47050. _this.getScene().addLight(_this);
  47051. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  47052. _this._buildUniformLayout();
  47053. _this.includedOnlyMeshes = new Array();
  47054. _this.excludedMeshes = new Array();
  47055. _this._resyncMeshes();
  47056. return _this;
  47057. }
  47058. Object.defineProperty(Light.prototype, "range", {
  47059. /**
  47060. * Defines how far from the source the light is impacting in scene units.
  47061. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47062. */
  47063. get: function () {
  47064. return this._range;
  47065. },
  47066. /**
  47067. * Defines how far from the source the light is impacting in scene units.
  47068. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47069. */
  47070. set: function (value) {
  47071. this._range = value;
  47072. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  47073. },
  47074. enumerable: true,
  47075. configurable: true
  47076. });
  47077. Object.defineProperty(Light.prototype, "intensityMode", {
  47078. /**
  47079. * Gets the photometric scale used to interpret the intensity.
  47080. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47081. */
  47082. get: function () {
  47083. return this._intensityMode;
  47084. },
  47085. /**
  47086. * Sets the photometric scale used to interpret the intensity.
  47087. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47088. */
  47089. set: function (value) {
  47090. this._intensityMode = value;
  47091. this._computePhotometricScale();
  47092. },
  47093. enumerable: true,
  47094. configurable: true
  47095. });
  47096. Object.defineProperty(Light.prototype, "radius", {
  47097. /**
  47098. * Gets the light radius used by PBR Materials to simulate soft area lights.
  47099. */
  47100. get: function () {
  47101. return this._radius;
  47102. },
  47103. /**
  47104. * sets the light radius used by PBR Materials to simulate soft area lights.
  47105. */
  47106. set: function (value) {
  47107. this._radius = value;
  47108. this._computePhotometricScale();
  47109. },
  47110. enumerable: true,
  47111. configurable: true
  47112. });
  47113. Object.defineProperty(Light.prototype, "shadowEnabled", {
  47114. /**
  47115. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47116. * the current shadow generator.
  47117. */
  47118. get: function () {
  47119. return this._shadowEnabled;
  47120. },
  47121. /**
  47122. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47123. * the current shadow generator.
  47124. */
  47125. set: function (value) {
  47126. if (this._shadowEnabled === value) {
  47127. return;
  47128. }
  47129. this._shadowEnabled = value;
  47130. this._markMeshesAsLightDirty();
  47131. },
  47132. enumerable: true,
  47133. configurable: true
  47134. });
  47135. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  47136. /**
  47137. * Gets the only meshes impacted by this light.
  47138. */
  47139. get: function () {
  47140. return this._includedOnlyMeshes;
  47141. },
  47142. /**
  47143. * Sets the only meshes impacted by this light.
  47144. */
  47145. set: function (value) {
  47146. this._includedOnlyMeshes = value;
  47147. this._hookArrayForIncludedOnly(value);
  47148. },
  47149. enumerable: true,
  47150. configurable: true
  47151. });
  47152. Object.defineProperty(Light.prototype, "excludedMeshes", {
  47153. /**
  47154. * Gets the meshes not impacted by this light.
  47155. */
  47156. get: function () {
  47157. return this._excludedMeshes;
  47158. },
  47159. /**
  47160. * Sets the meshes not impacted by this light.
  47161. */
  47162. set: function (value) {
  47163. this._excludedMeshes = value;
  47164. this._hookArrayForExcluded(value);
  47165. },
  47166. enumerable: true,
  47167. configurable: true
  47168. });
  47169. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  47170. /**
  47171. * Gets the layer id use to find what meshes are not impacted by the light.
  47172. * Inactive if 0
  47173. */
  47174. get: function () {
  47175. return this._excludeWithLayerMask;
  47176. },
  47177. /**
  47178. * Sets the layer id use to find what meshes are not impacted by the light.
  47179. * Inactive if 0
  47180. */
  47181. set: function (value) {
  47182. this._excludeWithLayerMask = value;
  47183. this._resyncMeshes();
  47184. },
  47185. enumerable: true,
  47186. configurable: true
  47187. });
  47188. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  47189. /**
  47190. * Gets the layer id use to find what meshes are impacted by the light.
  47191. * Inactive if 0
  47192. */
  47193. get: function () {
  47194. return this._includeOnlyWithLayerMask;
  47195. },
  47196. /**
  47197. * Sets the layer id use to find what meshes are impacted by the light.
  47198. * Inactive if 0
  47199. */
  47200. set: function (value) {
  47201. this._includeOnlyWithLayerMask = value;
  47202. this._resyncMeshes();
  47203. },
  47204. enumerable: true,
  47205. configurable: true
  47206. });
  47207. Object.defineProperty(Light.prototype, "lightmapMode", {
  47208. /**
  47209. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47210. */
  47211. get: function () {
  47212. return this._lightmapMode;
  47213. },
  47214. /**
  47215. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47216. */
  47217. set: function (value) {
  47218. if (this._lightmapMode === value) {
  47219. return;
  47220. }
  47221. this._lightmapMode = value;
  47222. this._markMeshesAsLightDirty();
  47223. },
  47224. enumerable: true,
  47225. configurable: true
  47226. });
  47227. /**
  47228. * Returns the string "Light".
  47229. * @returns the class name
  47230. */
  47231. Light.prototype.getClassName = function () {
  47232. return "Light";
  47233. };
  47234. /**
  47235. * Converts the light information to a readable string for debug purpose.
  47236. * @param fullDetails Supports for multiple levels of logging within scene loading
  47237. * @returns the human readable light info
  47238. */
  47239. Light.prototype.toString = function (fullDetails) {
  47240. var ret = "Name: " + this.name;
  47241. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  47242. if (this.animations) {
  47243. for (var i = 0; i < this.animations.length; i++) {
  47244. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  47245. }
  47246. }
  47247. if (fullDetails) {
  47248. }
  47249. return ret;
  47250. };
  47251. /** @hidden */
  47252. Light.prototype._syncParentEnabledState = function () {
  47253. _super.prototype._syncParentEnabledState.call(this);
  47254. this._resyncMeshes();
  47255. };
  47256. /**
  47257. * Set the enabled state of this node.
  47258. * @param value - the new enabled state
  47259. */
  47260. Light.prototype.setEnabled = function (value) {
  47261. _super.prototype.setEnabled.call(this, value);
  47262. this._resyncMeshes();
  47263. };
  47264. /**
  47265. * Returns the Light associated shadow generator if any.
  47266. * @return the associated shadow generator.
  47267. */
  47268. Light.prototype.getShadowGenerator = function () {
  47269. return this._shadowGenerator;
  47270. };
  47271. /**
  47272. * Returns a Vector3, the absolute light position in the World.
  47273. * @returns the world space position of the light
  47274. */
  47275. Light.prototype.getAbsolutePosition = function () {
  47276. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47277. };
  47278. /**
  47279. * Specifies if the light will affect the passed mesh.
  47280. * @param mesh The mesh to test against the light
  47281. * @return true the mesh is affected otherwise, false.
  47282. */
  47283. Light.prototype.canAffectMesh = function (mesh) {
  47284. if (!mesh) {
  47285. return true;
  47286. }
  47287. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  47288. return false;
  47289. }
  47290. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  47291. return false;
  47292. }
  47293. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  47294. return false;
  47295. }
  47296. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  47297. return false;
  47298. }
  47299. return true;
  47300. };
  47301. /**
  47302. * Sort function to order lights for rendering.
  47303. * @param a First Light object to compare to second.
  47304. * @param b Second Light object to compare first.
  47305. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  47306. */
  47307. Light.CompareLightsPriority = function (a, b) {
  47308. //shadow-casting lights have priority over non-shadow-casting lights
  47309. //the renderPrioirty is a secondary sort criterion
  47310. if (a.shadowEnabled !== b.shadowEnabled) {
  47311. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  47312. }
  47313. return b.renderPriority - a.renderPriority;
  47314. };
  47315. /**
  47316. * Releases resources associated with this node.
  47317. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47318. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47319. */
  47320. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  47321. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  47322. if (this._shadowGenerator) {
  47323. this._shadowGenerator.dispose();
  47324. this._shadowGenerator = null;
  47325. }
  47326. // Animations
  47327. this.getScene().stopAnimation(this);
  47328. // Remove from meshes
  47329. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47330. var mesh = _a[_i];
  47331. mesh._removeLightSource(this);
  47332. }
  47333. this._uniformBuffer.dispose();
  47334. // Remove from scene
  47335. this.getScene().removeLight(this);
  47336. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  47337. };
  47338. /**
  47339. * Returns the light type ID (integer).
  47340. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47341. */
  47342. Light.prototype.getTypeID = function () {
  47343. return 0;
  47344. };
  47345. /**
  47346. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  47347. * @returns the scaled intensity in intensity mode unit
  47348. */
  47349. Light.prototype.getScaledIntensity = function () {
  47350. return this._photometricScale * this.intensity;
  47351. };
  47352. /**
  47353. * Returns a new Light object, named "name", from the current one.
  47354. * @param name The name of the cloned light
  47355. * @returns the new created light
  47356. */
  47357. Light.prototype.clone = function (name) {
  47358. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  47359. if (!constructor) {
  47360. return null;
  47361. }
  47362. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  47363. };
  47364. /**
  47365. * Serializes the current light into a Serialization object.
  47366. * @returns the serialized object.
  47367. */
  47368. Light.prototype.serialize = function () {
  47369. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  47370. // Type
  47371. serializationObject.type = this.getTypeID();
  47372. // Parent
  47373. if (this.parent) {
  47374. serializationObject.parentId = this.parent.id;
  47375. }
  47376. // Inclusion / exclusions
  47377. if (this.excludedMeshes.length > 0) {
  47378. serializationObject.excludedMeshesIds = [];
  47379. this.excludedMeshes.forEach(function (mesh) {
  47380. serializationObject.excludedMeshesIds.push(mesh.id);
  47381. });
  47382. }
  47383. if (this.includedOnlyMeshes.length > 0) {
  47384. serializationObject.includedOnlyMeshesIds = [];
  47385. this.includedOnlyMeshes.forEach(function (mesh) {
  47386. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  47387. });
  47388. }
  47389. // Animations
  47390. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  47391. serializationObject.ranges = this.serializeAnimationRanges();
  47392. return serializationObject;
  47393. };
  47394. /**
  47395. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  47396. * This new light is named "name" and added to the passed scene.
  47397. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  47398. * @param name The friendly name of the light
  47399. * @param scene The scene the new light will belong to
  47400. * @returns the constructor function
  47401. */
  47402. Light.GetConstructorFromName = function (type, name, scene) {
  47403. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  47404. if (constructorFunc) {
  47405. return constructorFunc;
  47406. }
  47407. // Default to no light for none present once.
  47408. return null;
  47409. };
  47410. /**
  47411. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  47412. * @param parsedLight The JSON representation of the light
  47413. * @param scene The scene to create the parsed light in
  47414. * @returns the created light after parsing
  47415. */
  47416. Light.Parse = function (parsedLight, scene) {
  47417. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  47418. if (!constructor) {
  47419. return null;
  47420. }
  47421. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  47422. // Inclusion / exclusions
  47423. if (parsedLight.excludedMeshesIds) {
  47424. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  47425. }
  47426. if (parsedLight.includedOnlyMeshesIds) {
  47427. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  47428. }
  47429. // Parent
  47430. if (parsedLight.parentId) {
  47431. light._waitingParentId = parsedLight.parentId;
  47432. }
  47433. // Animations
  47434. if (parsedLight.animations) {
  47435. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  47436. var parsedAnimation = parsedLight.animations[animationIndex];
  47437. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  47438. if (internalClass) {
  47439. light.animations.push(internalClass.Parse(parsedAnimation));
  47440. }
  47441. }
  47442. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  47443. }
  47444. if (parsedLight.autoAnimate) {
  47445. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  47446. }
  47447. return light;
  47448. };
  47449. Light.prototype._hookArrayForExcluded = function (array) {
  47450. var _this = this;
  47451. var oldPush = array.push;
  47452. array.push = function () {
  47453. var items = [];
  47454. for (var _i = 0; _i < arguments.length; _i++) {
  47455. items[_i] = arguments[_i];
  47456. }
  47457. var result = oldPush.apply(array, items);
  47458. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  47459. var item = items_1[_a];
  47460. item._resyncLighSource(_this);
  47461. }
  47462. return result;
  47463. };
  47464. var oldSplice = array.splice;
  47465. array.splice = function (index, deleteCount) {
  47466. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47467. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  47468. var item = deleted_1[_i];
  47469. item._resyncLighSource(_this);
  47470. }
  47471. return deleted;
  47472. };
  47473. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  47474. var item = array_1[_i];
  47475. item._resyncLighSource(this);
  47476. }
  47477. };
  47478. Light.prototype._hookArrayForIncludedOnly = function (array) {
  47479. var _this = this;
  47480. var oldPush = array.push;
  47481. array.push = function () {
  47482. var items = [];
  47483. for (var _i = 0; _i < arguments.length; _i++) {
  47484. items[_i] = arguments[_i];
  47485. }
  47486. var result = oldPush.apply(array, items);
  47487. _this._resyncMeshes();
  47488. return result;
  47489. };
  47490. var oldSplice = array.splice;
  47491. array.splice = function (index, deleteCount) {
  47492. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47493. _this._resyncMeshes();
  47494. return deleted;
  47495. };
  47496. this._resyncMeshes();
  47497. };
  47498. Light.prototype._resyncMeshes = function () {
  47499. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47500. var mesh = _a[_i];
  47501. mesh._resyncLighSource(this);
  47502. }
  47503. };
  47504. /**
  47505. * Forces the meshes to update their light related information in their rendering used effects
  47506. * @hidden Internal Use Only
  47507. */
  47508. Light.prototype._markMeshesAsLightDirty = function () {
  47509. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47510. var mesh = _a[_i];
  47511. if (mesh._lightSources.indexOf(this) !== -1) {
  47512. mesh._markSubMeshesAsLightDirty();
  47513. }
  47514. }
  47515. };
  47516. /**
  47517. * Recomputes the cached photometric scale if needed.
  47518. */
  47519. Light.prototype._computePhotometricScale = function () {
  47520. this._photometricScale = this._getPhotometricScale();
  47521. this.getScene().resetCachedMaterial();
  47522. };
  47523. /**
  47524. * Returns the Photometric Scale according to the light type and intensity mode.
  47525. */
  47526. Light.prototype._getPhotometricScale = function () {
  47527. var photometricScale = 0.0;
  47528. var lightTypeID = this.getTypeID();
  47529. //get photometric mode
  47530. var photometricMode = this.intensityMode;
  47531. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  47532. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  47533. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  47534. }
  47535. else {
  47536. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  47537. }
  47538. }
  47539. //compute photometric scale
  47540. switch (lightTypeID) {
  47541. case Light.LIGHTTYPEID_POINTLIGHT:
  47542. case Light.LIGHTTYPEID_SPOTLIGHT:
  47543. switch (photometricMode) {
  47544. case Light.INTENSITYMODE_LUMINOUSPOWER:
  47545. photometricScale = 1.0 / (4.0 * Math.PI);
  47546. break;
  47547. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  47548. photometricScale = 1.0;
  47549. break;
  47550. case Light.INTENSITYMODE_LUMINANCE:
  47551. photometricScale = this.radius * this.radius;
  47552. break;
  47553. }
  47554. break;
  47555. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  47556. switch (photometricMode) {
  47557. case Light.INTENSITYMODE_ILLUMINANCE:
  47558. photometricScale = 1.0;
  47559. break;
  47560. case Light.INTENSITYMODE_LUMINANCE:
  47561. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  47562. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  47563. var apexAngleRadians = this.radius;
  47564. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  47565. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  47566. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  47567. photometricScale = solidAngle;
  47568. break;
  47569. }
  47570. break;
  47571. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  47572. // No fall off in hemisperic light.
  47573. photometricScale = 1.0;
  47574. break;
  47575. }
  47576. return photometricScale;
  47577. };
  47578. /**
  47579. * Reorder the light in the scene according to their defined priority.
  47580. * @hidden Internal Use Only
  47581. */
  47582. Light.prototype._reorderLightsInScene = function () {
  47583. var scene = this.getScene();
  47584. if (this._renderPriority != 0) {
  47585. scene.requireLightSorting = true;
  47586. }
  47587. this.getScene().sortLightsByPriority();
  47588. };
  47589. /**
  47590. * Falloff Default: light is falling off following the material specification:
  47591. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  47592. */
  47593. Light.FALLOFF_DEFAULT = 0;
  47594. /**
  47595. * Falloff Physical: light is falling off following the inverse squared distance law.
  47596. */
  47597. Light.FALLOFF_PHYSICAL = 1;
  47598. /**
  47599. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  47600. * to enhance interoperability with other engines.
  47601. */
  47602. Light.FALLOFF_GLTF = 2;
  47603. /**
  47604. * Falloff Standard: light is falling off like in the standard material
  47605. * to enhance interoperability with other materials.
  47606. */
  47607. Light.FALLOFF_STANDARD = 3;
  47608. //lightmapMode Consts
  47609. /**
  47610. * If every light affecting the material is in this lightmapMode,
  47611. * material.lightmapTexture adds or multiplies
  47612. * (depends on material.useLightmapAsShadowmap)
  47613. * after every other light calculations.
  47614. */
  47615. Light.LIGHTMAP_DEFAULT = 0;
  47616. /**
  47617. * material.lightmapTexture as only diffuse lighting from this light
  47618. * adds only specular lighting from this light
  47619. * adds dynamic shadows
  47620. */
  47621. Light.LIGHTMAP_SPECULAR = 1;
  47622. /**
  47623. * material.lightmapTexture as only lighting
  47624. * no light calculation from this light
  47625. * only adds dynamic shadows from this light
  47626. */
  47627. Light.LIGHTMAP_SHADOWSONLY = 2;
  47628. // Intensity Mode Consts
  47629. /**
  47630. * Each light type uses the default quantity according to its type:
  47631. * point/spot lights use luminous intensity
  47632. * directional lights use illuminance
  47633. */
  47634. Light.INTENSITYMODE_AUTOMATIC = 0;
  47635. /**
  47636. * lumen (lm)
  47637. */
  47638. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  47639. /**
  47640. * candela (lm/sr)
  47641. */
  47642. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  47643. /**
  47644. * lux (lm/m^2)
  47645. */
  47646. Light.INTENSITYMODE_ILLUMINANCE = 3;
  47647. /**
  47648. * nit (cd/m^2)
  47649. */
  47650. Light.INTENSITYMODE_LUMINANCE = 4;
  47651. // Light types ids const.
  47652. /**
  47653. * Light type const id of the point light.
  47654. */
  47655. Light.LIGHTTYPEID_POINTLIGHT = 0;
  47656. /**
  47657. * Light type const id of the directional light.
  47658. */
  47659. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  47660. /**
  47661. * Light type const id of the spot light.
  47662. */
  47663. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  47664. /**
  47665. * Light type const id of the hemispheric light.
  47666. */
  47667. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  47668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47670. ], Light.prototype, "diffuse", void 0);
  47671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47673. ], Light.prototype, "specular", void 0);
  47674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47676. ], Light.prototype, "falloffType", void 0);
  47677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47679. ], Light.prototype, "intensity", void 0);
  47680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47682. ], Light.prototype, "range", null);
  47683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47685. ], Light.prototype, "intensityMode", null);
  47686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47688. ], Light.prototype, "radius", null);
  47689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47691. ], Light.prototype, "_renderPriority", void 0);
  47692. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  47694. ], Light.prototype, "renderPriority", void 0);
  47695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  47697. ], Light.prototype, "_shadowEnabled", void 0);
  47698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  47700. ], Light.prototype, "_excludeWithLayerMask", void 0);
  47701. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47702. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  47703. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  47704. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  47706. ], Light.prototype, "_lightmapMode", void 0);
  47707. return Light;
  47708. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  47709. /***/ }),
  47710. /***/ "./Lights/pointLight.ts":
  47711. /*!******************************!*\
  47712. !*** ./Lights/pointLight.ts ***!
  47713. \******************************/
  47714. /*! exports provided: PointLight */
  47715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47716. "use strict";
  47717. __webpack_require__.r(__webpack_exports__);
  47718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  47719. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47720. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47721. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47722. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47723. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47724. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47725. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  47726. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  47727. });
  47728. /**
  47729. * A point light is a light defined by an unique point in world space.
  47730. * The light is emitted in every direction from this point.
  47731. * A good example of a point light is a standard light bulb.
  47732. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47733. */
  47734. var PointLight = /** @class */ (function (_super) {
  47735. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  47736. /**
  47737. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47738. * A PointLight emits the light in every direction.
  47739. * It can cast shadows.
  47740. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47741. * ```javascript
  47742. * var pointLight = new PointLight("pl", camera.position, scene);
  47743. * ```
  47744. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47745. * @param name The light friendly name
  47746. * @param position The position of the point light in the scene
  47747. * @param scene The scene the lights belongs to
  47748. */
  47749. function PointLight(name, position, scene) {
  47750. var _this = _super.call(this, name, scene) || this;
  47751. _this._shadowAngle = Math.PI / 2;
  47752. _this.position = position;
  47753. return _this;
  47754. }
  47755. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  47756. /**
  47757. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47758. * This specifies what angle the shadow will use to be created.
  47759. *
  47760. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47761. */
  47762. get: function () {
  47763. return this._shadowAngle;
  47764. },
  47765. /**
  47766. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47767. * This specifies what angle the shadow will use to be created.
  47768. *
  47769. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47770. */
  47771. set: function (value) {
  47772. this._shadowAngle = value;
  47773. this.forceProjectionMatrixCompute();
  47774. },
  47775. enumerable: true,
  47776. configurable: true
  47777. });
  47778. Object.defineProperty(PointLight.prototype, "direction", {
  47779. /**
  47780. * Gets the direction if it has been set.
  47781. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47782. */
  47783. get: function () {
  47784. return this._direction;
  47785. },
  47786. /**
  47787. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47788. */
  47789. set: function (value) {
  47790. var previousNeedCube = this.needCube();
  47791. this._direction = value;
  47792. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  47793. this._shadowGenerator.recreateShadowMap();
  47794. }
  47795. },
  47796. enumerable: true,
  47797. configurable: true
  47798. });
  47799. /**
  47800. * Returns the string "PointLight"
  47801. * @returns the class name
  47802. */
  47803. PointLight.prototype.getClassName = function () {
  47804. return "PointLight";
  47805. };
  47806. /**
  47807. * Returns the integer 0.
  47808. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47809. */
  47810. PointLight.prototype.getTypeID = function () {
  47811. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  47812. };
  47813. /**
  47814. * Specifies wether or not the shadowmap should be a cube texture.
  47815. * @returns true if the shadowmap needs to be a cube texture.
  47816. */
  47817. PointLight.prototype.needCube = function () {
  47818. return !this.direction;
  47819. };
  47820. /**
  47821. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47822. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47823. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47824. */
  47825. PointLight.prototype.getShadowDirection = function (faceIndex) {
  47826. if (this.direction) {
  47827. return _super.prototype.getShadowDirection.call(this, faceIndex);
  47828. }
  47829. else {
  47830. switch (faceIndex) {
  47831. case 0:
  47832. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  47833. case 1:
  47834. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  47835. case 2:
  47836. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  47837. case 3:
  47838. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  47839. case 4:
  47840. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  47841. case 5:
  47842. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  47843. }
  47844. }
  47845. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47846. };
  47847. /**
  47848. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47849. * - fov = PI / 2
  47850. * - aspect ratio : 1.0
  47851. * - z-near and far equal to the active camera minZ and maxZ.
  47852. * Returns the PointLight.
  47853. */
  47854. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47855. var activeCamera = this.getScene().activeCamera;
  47856. if (!activeCamera) {
  47857. return;
  47858. }
  47859. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47860. };
  47861. PointLight.prototype._buildUniformLayout = function () {
  47862. this._uniformBuffer.addUniform("vLightData", 4);
  47863. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47864. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47865. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47866. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47867. this._uniformBuffer.addUniform("depthValues", 2);
  47868. this._uniformBuffer.create();
  47869. };
  47870. /**
  47871. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47872. * @param effect The effect to update
  47873. * @param lightIndex The index of the light in the effect to update
  47874. * @returns The point light
  47875. */
  47876. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  47877. if (this.computeTransformedInformation()) {
  47878. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  47879. }
  47880. else {
  47881. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  47882. }
  47883. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  47884. return this;
  47885. };
  47886. /**
  47887. * Prepares the list of defines specific to the light type.
  47888. * @param defines the list of defines
  47889. * @param lightIndex defines the index of the light for the effect
  47890. */
  47891. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47892. defines["POINTLIGHT" + lightIndex] = true;
  47893. };
  47894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47896. ], PointLight.prototype, "shadowAngle", null);
  47897. return PointLight;
  47898. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47899. /***/ }),
  47900. /***/ "./Lights/shadowLight.ts":
  47901. /*!*******************************!*\
  47902. !*** ./Lights/shadowLight.ts ***!
  47903. \*******************************/
  47904. /*! exports provided: ShadowLight */
  47905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47906. "use strict";
  47907. __webpack_require__.r(__webpack_exports__);
  47908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  47909. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47910. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47911. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47912. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47913. /**
  47914. * Base implementation IShadowLight
  47915. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  47916. */
  47917. var ShadowLight = /** @class */ (function (_super) {
  47918. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  47919. function ShadowLight() {
  47920. var _this = _super !== null && _super.apply(this, arguments) || this;
  47921. _this._needProjectionMatrixCompute = true;
  47922. return _this;
  47923. }
  47924. ShadowLight.prototype._setPosition = function (value) {
  47925. this._position = value;
  47926. };
  47927. Object.defineProperty(ShadowLight.prototype, "position", {
  47928. /**
  47929. * Sets the position the shadow will be casted from. Also use as the light position for both
  47930. * point and spot lights.
  47931. */
  47932. get: function () {
  47933. return this._position;
  47934. },
  47935. /**
  47936. * Sets the position the shadow will be casted from. Also use as the light position for both
  47937. * point and spot lights.
  47938. */
  47939. set: function (value) {
  47940. this._setPosition(value);
  47941. },
  47942. enumerable: true,
  47943. configurable: true
  47944. });
  47945. ShadowLight.prototype._setDirection = function (value) {
  47946. this._direction = value;
  47947. };
  47948. Object.defineProperty(ShadowLight.prototype, "direction", {
  47949. /**
  47950. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  47951. * Also use as the light direction on spot and directional lights.
  47952. */
  47953. get: function () {
  47954. return this._direction;
  47955. },
  47956. /**
  47957. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  47958. * Also use as the light direction on spot and directional lights.
  47959. */
  47960. set: function (value) {
  47961. this._setDirection(value);
  47962. },
  47963. enumerable: true,
  47964. configurable: true
  47965. });
  47966. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  47967. /**
  47968. * Gets the shadow projection clipping minimum z value.
  47969. */
  47970. get: function () {
  47971. return this._shadowMinZ;
  47972. },
  47973. /**
  47974. * Sets the shadow projection clipping minimum z value.
  47975. */
  47976. set: function (value) {
  47977. this._shadowMinZ = value;
  47978. this.forceProjectionMatrixCompute();
  47979. },
  47980. enumerable: true,
  47981. configurable: true
  47982. });
  47983. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  47984. /**
  47985. * Sets the shadow projection clipping maximum z value.
  47986. */
  47987. get: function () {
  47988. return this._shadowMaxZ;
  47989. },
  47990. /**
  47991. * Gets the shadow projection clipping maximum z value.
  47992. */
  47993. set: function (value) {
  47994. this._shadowMaxZ = value;
  47995. this.forceProjectionMatrixCompute();
  47996. },
  47997. enumerable: true,
  47998. configurable: true
  47999. });
  48000. /**
  48001. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  48002. * @returns true if the information has been computed, false if it does not need to (no parenting)
  48003. */
  48004. ShadowLight.prototype.computeTransformedInformation = function () {
  48005. if (this.parent && this.parent.getWorldMatrix) {
  48006. if (!this.transformedPosition) {
  48007. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48008. }
  48009. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  48010. // In case the direction is present.
  48011. if (this.direction) {
  48012. if (!this.transformedDirection) {
  48013. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48014. }
  48015. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  48016. }
  48017. return true;
  48018. }
  48019. return false;
  48020. };
  48021. /**
  48022. * Return the depth scale used for the shadow map.
  48023. * @returns the depth scale.
  48024. */
  48025. ShadowLight.prototype.getDepthScale = function () {
  48026. return 50.0;
  48027. };
  48028. /**
  48029. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  48030. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48031. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48032. */
  48033. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  48034. return this.transformedDirection ? this.transformedDirection : this.direction;
  48035. };
  48036. /**
  48037. * Returns the ShadowLight absolute position in the World.
  48038. * @returns the position vector in world space
  48039. */
  48040. ShadowLight.prototype.getAbsolutePosition = function () {
  48041. return this.transformedPosition ? this.transformedPosition : this.position;
  48042. };
  48043. /**
  48044. * Sets the ShadowLight direction toward the passed target.
  48045. * @param target The point to target in local space
  48046. * @returns the updated ShadowLight direction
  48047. */
  48048. ShadowLight.prototype.setDirectionToTarget = function (target) {
  48049. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  48050. return this.direction;
  48051. };
  48052. /**
  48053. * Returns the light rotation in euler definition.
  48054. * @returns the x y z rotation in local space.
  48055. */
  48056. ShadowLight.prototype.getRotation = function () {
  48057. this.direction.normalize();
  48058. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  48059. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  48060. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  48061. };
  48062. /**
  48063. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  48064. * @returns true if a cube texture needs to be use
  48065. */
  48066. ShadowLight.prototype.needCube = function () {
  48067. return false;
  48068. };
  48069. /**
  48070. * Detects if the projection matrix requires to be recomputed this frame.
  48071. * @returns true if it requires to be recomputed otherwise, false.
  48072. */
  48073. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  48074. return this._needProjectionMatrixCompute;
  48075. };
  48076. /**
  48077. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  48078. */
  48079. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  48080. this._needProjectionMatrixCompute = true;
  48081. };
  48082. /** @hidden */
  48083. ShadowLight.prototype._initCache = function () {
  48084. _super.prototype._initCache.call(this);
  48085. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48086. };
  48087. /** @hidden */
  48088. ShadowLight.prototype._isSynchronized = function () {
  48089. if (!this._cache.position.equals(this.position)) {
  48090. return false;
  48091. }
  48092. return true;
  48093. };
  48094. /**
  48095. * Computes the world matrix of the node
  48096. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  48097. * @returns the world matrix
  48098. */
  48099. ShadowLight.prototype.computeWorldMatrix = function (force) {
  48100. if (!force && this.isSynchronized()) {
  48101. this._currentRenderId = this.getScene().getRenderId();
  48102. return this._worldMatrix;
  48103. }
  48104. this._updateCache();
  48105. this._cache.position.copyFrom(this.position);
  48106. if (!this._worldMatrix) {
  48107. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  48108. }
  48109. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  48110. if (this.parent && this.parent.getWorldMatrix) {
  48111. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  48112. this._markSyncedWithParent();
  48113. }
  48114. // Cache the determinant
  48115. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  48116. return this._worldMatrix;
  48117. };
  48118. /**
  48119. * Gets the minZ used for shadow according to both the scene and the light.
  48120. * @param activeCamera The camera we are returning the min for
  48121. * @returns the depth min z
  48122. */
  48123. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  48124. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  48125. };
  48126. /**
  48127. * Gets the maxZ used for shadow according to both the scene and the light.
  48128. * @param activeCamera The camera we are returning the max for
  48129. * @returns the depth max z
  48130. */
  48131. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  48132. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  48133. };
  48134. /**
  48135. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  48136. * @param matrix The materix to updated with the projection information
  48137. * @param viewMatrix The transform matrix of the light
  48138. * @param renderList The list of mesh to render in the map
  48139. * @returns The current light
  48140. */
  48141. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48142. if (this.customProjectionMatrixBuilder) {
  48143. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  48144. }
  48145. else {
  48146. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  48147. }
  48148. return this;
  48149. };
  48150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48152. ], ShadowLight.prototype, "position", null);
  48153. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48154. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48155. ], ShadowLight.prototype, "direction", null);
  48156. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48157. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48158. ], ShadowLight.prototype, "shadowMinZ", null);
  48159. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48160. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48161. ], ShadowLight.prototype, "shadowMaxZ", null);
  48162. return ShadowLight;
  48163. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  48164. /***/ }),
  48165. /***/ "./Lights/spotLight.ts":
  48166. /*!*****************************!*\
  48167. !*** ./Lights/spotLight.ts ***!
  48168. \*****************************/
  48169. /*! exports provided: SpotLight */
  48170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48171. "use strict";
  48172. __webpack_require__.r(__webpack_exports__);
  48173. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  48174. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48175. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48176. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48177. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48178. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48179. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48180. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  48181. 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); };
  48182. });
  48183. /**
  48184. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48185. * These values define a cone of light starting from the position, emitting toward the direction.
  48186. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48187. * and the exponent defines the speed of the decay of the light with distance (reach).
  48188. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48189. */
  48190. var SpotLight = /** @class */ (function (_super) {
  48191. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  48192. /**
  48193. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48194. * It can cast shadows.
  48195. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48196. * @param name The light friendly name
  48197. * @param position The position of the spot light in the scene
  48198. * @param direction The direction of the light in the scene
  48199. * @param angle The cone angle of the light in Radians
  48200. * @param exponent The light decay speed with the distance from the emission spot
  48201. * @param scene The scene the lights belongs to
  48202. */
  48203. function SpotLight(name, position, direction, angle, exponent, scene) {
  48204. var _this = _super.call(this, name, scene) || this;
  48205. _this._innerAngle = 0;
  48206. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48207. _this._projectionTextureLightNear = 1e-6;
  48208. _this._projectionTextureLightFar = 1000.0;
  48209. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  48210. _this._projectionTextureViewLightDirty = true;
  48211. _this._projectionTextureProjectionLightDirty = true;
  48212. _this._projectionTextureDirty = true;
  48213. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48214. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48215. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48216. _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);
  48217. _this.position = position;
  48218. _this.direction = direction;
  48219. _this.angle = angle;
  48220. _this.exponent = exponent;
  48221. return _this;
  48222. }
  48223. Object.defineProperty(SpotLight.prototype, "angle", {
  48224. /**
  48225. * Gets the cone angle of the spot light in Radians.
  48226. */
  48227. get: function () {
  48228. return this._angle;
  48229. },
  48230. /**
  48231. * Sets the cone angle of the spot light in Radians.
  48232. */
  48233. set: function (value) {
  48234. this._angle = value;
  48235. this._cosHalfAngle = Math.cos(value * 0.5);
  48236. this._projectionTextureProjectionLightDirty = true;
  48237. this.forceProjectionMatrixCompute();
  48238. this._computeAngleValues();
  48239. },
  48240. enumerable: true,
  48241. configurable: true
  48242. });
  48243. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  48244. /**
  48245. * Only used in gltf falloff mode, this defines the angle where
  48246. * the directional falloff will start before cutting at angle which could be seen
  48247. * as outer angle.
  48248. */
  48249. get: function () {
  48250. return this._innerAngle;
  48251. },
  48252. /**
  48253. * Only used in gltf falloff mode, this defines the angle where
  48254. * the directional falloff will start before cutting at angle which could be seen
  48255. * as outer angle.
  48256. */
  48257. set: function (value) {
  48258. this._innerAngle = value;
  48259. this._computeAngleValues();
  48260. },
  48261. enumerable: true,
  48262. configurable: true
  48263. });
  48264. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  48265. /**
  48266. * Allows scaling the angle of the light for shadow generation only.
  48267. */
  48268. get: function () {
  48269. return this._shadowAngleScale;
  48270. },
  48271. /**
  48272. * Allows scaling the angle of the light for shadow generation only.
  48273. */
  48274. set: function (value) {
  48275. this._shadowAngleScale = value;
  48276. this.forceProjectionMatrixCompute();
  48277. },
  48278. enumerable: true,
  48279. configurable: true
  48280. });
  48281. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  48282. /**
  48283. * Allows reading the projecton texture
  48284. */
  48285. get: function () {
  48286. return this._projectionTextureMatrix;
  48287. },
  48288. enumerable: true,
  48289. configurable: true
  48290. });
  48291. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  48292. /**
  48293. * Gets the near clip of the Spotlight for texture projection.
  48294. */
  48295. get: function () {
  48296. return this._projectionTextureLightNear;
  48297. },
  48298. /**
  48299. * Sets the near clip of the Spotlight for texture projection.
  48300. */
  48301. set: function (value) {
  48302. this._projectionTextureLightNear = value;
  48303. this._projectionTextureProjectionLightDirty = true;
  48304. },
  48305. enumerable: true,
  48306. configurable: true
  48307. });
  48308. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  48309. /**
  48310. * Gets the far clip of the Spotlight for texture projection.
  48311. */
  48312. get: function () {
  48313. return this._projectionTextureLightFar;
  48314. },
  48315. /**
  48316. * Sets the far clip of the Spotlight for texture projection.
  48317. */
  48318. set: function (value) {
  48319. this._projectionTextureLightFar = value;
  48320. this._projectionTextureProjectionLightDirty = true;
  48321. },
  48322. enumerable: true,
  48323. configurable: true
  48324. });
  48325. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  48326. /**
  48327. * Gets the Up vector of the Spotlight for texture projection.
  48328. */
  48329. get: function () {
  48330. return this._projectionTextureUpDirection;
  48331. },
  48332. /**
  48333. * Sets the Up vector of the Spotlight for texture projection.
  48334. */
  48335. set: function (value) {
  48336. this._projectionTextureUpDirection = value;
  48337. this._projectionTextureProjectionLightDirty = true;
  48338. },
  48339. enumerable: true,
  48340. configurable: true
  48341. });
  48342. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  48343. /**
  48344. * Gets the projection texture of the light.
  48345. */
  48346. get: function () {
  48347. return this._projectionTexture;
  48348. },
  48349. /**
  48350. * Sets the projection texture of the light.
  48351. */
  48352. set: function (value) {
  48353. this._projectionTexture = value;
  48354. this._projectionTextureDirty = true;
  48355. },
  48356. enumerable: true,
  48357. configurable: true
  48358. });
  48359. /**
  48360. * Returns the string "SpotLight".
  48361. * @returns the class name
  48362. */
  48363. SpotLight.prototype.getClassName = function () {
  48364. return "SpotLight";
  48365. };
  48366. /**
  48367. * Returns the integer 2.
  48368. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48369. */
  48370. SpotLight.prototype.getTypeID = function () {
  48371. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  48372. };
  48373. /**
  48374. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48375. */
  48376. SpotLight.prototype._setDirection = function (value) {
  48377. _super.prototype._setDirection.call(this, value);
  48378. this._projectionTextureViewLightDirty = true;
  48379. };
  48380. /**
  48381. * Overrides the position setter to recompute the projection texture view light Matrix.
  48382. */
  48383. SpotLight.prototype._setPosition = function (value) {
  48384. _super.prototype._setPosition.call(this, value);
  48385. this._projectionTextureViewLightDirty = true;
  48386. };
  48387. /**
  48388. * 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.
  48389. * Returns the SpotLight.
  48390. */
  48391. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48392. var activeCamera = this.getScene().activeCamera;
  48393. if (!activeCamera) {
  48394. return;
  48395. }
  48396. this._shadowAngleScale = this._shadowAngleScale || 1;
  48397. var angle = this._shadowAngleScale * this._angle;
  48398. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48399. };
  48400. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  48401. this._projectionTextureViewLightDirty = false;
  48402. this._projectionTextureDirty = true;
  48403. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  48404. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  48405. };
  48406. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  48407. this._projectionTextureProjectionLightDirty = false;
  48408. this._projectionTextureDirty = true;
  48409. var light_far = this.projectionTextureLightFar;
  48410. var light_near = this.projectionTextureLightNear;
  48411. var P = light_far / (light_far - light_near);
  48412. var Q = -P * light_near;
  48413. var S = 1.0 / Math.tan(this._angle / 2.0);
  48414. var A = 1.0;
  48415. _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);
  48416. };
  48417. /**
  48418. * Main function for light texture projection matrix computing.
  48419. */
  48420. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  48421. this._projectionTextureDirty = false;
  48422. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  48423. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  48424. };
  48425. SpotLight.prototype._buildUniformLayout = function () {
  48426. this._uniformBuffer.addUniform("vLightData", 4);
  48427. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48428. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48429. this._uniformBuffer.addUniform("vLightDirection", 3);
  48430. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48431. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48432. this._uniformBuffer.addUniform("depthValues", 2);
  48433. this._uniformBuffer.create();
  48434. };
  48435. SpotLight.prototype._computeAngleValues = function () {
  48436. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  48437. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  48438. };
  48439. /**
  48440. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48441. * @param effect The effect to update
  48442. * @param lightIndex The index of the light in the effect to update
  48443. * @returns The spot light
  48444. */
  48445. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  48446. var normalizeDirection;
  48447. if (this.computeTransformedInformation()) {
  48448. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  48449. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  48450. }
  48451. else {
  48452. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  48453. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  48454. }
  48455. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  48456. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  48457. if (this.projectionTexture && this.projectionTexture.isReady()) {
  48458. if (this._projectionTextureViewLightDirty) {
  48459. this._computeProjectionTextureViewLightMatrix();
  48460. }
  48461. if (this._projectionTextureProjectionLightDirty) {
  48462. this._computeProjectionTextureProjectionLightMatrix();
  48463. }
  48464. if (this._projectionTextureDirty) {
  48465. this._computeProjectionTextureMatrix();
  48466. }
  48467. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  48468. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  48469. }
  48470. return this;
  48471. };
  48472. /**
  48473. * Disposes the light and the associated resources.
  48474. */
  48475. SpotLight.prototype.dispose = function () {
  48476. _super.prototype.dispose.call(this);
  48477. if (this._projectionTexture) {
  48478. this._projectionTexture.dispose();
  48479. }
  48480. };
  48481. /**
  48482. * Prepares the list of defines specific to the light type.
  48483. * @param defines the list of defines
  48484. * @param lightIndex defines the index of the light for the effect
  48485. */
  48486. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48487. defines["SPOTLIGHT" + lightIndex] = true;
  48488. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  48489. };
  48490. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48491. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48492. ], SpotLight.prototype, "angle", null);
  48493. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48494. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48495. ], SpotLight.prototype, "innerAngle", null);
  48496. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48497. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48498. ], SpotLight.prototype, "shadowAngleScale", null);
  48499. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48500. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48501. ], SpotLight.prototype, "exponent", void 0);
  48502. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48503. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48504. ], SpotLight.prototype, "projectionTextureLightNear", null);
  48505. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48506. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48507. ], SpotLight.prototype, "projectionTextureLightFar", null);
  48508. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48509. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48510. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  48511. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48512. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  48513. ], SpotLight.prototype, "_projectionTexture", void 0);
  48514. return SpotLight;
  48515. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48516. /***/ }),
  48517. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  48518. /*!**********************************************!*\
  48519. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  48520. \**********************************************/
  48521. /*! exports provided: _BabylonLoaderRegistered */
  48522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48523. "use strict";
  48524. __webpack_require__.r(__webpack_exports__);
  48525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  48526. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48527. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  48528. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48529. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  48530. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  48531. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  48532. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  48533. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  48534. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  48535. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  48536. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  48537. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  48538. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  48539. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  48540. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  48541. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  48542. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  48543. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  48544. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  48545. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  48546. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  48547. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  48548. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48549. /** @hidden */
  48550. var _BabylonLoaderRegistered = true;
  48551. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  48552. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48553. var parsedMaterial = parsedData.materials[index];
  48554. if (parsedMaterial.id === id) {
  48555. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48556. }
  48557. }
  48558. return null;
  48559. };
  48560. var isDescendantOf = function (mesh, names, hierarchyIds) {
  48561. for (var i in names) {
  48562. if (mesh.name === names[i]) {
  48563. hierarchyIds.push(mesh.id);
  48564. return true;
  48565. }
  48566. }
  48567. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  48568. hierarchyIds.push(mesh.id);
  48569. return true;
  48570. }
  48571. return false;
  48572. };
  48573. var logOperation = function (operation, producer) {
  48574. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  48575. };
  48576. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  48577. if (addToScene === void 0) { addToScene = false; }
  48578. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  48579. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48580. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48581. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48582. // and avoid problems with multiple concurrent .babylon loads.
  48583. var log = "importScene has failed JSON parse";
  48584. try {
  48585. var parsedData = JSON.parse(data);
  48586. log = "";
  48587. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48588. var index;
  48589. var cache;
  48590. // Environment texture
  48591. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48592. // PBR needed for both HDR texture (gamma space) & a sky box
  48593. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48594. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48595. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48596. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48597. if (parsedData.environmentTextureRotationY) {
  48598. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48599. }
  48600. scene.environmentTexture = hdrTexture;
  48601. }
  48602. else {
  48603. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  48604. if (parsedData.environmentTextureRotationY) {
  48605. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48606. }
  48607. scene.environmentTexture = cubeTexture;
  48608. }
  48609. if (parsedData.createDefaultSkybox === true) {
  48610. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48611. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48612. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48613. }
  48614. container.environmentTexture = scene.environmentTexture;
  48615. }
  48616. // Lights
  48617. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  48618. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  48619. var parsedLight = parsedData.lights[index];
  48620. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  48621. if (light) {
  48622. container.lights.push(light);
  48623. log += (index === 0 ? "\n\tLights:" : "");
  48624. log += "\n\t\t" + light.toString(fullDetails);
  48625. }
  48626. }
  48627. }
  48628. // Reflection probes
  48629. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  48630. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  48631. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  48632. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  48633. if (reflectionProbe) {
  48634. container.reflectionProbes.push(reflectionProbe);
  48635. log += (index === 0 ? "\n\tReflection Probes:" : "");
  48636. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  48637. }
  48638. }
  48639. }
  48640. // Animations
  48641. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  48642. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  48643. var parsedAnimation = parsedData.animations[index];
  48644. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  48645. if (internalClass) {
  48646. var animation = internalClass.Parse(parsedAnimation);
  48647. scene.animations.push(animation);
  48648. container.animations.push(animation);
  48649. log += (index === 0 ? "\n\tAnimations:" : "");
  48650. log += "\n\t\t" + animation.toString(fullDetails);
  48651. }
  48652. }
  48653. }
  48654. // Materials
  48655. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  48656. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48657. var parsedMaterial = parsedData.materials[index];
  48658. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48659. container.materials.push(mat);
  48660. log += (index === 0 ? "\n\tMaterials:" : "");
  48661. log += "\n\t\t" + mat.toString(fullDetails);
  48662. }
  48663. }
  48664. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48665. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  48666. var parsedMultiMaterial = parsedData.multiMaterials[index];
  48667. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48668. container.multiMaterials.push(mmat);
  48669. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  48670. log += "\n\t\t" + mmat.toString(fullDetails);
  48671. }
  48672. }
  48673. // Morph targets
  48674. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48675. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48676. var managerData = _a[_i];
  48677. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  48678. }
  48679. }
  48680. // Skeletons
  48681. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48682. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  48683. var parsedSkeleton = parsedData.skeletons[index];
  48684. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48685. container.skeletons.push(skeleton);
  48686. log += (index === 0 ? "\n\tSkeletons:" : "");
  48687. log += "\n\t\t" + skeleton.toString(fullDetails);
  48688. }
  48689. }
  48690. // Geometries
  48691. var geometries = parsedData.geometries;
  48692. if (geometries !== undefined && geometries !== null) {
  48693. var addedGeometry = new Array();
  48694. // VertexData
  48695. var vertexData = geometries.vertexData;
  48696. if (vertexData !== undefined && vertexData !== null) {
  48697. for (index = 0, cache = vertexData.length; index < cache; index++) {
  48698. var parsedVertexData = vertexData[index];
  48699. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  48700. }
  48701. }
  48702. addedGeometry.forEach(function (g) {
  48703. if (g) {
  48704. container.geometries.push(g);
  48705. }
  48706. });
  48707. }
  48708. // Transform nodes
  48709. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  48710. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  48711. var parsedTransformNode = parsedData.transformNodes[index];
  48712. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  48713. container.transformNodes.push(node);
  48714. }
  48715. }
  48716. // Meshes
  48717. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48718. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48719. var parsedMesh = parsedData.meshes[index];
  48720. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48721. container.meshes.push(mesh);
  48722. log += (index === 0 ? "\n\tMeshes:" : "");
  48723. log += "\n\t\t" + mesh.toString(fullDetails);
  48724. }
  48725. }
  48726. // Cameras
  48727. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  48728. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  48729. var parsedCamera = parsedData.cameras[index];
  48730. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  48731. container.cameras.push(camera);
  48732. log += (index === 0 ? "\n\tCameras:" : "");
  48733. log += "\n\t\t" + camera.toString(fullDetails);
  48734. }
  48735. }
  48736. // Animation Groups
  48737. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  48738. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  48739. var parsedAnimationGroup = parsedData.animationGroups[index];
  48740. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  48741. container.animationGroups.push(animationGroup);
  48742. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  48743. log += "\n\t\t" + animationGroup.toString(fullDetails);
  48744. }
  48745. }
  48746. // Browsing all the graph to connect the dots
  48747. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  48748. var camera = scene.cameras[index];
  48749. if (camera._waitingParentId) {
  48750. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  48751. camera._waitingParentId = null;
  48752. }
  48753. }
  48754. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  48755. var light_1 = scene.lights[index];
  48756. if (light_1 && light_1._waitingParentId) {
  48757. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  48758. light_1._waitingParentId = null;
  48759. }
  48760. }
  48761. // Connect parents & children and parse actions
  48762. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  48763. var transformNode = scene.transformNodes[index];
  48764. if (transformNode._waitingParentId) {
  48765. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  48766. transformNode._waitingParentId = null;
  48767. }
  48768. }
  48769. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48770. var mesh = scene.meshes[index];
  48771. if (mesh._waitingParentId) {
  48772. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  48773. mesh._waitingParentId = null;
  48774. }
  48775. }
  48776. // freeze world matrix application
  48777. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48778. var currentMesh = scene.meshes[index];
  48779. if (currentMesh._waitingFreezeWorldMatrix) {
  48780. currentMesh.freezeWorldMatrix();
  48781. currentMesh._waitingFreezeWorldMatrix = null;
  48782. }
  48783. else {
  48784. currentMesh.computeWorldMatrix(true);
  48785. }
  48786. }
  48787. // Lights exclusions / inclusions
  48788. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  48789. var light_2 = scene.lights[index];
  48790. // Excluded check
  48791. if (light_2._excludedMeshesIds.length > 0) {
  48792. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  48793. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  48794. if (excludedMesh) {
  48795. light_2.excludedMeshes.push(excludedMesh);
  48796. }
  48797. }
  48798. light_2._excludedMeshesIds = [];
  48799. }
  48800. // Included check
  48801. if (light_2._includedOnlyMeshesIds.length > 0) {
  48802. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  48803. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  48804. if (includedOnlyMesh) {
  48805. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  48806. }
  48807. }
  48808. light_2._includedOnlyMeshesIds = [];
  48809. }
  48810. }
  48811. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  48812. // Actions (scene) Done last as it can access other objects.
  48813. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48814. var mesh = scene.meshes[index];
  48815. if (mesh._waitingActions) {
  48816. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  48817. mesh._waitingActions = null;
  48818. }
  48819. }
  48820. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  48821. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  48822. }
  48823. if (!addToScene) {
  48824. container.removeAllFromScene();
  48825. }
  48826. }
  48827. catch (err) {
  48828. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  48829. if (onError) {
  48830. onError(msg, err);
  48831. }
  48832. else {
  48833. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48834. throw err;
  48835. }
  48836. }
  48837. finally {
  48838. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48839. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  48840. }
  48841. }
  48842. return container;
  48843. };
  48844. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  48845. name: "babylon.js",
  48846. extensions: ".babylon",
  48847. canDirectLoad: function (data) {
  48848. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  48849. return true;
  48850. }
  48851. return false;
  48852. },
  48853. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  48854. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48855. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48856. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48857. // and avoid problems with multiple concurrent .babylon loads.
  48858. var log = "importMesh has failed JSON parse";
  48859. try {
  48860. var parsedData = JSON.parse(data);
  48861. log = "";
  48862. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48863. if (!meshesNames) {
  48864. meshesNames = null;
  48865. }
  48866. else if (!Array.isArray(meshesNames)) {
  48867. meshesNames = [meshesNames];
  48868. }
  48869. var hierarchyIds = new Array();
  48870. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48871. var loadedSkeletonsIds = [];
  48872. var loadedMaterialsIds = [];
  48873. var index;
  48874. var cache;
  48875. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48876. var parsedMesh = parsedData.meshes[index];
  48877. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  48878. if (meshesNames !== null) {
  48879. // Remove found mesh name from list.
  48880. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  48881. }
  48882. //Geometry?
  48883. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  48884. //does the file contain geometries?
  48885. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  48886. //find the correct geometry and add it to the scene
  48887. var found = false;
  48888. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  48889. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  48890. return;
  48891. }
  48892. else {
  48893. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  48894. if (parsedGeometryData.id === parsedMesh.geometryId) {
  48895. switch (geometryType) {
  48896. case "vertexData":
  48897. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  48898. break;
  48899. }
  48900. found = true;
  48901. }
  48902. });
  48903. }
  48904. });
  48905. if (found === false) {
  48906. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  48907. }
  48908. }
  48909. }
  48910. // Material ?
  48911. if (parsedMesh.materialId) {
  48912. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  48913. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48914. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  48915. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  48916. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  48917. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  48918. var subMatId = parsedMultiMaterial.materials[matIndex];
  48919. loadedMaterialsIds.push(subMatId);
  48920. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  48921. if (mat) {
  48922. log += "\n\tMaterial " + mat.toString(fullDetails);
  48923. }
  48924. }
  48925. loadedMaterialsIds.push(parsedMultiMaterial.id);
  48926. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48927. if (mmat) {
  48928. materialFound = true;
  48929. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  48930. }
  48931. break;
  48932. }
  48933. }
  48934. }
  48935. if (materialFound === false) {
  48936. loadedMaterialsIds.push(parsedMesh.materialId);
  48937. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  48938. if (!mat) {
  48939. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  48940. }
  48941. else {
  48942. log += "\n\tMaterial " + mat.toString(fullDetails);
  48943. }
  48944. }
  48945. }
  48946. // Skeleton ?
  48947. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48948. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  48949. if (skeletonAlreadyLoaded === false) {
  48950. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  48951. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  48952. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  48953. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48954. skeletons.push(skeleton);
  48955. loadedSkeletonsIds.push(parsedSkeleton.id);
  48956. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  48957. }
  48958. }
  48959. }
  48960. }
  48961. // Morph targets ?
  48962. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48963. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48964. var managerData = _a[_i];
  48965. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  48966. }
  48967. }
  48968. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48969. meshes.push(mesh);
  48970. log += "\n\tMesh " + mesh.toString(fullDetails);
  48971. }
  48972. }
  48973. // Connecting parents
  48974. var currentMesh;
  48975. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48976. currentMesh = scene.meshes[index];
  48977. if (currentMesh._waitingParentId) {
  48978. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  48979. currentMesh._waitingParentId = null;
  48980. }
  48981. }
  48982. // freeze and compute world matrix application
  48983. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48984. currentMesh = scene.meshes[index];
  48985. if (currentMesh._waitingFreezeWorldMatrix) {
  48986. currentMesh.freezeWorldMatrix();
  48987. currentMesh._waitingFreezeWorldMatrix = null;
  48988. }
  48989. else {
  48990. currentMesh.computeWorldMatrix(true);
  48991. }
  48992. }
  48993. }
  48994. // Particles
  48995. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  48996. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  48997. if (parser) {
  48998. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  48999. var parsedParticleSystem = parsedData.particleSystems[index];
  49000. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  49001. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  49002. }
  49003. }
  49004. }
  49005. }
  49006. return true;
  49007. }
  49008. catch (err) {
  49009. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  49010. if (onError) {
  49011. onError(msg, err);
  49012. }
  49013. else {
  49014. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49015. throw err;
  49016. }
  49017. }
  49018. finally {
  49019. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49020. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  49021. }
  49022. }
  49023. return false;
  49024. },
  49025. load: function (scene, data, rootUrl, onError) {
  49026. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49027. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49028. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49029. // and avoid problems with multiple concurrent .babylon loads.
  49030. var log = "importScene has failed JSON parse";
  49031. try {
  49032. var parsedData = JSON.parse(data);
  49033. log = "";
  49034. // Scene
  49035. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  49036. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  49037. }
  49038. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  49039. scene.autoClear = parsedData.autoClear;
  49040. }
  49041. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  49042. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  49043. }
  49044. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  49045. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  49046. }
  49047. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  49048. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  49049. }
  49050. // Fog
  49051. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  49052. scene.fogMode = parsedData.fogMode;
  49053. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  49054. scene.fogStart = parsedData.fogStart;
  49055. scene.fogEnd = parsedData.fogEnd;
  49056. scene.fogDensity = parsedData.fogDensity;
  49057. log += "\tFog mode for scene: ";
  49058. switch (scene.fogMode) {
  49059. // getters not compiling, so using hardcoded
  49060. case 1:
  49061. log += "exp\n";
  49062. break;
  49063. case 2:
  49064. log += "exp2\n";
  49065. break;
  49066. case 3:
  49067. log += "linear\n";
  49068. break;
  49069. }
  49070. }
  49071. //Physics
  49072. if (parsedData.physicsEnabled) {
  49073. var physicsPlugin;
  49074. if (parsedData.physicsEngine === "cannon") {
  49075. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  49076. }
  49077. else if (parsedData.physicsEngine === "oimo") {
  49078. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  49079. }
  49080. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  49081. //else - default engine, which is currently oimo
  49082. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  49083. scene.enablePhysics(physicsGravity, physicsPlugin);
  49084. }
  49085. // Metadata
  49086. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  49087. scene.metadata = parsedData.metadata;
  49088. }
  49089. //collisions, if defined. otherwise, default is true
  49090. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  49091. scene.collisionsEnabled = parsedData.collisionsEnabled;
  49092. }
  49093. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  49094. if (!container) {
  49095. return false;
  49096. }
  49097. if (parsedData.autoAnimate) {
  49098. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  49099. }
  49100. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  49101. scene.setActiveCameraByID(parsedData.activeCameraID);
  49102. }
  49103. // Environment texture
  49104. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  49105. // PBR needed for both HDR texture (gamma space) & a sky box
  49106. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  49107. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  49108. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  49109. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  49110. if (parsedData.environmentTextureRotationY) {
  49111. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  49112. }
  49113. scene.environmentTexture = hdrTexture;
  49114. }
  49115. else {
  49116. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  49117. if (parsedData.environmentTextureRotationY) {
  49118. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  49119. }
  49120. scene.environmentTexture = cubeTexture;
  49121. }
  49122. if (parsedData.createDefaultSkybox === true) {
  49123. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  49124. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  49125. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  49126. }
  49127. }
  49128. // Finish
  49129. return true;
  49130. }
  49131. catch (err) {
  49132. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  49133. if (onError) {
  49134. onError(msg, err);
  49135. }
  49136. else {
  49137. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49138. throw err;
  49139. }
  49140. }
  49141. finally {
  49142. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49143. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  49144. }
  49145. }
  49146. return false;
  49147. },
  49148. loadAssetContainer: function (scene, data, rootUrl, onError) {
  49149. var container = loadAssetContainer(scene, data, rootUrl, onError);
  49150. return container;
  49151. }
  49152. });
  49153. /***/ }),
  49154. /***/ "./Loading/Plugins/index.ts":
  49155. /*!**********************************!*\
  49156. !*** ./Loading/Plugins/index.ts ***!
  49157. \**********************************/
  49158. /*! exports provided: _BabylonLoaderRegistered */
  49159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49160. "use strict";
  49161. __webpack_require__.r(__webpack_exports__);
  49162. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  49163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  49164. /***/ }),
  49165. /***/ "./Loading/index.ts":
  49166. /*!**************************!*\
  49167. !*** ./Loading/index.ts ***!
  49168. \**************************/
  49169. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  49170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49171. "use strict";
  49172. __webpack_require__.r(__webpack_exports__);
  49173. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  49174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  49175. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  49176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  49177. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  49178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  49179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  49180. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  49182. /***/ }),
  49183. /***/ "./Loading/loadingScreen.ts":
  49184. /*!**********************************!*\
  49185. !*** ./Loading/loadingScreen.ts ***!
  49186. \**********************************/
  49187. /*! exports provided: DefaultLoadingScreen */
  49188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49189. "use strict";
  49190. __webpack_require__.r(__webpack_exports__);
  49191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  49192. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49193. /**
  49194. * Class used for the default loading screen
  49195. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  49196. */
  49197. var DefaultLoadingScreen = /** @class */ (function () {
  49198. /**
  49199. * Creates a new default loading screen
  49200. * @param _renderingCanvas defines the canvas used to render the scene
  49201. * @param _loadingText defines the default text to display
  49202. * @param _loadingDivBackgroundColor defines the default background color
  49203. */
  49204. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  49205. if (_loadingText === void 0) { _loadingText = ""; }
  49206. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  49207. var _this = this;
  49208. this._renderingCanvas = _renderingCanvas;
  49209. this._loadingText = _loadingText;
  49210. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  49211. // Resize
  49212. this._resizeLoadingUI = function () {
  49213. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  49214. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  49215. if (!_this._loadingDiv) {
  49216. return;
  49217. }
  49218. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  49219. _this._loadingDiv.style.left = canvasRect.left + "px";
  49220. _this._loadingDiv.style.top = canvasRect.top + "px";
  49221. _this._loadingDiv.style.width = canvasRect.width + "px";
  49222. _this._loadingDiv.style.height = canvasRect.height + "px";
  49223. };
  49224. }
  49225. /**
  49226. * Function called to display the loading screen
  49227. */
  49228. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  49229. if (this._loadingDiv) {
  49230. // Do not add a loading screen if there is already one
  49231. return;
  49232. }
  49233. this._loadingDiv = document.createElement("div");
  49234. this._loadingDiv.id = "babylonjsLoadingDiv";
  49235. this._loadingDiv.style.opacity = "0";
  49236. this._loadingDiv.style.transition = "opacity 1.5s ease";
  49237. this._loadingDiv.style.pointerEvents = "none";
  49238. // Loading text
  49239. this._loadingTextDiv = document.createElement("div");
  49240. this._loadingTextDiv.style.position = "absolute";
  49241. this._loadingTextDiv.style.left = "0";
  49242. this._loadingTextDiv.style.top = "50%";
  49243. this._loadingTextDiv.style.marginTop = "80px";
  49244. this._loadingTextDiv.style.width = "100%";
  49245. this._loadingTextDiv.style.height = "20px";
  49246. this._loadingTextDiv.style.fontFamily = "Arial";
  49247. this._loadingTextDiv.style.fontSize = "14px";
  49248. this._loadingTextDiv.style.color = "white";
  49249. this._loadingTextDiv.style.textAlign = "center";
  49250. this._loadingTextDiv.innerHTML = "Loading";
  49251. this._loadingDiv.appendChild(this._loadingTextDiv);
  49252. //set the predefined text
  49253. this._loadingTextDiv.innerHTML = this._loadingText;
  49254. // Generating keyframes
  49255. var style = document.createElement('style');
  49256. style.type = 'text/css';
  49257. 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 }";
  49258. style.innerHTML = keyFrames;
  49259. document.getElementsByTagName('head')[0].appendChild(style);
  49260. // Loading img
  49261. var imgBack = new Image();
  49262. 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";
  49263. imgBack.style.position = "absolute";
  49264. imgBack.style.left = "50%";
  49265. imgBack.style.top = "50%";
  49266. imgBack.style.marginLeft = "-60px";
  49267. imgBack.style.marginTop = "-60px";
  49268. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  49269. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  49270. imgBack.style.transformOrigin = "50% 50%";
  49271. imgBack.style.webkitTransformOrigin = "50% 50%";
  49272. this._loadingDiv.appendChild(imgBack);
  49273. this._resizeLoadingUI();
  49274. window.addEventListener("resize", this._resizeLoadingUI);
  49275. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49276. document.body.appendChild(this._loadingDiv);
  49277. this._loadingDiv.style.opacity = "1";
  49278. };
  49279. /**
  49280. * Function called to hide the loading screen
  49281. */
  49282. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  49283. var _this = this;
  49284. if (!this._loadingDiv) {
  49285. return;
  49286. }
  49287. var onTransitionEnd = function () {
  49288. if (!_this._loadingDiv) {
  49289. return;
  49290. }
  49291. if (_this._loadingDiv.parentElement) {
  49292. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  49293. }
  49294. window.removeEventListener("resize", _this._resizeLoadingUI);
  49295. _this._loadingDiv = null;
  49296. };
  49297. this._loadingDiv.style.opacity = "0";
  49298. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  49299. };
  49300. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  49301. get: function () {
  49302. return this._loadingText;
  49303. },
  49304. /**
  49305. * Gets or sets the text to display while loading
  49306. */
  49307. set: function (text) {
  49308. this._loadingText = text;
  49309. if (this._loadingTextDiv) {
  49310. this._loadingTextDiv.innerHTML = this._loadingText;
  49311. }
  49312. },
  49313. enumerable: true,
  49314. configurable: true
  49315. });
  49316. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  49317. /**
  49318. * Gets or sets the color to use for the background
  49319. */
  49320. get: function () {
  49321. return this._loadingDivBackgroundColor;
  49322. },
  49323. set: function (color) {
  49324. this._loadingDivBackgroundColor = color;
  49325. if (!this._loadingDiv) {
  49326. return;
  49327. }
  49328. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49329. },
  49330. enumerable: true,
  49331. configurable: true
  49332. });
  49333. return DefaultLoadingScreen;
  49334. }());
  49335. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  49336. /***/ }),
  49337. /***/ "./Loading/sceneLoader.ts":
  49338. /*!********************************!*\
  49339. !*** ./Loading/sceneLoader.ts ***!
  49340. \********************************/
  49341. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  49342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49343. "use strict";
  49344. __webpack_require__.r(__webpack_exports__);
  49345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  49346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  49347. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  49348. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  49349. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  49350. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  49351. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49352. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  49353. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  49354. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49355. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49356. /**
  49357. * Class used to represent data loading progression
  49358. */
  49359. var SceneLoaderProgressEvent = /** @class */ (function () {
  49360. /**
  49361. * Create a new progress event
  49362. * @param lengthComputable defines if data length to load can be evaluated
  49363. * @param loaded defines the loaded data length
  49364. * @param total defines the data length to load
  49365. */
  49366. function SceneLoaderProgressEvent(
  49367. /** defines if data length to load can be evaluated */
  49368. lengthComputable,
  49369. /** defines the loaded data length */
  49370. loaded,
  49371. /** defines the data length to load */
  49372. total) {
  49373. this.lengthComputable = lengthComputable;
  49374. this.loaded = loaded;
  49375. this.total = total;
  49376. }
  49377. /**
  49378. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  49379. * @param event defines the source event
  49380. * @returns a new SceneLoaderProgressEvent
  49381. */
  49382. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  49383. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  49384. };
  49385. return SceneLoaderProgressEvent;
  49386. }());
  49387. /**
  49388. * Class used to load scene from various file formats using registered plugins
  49389. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  49390. */
  49391. var SceneLoader = /** @class */ (function () {
  49392. function SceneLoader() {
  49393. }
  49394. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  49395. /**
  49396. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49397. */
  49398. get: function () {
  49399. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  49400. },
  49401. set: function (value) {
  49402. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  49403. },
  49404. enumerable: true,
  49405. configurable: true
  49406. });
  49407. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  49408. /**
  49409. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49410. */
  49411. get: function () {
  49412. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  49413. },
  49414. set: function (value) {
  49415. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  49416. },
  49417. enumerable: true,
  49418. configurable: true
  49419. });
  49420. Object.defineProperty(SceneLoader, "loggingLevel", {
  49421. /**
  49422. * Defines the current logging level (while loading the scene)
  49423. * @ignorenaming
  49424. */
  49425. get: function () {
  49426. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  49427. },
  49428. set: function (value) {
  49429. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  49430. },
  49431. enumerable: true,
  49432. configurable: true
  49433. });
  49434. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  49435. /**
  49436. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49437. */
  49438. get: function () {
  49439. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  49440. },
  49441. set: function (value) {
  49442. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  49443. },
  49444. enumerable: true,
  49445. configurable: true
  49446. });
  49447. SceneLoader._getDefaultPlugin = function () {
  49448. return SceneLoader._registeredPlugins[".babylon"];
  49449. };
  49450. SceneLoader._getPluginForExtension = function (extension) {
  49451. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  49452. if (registeredPlugin) {
  49453. return registeredPlugin;
  49454. }
  49455. _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");
  49456. return SceneLoader._getDefaultPlugin();
  49457. };
  49458. SceneLoader._getPluginForDirectLoad = function (data) {
  49459. for (var extension in SceneLoader._registeredPlugins) {
  49460. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  49461. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  49462. return SceneLoader._registeredPlugins[extension];
  49463. }
  49464. }
  49465. return SceneLoader._getDefaultPlugin();
  49466. };
  49467. SceneLoader._getPluginForFilename = function (sceneFilename) {
  49468. var queryStringPosition = sceneFilename.indexOf("?");
  49469. if (queryStringPosition !== -1) {
  49470. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  49471. }
  49472. var dotPosition = sceneFilename.lastIndexOf(".");
  49473. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  49474. return SceneLoader._getPluginForExtension(extension);
  49475. };
  49476. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  49477. SceneLoader._getDirectLoad = function (sceneFilename) {
  49478. if (sceneFilename.substr(0, 5) === "data:") {
  49479. return sceneFilename.substr(5);
  49480. }
  49481. return null;
  49482. };
  49483. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  49484. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  49485. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  49486. var plugin;
  49487. if (registeredPlugin.plugin.createPlugin) {
  49488. plugin = registeredPlugin.plugin.createPlugin();
  49489. }
  49490. else {
  49491. plugin = registeredPlugin.plugin;
  49492. }
  49493. if (!plugin) {
  49494. throw "The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.";
  49495. }
  49496. var useArrayBuffer = registeredPlugin.isBinary;
  49497. var offlineProvider;
  49498. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  49499. var dataCallback = function (data, responseURL) {
  49500. if (scene.isDisposed) {
  49501. onError("Scene has been disposed");
  49502. return;
  49503. }
  49504. scene.offlineProvider = offlineProvider;
  49505. onSuccess(plugin, data, responseURL);
  49506. };
  49507. var request = null;
  49508. var pluginDisposed = false;
  49509. var onDisposeObservable = plugin.onDisposeObservable;
  49510. if (onDisposeObservable) {
  49511. onDisposeObservable.add(function () {
  49512. pluginDisposed = true;
  49513. if (request) {
  49514. request.abort();
  49515. request = null;
  49516. }
  49517. onDispose();
  49518. });
  49519. }
  49520. var manifestChecked = function () {
  49521. if (pluginDisposed) {
  49522. return;
  49523. }
  49524. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  49525. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  49526. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  49527. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  49528. });
  49529. };
  49530. if (directLoad) {
  49531. dataCallback(directLoad);
  49532. return plugin;
  49533. }
  49534. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  49535. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  49536. var engine = scene.getEngine();
  49537. var canUseOfflineSupport = engine.enableOfflineSupport;
  49538. if (canUseOfflineSupport) {
  49539. // Also check for exceptions
  49540. var exceptionFound = false;
  49541. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  49542. var regex = _a[_i];
  49543. if (regex.test(fileInfo.url)) {
  49544. exceptionFound = true;
  49545. break;
  49546. }
  49547. }
  49548. canUseOfflineSupport = !exceptionFound;
  49549. }
  49550. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  49551. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  49552. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  49553. }
  49554. else {
  49555. manifestChecked();
  49556. }
  49557. }
  49558. // Loading file from disk via input file or drag'n'drop
  49559. else {
  49560. if (file) {
  49561. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  49562. }
  49563. else {
  49564. onError("Unable to find file named " + fileInfo.name);
  49565. }
  49566. }
  49567. return plugin;
  49568. };
  49569. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  49570. var url;
  49571. var name;
  49572. var file = null;
  49573. if (!sceneFilename) {
  49574. url = rootUrl;
  49575. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  49576. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  49577. }
  49578. else if (sceneFilename.name) {
  49579. var sceneFile = sceneFilename;
  49580. url = rootUrl + sceneFile.name;
  49581. name = sceneFile.name;
  49582. file = sceneFile;
  49583. }
  49584. else {
  49585. var filename = sceneFilename;
  49586. if (filename.substr(0, 1) === "/") {
  49587. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  49588. return null;
  49589. }
  49590. url = rootUrl + filename;
  49591. name = filename;
  49592. }
  49593. return {
  49594. url: url,
  49595. rootUrl: rootUrl,
  49596. name: name,
  49597. file: file
  49598. };
  49599. };
  49600. // Public functions
  49601. /**
  49602. * Gets a plugin that can load the given extension
  49603. * @param extension defines the extension to load
  49604. * @returns a plugin or null if none works
  49605. */
  49606. SceneLoader.GetPluginForExtension = function (extension) {
  49607. return SceneLoader._getPluginForExtension(extension).plugin;
  49608. };
  49609. /**
  49610. * Gets a boolean indicating that the given extension can be loaded
  49611. * @param extension defines the extension to load
  49612. * @returns true if the extension is supported
  49613. */
  49614. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  49615. return !!SceneLoader._registeredPlugins[extension];
  49616. };
  49617. /**
  49618. * Adds a new plugin to the list of registered plugins
  49619. * @param plugin defines the plugin to add
  49620. */
  49621. SceneLoader.RegisterPlugin = function (plugin) {
  49622. if (typeof plugin.extensions === "string") {
  49623. var extension = plugin.extensions;
  49624. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49625. plugin: plugin,
  49626. isBinary: false
  49627. };
  49628. }
  49629. else {
  49630. var extensions = plugin.extensions;
  49631. Object.keys(extensions).forEach(function (extension) {
  49632. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49633. plugin: plugin,
  49634. isBinary: extensions[extension].isBinary
  49635. };
  49636. });
  49637. }
  49638. };
  49639. /**
  49640. * Import meshes into a scene
  49641. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49642. * @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)
  49643. * @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)
  49644. * @param scene the instance of BABYLON.Scene to append to
  49645. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49646. * @param onProgress a callback with a progress event for each file being loaded
  49647. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49648. * @param pluginExtension the extension used to determine the plugin
  49649. * @returns The loaded plugin
  49650. */
  49651. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49652. if (sceneFilename === void 0) { sceneFilename = ""; }
  49653. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49654. if (onSuccess === void 0) { onSuccess = null; }
  49655. if (onProgress === void 0) { onProgress = null; }
  49656. if (onError === void 0) { onError = null; }
  49657. if (pluginExtension === void 0) { pluginExtension = null; }
  49658. if (!scene) {
  49659. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  49660. return null;
  49661. }
  49662. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49663. if (!fileInfo) {
  49664. return null;
  49665. }
  49666. var loadingToken = {};
  49667. scene._addPendingData(loadingToken);
  49668. var disposeHandler = function () {
  49669. scene._removePendingData(loadingToken);
  49670. };
  49671. var errorHandler = function (message, exception) {
  49672. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  49673. if (onError) {
  49674. onError(scene, errorMessage, exception);
  49675. }
  49676. else {
  49677. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49678. // should the exception be thrown?
  49679. }
  49680. disposeHandler();
  49681. };
  49682. var progressHandler = onProgress ? function (event) {
  49683. try {
  49684. onProgress(event);
  49685. }
  49686. catch (e) {
  49687. errorHandler("Error in onProgress callback", e);
  49688. }
  49689. } : undefined;
  49690. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  49691. scene.importedMeshesFiles.push(fileInfo.url);
  49692. if (onSuccess) {
  49693. try {
  49694. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  49695. }
  49696. catch (e) {
  49697. errorHandler("Error in onSuccess callback", e);
  49698. }
  49699. }
  49700. scene._removePendingData(loadingToken);
  49701. };
  49702. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  49703. if (plugin.rewriteRootURL) {
  49704. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  49705. }
  49706. if (plugin.importMesh) {
  49707. var syncedPlugin = plugin;
  49708. var meshes = new Array();
  49709. var particleSystems = new Array();
  49710. var skeletons = new Array();
  49711. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  49712. return;
  49713. }
  49714. scene.loadingPluginName = plugin.name;
  49715. successHandler(meshes, particleSystems, skeletons, []);
  49716. }
  49717. else {
  49718. var asyncedPlugin = plugin;
  49719. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  49720. scene.loadingPluginName = plugin.name;
  49721. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  49722. }).catch(function (error) {
  49723. errorHandler(error.message, error);
  49724. });
  49725. }
  49726. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49727. };
  49728. /**
  49729. * Import meshes into a scene
  49730. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49731. * @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)
  49732. * @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)
  49733. * @param scene the instance of BABYLON.Scene to append to
  49734. * @param onProgress a callback with a progress event for each file being loaded
  49735. * @param pluginExtension the extension used to determine the plugin
  49736. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49737. */
  49738. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49739. if (sceneFilename === void 0) { sceneFilename = ""; }
  49740. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49741. if (onProgress === void 0) { onProgress = null; }
  49742. if (pluginExtension === void 0) { pluginExtension = null; }
  49743. return new Promise(function (resolve, reject) {
  49744. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  49745. resolve({
  49746. meshes: meshes,
  49747. particleSystems: particleSystems,
  49748. skeletons: skeletons,
  49749. animationGroups: animationGroups
  49750. });
  49751. }, onProgress, function (scene, message, exception) {
  49752. reject(exception || new Error(message));
  49753. }, pluginExtension);
  49754. });
  49755. };
  49756. /**
  49757. * Load a scene
  49758. * @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)
  49759. * @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)
  49760. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49761. * @param onSuccess a callback with the scene when import succeeds
  49762. * @param onProgress a callback with a progress event for each file being loaded
  49763. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49764. * @param pluginExtension the extension used to determine the plugin
  49765. * @returns The loaded plugin
  49766. */
  49767. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  49768. if (sceneFilename === void 0) { sceneFilename = ""; }
  49769. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  49770. if (onSuccess === void 0) { onSuccess = null; }
  49771. if (onProgress === void 0) { onProgress = null; }
  49772. if (onError === void 0) { onError = null; }
  49773. if (pluginExtension === void 0) { pluginExtension = null; }
  49774. if (!engine) {
  49775. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  49776. return null;
  49777. }
  49778. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  49779. };
  49780. /**
  49781. * Load a scene
  49782. * @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)
  49783. * @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)
  49784. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49785. * @param onProgress a callback with a progress event for each file being loaded
  49786. * @param pluginExtension the extension used to determine the plugin
  49787. * @returns The loaded scene
  49788. */
  49789. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  49790. if (sceneFilename === void 0) { sceneFilename = ""; }
  49791. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  49792. if (onProgress === void 0) { onProgress = null; }
  49793. if (pluginExtension === void 0) { pluginExtension = null; }
  49794. return new Promise(function (resolve, reject) {
  49795. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  49796. resolve(scene);
  49797. }, onProgress, function (scene, message, exception) {
  49798. reject(exception || new Error(message));
  49799. }, pluginExtension);
  49800. });
  49801. };
  49802. /**
  49803. * Append a scene
  49804. * @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)
  49805. * @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)
  49806. * @param scene is the instance of BABYLON.Scene to append to
  49807. * @param onSuccess a callback with the scene when import succeeds
  49808. * @param onProgress a callback with a progress event for each file being loaded
  49809. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49810. * @param pluginExtension the extension used to determine the plugin
  49811. * @returns The loaded plugin
  49812. */
  49813. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49814. if (sceneFilename === void 0) { sceneFilename = ""; }
  49815. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49816. if (onSuccess === void 0) { onSuccess = null; }
  49817. if (onProgress === void 0) { onProgress = null; }
  49818. if (onError === void 0) { onError = null; }
  49819. if (pluginExtension === void 0) { pluginExtension = null; }
  49820. if (!scene) {
  49821. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  49822. return null;
  49823. }
  49824. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49825. if (!fileInfo) {
  49826. return null;
  49827. }
  49828. if (SceneLoader.ShowLoadingScreen) {
  49829. scene.getEngine().displayLoadingUI();
  49830. }
  49831. var loadingToken = {};
  49832. scene._addPendingData(loadingToken);
  49833. var disposeHandler = function () {
  49834. scene._removePendingData(loadingToken);
  49835. scene.getEngine().hideLoadingUI();
  49836. };
  49837. var errorHandler = function (message, exception) {
  49838. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  49839. if (onError) {
  49840. onError(scene, errorMessage, exception);
  49841. }
  49842. else {
  49843. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49844. // should the exception be thrown?
  49845. }
  49846. disposeHandler();
  49847. };
  49848. var progressHandler = onProgress ? function (event) {
  49849. try {
  49850. onProgress(event);
  49851. }
  49852. catch (e) {
  49853. errorHandler("Error in onProgress callback", e);
  49854. }
  49855. } : undefined;
  49856. var successHandler = function () {
  49857. if (onSuccess) {
  49858. try {
  49859. onSuccess(scene);
  49860. }
  49861. catch (e) {
  49862. errorHandler("Error in onSuccess callback", e);
  49863. }
  49864. }
  49865. scene._removePendingData(loadingToken);
  49866. };
  49867. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49868. if (plugin.load) {
  49869. var syncedPlugin = plugin;
  49870. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  49871. return;
  49872. }
  49873. scene.loadingPluginName = plugin.name;
  49874. successHandler();
  49875. }
  49876. else {
  49877. var asyncedPlugin = plugin;
  49878. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  49879. scene.loadingPluginName = plugin.name;
  49880. successHandler();
  49881. }).catch(function (error) {
  49882. errorHandler(error.message, error);
  49883. });
  49884. }
  49885. if (SceneLoader.ShowLoadingScreen) {
  49886. scene.executeWhenReady(function () {
  49887. scene.getEngine().hideLoadingUI();
  49888. });
  49889. }
  49890. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49891. };
  49892. /**
  49893. * Append a scene
  49894. * @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)
  49895. * @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)
  49896. * @param scene is the instance of BABYLON.Scene to append to
  49897. * @param onProgress a callback with a progress event for each file being loaded
  49898. * @param pluginExtension the extension used to determine the plugin
  49899. * @returns The given scene
  49900. */
  49901. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49902. if (sceneFilename === void 0) { sceneFilename = ""; }
  49903. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49904. if (onProgress === void 0) { onProgress = null; }
  49905. if (pluginExtension === void 0) { pluginExtension = null; }
  49906. return new Promise(function (resolve, reject) {
  49907. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  49908. resolve(scene);
  49909. }, onProgress, function (scene, message, exception) {
  49910. reject(exception || new Error(message));
  49911. }, pluginExtension);
  49912. });
  49913. };
  49914. /**
  49915. * Load a scene into an asset container
  49916. * @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)
  49917. * @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)
  49918. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49919. * @param onSuccess a callback with the scene when import succeeds
  49920. * @param onProgress a callback with a progress event for each file being loaded
  49921. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49922. * @param pluginExtension the extension used to determine the plugin
  49923. * @returns The loaded plugin
  49924. */
  49925. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49926. if (sceneFilename === void 0) { sceneFilename = ""; }
  49927. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49928. if (onSuccess === void 0) { onSuccess = null; }
  49929. if (onProgress === void 0) { onProgress = null; }
  49930. if (onError === void 0) { onError = null; }
  49931. if (pluginExtension === void 0) { pluginExtension = null; }
  49932. if (!scene) {
  49933. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  49934. return null;
  49935. }
  49936. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49937. if (!fileInfo) {
  49938. return null;
  49939. }
  49940. var loadingToken = {};
  49941. scene._addPendingData(loadingToken);
  49942. var disposeHandler = function () {
  49943. scene._removePendingData(loadingToken);
  49944. };
  49945. var errorHandler = function (message, exception) {
  49946. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  49947. if (onError) {
  49948. onError(scene, errorMessage, exception);
  49949. }
  49950. else {
  49951. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49952. // should the exception be thrown?
  49953. }
  49954. disposeHandler();
  49955. };
  49956. var progressHandler = onProgress ? function (event) {
  49957. try {
  49958. onProgress(event);
  49959. }
  49960. catch (e) {
  49961. errorHandler("Error in onProgress callback", e);
  49962. }
  49963. } : undefined;
  49964. var successHandler = function (assets) {
  49965. if (onSuccess) {
  49966. try {
  49967. onSuccess(assets);
  49968. }
  49969. catch (e) {
  49970. errorHandler("Error in onSuccess callback", e);
  49971. }
  49972. }
  49973. scene._removePendingData(loadingToken);
  49974. };
  49975. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49976. if (plugin.loadAssetContainer) {
  49977. var syncedPlugin = plugin;
  49978. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  49979. if (!assetContainer) {
  49980. return;
  49981. }
  49982. scene.loadingPluginName = plugin.name;
  49983. successHandler(assetContainer);
  49984. }
  49985. else if (plugin.loadAssetContainerAsync) {
  49986. var asyncedPlugin = plugin;
  49987. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  49988. scene.loadingPluginName = plugin.name;
  49989. successHandler(assetContainer);
  49990. }).catch(function (error) {
  49991. errorHandler(error.message, error);
  49992. });
  49993. }
  49994. else {
  49995. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  49996. }
  49997. if (SceneLoader.ShowLoadingScreen) {
  49998. scene.executeWhenReady(function () {
  49999. scene.getEngine().hideLoadingUI();
  50000. });
  50001. }
  50002. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50003. };
  50004. /**
  50005. * Load a scene into an asset container
  50006. * @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)
  50007. * @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)
  50008. * @param scene is the instance of Scene to append to
  50009. * @param onProgress a callback with a progress event for each file being loaded
  50010. * @param pluginExtension the extension used to determine the plugin
  50011. * @returns The loaded asset container
  50012. */
  50013. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50014. if (sceneFilename === void 0) { sceneFilename = ""; }
  50015. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50016. if (onProgress === void 0) { onProgress = null; }
  50017. if (pluginExtension === void 0) { pluginExtension = null; }
  50018. return new Promise(function (resolve, reject) {
  50019. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  50020. resolve(assetContainer);
  50021. }, onProgress, function (scene, message, exception) {
  50022. reject(exception || new Error(message));
  50023. }, pluginExtension);
  50024. });
  50025. };
  50026. /**
  50027. * No logging while loading
  50028. */
  50029. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  50030. /**
  50031. * Minimal logging while loading
  50032. */
  50033. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  50034. /**
  50035. * Summary logging while loading
  50036. */
  50037. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  50038. /**
  50039. * Detailled logging while loading
  50040. */
  50041. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  50042. // Members
  50043. /**
  50044. * Event raised when a plugin is used to load a scene
  50045. */
  50046. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  50047. SceneLoader._registeredPlugins = {};
  50048. return SceneLoader;
  50049. }());
  50050. /***/ }),
  50051. /***/ "./Loading/sceneLoaderFlags.ts":
  50052. /*!*************************************!*\
  50053. !*** ./Loading/sceneLoaderFlags.ts ***!
  50054. \*************************************/
  50055. /*! exports provided: SceneLoaderFlags */
  50056. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50057. "use strict";
  50058. __webpack_require__.r(__webpack_exports__);
  50059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  50060. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  50061. /**
  50062. * Class used to represent data loading progression
  50063. */
  50064. var SceneLoaderFlags = /** @class */ (function () {
  50065. function SceneLoaderFlags() {
  50066. }
  50067. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  50068. /**
  50069. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50070. */
  50071. get: function () {
  50072. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  50073. },
  50074. set: function (value) {
  50075. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  50076. },
  50077. enumerable: true,
  50078. configurable: true
  50079. });
  50080. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  50081. /**
  50082. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50083. */
  50084. get: function () {
  50085. return SceneLoaderFlags._ShowLoadingScreen;
  50086. },
  50087. set: function (value) {
  50088. SceneLoaderFlags._ShowLoadingScreen = value;
  50089. },
  50090. enumerable: true,
  50091. configurable: true
  50092. });
  50093. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  50094. /**
  50095. * Defines the current logging level (while loading the scene)
  50096. * @ignorenaming
  50097. */
  50098. get: function () {
  50099. return SceneLoaderFlags._loggingLevel;
  50100. },
  50101. set: function (value) {
  50102. SceneLoaderFlags._loggingLevel = value;
  50103. },
  50104. enumerable: true,
  50105. configurable: true
  50106. });
  50107. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  50108. /**
  50109. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50110. */
  50111. get: function () {
  50112. return SceneLoaderFlags._CleanBoneMatrixWeights;
  50113. },
  50114. set: function (value) {
  50115. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  50116. },
  50117. enumerable: true,
  50118. configurable: true
  50119. });
  50120. // Flags
  50121. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  50122. SceneLoaderFlags._ShowLoadingScreen = true;
  50123. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  50124. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  50125. return SceneLoaderFlags;
  50126. }());
  50127. /***/ }),
  50128. /***/ "./Materials/Background/backgroundMaterial.ts":
  50129. /*!****************************************************!*\
  50130. !*** ./Materials/Background/backgroundMaterial.ts ***!
  50131. \****************************************************/
  50132. /*! exports provided: BackgroundMaterial */
  50133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50134. "use strict";
  50135. __webpack_require__.r(__webpack_exports__);
  50136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  50137. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50138. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50139. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50140. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50141. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50142. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50143. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50144. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50145. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50146. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50147. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50148. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50149. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50150. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  50151. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50152. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  50153. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  50154. /**
  50155. * Background material defines definition.
  50156. * @hidden Mainly internal Use
  50157. */
  50158. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  50159. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  50160. /**
  50161. * Constructor of the defines.
  50162. */
  50163. function BackgroundMaterialDefines() {
  50164. var _this = _super.call(this) || this;
  50165. /**
  50166. * True if the diffuse texture is in use.
  50167. */
  50168. _this.DIFFUSE = false;
  50169. /**
  50170. * The direct UV channel to use.
  50171. */
  50172. _this.DIFFUSEDIRECTUV = 0;
  50173. /**
  50174. * True if the diffuse texture is in gamma space.
  50175. */
  50176. _this.GAMMADIFFUSE = false;
  50177. /**
  50178. * True if the diffuse texture has opacity in the alpha channel.
  50179. */
  50180. _this.DIFFUSEHASALPHA = false;
  50181. /**
  50182. * True if you want the material to fade to transparent at grazing angle.
  50183. */
  50184. _this.OPACITYFRESNEL = false;
  50185. /**
  50186. * True if an extra blur needs to be added in the reflection.
  50187. */
  50188. _this.REFLECTIONBLUR = false;
  50189. /**
  50190. * True if you want the material to fade to reflection at grazing angle.
  50191. */
  50192. _this.REFLECTIONFRESNEL = false;
  50193. /**
  50194. * True if you want the material to falloff as far as you move away from the scene center.
  50195. */
  50196. _this.REFLECTIONFALLOFF = false;
  50197. /**
  50198. * False if the current Webgl implementation does not support the texture lod extension.
  50199. */
  50200. _this.TEXTURELODSUPPORT = false;
  50201. /**
  50202. * True to ensure the data are premultiplied.
  50203. */
  50204. _this.PREMULTIPLYALPHA = false;
  50205. /**
  50206. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  50207. */
  50208. _this.USERGBCOLOR = false;
  50209. /**
  50210. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  50211. * stays aligned with the desired configuration.
  50212. */
  50213. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  50214. /**
  50215. * True to add noise in order to reduce the banding effect.
  50216. */
  50217. _this.NOISE = false;
  50218. /**
  50219. * is the reflection texture in BGR color scheme?
  50220. * Mainly used to solve a bug in ios10 video tag
  50221. */
  50222. _this.REFLECTIONBGR = false;
  50223. _this.IMAGEPROCESSING = false;
  50224. _this.VIGNETTE = false;
  50225. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50226. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50227. _this.TONEMAPPING = false;
  50228. _this.TONEMAPPING_ACES = false;
  50229. _this.CONTRAST = false;
  50230. _this.COLORCURVES = false;
  50231. _this.COLORGRADING = false;
  50232. _this.COLORGRADING3D = false;
  50233. _this.SAMPLER3DGREENDEPTH = false;
  50234. _this.SAMPLER3DBGRMAP = false;
  50235. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50236. _this.EXPOSURE = false;
  50237. _this.MULTIVIEW = false;
  50238. // Reflection.
  50239. _this.REFLECTION = false;
  50240. _this.REFLECTIONMAP_3D = false;
  50241. _this.REFLECTIONMAP_SPHERICAL = false;
  50242. _this.REFLECTIONMAP_PLANAR = false;
  50243. _this.REFLECTIONMAP_CUBIC = false;
  50244. _this.REFLECTIONMAP_PROJECTION = false;
  50245. _this.REFLECTIONMAP_SKYBOX = false;
  50246. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50247. _this.REFLECTIONMAP_EXPLICIT = false;
  50248. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50249. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50250. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50251. _this.INVERTCUBICMAP = false;
  50252. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50253. _this.LODINREFLECTIONALPHA = false;
  50254. _this.GAMMAREFLECTION = false;
  50255. _this.RGBDREFLECTION = false;
  50256. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  50257. // Default BJS.
  50258. _this.MAINUV1 = false;
  50259. _this.MAINUV2 = false;
  50260. _this.UV1 = false;
  50261. _this.UV2 = false;
  50262. _this.CLIPPLANE = false;
  50263. _this.CLIPPLANE2 = false;
  50264. _this.CLIPPLANE3 = false;
  50265. _this.CLIPPLANE4 = false;
  50266. _this.POINTSIZE = false;
  50267. _this.FOG = false;
  50268. _this.NORMAL = false;
  50269. _this.NUM_BONE_INFLUENCERS = 0;
  50270. _this.BonesPerMesh = 0;
  50271. _this.INSTANCES = false;
  50272. _this.SHADOWFLOAT = false;
  50273. _this.rebuild();
  50274. return _this;
  50275. }
  50276. return BackgroundMaterialDefines;
  50277. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  50278. /**
  50279. * Background material used to create an efficient environement around your scene.
  50280. */
  50281. var BackgroundMaterial = /** @class */ (function (_super) {
  50282. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  50283. /**
  50284. * Instantiates a Background Material in the given scene
  50285. * @param name The friendly name of the material
  50286. * @param scene The scene to add the material to
  50287. */
  50288. function BackgroundMaterial(name, scene) {
  50289. var _this = _super.call(this, name, scene) || this;
  50290. /**
  50291. * Key light Color (multiply against the environement texture)
  50292. */
  50293. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50294. _this._primaryColorShadowLevel = 0;
  50295. _this._primaryColorHighlightLevel = 0;
  50296. /**
  50297. * Reflection Texture used in the material.
  50298. * Should be author in a specific way for the best result (refer to the documentation).
  50299. */
  50300. _this.reflectionTexture = null;
  50301. /**
  50302. * Reflection Texture level of blur.
  50303. *
  50304. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50305. * texture twice.
  50306. */
  50307. _this.reflectionBlur = 0;
  50308. /**
  50309. * Diffuse Texture used in the material.
  50310. * Should be author in a specific way for the best result (refer to the documentation).
  50311. */
  50312. _this.diffuseTexture = null;
  50313. _this._shadowLights = null;
  50314. /**
  50315. * Specify the list of lights casting shadow on the material.
  50316. * All scene shadow lights will be included if null.
  50317. */
  50318. _this.shadowLights = null;
  50319. /**
  50320. * Helps adjusting the shadow to a softer level if required.
  50321. * 0 means black shadows and 1 means no shadows.
  50322. */
  50323. _this.shadowLevel = 0;
  50324. /**
  50325. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50326. * It is usually zero but might be interesting to modify according to your setup.
  50327. */
  50328. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  50329. /**
  50330. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50331. * This helps ensuring a nice transition when the camera goes under the ground.
  50332. */
  50333. _this.opacityFresnel = true;
  50334. /**
  50335. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50336. * This helps adding a mirror texture on the ground.
  50337. */
  50338. _this.reflectionFresnel = false;
  50339. /**
  50340. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50341. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50342. */
  50343. _this.reflectionFalloffDistance = 0.0;
  50344. /**
  50345. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50346. */
  50347. _this.reflectionAmount = 1.0;
  50348. /**
  50349. * This specifies the weight of the reflection at grazing angle.
  50350. */
  50351. _this.reflectionReflectance0 = 0.05;
  50352. /**
  50353. * This specifies the weight of the reflection at a perpendicular point of view.
  50354. */
  50355. _this.reflectionReflectance90 = 0.5;
  50356. /**
  50357. * Helps to directly use the maps channels instead of their level.
  50358. */
  50359. _this.useRGBColor = true;
  50360. /**
  50361. * This helps reducing the banding effect that could occur on the background.
  50362. */
  50363. _this.enableNoise = false;
  50364. _this._fovMultiplier = 1.0;
  50365. /**
  50366. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50367. */
  50368. _this.useEquirectangularFOV = false;
  50369. _this._maxSimultaneousLights = 4;
  50370. /**
  50371. * Number of Simultaneous lights allowed on the material.
  50372. */
  50373. _this.maxSimultaneousLights = 4;
  50374. /**
  50375. * Keep track of the image processing observer to allow dispose and replace.
  50376. */
  50377. _this._imageProcessingObserver = null;
  50378. /**
  50379. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50380. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50381. */
  50382. _this.switchToBGR = false;
  50383. // Temp values kept as cache in the material.
  50384. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  50385. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  50386. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50387. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50388. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50389. // Setup the default processing configuration to the scene.
  50390. _this._attachImageProcessingConfiguration(null);
  50391. _this.getRenderTargetTextures = function () {
  50392. _this._renderTargets.reset();
  50393. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  50394. _this._renderTargets.push(_this._diffuseTexture);
  50395. }
  50396. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50397. _this._renderTargets.push(_this._reflectionTexture);
  50398. }
  50399. return _this._renderTargets;
  50400. };
  50401. return _this;
  50402. }
  50403. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  50404. /**
  50405. * Experimental Internal Use Only.
  50406. *
  50407. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50408. * This acts as a helper to set the primary color to a more "human friendly" value.
  50409. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50410. * output color as close as possible from the chosen value.
  50411. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50412. * part of lighting setup.)
  50413. */
  50414. get: function () {
  50415. return this.__perceptualColor;
  50416. },
  50417. set: function (value) {
  50418. this.__perceptualColor = value;
  50419. this._computePrimaryColorFromPerceptualColor();
  50420. this._markAllSubMeshesAsLightsDirty();
  50421. },
  50422. enumerable: true,
  50423. configurable: true
  50424. });
  50425. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  50426. /**
  50427. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50428. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50429. */
  50430. get: function () {
  50431. return this._primaryColorShadowLevel;
  50432. },
  50433. set: function (value) {
  50434. this._primaryColorShadowLevel = value;
  50435. this._computePrimaryColors();
  50436. this._markAllSubMeshesAsLightsDirty();
  50437. },
  50438. enumerable: true,
  50439. configurable: true
  50440. });
  50441. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  50442. /**
  50443. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50444. * The primary color is used at the level chosen to define what the white area would look.
  50445. */
  50446. get: function () {
  50447. return this._primaryColorHighlightLevel;
  50448. },
  50449. set: function (value) {
  50450. this._primaryColorHighlightLevel = value;
  50451. this._computePrimaryColors();
  50452. this._markAllSubMeshesAsLightsDirty();
  50453. },
  50454. enumerable: true,
  50455. configurable: true
  50456. });
  50457. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  50458. /**
  50459. * Sets the reflection reflectance fresnel values according to the default standard
  50460. * empirically know to work well :-)
  50461. */
  50462. set: function (value) {
  50463. var reflectionWeight = value;
  50464. if (reflectionWeight < 0.5) {
  50465. reflectionWeight = reflectionWeight * 2.0;
  50466. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  50467. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  50468. }
  50469. else {
  50470. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  50471. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  50472. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  50473. }
  50474. },
  50475. enumerable: true,
  50476. configurable: true
  50477. });
  50478. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  50479. /**
  50480. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50481. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50482. * Recommended to be keep at 1.0 except for special cases.
  50483. */
  50484. get: function () {
  50485. return this._fovMultiplier;
  50486. },
  50487. set: function (value) {
  50488. if (isNaN(value)) {
  50489. value = 1.0;
  50490. }
  50491. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  50492. },
  50493. enumerable: true,
  50494. configurable: true
  50495. });
  50496. /**
  50497. * Attaches a new image processing configuration to the PBR Material.
  50498. * @param configuration (if null the scene configuration will be use)
  50499. */
  50500. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50501. var _this = this;
  50502. if (configuration === this._imageProcessingConfiguration) {
  50503. return;
  50504. }
  50505. // Detaches observer.
  50506. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50507. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50508. }
  50509. // Pick the scene configuration if needed.
  50510. if (!configuration) {
  50511. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50512. }
  50513. else {
  50514. this._imageProcessingConfiguration = configuration;
  50515. }
  50516. // Attaches observer.
  50517. if (this._imageProcessingConfiguration) {
  50518. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50519. _this._computePrimaryColorFromPerceptualColor();
  50520. _this._markAllSubMeshesAsImageProcessingDirty();
  50521. });
  50522. }
  50523. };
  50524. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  50525. /**
  50526. * Gets the image processing configuration used either in this material.
  50527. */
  50528. get: function () {
  50529. return this._imageProcessingConfiguration;
  50530. },
  50531. /**
  50532. * Sets the Default image processing configuration used either in the this material.
  50533. *
  50534. * If sets to null, the scene one is in use.
  50535. */
  50536. set: function (value) {
  50537. this._attachImageProcessingConfiguration(value);
  50538. // Ensure the effect will be rebuilt.
  50539. this._markAllSubMeshesAsTexturesDirty();
  50540. },
  50541. enumerable: true,
  50542. configurable: true
  50543. });
  50544. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  50545. /**
  50546. * Gets wether the color curves effect is enabled.
  50547. */
  50548. get: function () {
  50549. return this.imageProcessingConfiguration.colorCurvesEnabled;
  50550. },
  50551. /**
  50552. * Sets wether the color curves effect is enabled.
  50553. */
  50554. set: function (value) {
  50555. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  50556. },
  50557. enumerable: true,
  50558. configurable: true
  50559. });
  50560. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  50561. /**
  50562. * Gets wether the color grading effect is enabled.
  50563. */
  50564. get: function () {
  50565. return this.imageProcessingConfiguration.colorGradingEnabled;
  50566. },
  50567. /**
  50568. * Gets wether the color grading effect is enabled.
  50569. */
  50570. set: function (value) {
  50571. this.imageProcessingConfiguration.colorGradingEnabled = value;
  50572. },
  50573. enumerable: true,
  50574. configurable: true
  50575. });
  50576. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  50577. /**
  50578. * Gets wether tonemapping is enabled or not.
  50579. */
  50580. get: function () {
  50581. return this._imageProcessingConfiguration.toneMappingEnabled;
  50582. },
  50583. /**
  50584. * Sets wether tonemapping is enabled or not
  50585. */
  50586. set: function (value) {
  50587. this._imageProcessingConfiguration.toneMappingEnabled = value;
  50588. },
  50589. enumerable: true,
  50590. configurable: true
  50591. });
  50592. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  50593. /**
  50594. * The camera exposure used on this material.
  50595. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50596. * This corresponds to a photographic exposure.
  50597. */
  50598. get: function () {
  50599. return this._imageProcessingConfiguration.exposure;
  50600. },
  50601. /**
  50602. * The camera exposure used on this material.
  50603. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50604. * This corresponds to a photographic exposure.
  50605. */
  50606. set: function (value) {
  50607. this._imageProcessingConfiguration.exposure = value;
  50608. },
  50609. enumerable: true,
  50610. configurable: true
  50611. });
  50612. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  50613. /**
  50614. * Gets The camera contrast used on this material.
  50615. */
  50616. get: function () {
  50617. return this._imageProcessingConfiguration.contrast;
  50618. },
  50619. /**
  50620. * Sets The camera contrast used on this material.
  50621. */
  50622. set: function (value) {
  50623. this._imageProcessingConfiguration.contrast = value;
  50624. },
  50625. enumerable: true,
  50626. configurable: true
  50627. });
  50628. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  50629. /**
  50630. * Gets the Color Grading 2D Lookup Texture.
  50631. */
  50632. get: function () {
  50633. return this._imageProcessingConfiguration.colorGradingTexture;
  50634. },
  50635. /**
  50636. * Sets the Color Grading 2D Lookup Texture.
  50637. */
  50638. set: function (value) {
  50639. this.imageProcessingConfiguration.colorGradingTexture = value;
  50640. },
  50641. enumerable: true,
  50642. configurable: true
  50643. });
  50644. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  50645. /**
  50646. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50647. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50648. * 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;
  50649. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50650. */
  50651. get: function () {
  50652. return this.imageProcessingConfiguration.colorCurves;
  50653. },
  50654. /**
  50655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50657. * 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;
  50658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50659. */
  50660. set: function (value) {
  50661. this.imageProcessingConfiguration.colorCurves = value;
  50662. },
  50663. enumerable: true,
  50664. configurable: true
  50665. });
  50666. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  50667. /**
  50668. * Gets a boolean indicating that current material needs to register RTT
  50669. */
  50670. get: function () {
  50671. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50672. return true;
  50673. }
  50674. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50675. return true;
  50676. }
  50677. return false;
  50678. },
  50679. enumerable: true,
  50680. configurable: true
  50681. });
  50682. /**
  50683. * The entire material has been created in order to prevent overdraw.
  50684. * @returns false
  50685. */
  50686. BackgroundMaterial.prototype.needAlphaTesting = function () {
  50687. return true;
  50688. };
  50689. /**
  50690. * The entire material has been created in order to prevent overdraw.
  50691. * @returns true if blending is enable
  50692. */
  50693. BackgroundMaterial.prototype.needAlphaBlending = function () {
  50694. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  50695. };
  50696. /**
  50697. * Checks wether the material is ready to be rendered for a given mesh.
  50698. * @param mesh The mesh to render
  50699. * @param subMesh The submesh to check against
  50700. * @param useInstances Specify wether or not the material is used with instances
  50701. * @returns true if all the dependencies are ready (Textures, Effects...)
  50702. */
  50703. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  50704. var _this = this;
  50705. if (useInstances === void 0) { useInstances = false; }
  50706. if (subMesh.effect && this.isFrozen) {
  50707. if (this._wasPreviouslyReady) {
  50708. return true;
  50709. }
  50710. }
  50711. if (!subMesh._materialDefines) {
  50712. subMesh._materialDefines = new BackgroundMaterialDefines();
  50713. }
  50714. var scene = this.getScene();
  50715. var defines = subMesh._materialDefines;
  50716. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  50717. if (defines._renderId === scene.getRenderId()) {
  50718. return true;
  50719. }
  50720. }
  50721. var engine = scene.getEngine();
  50722. // Lights
  50723. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  50724. defines._needNormals = true;
  50725. // Multiview
  50726. if (scene.activeCamera) {
  50727. var previousMultiview = defines.MULTIVIEW;
  50728. defines.MULTIVIEW = (scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1);
  50729. if (defines.MULTIVIEW != previousMultiview) {
  50730. defines.markAsUnprocessed();
  50731. }
  50732. }
  50733. // Textures
  50734. if (defines._areTexturesDirty) {
  50735. defines._needUVs = false;
  50736. if (scene.texturesEnabled) {
  50737. if (scene.getEngine().getCaps().textureLOD) {
  50738. defines.TEXTURELODSUPPORT = true;
  50739. }
  50740. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50741. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  50742. return false;
  50743. }
  50744. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  50745. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  50746. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  50747. defines.OPACITYFRESNEL = this._opacityFresnel;
  50748. }
  50749. else {
  50750. defines.DIFFUSE = false;
  50751. defines.DIFFUSEHASALPHA = false;
  50752. defines.GAMMADIFFUSE = false;
  50753. defines.OPACITYFRESNEL = false;
  50754. }
  50755. var reflectionTexture = this._reflectionTexture;
  50756. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50757. if (!reflectionTexture.isReadyOrNotBlocking()) {
  50758. return false;
  50759. }
  50760. defines.REFLECTION = true;
  50761. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  50762. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  50763. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  50764. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  50765. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  50766. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  50767. defines.REFLECTIONBGR = this.switchToBGR;
  50768. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  50769. defines.INVERTCUBICMAP = true;
  50770. }
  50771. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  50772. switch (reflectionTexture.coordinatesMode) {
  50773. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  50774. defines.REFLECTIONMAP_EXPLICIT = true;
  50775. break;
  50776. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  50777. defines.REFLECTIONMAP_PLANAR = true;
  50778. break;
  50779. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  50780. defines.REFLECTIONMAP_PROJECTION = true;
  50781. break;
  50782. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  50783. defines.REFLECTIONMAP_SKYBOX = true;
  50784. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  50785. break;
  50786. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  50787. defines.REFLECTIONMAP_SPHERICAL = true;
  50788. break;
  50789. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  50790. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  50791. break;
  50792. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  50793. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  50794. break;
  50795. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  50796. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  50797. break;
  50798. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  50799. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  50800. default:
  50801. defines.REFLECTIONMAP_CUBIC = true;
  50802. break;
  50803. }
  50804. if (this.reflectionFresnel) {
  50805. defines.REFLECTIONFRESNEL = true;
  50806. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  50807. this._reflectionControls.x = this.reflectionAmount;
  50808. this._reflectionControls.y = this.reflectionReflectance0;
  50809. this._reflectionControls.z = this.reflectionReflectance90;
  50810. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  50811. }
  50812. else {
  50813. defines.REFLECTIONFRESNEL = false;
  50814. defines.REFLECTIONFALLOFF = false;
  50815. }
  50816. }
  50817. else {
  50818. defines.REFLECTION = false;
  50819. defines.REFLECTIONFRESNEL = false;
  50820. defines.REFLECTIONFALLOFF = false;
  50821. defines.REFLECTIONBLUR = false;
  50822. defines.REFLECTIONMAP_3D = false;
  50823. defines.REFLECTIONMAP_SPHERICAL = false;
  50824. defines.REFLECTIONMAP_PLANAR = false;
  50825. defines.REFLECTIONMAP_CUBIC = false;
  50826. defines.REFLECTIONMAP_PROJECTION = false;
  50827. defines.REFLECTIONMAP_SKYBOX = false;
  50828. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50829. defines.REFLECTIONMAP_EXPLICIT = false;
  50830. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50831. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50832. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50833. defines.INVERTCUBICMAP = false;
  50834. defines.REFLECTIONMAP_OPPOSITEZ = false;
  50835. defines.LODINREFLECTIONALPHA = false;
  50836. defines.GAMMAREFLECTION = false;
  50837. defines.RGBDREFLECTION = false;
  50838. }
  50839. }
  50840. 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);
  50841. defines.USERGBCOLOR = this._useRGBColor;
  50842. defines.NOISE = this._enableNoise;
  50843. }
  50844. if (defines._areLightsDirty) {
  50845. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  50846. }
  50847. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50848. if (!this._imageProcessingConfiguration.isReady()) {
  50849. return false;
  50850. }
  50851. this._imageProcessingConfiguration.prepareDefines(defines);
  50852. }
  50853. // Misc.
  50854. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  50855. // Values that need to be evaluated on every frame
  50856. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  50857. // Attribs
  50858. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  50859. if (mesh) {
  50860. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  50861. mesh.createNormals(true);
  50862. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  50863. }
  50864. }
  50865. }
  50866. // Get correct effect
  50867. if (defines.isDirty) {
  50868. defines.markAsProcessed();
  50869. scene.resetCachedMaterial();
  50870. // Fallbacks
  50871. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  50872. if (defines.FOG) {
  50873. fallbacks.addFallback(0, "FOG");
  50874. }
  50875. if (defines.POINTSIZE) {
  50876. fallbacks.addFallback(1, "POINTSIZE");
  50877. }
  50878. if (defines.MULTIVIEW) {
  50879. fallbacks.addFallback(0, "MULTIVIEW");
  50880. }
  50881. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  50882. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50883. fallbacks.addCPUSkinningFallback(0, mesh);
  50884. }
  50885. //Attributes
  50886. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  50887. if (defines.NORMAL) {
  50888. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  50889. }
  50890. if (defines.UV1) {
  50891. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  50892. }
  50893. if (defines.UV2) {
  50894. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  50895. }
  50896. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50897. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50898. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  50899. "vFogInfos", "vFogColor", "pointSize",
  50900. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  50901. "vPrimaryColor", "vPrimaryColorShadow",
  50902. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  50903. "shadowLevel", "alpha",
  50904. "vBackgroundCenter", "vReflectionControl",
  50905. "vDiffuseInfos", "diffuseMatrix",
  50906. ];
  50907. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  50908. var uniformBuffers = ["Material", "Scene"];
  50909. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  50910. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50911. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50912. }
  50913. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50914. uniformsNames: uniforms,
  50915. uniformBuffersNames: uniformBuffers,
  50916. samplers: samplers,
  50917. defines: defines,
  50918. maxSimultaneousLights: this._maxSimultaneousLights
  50919. });
  50920. var onCompiled = function (effect) {
  50921. if (_this.onCompiled) {
  50922. _this.onCompiled(effect);
  50923. }
  50924. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  50925. };
  50926. var join = defines.toString();
  50927. subMesh.setEffect(scene.getEngine().createEffect("background", {
  50928. attributes: attribs,
  50929. uniformsNames: uniforms,
  50930. uniformBuffersNames: uniformBuffers,
  50931. samplers: samplers,
  50932. defines: join,
  50933. fallbacks: fallbacks,
  50934. onCompiled: onCompiled,
  50935. onError: this.onError,
  50936. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  50937. }, engine), defines);
  50938. this.buildUniformLayout();
  50939. }
  50940. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50941. return false;
  50942. }
  50943. defines._renderId = scene.getRenderId();
  50944. this._wasPreviouslyReady = true;
  50945. return true;
  50946. };
  50947. /**
  50948. * Compute the primary color according to the chosen perceptual color.
  50949. */
  50950. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  50951. if (!this.__perceptualColor) {
  50952. return;
  50953. }
  50954. this._primaryColor.copyFrom(this.__perceptualColor);
  50955. // Revert gamma space.
  50956. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  50957. // Revert image processing configuration.
  50958. if (this._imageProcessingConfiguration) {
  50959. // Revert Exposure.
  50960. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  50961. }
  50962. this._computePrimaryColors();
  50963. };
  50964. /**
  50965. * Compute the highlights and shadow colors according to their chosen levels.
  50966. */
  50967. BackgroundMaterial.prototype._computePrimaryColors = function () {
  50968. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  50969. return;
  50970. }
  50971. // Find the highlight color based on the configuration.
  50972. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  50973. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  50974. // Find the shadow color based on the configuration.
  50975. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  50976. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  50977. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  50978. };
  50979. /**
  50980. * Build the uniform buffer used in the material.
  50981. */
  50982. BackgroundMaterial.prototype.buildUniformLayout = function () {
  50983. // Order is important !
  50984. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  50985. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  50986. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  50987. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50988. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  50989. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50990. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50991. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  50992. this._uniformBuffer.addUniform("pointSize", 1);
  50993. this._uniformBuffer.addUniform("shadowLevel", 1);
  50994. this._uniformBuffer.addUniform("alpha", 1);
  50995. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  50996. this._uniformBuffer.addUniform("vReflectionControl", 4);
  50997. this._uniformBuffer.create();
  50998. };
  50999. /**
  51000. * Unbind the material.
  51001. */
  51002. BackgroundMaterial.prototype.unbind = function () {
  51003. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  51004. this._uniformBuffer.setTexture("diffuseSampler", null);
  51005. }
  51006. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51007. this._uniformBuffer.setTexture("reflectionSampler", null);
  51008. }
  51009. _super.prototype.unbind.call(this);
  51010. };
  51011. /**
  51012. * Bind only the world matrix to the material.
  51013. * @param world The world matrix to bind.
  51014. */
  51015. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  51016. this._activeEffect.setMatrix("world", world);
  51017. };
  51018. /**
  51019. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51020. * @param world The world matrix to bind.
  51021. * @param subMesh The submesh to bind for.
  51022. */
  51023. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51024. var scene = this.getScene();
  51025. var defines = subMesh._materialDefines;
  51026. if (!defines) {
  51027. return;
  51028. }
  51029. var effect = subMesh.effect;
  51030. if (!effect) {
  51031. return;
  51032. }
  51033. this._activeEffect = effect;
  51034. // Matrices
  51035. this.bindOnlyWorldMatrix(world);
  51036. // Bones
  51037. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51038. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51039. if (mustRebind) {
  51040. this._uniformBuffer.bindToEffect(effect, "Material");
  51041. this.bindViewProjection(effect);
  51042. var reflectionTexture = this._reflectionTexture;
  51043. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51044. // Texture uniforms
  51045. if (scene.texturesEnabled) {
  51046. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51047. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  51048. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  51049. }
  51050. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51051. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51052. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  51053. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51054. }
  51055. }
  51056. if (this.shadowLevel > 0) {
  51057. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  51058. }
  51059. this._uniformBuffer.updateFloat("alpha", this.alpha);
  51060. // Point size
  51061. if (this.pointsCloud) {
  51062. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51063. }
  51064. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  51065. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  51066. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  51067. }
  51068. else {
  51069. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  51070. }
  51071. }
  51072. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  51073. // Textures
  51074. if (scene.texturesEnabled) {
  51075. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51076. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  51077. }
  51078. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51079. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  51080. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51081. }
  51082. else if (!defines.REFLECTIONBLUR) {
  51083. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51084. }
  51085. else {
  51086. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51087. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51088. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51089. }
  51090. if (defines.REFLECTIONFRESNEL) {
  51091. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  51092. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  51093. }
  51094. }
  51095. }
  51096. // Clip plane
  51097. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51098. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  51099. }
  51100. if (mustRebind || !this.isFrozen) {
  51101. if (scene.lightsEnabled) {
  51102. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  51103. }
  51104. // View
  51105. this.bindView(effect);
  51106. // Fog
  51107. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51108. // image processing
  51109. if (this._imageProcessingConfiguration) {
  51110. this._imageProcessingConfiguration.bind(this._activeEffect);
  51111. }
  51112. }
  51113. this._uniformBuffer.update();
  51114. this._afterBind(mesh, this._activeEffect);
  51115. };
  51116. /**
  51117. * Dispose the material.
  51118. * @param forceDisposeEffect Force disposal of the associated effect.
  51119. * @param forceDisposeTextures Force disposal of the associated textures.
  51120. */
  51121. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51122. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  51123. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  51124. if (forceDisposeTextures) {
  51125. if (this.diffuseTexture) {
  51126. this.diffuseTexture.dispose();
  51127. }
  51128. if (this.reflectionTexture) {
  51129. this.reflectionTexture.dispose();
  51130. }
  51131. }
  51132. this._renderTargets.dispose();
  51133. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51134. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51135. }
  51136. _super.prototype.dispose.call(this, forceDisposeEffect);
  51137. };
  51138. /**
  51139. * Clones the material.
  51140. * @param name The cloned name.
  51141. * @returns The cloned material.
  51142. */
  51143. BackgroundMaterial.prototype.clone = function (name) {
  51144. var _this = this;
  51145. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  51146. };
  51147. /**
  51148. * Serializes the current material to its JSON representation.
  51149. * @returns The JSON representation.
  51150. */
  51151. BackgroundMaterial.prototype.serialize = function () {
  51152. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51153. serializationObject.customType = "BABYLON.BackgroundMaterial";
  51154. return serializationObject;
  51155. };
  51156. /**
  51157. * Gets the class name of the material
  51158. * @returns "BackgroundMaterial"
  51159. */
  51160. BackgroundMaterial.prototype.getClassName = function () {
  51161. return "BackgroundMaterial";
  51162. };
  51163. /**
  51164. * Parse a JSON input to create back a background material.
  51165. * @param source The JSON data to parse
  51166. * @param scene The scene to create the parsed material in
  51167. * @param rootUrl The root url of the assets the material depends upon
  51168. * @returns the instantiated BackgroundMaterial.
  51169. */
  51170. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  51171. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  51172. };
  51173. /**
  51174. * Standard reflectance value at parallel view angle.
  51175. */
  51176. BackgroundMaterial.StandardReflectance0 = 0.05;
  51177. /**
  51178. * Standard reflectance value at grazing angle.
  51179. */
  51180. BackgroundMaterial.StandardReflectance90 = 0.5;
  51181. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51182. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51183. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  51184. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51185. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51186. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  51187. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51188. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51189. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  51190. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51191. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51192. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  51193. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51194. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51195. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  51196. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51197. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51198. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  51199. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51200. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51201. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  51202. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51203. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51204. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  51205. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51206. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51207. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  51208. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51210. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  51211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51213. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  51214. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51215. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51216. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  51217. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51218. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51219. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  51220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51222. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  51223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51225. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  51226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  51228. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  51229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51231. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  51232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51234. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  51235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51237. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  51238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51240. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  51241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51243. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  51244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51246. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  51247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51249. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  51250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51252. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  51253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51255. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  51256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51258. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  51259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51261. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  51262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51264. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  51265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51267. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  51268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51270. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  51271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51273. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  51274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51276. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  51277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51279. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  51280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51282. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  51283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51285. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  51286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51288. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51289. return BackgroundMaterial;
  51290. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  51291. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  51292. /***/ }),
  51293. /***/ "./Materials/Background/index.ts":
  51294. /*!***************************************!*\
  51295. !*** ./Materials/Background/index.ts ***!
  51296. \***************************************/
  51297. /*! exports provided: BackgroundMaterial */
  51298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51299. "use strict";
  51300. __webpack_require__.r(__webpack_exports__);
  51301. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  51302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  51303. /***/ }),
  51304. /***/ "./Materials/PBR/index.ts":
  51305. /*!********************************!*\
  51306. !*** ./Materials/PBR/index.ts ***!
  51307. \********************************/
  51308. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  51309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51310. "use strict";
  51311. __webpack_require__.r(__webpack_exports__);
  51312. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  51314. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  51315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  51316. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  51317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  51318. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  51319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  51320. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  51321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  51322. /***/ }),
  51323. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  51324. /*!******************************************************!*\
  51325. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  51326. \******************************************************/
  51327. /*! exports provided: PBRAnisotropicConfiguration */
  51328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51329. "use strict";
  51330. __webpack_require__.r(__webpack_exports__);
  51331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  51332. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51333. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51334. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51335. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51336. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  51337. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51338. /**
  51339. * Define the code related to the anisotropic parameters of the pbr material.
  51340. */
  51341. var PBRAnisotropicConfiguration = /** @class */ (function () {
  51342. /**
  51343. * Instantiate a new istance of anisotropy configuration.
  51344. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51345. */
  51346. function PBRAnisotropicConfiguration(markAllSubMeshesAsTexturesDirty) {
  51347. this._isEnabled = false;
  51348. /**
  51349. * Defines if the anisotropy is enabled in the material.
  51350. */
  51351. this.isEnabled = false;
  51352. /**
  51353. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51354. */
  51355. this.intensity = 1;
  51356. /**
  51357. * Defines if the effect is along the tangents, bitangents or in between.
  51358. * By default, the effect is "strectching" the highlights along the tangents.
  51359. */
  51360. this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0);
  51361. this._texture = null;
  51362. /**
  51363. * Stores the anisotropy values in a texture.
  51364. * rg is direction (like normal from -1 to 1)
  51365. * b is a intensity
  51366. */
  51367. this.texture = null;
  51368. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  51369. }
  51370. /** @hidden */
  51371. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  51372. this._internalMarkAllSubMeshesAsTexturesDirty();
  51373. };
  51374. /**
  51375. * Specifies that the submesh is ready to be used.
  51376. * @param defines the list of "defines" to update.
  51377. * @param scene defines the scene the material belongs to.
  51378. * @returns - boolean indicating that the submesh is ready or not.
  51379. */
  51380. PBRAnisotropicConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  51381. if (defines._areTexturesDirty) {
  51382. if (scene.texturesEnabled) {
  51383. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51384. if (!this._texture.isReadyOrNotBlocking()) {
  51385. return false;
  51386. }
  51387. }
  51388. }
  51389. }
  51390. return true;
  51391. };
  51392. /**
  51393. * Checks to see if a texture is used in the material.
  51394. * @param defines the list of "defines" to update.
  51395. * @param mesh the mesh we are preparing the defines for.
  51396. * @param scene defines the scene the material belongs to.
  51397. */
  51398. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh, scene) {
  51399. if (this._isEnabled) {
  51400. defines.ANISOTROPIC = this._isEnabled;
  51401. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  51402. defines._needUVs = true;
  51403. defines.MAINUV1 = true;
  51404. }
  51405. if (defines._areTexturesDirty) {
  51406. if (scene.texturesEnabled) {
  51407. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51408. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "ANISOTROPIC_TEXTURE");
  51409. }
  51410. else {
  51411. defines.ANISOTROPIC_TEXTURE = false;
  51412. }
  51413. }
  51414. }
  51415. }
  51416. else {
  51417. defines.ANISOTROPIC = false;
  51418. defines.ANISOTROPIC_TEXTURE = false;
  51419. }
  51420. };
  51421. /**
  51422. * Binds the material data.
  51423. * @param uniformBuffer defines the Uniform buffer to fill in.
  51424. * @param scene defines the scene the material belongs to.
  51425. * @param isFrozen defines wether the material is frozen or not.
  51426. */
  51427. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  51428. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  51429. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51430. uniformBuffer.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level);
  51431. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "anisotropy");
  51432. }
  51433. // Anisotropy
  51434. uniformBuffer.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity);
  51435. }
  51436. // Textures
  51437. if (scene.texturesEnabled) {
  51438. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51439. uniformBuffer.setTexture("anisotropySampler", this._texture);
  51440. }
  51441. }
  51442. };
  51443. /**
  51444. * Checks to see if a texture is used in the material.
  51445. * @param texture - Base texture to use.
  51446. * @returns - Boolean specifying if a texture is used in the material.
  51447. */
  51448. PBRAnisotropicConfiguration.prototype.hasTexture = function (texture) {
  51449. if (this._texture === texture) {
  51450. return true;
  51451. }
  51452. return false;
  51453. };
  51454. /**
  51455. * Returns an array of the actively used textures.
  51456. * @param activeTextures Array of BaseTextures
  51457. */
  51458. PBRAnisotropicConfiguration.prototype.getActiveTextures = function (activeTextures) {
  51459. if (this._texture) {
  51460. activeTextures.push(this._texture);
  51461. }
  51462. };
  51463. /**
  51464. * Returns the animatable textures.
  51465. * @param animatables Array of animatable textures.
  51466. */
  51467. PBRAnisotropicConfiguration.prototype.getAnimatables = function (animatables) {
  51468. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  51469. animatables.push(this._texture);
  51470. }
  51471. };
  51472. /**
  51473. * Disposes the resources of the material.
  51474. * @param forceDisposeTextures - Forces the disposal of all textures.
  51475. */
  51476. PBRAnisotropicConfiguration.prototype.dispose = function (forceDisposeTextures) {
  51477. if (forceDisposeTextures) {
  51478. if (this._texture) {
  51479. this._texture.dispose();
  51480. }
  51481. }
  51482. };
  51483. /**
  51484. * Get the current class name of the texture useful for serialization or dynamic coding.
  51485. * @returns "PBRAnisotropicConfiguration"
  51486. */
  51487. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  51488. return "PBRAnisotropicConfiguration";
  51489. };
  51490. /**
  51491. * Add fallbacks to the effect fallbacks list.
  51492. * @param defines defines the Base texture to use.
  51493. * @param fallbacks defines the current fallback list.
  51494. * @param currentRank defines the current fallback rank.
  51495. * @returns the new fallback rank.
  51496. */
  51497. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  51498. if (defines.ANISOTROPIC) {
  51499. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  51500. }
  51501. return currentRank;
  51502. };
  51503. /**
  51504. * Add the required uniforms to the current list.
  51505. * @param uniforms defines the current uniform list.
  51506. */
  51507. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  51508. uniforms.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
  51509. };
  51510. /**
  51511. * Add the required uniforms to the current buffer.
  51512. * @param uniformBuffer defines the current uniform buffer.
  51513. */
  51514. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  51515. uniformBuffer.addUniform("vAnisotropy", 3);
  51516. uniformBuffer.addUniform("vAnisotropyInfos", 2);
  51517. uniformBuffer.addUniform("anisotropyMatrix", 16);
  51518. };
  51519. /**
  51520. * Add the required samplers to the current list.
  51521. * @param samplers defines the current sampler list.
  51522. */
  51523. PBRAnisotropicConfiguration.AddSamplers = function (samplers) {
  51524. samplers.push("anisotropySampler");
  51525. };
  51526. /**
  51527. * Makes a duplicate of the current configuration into another one.
  51528. * @param anisotropicConfiguration define the config where to copy the info
  51529. */
  51530. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  51531. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  51532. };
  51533. /**
  51534. * Serializes this anisotropy configuration.
  51535. * @returns - An object with the serialized config.
  51536. */
  51537. PBRAnisotropicConfiguration.prototype.serialize = function () {
  51538. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51539. };
  51540. /**
  51541. * Parses a anisotropy Configuration from a serialized object.
  51542. * @param source - Serialized object.
  51543. */
  51544. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  51545. var _this = this;
  51546. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51547. };
  51548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51550. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  51551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51553. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  51554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51556. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  51557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
  51559. ], PBRAnisotropicConfiguration.prototype, "direction", void 0);
  51560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51562. ], PBRAnisotropicConfiguration.prototype, "_texture", void 0);
  51563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51565. ], PBRAnisotropicConfiguration.prototype, "texture", void 0);
  51566. return PBRAnisotropicConfiguration;
  51567. }());
  51568. /***/ }),
  51569. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  51570. /*!***********************************************!*\
  51571. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  51572. \***********************************************/
  51573. /*! exports provided: PBRBRDFConfiguration */
  51574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51575. "use strict";
  51576. __webpack_require__.r(__webpack_exports__);
  51577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  51578. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51579. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51580. /**
  51581. * Define the code related to the BRDF parameters of the pbr material.
  51582. */
  51583. var PBRBRDFConfiguration = /** @class */ (function () {
  51584. /**
  51585. * Instantiate a new istance of clear coat configuration.
  51586. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51587. */
  51588. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  51589. this._useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51590. /**
  51591. * Defines if the material uses energy conservation.
  51592. */
  51593. this.useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51594. this._useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51595. /**
  51596. * LEGACY Mode set to false
  51597. * Defines if the material uses height smith correlated visibility term.
  51598. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51599. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51600. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51601. * Not relying on height correlated will also disable energy conservation.
  51602. */
  51603. this.useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51604. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  51605. }
  51606. /** @hidden */
  51607. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  51608. this._internalMarkAllSubMeshesAsMiscDirty();
  51609. };
  51610. /**
  51611. * Checks to see if a texture is used in the material.
  51612. * @param defines the list of "defines" to update.
  51613. */
  51614. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  51615. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  51616. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  51617. };
  51618. /**
  51619. * Get the current class name of the texture useful for serialization or dynamic coding.
  51620. * @returns "PBRClearCoatConfiguration"
  51621. */
  51622. PBRBRDFConfiguration.prototype.getClassName = function () {
  51623. return "PBRClearCoatConfiguration";
  51624. };
  51625. /**
  51626. * Makes a duplicate of the current configuration into another one.
  51627. * @param brdfConfiguration define the config where to copy the info
  51628. */
  51629. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  51630. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  51631. };
  51632. /**
  51633. * Serializes this BRDF configuration.
  51634. * @returns - An object with the serialized config.
  51635. */
  51636. PBRBRDFConfiguration.prototype.serialize = function () {
  51637. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51638. };
  51639. /**
  51640. * Parses a BRDF Configuration from a serialized object.
  51641. * @param source - Serialized object.
  51642. */
  51643. PBRBRDFConfiguration.prototype.parse = function (source) {
  51644. var _this = this;
  51645. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51646. };
  51647. /**
  51648. * Default value used for the energy conservation.
  51649. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51650. */
  51651. PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION = true;
  51652. /**
  51653. * Default value used for the Smith Visibility Height Correlated mode.
  51654. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51655. */
  51656. PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = true;
  51657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51659. ], PBRBRDFConfiguration.prototype, "_useEnergyConservation", void 0);
  51660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51662. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  51663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51665. ], PBRBRDFConfiguration.prototype, "_useSmithVisibilityHeightCorrelated", void 0);
  51666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51668. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  51669. return PBRBRDFConfiguration;
  51670. }());
  51671. /***/ }),
  51672. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  51673. /*!******************************************!*\
  51674. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  51675. \******************************************/
  51676. /*! exports provided: PBRBaseMaterial */
  51677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51678. "use strict";
  51679. __webpack_require__.r(__webpack_exports__);
  51680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  51681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51682. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51683. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  51684. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  51685. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  51686. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  51687. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51688. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51689. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  51690. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  51691. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  51692. /* harmony import */ var _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./pbrSheenConfiguration */ "./Materials/PBR/pbrSheenConfiguration.ts");
  51693. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  51694. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  51695. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  51696. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  51697. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51698. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  51699. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  51700. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  51701. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  51702. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  51703. /**
  51704. * Manages the defines for the PBR Material.
  51705. * @hiddenChildren
  51706. */
  51707. var PBRMaterialDefines = /** @class */ (function (_super) {
  51708. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  51709. /**
  51710. * Initializes the PBR Material defines.
  51711. */
  51712. function PBRMaterialDefines() {
  51713. var _this = _super.call(this) || this;
  51714. _this.PBR = true;
  51715. _this.MAINUV1 = false;
  51716. _this.MAINUV2 = false;
  51717. _this.UV1 = false;
  51718. _this.UV2 = false;
  51719. _this.ALBEDO = false;
  51720. _this.ALBEDODIRECTUV = 0;
  51721. _this.VERTEXCOLOR = false;
  51722. _this.AMBIENT = false;
  51723. _this.AMBIENTDIRECTUV = 0;
  51724. _this.AMBIENTINGRAYSCALE = false;
  51725. _this.OPACITY = false;
  51726. _this.VERTEXALPHA = false;
  51727. _this.OPACITYDIRECTUV = 0;
  51728. _this.OPACITYRGB = false;
  51729. _this.ALPHATEST = false;
  51730. _this.DEPTHPREPASS = false;
  51731. _this.ALPHABLEND = false;
  51732. _this.ALPHAFROMALBEDO = false;
  51733. _this.ALPHATESTVALUE = "0.5";
  51734. _this.SPECULAROVERALPHA = false;
  51735. _this.RADIANCEOVERALPHA = false;
  51736. _this.ALPHAFRESNEL = false;
  51737. _this.LINEARALPHAFRESNEL = false;
  51738. _this.PREMULTIPLYALPHA = false;
  51739. _this.EMISSIVE = false;
  51740. _this.EMISSIVEDIRECTUV = 0;
  51741. _this.REFLECTIVITY = false;
  51742. _this.REFLECTIVITYDIRECTUV = 0;
  51743. _this.SPECULARTERM = false;
  51744. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  51745. _this.MICROSURFACEAUTOMATIC = false;
  51746. _this.LODBASEDMICROSFURACE = false;
  51747. _this.MICROSURFACEMAP = false;
  51748. _this.MICROSURFACEMAPDIRECTUV = 0;
  51749. _this.METALLICWORKFLOW = false;
  51750. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  51751. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  51752. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  51753. _this.AOSTOREINMETALMAPRED = false;
  51754. _this.ENVIRONMENTBRDF = false;
  51755. _this.ENVIRONMENTBRDF_RGBD = false;
  51756. _this.NORMAL = false;
  51757. _this.TANGENT = false;
  51758. _this.BUMP = false;
  51759. _this.BUMPDIRECTUV = 0;
  51760. _this.OBJECTSPACE_NORMALMAP = false;
  51761. _this.PARALLAX = false;
  51762. _this.PARALLAXOCCLUSION = false;
  51763. _this.NORMALXYSCALE = true;
  51764. _this.LIGHTMAP = false;
  51765. _this.LIGHTMAPDIRECTUV = 0;
  51766. _this.USELIGHTMAPASSHADOWMAP = false;
  51767. _this.GAMMALIGHTMAP = false;
  51768. _this.REFLECTION = false;
  51769. _this.REFLECTIONMAP_3D = false;
  51770. _this.REFLECTIONMAP_SPHERICAL = false;
  51771. _this.REFLECTIONMAP_PLANAR = false;
  51772. _this.REFLECTIONMAP_CUBIC = false;
  51773. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51774. _this.REFLECTIONMAP_PROJECTION = false;
  51775. _this.REFLECTIONMAP_SKYBOX = false;
  51776. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51777. _this.REFLECTIONMAP_EXPLICIT = false;
  51778. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51779. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51780. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51781. _this.INVERTCUBICMAP = false;
  51782. _this.USESPHERICALFROMREFLECTIONMAP = false;
  51783. _this.USESPHERICALINVERTEX = false;
  51784. _this.REFLECTIONMAP_OPPOSITEZ = false;
  51785. _this.LODINREFLECTIONALPHA = false;
  51786. _this.GAMMAREFLECTION = false;
  51787. _this.RGBDREFLECTION = false;
  51788. _this.RADIANCEOCCLUSION = false;
  51789. _this.HORIZONOCCLUSION = false;
  51790. _this.REFRACTION = false;
  51791. _this.REFRACTIONMAP_3D = false;
  51792. _this.REFRACTIONMAP_OPPOSITEZ = false;
  51793. _this.LODINREFRACTIONALPHA = false;
  51794. _this.GAMMAREFRACTION = false;
  51795. _this.RGBDREFRACTION = false;
  51796. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  51797. _this.INSTANCES = false;
  51798. _this.NUM_BONE_INFLUENCERS = 0;
  51799. _this.BonesPerMesh = 0;
  51800. _this.BONETEXTURE = false;
  51801. _this.NONUNIFORMSCALING = false;
  51802. _this.MORPHTARGETS = false;
  51803. _this.MORPHTARGETS_NORMAL = false;
  51804. _this.MORPHTARGETS_TANGENT = false;
  51805. _this.NUM_MORPH_INFLUENCERS = 0;
  51806. _this.IMAGEPROCESSING = false;
  51807. _this.VIGNETTE = false;
  51808. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  51809. _this.VIGNETTEBLENDMODEOPAQUE = false;
  51810. _this.TONEMAPPING = false;
  51811. _this.TONEMAPPING_ACES = false;
  51812. _this.CONTRAST = false;
  51813. _this.COLORCURVES = false;
  51814. _this.COLORGRADING = false;
  51815. _this.COLORGRADING3D = false;
  51816. _this.SAMPLER3DGREENDEPTH = false;
  51817. _this.SAMPLER3DBGRMAP = false;
  51818. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  51819. _this.EXPOSURE = false;
  51820. _this.MULTIVIEW = false;
  51821. _this.USEPHYSICALLIGHTFALLOFF = false;
  51822. _this.USEGLTFLIGHTFALLOFF = false;
  51823. _this.TWOSIDEDLIGHTING = false;
  51824. _this.SHADOWFLOAT = false;
  51825. _this.CLIPPLANE = false;
  51826. _this.CLIPPLANE2 = false;
  51827. _this.CLIPPLANE3 = false;
  51828. _this.CLIPPLANE4 = false;
  51829. _this.POINTSIZE = false;
  51830. _this.FOG = false;
  51831. _this.LOGARITHMICDEPTH = false;
  51832. _this.FORCENORMALFORWARD = false;
  51833. _this.SPECULARAA = false;
  51834. _this.CLEARCOAT = false;
  51835. _this.CLEARCOAT_DEFAULTIOR = false;
  51836. _this.CLEARCOAT_TEXTURE = false;
  51837. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  51838. _this.CLEARCOAT_BUMP = false;
  51839. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  51840. _this.CLEARCOAT_TINT = false;
  51841. _this.CLEARCOAT_TINT_TEXTURE = false;
  51842. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  51843. _this.ANISOTROPIC = false;
  51844. _this.ANISOTROPIC_TEXTURE = false;
  51845. _this.ANISOTROPIC_TEXTUREDIRECTUV = 0;
  51846. _this.BRDF_V_HEIGHT_CORRELATED = false;
  51847. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  51848. _this.SHEEN = false;
  51849. _this.SHEEN_TEXTURE = false;
  51850. _this.SHEEN_TEXTUREDIRECTUV = 0;
  51851. _this.SHEEN_LINKWITHALBEDO = false;
  51852. _this.UNLIT = false;
  51853. _this.DEBUGMODE = 0;
  51854. _this.rebuild();
  51855. return _this;
  51856. }
  51857. /**
  51858. * Resets the PBR Material defines.
  51859. */
  51860. PBRMaterialDefines.prototype.reset = function () {
  51861. _super.prototype.reset.call(this);
  51862. this.ALPHATESTVALUE = "0.5";
  51863. this.PBR = true;
  51864. };
  51865. return PBRMaterialDefines;
  51866. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_14__["MaterialDefines"]));
  51867. /**
  51868. * The Physically based material base class of BJS.
  51869. *
  51870. * This offers the main features of a standard PBR material.
  51871. * For more information, please refer to the documentation :
  51872. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  51873. */
  51874. var PBRBaseMaterial = /** @class */ (function (_super) {
  51875. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  51876. /**
  51877. * Instantiates a new PBRMaterial instance.
  51878. *
  51879. * @param name The material name
  51880. * @param scene The scene the material will be use in.
  51881. */
  51882. function PBRBaseMaterial(name, scene) {
  51883. var _this = _super.call(this, name, scene) || this;
  51884. /**
  51885. * Intensity of the direct lights e.g. the four lights available in your scene.
  51886. * This impacts both the direct diffuse and specular highlights.
  51887. */
  51888. _this._directIntensity = 1.0;
  51889. /**
  51890. * Intensity of the emissive part of the material.
  51891. * This helps controlling the emissive effect without modifying the emissive color.
  51892. */
  51893. _this._emissiveIntensity = 1.0;
  51894. /**
  51895. * Intensity of the environment e.g. how much the environment will light the object
  51896. * either through harmonics for rough material or through the refelction for shiny ones.
  51897. */
  51898. _this._environmentIntensity = 1.0;
  51899. /**
  51900. * This is a special control allowing the reduction of the specular highlights coming from the
  51901. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51902. */
  51903. _this._specularIntensity = 1.0;
  51904. /**
  51905. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51906. */
  51907. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  51908. /**
  51909. * Debug Control allowing disabling the bump map on this material.
  51910. */
  51911. _this._disableBumpMap = false;
  51912. /**
  51913. * AKA Occlusion Texture Intensity in other nomenclature.
  51914. */
  51915. _this._ambientTextureStrength = 1.0;
  51916. /**
  51917. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51918. * 1 means it completely occludes it
  51919. * 0 mean it has no impact
  51920. */
  51921. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51922. /**
  51923. * The color of a material in ambient lighting.
  51924. */
  51925. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51926. /**
  51927. * AKA Diffuse Color in other nomenclature.
  51928. */
  51929. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51930. /**
  51931. * AKA Specular Color in other nomenclature.
  51932. */
  51933. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51934. /**
  51935. * The color applied when light is reflected from a material.
  51936. */
  51937. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51938. /**
  51939. * The color applied when light is emitted from a material.
  51940. */
  51941. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51942. /**
  51943. * AKA Glossiness in other nomenclature.
  51944. */
  51945. _this._microSurface = 0.9;
  51946. /**
  51947. * source material index of refraction (IOR)' / 'destination material IOR.
  51948. */
  51949. _this._indexOfRefraction = 0.66;
  51950. /**
  51951. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51952. */
  51953. _this._invertRefractionY = false;
  51954. /**
  51955. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51956. * Materials half opaque for instance using refraction could benefit from this control.
  51957. */
  51958. _this._linkRefractionWithTransparency = false;
  51959. /**
  51960. * Specifies that the material will use the light map as a show map.
  51961. */
  51962. _this._useLightmapAsShadowmap = false;
  51963. /**
  51964. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51965. * makes the reflect vector face the model (under horizon).
  51966. */
  51967. _this._useHorizonOcclusion = true;
  51968. /**
  51969. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51970. * too much the area relying on ambient texture to define their ambient occlusion.
  51971. */
  51972. _this._useRadianceOcclusion = true;
  51973. /**
  51974. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51975. */
  51976. _this._useAlphaFromAlbedoTexture = false;
  51977. /**
  51978. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51979. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51980. */
  51981. _this._useSpecularOverAlpha = true;
  51982. /**
  51983. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51984. */
  51985. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  51986. /**
  51987. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51988. */
  51989. _this._useRoughnessFromMetallicTextureAlpha = true;
  51990. /**
  51991. * Specifies if the metallic texture contains the roughness information in its green channel.
  51992. */
  51993. _this._useRoughnessFromMetallicTextureGreen = false;
  51994. /**
  51995. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51996. */
  51997. _this._useMetallnessFromMetallicTextureBlue = false;
  51998. /**
  51999. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52000. */
  52001. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  52002. /**
  52003. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52004. */
  52005. _this._useAmbientInGrayScale = false;
  52006. /**
  52007. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52008. * The material will try to infer what glossiness each pixel should be.
  52009. */
  52010. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  52011. /**
  52012. * Defines the falloff type used in this material.
  52013. * It by default is Physical.
  52014. */
  52015. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  52016. /**
  52017. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52018. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52019. */
  52020. _this._useRadianceOverAlpha = true;
  52021. /**
  52022. * Allows using an object space normal map (instead of tangent space).
  52023. */
  52024. _this._useObjectSpaceNormalMap = false;
  52025. /**
  52026. * Allows using the bump map in parallax mode.
  52027. */
  52028. _this._useParallax = false;
  52029. /**
  52030. * Allows using the bump map in parallax occlusion mode.
  52031. */
  52032. _this._useParallaxOcclusion = false;
  52033. /**
  52034. * Controls the scale bias of the parallax mode.
  52035. */
  52036. _this._parallaxScaleBias = 0.05;
  52037. /**
  52038. * If sets to true, disables all the lights affecting the material.
  52039. */
  52040. _this._disableLighting = false;
  52041. /**
  52042. * Number of Simultaneous lights allowed on the material.
  52043. */
  52044. _this._maxSimultaneousLights = 4;
  52045. /**
  52046. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52047. */
  52048. _this._invertNormalMapX = false;
  52049. /**
  52050. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52051. */
  52052. _this._invertNormalMapY = false;
  52053. /**
  52054. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52055. */
  52056. _this._twoSidedLighting = false;
  52057. /**
  52058. * Defines the alpha limits in alpha test mode.
  52059. */
  52060. _this._alphaCutOff = 0.4;
  52061. /**
  52062. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52063. */
  52064. _this._forceAlphaTest = false;
  52065. /**
  52066. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52067. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52068. */
  52069. _this._useAlphaFresnel = false;
  52070. /**
  52071. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52072. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52073. */
  52074. _this._useLinearAlphaFresnel = false;
  52075. /**
  52076. * The transparency mode of the material.
  52077. */
  52078. _this._transparencyMode = null;
  52079. /**
  52080. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52081. * from cos thetav and roughness:
  52082. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52083. */
  52084. _this._environmentBRDFTexture = null;
  52085. /**
  52086. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52087. */
  52088. _this._forceIrradianceInFragment = false;
  52089. /**
  52090. * Force normal to face away from face.
  52091. */
  52092. _this._forceNormalForward = false;
  52093. /**
  52094. * Enables specular anti aliasing in the PBR shader.
  52095. * It will both interacts on the Geometry for analytical and IBL lighting.
  52096. * It also prefilter the roughness map based on the bump values.
  52097. */
  52098. _this._enableSpecularAntiAliasing = false;
  52099. /**
  52100. * Stores the available render targets.
  52101. */
  52102. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  52103. /**
  52104. * Sets the global ambient color for the material used in lighting calculations.
  52105. */
  52106. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52107. /**
  52108. * If set to true, no lighting calculations will be applied.
  52109. */
  52110. _this._unlit = false;
  52111. _this._debugMode = 0;
  52112. /**
  52113. * @hidden
  52114. * This is reserved for the inspector.
  52115. * Defines the material debug mode.
  52116. * It helps seeing only some components of the material while troubleshooting.
  52117. */
  52118. _this.debugMode = 0;
  52119. /**
  52120. * @hidden
  52121. * This is reserved for the inspector.
  52122. * Specify from where on screen the debug mode should start.
  52123. * The value goes from -1 (full screen) to 1 (not visible)
  52124. * It helps with side by side comparison against the final render
  52125. * This defaults to -1
  52126. */
  52127. _this.debugLimit = -1;
  52128. /**
  52129. * @hidden
  52130. * This is reserved for the inspector.
  52131. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52132. * You can use the factor to better multiply the final value.
  52133. */
  52134. _this.debugFactor = 1;
  52135. /**
  52136. * Defines the clear coat layer parameters for the material.
  52137. */
  52138. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52139. /**
  52140. * Defines the anisotropic parameters for the material.
  52141. */
  52142. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52143. /**
  52144. * Defines the BRDF parameters for the material.
  52145. */
  52146. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  52147. /**
  52148. * Defines the Sheen parameters for the material.
  52149. */
  52150. _this.sheen = new _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52151. // Setup the default processing configuration to the scene.
  52152. _this._attachImageProcessingConfiguration(null);
  52153. _this.getRenderTargetTextures = function () {
  52154. _this._renderTargets.reset();
  52155. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  52156. _this._renderTargets.push(_this._reflectionTexture);
  52157. }
  52158. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  52159. _this._renderTargets.push(_this._refractionTexture);
  52160. }
  52161. return _this._renderTargets;
  52162. };
  52163. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  52164. return _this;
  52165. }
  52166. /**
  52167. * Attaches a new image processing configuration to the PBR Material.
  52168. * @param configuration
  52169. */
  52170. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  52171. var _this = this;
  52172. if (configuration === this._imageProcessingConfiguration) {
  52173. return;
  52174. }
  52175. // Detaches observer.
  52176. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  52177. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  52178. }
  52179. // Pick the scene configuration if needed.
  52180. if (!configuration) {
  52181. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  52182. }
  52183. else {
  52184. this._imageProcessingConfiguration = configuration;
  52185. }
  52186. // Attaches observer.
  52187. if (this._imageProcessingConfiguration) {
  52188. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  52189. _this._markAllSubMeshesAsImageProcessingDirty();
  52190. });
  52191. }
  52192. };
  52193. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  52194. /**
  52195. * Gets a boolean indicating that current material needs to register RTT
  52196. */
  52197. get: function () {
  52198. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52199. return true;
  52200. }
  52201. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  52202. return true;
  52203. }
  52204. return false;
  52205. },
  52206. enumerable: true,
  52207. configurable: true
  52208. });
  52209. /**
  52210. * Gets the name of the material class.
  52211. */
  52212. PBRBaseMaterial.prototype.getClassName = function () {
  52213. return "PBRBaseMaterial";
  52214. };
  52215. /**
  52216. * Gets the name of the material shader.
  52217. * @returns - string that specifies the shader program of the material.
  52218. */
  52219. PBRBaseMaterial.prototype.getShaderName = function () {
  52220. return "pbr";
  52221. };
  52222. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  52223. /**
  52224. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52225. */
  52226. get: function () {
  52227. return this._useLogarithmicDepth;
  52228. },
  52229. /**
  52230. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52231. */
  52232. set: function (value) {
  52233. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  52234. },
  52235. enumerable: true,
  52236. configurable: true
  52237. });
  52238. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  52239. /**
  52240. * Gets the current transparency mode.
  52241. */
  52242. get: function () {
  52243. return this._transparencyMode;
  52244. },
  52245. /**
  52246. * Sets the transparency mode of the material.
  52247. *
  52248. * | Value | Type | Description |
  52249. * | ----- | ----------------------------------- | ----------- |
  52250. * | 0 | OPAQUE | |
  52251. * | 1 | ALPHATEST | |
  52252. * | 2 | ALPHABLEND | |
  52253. * | 3 | ALPHATESTANDBLEND | |
  52254. *
  52255. */
  52256. set: function (value) {
  52257. if (this._transparencyMode === value) {
  52258. return;
  52259. }
  52260. this._transparencyMode = value;
  52261. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  52262. this._markAllSubMeshesAsTexturesAndMiscDirty();
  52263. },
  52264. enumerable: true,
  52265. configurable: true
  52266. });
  52267. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  52268. /**
  52269. * Returns true if alpha blending should be disabled.
  52270. */
  52271. get: function () {
  52272. return (this._linkRefractionWithTransparency ||
  52273. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  52274. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52275. },
  52276. enumerable: true,
  52277. configurable: true
  52278. });
  52279. /**
  52280. * Specifies whether or not this material should be rendered in alpha blend mode.
  52281. */
  52282. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  52283. if (this._disableAlphaBlending) {
  52284. return false;
  52285. }
  52286. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  52287. };
  52288. /**
  52289. * Specifies if the mesh will require alpha blending.
  52290. * @param mesh - BJS mesh.
  52291. */
  52292. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  52293. if (this._disableAlphaBlending && mesh.visibility >= 1.0) {
  52294. return false;
  52295. }
  52296. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  52297. };
  52298. /**
  52299. * Specifies whether or not this material should be rendered in alpha test mode.
  52300. */
  52301. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  52302. if (this._forceAlphaTest) {
  52303. return true;
  52304. }
  52305. if (this._linkRefractionWithTransparency) {
  52306. return false;
  52307. }
  52308. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52309. };
  52310. /**
  52311. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52312. */
  52313. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  52314. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  52315. };
  52316. /**
  52317. * Gets the texture used for the alpha test.
  52318. */
  52319. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  52320. return this._albedoTexture;
  52321. };
  52322. /**
  52323. * Specifies that the submesh is ready to be used.
  52324. * @param mesh - BJS mesh.
  52325. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52326. * @param useInstances - Specifies that instances should be used.
  52327. * @returns - boolean indicating that the submesh is ready or not.
  52328. */
  52329. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  52330. if (subMesh.effect && this.isFrozen) {
  52331. if (this._wasPreviouslyReady) {
  52332. return true;
  52333. }
  52334. }
  52335. if (!subMesh._materialDefines) {
  52336. subMesh._materialDefines = new PBRMaterialDefines();
  52337. }
  52338. var defines = subMesh._materialDefines;
  52339. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  52340. if (defines._renderId === this.getScene().getRenderId()) {
  52341. return true;
  52342. }
  52343. }
  52344. var scene = this.getScene();
  52345. var engine = scene.getEngine();
  52346. if (defines._areTexturesDirty) {
  52347. if (scene.texturesEnabled) {
  52348. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52349. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  52350. return false;
  52351. }
  52352. }
  52353. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52354. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  52355. return false;
  52356. }
  52357. }
  52358. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52359. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  52360. return false;
  52361. }
  52362. }
  52363. var reflectionTexture = this._getReflectionTexture();
  52364. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52365. if (!reflectionTexture.isReadyOrNotBlocking()) {
  52366. return false;
  52367. }
  52368. }
  52369. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52370. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  52371. return false;
  52372. }
  52373. }
  52374. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52375. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  52376. return false;
  52377. }
  52378. }
  52379. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52380. if (this._metallicTexture) {
  52381. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  52382. return false;
  52383. }
  52384. }
  52385. else if (this._reflectivityTexture) {
  52386. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  52387. return false;
  52388. }
  52389. }
  52390. if (this._microSurfaceTexture) {
  52391. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  52392. return false;
  52393. }
  52394. }
  52395. }
  52396. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52397. // Bump texture cannot be not blocking.
  52398. if (!this._bumpTexture.isReady()) {
  52399. return false;
  52400. }
  52401. }
  52402. var refractionTexture = this._getRefractionTexture();
  52403. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52404. if (!refractionTexture.isReadyOrNotBlocking()) {
  52405. return false;
  52406. }
  52407. }
  52408. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52409. // This is blocking.
  52410. if (!this._environmentBRDFTexture.isReady()) {
  52411. return false;
  52412. }
  52413. }
  52414. }
  52415. }
  52416. if (!this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap)) {
  52417. return false;
  52418. }
  52419. if (!this.sheen.isReadyForSubMesh(defines, scene)) {
  52420. return false;
  52421. }
  52422. if (!this.anisotropy.isReadyForSubMesh(defines, scene)) {
  52423. return false;
  52424. }
  52425. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52426. if (!this._imageProcessingConfiguration.isReady()) {
  52427. return false;
  52428. }
  52429. }
  52430. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  52431. mesh.createNormals(true);
  52432. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  52433. }
  52434. var previousEffect = subMesh.effect;
  52435. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  52436. if (effect) {
  52437. // Use previous effect while new one is compiling
  52438. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  52439. effect = previousEffect;
  52440. defines.markAsUnprocessed();
  52441. }
  52442. else {
  52443. scene.resetCachedMaterial();
  52444. subMesh.setEffect(effect, defines);
  52445. this.buildUniformLayout();
  52446. }
  52447. }
  52448. if (!subMesh.effect || !subMesh.effect.isReady()) {
  52449. return false;
  52450. }
  52451. defines._renderId = scene.getRenderId();
  52452. this._wasPreviouslyReady = true;
  52453. return true;
  52454. };
  52455. /**
  52456. * Specifies if the material uses metallic roughness workflow.
  52457. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52458. */
  52459. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  52460. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  52461. return true;
  52462. }
  52463. return false;
  52464. };
  52465. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  52466. if (onCompiled === void 0) { onCompiled = null; }
  52467. if (onError === void 0) { onError = null; }
  52468. if (useInstances === void 0) { useInstances = null; }
  52469. if (useClipPlane === void 0) { useClipPlane = null; }
  52470. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  52471. if (!defines.isDirty) {
  52472. return null;
  52473. }
  52474. defines.markAsProcessed();
  52475. var scene = this.getScene();
  52476. var engine = scene.getEngine();
  52477. // Fallbacks
  52478. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_13__["EffectFallbacks"]();
  52479. var fallbackRank = 0;
  52480. if (defines.USESPHERICALINVERTEX) {
  52481. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  52482. }
  52483. if (defines.FOG) {
  52484. fallbacks.addFallback(fallbackRank, "FOG");
  52485. }
  52486. if (defines.SPECULARAA) {
  52487. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  52488. }
  52489. if (defines.POINTSIZE) {
  52490. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  52491. }
  52492. if (defines.LOGARITHMICDEPTH) {
  52493. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  52494. }
  52495. if (defines.PARALLAX) {
  52496. fallbacks.addFallback(fallbackRank, "PARALLAX");
  52497. }
  52498. if (defines.PARALLAXOCCLUSION) {
  52499. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  52500. }
  52501. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52502. fallbackRank = _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52503. fallbackRank = _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52504. if (defines.ENVIRONMENTBRDF) {
  52505. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  52506. }
  52507. if (defines.TANGENT) {
  52508. fallbacks.addFallback(fallbackRank++, "TANGENT");
  52509. }
  52510. if (defines.BUMP) {
  52511. fallbacks.addFallback(fallbackRank++, "BUMP");
  52512. }
  52513. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  52514. if (defines.SPECULARTERM) {
  52515. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  52516. }
  52517. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  52518. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  52519. }
  52520. if (defines.LIGHTMAP) {
  52521. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  52522. }
  52523. if (defines.NORMAL) {
  52524. fallbacks.addFallback(fallbackRank++, "NORMAL");
  52525. }
  52526. if (defines.AMBIENT) {
  52527. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  52528. }
  52529. if (defines.EMISSIVE) {
  52530. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  52531. }
  52532. if (defines.VERTEXCOLOR) {
  52533. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  52534. }
  52535. if (defines.NUM_BONE_INFLUENCERS > 0) {
  52536. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  52537. }
  52538. if (defines.MORPHTARGETS) {
  52539. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  52540. }
  52541. if (defines.MULTIVIEW) {
  52542. fallbacks.addFallback(0, "MULTIVIEW");
  52543. }
  52544. //Attributes
  52545. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  52546. if (defines.NORMAL) {
  52547. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  52548. }
  52549. if (defines.TANGENT) {
  52550. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  52551. }
  52552. if (defines.UV1) {
  52553. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  52554. }
  52555. if (defines.UV2) {
  52556. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  52557. }
  52558. if (defines.VERTEXCOLOR) {
  52559. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  52560. }
  52561. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  52562. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  52563. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  52564. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "visibility", "vReflectionColor",
  52565. "vFogInfos", "vFogColor", "pointSize",
  52566. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  52567. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  52568. "mBones",
  52569. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  52570. "vLightingIntensity",
  52571. "logarithmicDepthConstant",
  52572. "vSphericalX", "vSphericalY", "vSphericalZ",
  52573. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  52574. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  52575. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  52576. "vTangentSpaceParams", "boneTextureWidth",
  52577. "vDebugMode"
  52578. ];
  52579. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  52580. "bumpSampler", "lightmapSampler", "opacitySampler",
  52581. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  52582. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  52583. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  52584. var uniformBuffers = ["Material", "Scene"];
  52585. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  52586. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  52587. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  52588. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddSamplers(samplers);
  52589. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddUniforms(uniforms);
  52590. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddSamplers(samplers);
  52591. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  52592. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  52593. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  52594. }
  52595. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareUniformsAndSamplersList({
  52596. uniformsNames: uniforms,
  52597. uniformBuffersNames: uniformBuffers,
  52598. samplers: samplers,
  52599. defines: defines,
  52600. maxSimultaneousLights: this._maxSimultaneousLights
  52601. });
  52602. var join = defines.toString();
  52603. return engine.createEffect(this.getShaderName(), {
  52604. attributes: attribs,
  52605. uniformsNames: uniforms,
  52606. uniformBuffersNames: uniformBuffers,
  52607. samplers: samplers,
  52608. defines: join,
  52609. fallbacks: fallbacks,
  52610. onCompiled: onCompiled,
  52611. onError: onError,
  52612. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  52613. }, engine);
  52614. };
  52615. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  52616. if (useInstances === void 0) { useInstances = null; }
  52617. if (useClipPlane === void 0) { useClipPlane = null; }
  52618. var scene = this.getScene();
  52619. var engine = scene.getEngine();
  52620. // Lights
  52621. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  52622. defines._needNormals = true;
  52623. // Multiview
  52624. if (scene.activeCamera) {
  52625. var previousMultiview = defines.MULTIVIEW;
  52626. defines.MULTIVIEW = (scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1);
  52627. if (defines.MULTIVIEW != previousMultiview) {
  52628. defines.markAsUnprocessed();
  52629. }
  52630. }
  52631. // Textures
  52632. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  52633. if (defines._areTexturesDirty) {
  52634. defines._needUVs = false;
  52635. if (scene.texturesEnabled) {
  52636. if (scene.getEngine().getCaps().textureLOD) {
  52637. defines.LODBASEDMICROSFURACE = true;
  52638. }
  52639. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52640. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  52641. }
  52642. else {
  52643. defines.ALBEDO = false;
  52644. }
  52645. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52646. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  52647. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  52648. }
  52649. else {
  52650. defines.AMBIENT = false;
  52651. }
  52652. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52653. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  52654. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  52655. }
  52656. else {
  52657. defines.OPACITY = false;
  52658. }
  52659. var reflectionTexture = this._getReflectionTexture();
  52660. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52661. defines.REFLECTION = true;
  52662. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  52663. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  52664. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  52665. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  52666. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].INVCUBIC_MODE) {
  52667. defines.INVERTCUBICMAP = true;
  52668. }
  52669. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  52670. defines.REFLECTIONMAP_CUBIC = false;
  52671. defines.REFLECTIONMAP_EXPLICIT = false;
  52672. defines.REFLECTIONMAP_PLANAR = false;
  52673. defines.REFLECTIONMAP_PROJECTION = false;
  52674. defines.REFLECTIONMAP_SKYBOX = false;
  52675. defines.REFLECTIONMAP_SPHERICAL = false;
  52676. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52677. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52678. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52679. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52680. switch (reflectionTexture.coordinatesMode) {
  52681. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].EXPLICIT_MODE:
  52682. defines.REFLECTIONMAP_EXPLICIT = true;
  52683. break;
  52684. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].PLANAR_MODE:
  52685. defines.REFLECTIONMAP_PLANAR = true;
  52686. break;
  52687. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].PROJECTION_MODE:
  52688. defines.REFLECTIONMAP_PROJECTION = true;
  52689. break;
  52690. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SKYBOX_MODE:
  52691. defines.REFLECTIONMAP_SKYBOX = true;
  52692. break;
  52693. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SPHERICAL_MODE:
  52694. defines.REFLECTIONMAP_SPHERICAL = true;
  52695. break;
  52696. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].EQUIRECTANGULAR_MODE:
  52697. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  52698. break;
  52699. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  52700. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  52701. break;
  52702. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  52703. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  52704. break;
  52705. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].CUBIC_MODE:
  52706. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].INVCUBIC_MODE:
  52707. default:
  52708. defines.REFLECTIONMAP_CUBIC = true;
  52709. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  52710. break;
  52711. }
  52712. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SKYBOX_MODE) {
  52713. if (reflectionTexture.sphericalPolynomial) {
  52714. defines.USESPHERICALFROMREFLECTIONMAP = true;
  52715. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  52716. defines.USESPHERICALINVERTEX = false;
  52717. }
  52718. else {
  52719. defines.USESPHERICALINVERTEX = true;
  52720. }
  52721. }
  52722. }
  52723. else {
  52724. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  52725. }
  52726. }
  52727. else {
  52728. defines.REFLECTION = false;
  52729. defines.REFLECTIONMAP_3D = false;
  52730. defines.REFLECTIONMAP_SPHERICAL = false;
  52731. defines.REFLECTIONMAP_PLANAR = false;
  52732. defines.REFLECTIONMAP_CUBIC = false;
  52733. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  52734. defines.REFLECTIONMAP_PROJECTION = false;
  52735. defines.REFLECTIONMAP_SKYBOX = false;
  52736. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52737. defines.REFLECTIONMAP_EXPLICIT = false;
  52738. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52739. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52740. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52741. defines.INVERTCUBICMAP = false;
  52742. defines.USESPHERICALFROMREFLECTIONMAP = false;
  52743. defines.USESPHERICALINVERTEX = false;
  52744. defines.REFLECTIONMAP_OPPOSITEZ = false;
  52745. defines.LODINREFLECTIONALPHA = false;
  52746. defines.GAMMAREFLECTION = false;
  52747. defines.RGBDREFLECTION = false;
  52748. }
  52749. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52750. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  52751. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  52752. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  52753. }
  52754. else {
  52755. defines.LIGHTMAP = false;
  52756. }
  52757. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52758. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  52759. }
  52760. else {
  52761. defines.EMISSIVE = false;
  52762. }
  52763. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52764. if (this._metallicTexture) {
  52765. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  52766. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  52767. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  52768. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  52769. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  52770. }
  52771. else if (this._reflectivityTexture) {
  52772. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  52773. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  52774. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  52775. }
  52776. else {
  52777. defines.REFLECTIVITY = false;
  52778. }
  52779. if (this._microSurfaceTexture) {
  52780. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  52781. }
  52782. else {
  52783. defines.MICROSURFACEMAP = false;
  52784. }
  52785. }
  52786. else {
  52787. defines.REFLECTIVITY = false;
  52788. defines.MICROSURFACEMAP = false;
  52789. }
  52790. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52791. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  52792. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52793. defines.PARALLAX = true;
  52794. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  52795. }
  52796. else {
  52797. defines.PARALLAX = false;
  52798. }
  52799. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  52800. }
  52801. else {
  52802. defines.BUMP = false;
  52803. }
  52804. var refractionTexture = this._getRefractionTexture();
  52805. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52806. defines.REFRACTION = true;
  52807. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  52808. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  52809. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  52810. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  52811. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  52812. if (this._linkRefractionWithTransparency) {
  52813. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  52814. }
  52815. }
  52816. else {
  52817. defines.REFRACTION = false;
  52818. }
  52819. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52820. defines.ENVIRONMENTBRDF = true;
  52821. // Not actual true RGBD, only the B chanel is encoded as RGBD for sheen.
  52822. defines.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD;
  52823. }
  52824. else {
  52825. defines.ENVIRONMENTBRDF = false;
  52826. defines.ENVIRONMENTBRDF_RGBD = false;
  52827. }
  52828. if (this._shouldUseAlphaFromAlbedoTexture()) {
  52829. defines.ALPHAFROMALBEDO = true;
  52830. }
  52831. else {
  52832. defines.ALPHAFROMALBEDO = false;
  52833. }
  52834. }
  52835. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  52836. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  52837. defines.USEPHYSICALLIGHTFALLOFF = false;
  52838. defines.USEGLTFLIGHTFALLOFF = false;
  52839. }
  52840. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  52841. defines.USEPHYSICALLIGHTFALLOFF = false;
  52842. defines.USEGLTFLIGHTFALLOFF = true;
  52843. }
  52844. else {
  52845. defines.USEPHYSICALLIGHTFALLOFF = true;
  52846. defines.USEGLTFLIGHTFALLOFF = false;
  52847. }
  52848. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  52849. if (!this.backFaceCulling && this._twoSidedLighting) {
  52850. defines.TWOSIDEDLIGHTING = true;
  52851. }
  52852. else {
  52853. defines.TWOSIDEDLIGHTING = false;
  52854. }
  52855. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  52856. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  52857. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  52858. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  52859. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  52860. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  52861. }
  52862. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52863. this._imageProcessingConfiguration.prepareDefines(defines);
  52864. }
  52865. defines.FORCENORMALFORWARD = this._forceNormalForward;
  52866. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  52867. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  52868. // Misc.
  52869. if (defines._areMiscDirty) {
  52870. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  52871. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  52872. defines.DEBUGMODE = this._debugMode;
  52873. }
  52874. // External config
  52875. this.clearCoat.prepareDefines(defines, scene);
  52876. this.anisotropy.prepareDefines(defines, mesh, scene);
  52877. this.brdf.prepareDefines(defines);
  52878. this.sheen.prepareDefines(defines, scene);
  52879. // Values that need to be evaluated on every frame
  52880. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  52881. // Attribs
  52882. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  52883. };
  52884. /**
  52885. * Force shader compilation
  52886. */
  52887. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  52888. var _this = this;
  52889. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  52890. var defines = new PBRMaterialDefines();
  52891. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  52892. if (effect.isReady()) {
  52893. if (onCompiled) {
  52894. onCompiled(this);
  52895. }
  52896. }
  52897. else {
  52898. effect.onCompileObservable.add(function () {
  52899. if (onCompiled) {
  52900. onCompiled(_this);
  52901. }
  52902. });
  52903. }
  52904. };
  52905. /**
  52906. * Initializes the uniform buffer layout for the shader.
  52907. */
  52908. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  52909. // Order is important !
  52910. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  52911. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  52912. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  52913. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  52914. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  52915. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  52916. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  52917. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  52918. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  52919. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  52920. this._uniformBuffer.addUniform("vReflectionSize", 3);
  52921. this._uniformBuffer.addUniform("vBumpInfos", 3);
  52922. this._uniformBuffer.addUniform("albedoMatrix", 16);
  52923. this._uniformBuffer.addUniform("ambientMatrix", 16);
  52924. this._uniformBuffer.addUniform("opacityMatrix", 16);
  52925. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  52926. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  52927. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  52928. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  52929. this._uniformBuffer.addUniform("bumpMatrix", 16);
  52930. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  52931. this._uniformBuffer.addUniform("refractionMatrix", 16);
  52932. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  52933. this._uniformBuffer.addUniform("vReflectionColor", 3);
  52934. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  52935. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  52936. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  52937. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  52938. this._uniformBuffer.addUniform("pointSize", 1);
  52939. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  52940. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  52941. this._uniformBuffer.addUniform("visibility", 1);
  52942. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52943. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52944. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52945. this._uniformBuffer.create();
  52946. };
  52947. /**
  52948. * Unbinds the textures.
  52949. */
  52950. PBRBaseMaterial.prototype.unbind = function () {
  52951. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52952. this._uniformBuffer.setTexture("reflectionSampler", null);
  52953. }
  52954. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  52955. this._uniformBuffer.setTexture("refractionSampler", null);
  52956. }
  52957. _super.prototype.unbind.call(this);
  52958. };
  52959. /**
  52960. * Binds the submesh data.
  52961. * @param world - The world matrix.
  52962. * @param mesh - The BJS mesh.
  52963. * @param subMesh - A submesh of the BJS mesh.
  52964. */
  52965. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  52966. var scene = this.getScene();
  52967. var defines = subMesh._materialDefines;
  52968. if (!defines) {
  52969. return;
  52970. }
  52971. var effect = subMesh.effect;
  52972. if (!effect) {
  52973. return;
  52974. }
  52975. this._activeEffect = effect;
  52976. // Matrices
  52977. this.bindOnlyWorldMatrix(world);
  52978. // Normal Matrix
  52979. if (defines.OBJECTSPACE_NORMALMAP) {
  52980. world.toNormalMatrix(this._normalMatrix);
  52981. this.bindOnlyNormalMatrix(this._normalMatrix);
  52982. }
  52983. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  52984. // Bones
  52985. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  52986. var reflectionTexture = null;
  52987. if (mustRebind) {
  52988. var engine = scene.getEngine();
  52989. this._uniformBuffer.bindToEffect(effect, "Material");
  52990. this.bindViewProjection(effect);
  52991. reflectionTexture = this._getReflectionTexture();
  52992. var refractionTexture = this._getRefractionTexture();
  52993. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  52994. // Texture uniforms
  52995. if (scene.texturesEnabled) {
  52996. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52997. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  52998. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  52999. }
  53000. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  53001. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  53002. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  53003. }
  53004. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  53005. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  53006. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  53007. }
  53008. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  53009. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  53010. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  53011. if (reflectionTexture.boundingBoxSize) {
  53012. var cubeTexture = reflectionTexture;
  53013. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  53014. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  53015. }
  53016. var polynomials = reflectionTexture.sphericalPolynomial;
  53017. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  53018. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  53019. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  53020. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  53021. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  53022. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  53023. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  53024. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  53025. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  53026. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  53027. }
  53028. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  53029. }
  53030. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  53031. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  53032. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  53033. }
  53034. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  53035. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  53036. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  53037. }
  53038. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  53039. if (this._metallicTexture) {
  53040. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  53041. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  53042. }
  53043. else if (this._reflectivityTexture) {
  53044. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  53045. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  53046. }
  53047. if (this._microSurfaceTexture) {
  53048. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  53049. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  53050. }
  53051. }
  53052. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53053. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  53054. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  53055. if (scene._mirroredCameraPosition) {
  53056. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  53057. }
  53058. else {
  53059. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  53060. }
  53061. }
  53062. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  53063. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  53064. var depth = 1.0;
  53065. if (!refractionTexture.isCube) {
  53066. if (refractionTexture.depth) {
  53067. depth = refractionTexture.depth;
  53068. }
  53069. }
  53070. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  53071. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  53072. }
  53073. }
  53074. // Point size
  53075. if (this.pointsCloud) {
  53076. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  53077. }
  53078. // Colors
  53079. if (defines.METALLICWORKFLOW) {
  53080. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  53081. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  53082. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  53083. }
  53084. else {
  53085. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  53086. }
  53087. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  53088. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  53089. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha);
  53090. // Visibility
  53091. this._uniformBuffer.updateFloat("visibility", mesh.visibility);
  53092. // Misc
  53093. this._lightingInfos.x = this._directIntensity;
  53094. this._lightingInfos.y = this._emissiveIntensity;
  53095. this._lightingInfos.z = this._environmentIntensity;
  53096. this._lightingInfos.w = this._specularIntensity;
  53097. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  53098. }
  53099. // Textures
  53100. if (scene.texturesEnabled) {
  53101. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  53102. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  53103. }
  53104. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  53105. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  53106. }
  53107. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  53108. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  53109. }
  53110. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  53111. if (defines.LODBASEDMICROSFURACE) {
  53112. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  53113. }
  53114. else {
  53115. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  53116. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  53117. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  53118. }
  53119. }
  53120. if (defines.ENVIRONMENTBRDF) {
  53121. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  53122. }
  53123. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  53124. if (defines.LODBASEDMICROSFURACE) {
  53125. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  53126. }
  53127. else {
  53128. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  53129. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  53130. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  53131. }
  53132. }
  53133. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  53134. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  53135. }
  53136. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  53137. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  53138. }
  53139. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  53140. if (this._metallicTexture) {
  53141. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  53142. }
  53143. else if (this._reflectivityTexture) {
  53144. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  53145. }
  53146. if (this._microSurfaceTexture) {
  53147. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  53148. }
  53149. }
  53150. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53151. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  53152. }
  53153. }
  53154. this.clearCoat.bindForSubMesh(this._uniformBuffer, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  53155. this.anisotropy.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  53156. this.sheen.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  53157. // Clip plane
  53158. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  53159. // Colors
  53160. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  53161. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  53162. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  53163. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  53164. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  53165. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  53166. }
  53167. if (mustRebind || !this.isFrozen) {
  53168. // Lights
  53169. if (scene.lightsEnabled && !this._disableLighting) {
  53170. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  53171. }
  53172. // View
  53173. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  53174. this.bindView(effect);
  53175. }
  53176. // Fog
  53177. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  53178. // Morph targets
  53179. if (defines.NUM_MORPH_INFLUENCERS) {
  53180. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  53181. }
  53182. // image processing
  53183. this._imageProcessingConfiguration.bind(this._activeEffect);
  53184. // Log. depth
  53185. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  53186. }
  53187. this._uniformBuffer.update();
  53188. this._afterBind(mesh, this._activeEffect);
  53189. };
  53190. /**
  53191. * Returns the animatable textures.
  53192. * @returns - Array of animatable textures.
  53193. */
  53194. PBRBaseMaterial.prototype.getAnimatables = function () {
  53195. var results = [];
  53196. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  53197. results.push(this._albedoTexture);
  53198. }
  53199. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  53200. results.push(this._ambientTexture);
  53201. }
  53202. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  53203. results.push(this._opacityTexture);
  53204. }
  53205. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  53206. results.push(this._reflectionTexture);
  53207. }
  53208. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  53209. results.push(this._emissiveTexture);
  53210. }
  53211. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  53212. results.push(this._metallicTexture);
  53213. }
  53214. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  53215. results.push(this._reflectivityTexture);
  53216. }
  53217. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53218. results.push(this._bumpTexture);
  53219. }
  53220. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  53221. results.push(this._lightmapTexture);
  53222. }
  53223. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  53224. results.push(this._refractionTexture);
  53225. }
  53226. this.clearCoat.getAnimatables(results);
  53227. this.sheen.getAnimatables(results);
  53228. this.anisotropy.getAnimatables(results);
  53229. return results;
  53230. };
  53231. /**
  53232. * Returns the texture used for reflections.
  53233. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53234. */
  53235. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  53236. if (this._reflectionTexture) {
  53237. return this._reflectionTexture;
  53238. }
  53239. return this.getScene().environmentTexture;
  53240. };
  53241. /**
  53242. * Returns the texture used for refraction or null if none is used.
  53243. * @returns - Refection texture if present. If no refraction texture and refraction
  53244. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53245. */
  53246. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  53247. if (this._refractionTexture) {
  53248. return this._refractionTexture;
  53249. }
  53250. if (this._linkRefractionWithTransparency) {
  53251. return this.getScene().environmentTexture;
  53252. }
  53253. return null;
  53254. };
  53255. /**
  53256. * Returns an array of the actively used textures.
  53257. * @returns - Array of BaseTextures
  53258. */
  53259. PBRBaseMaterial.prototype.getActiveTextures = function () {
  53260. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53261. if (this._albedoTexture) {
  53262. activeTextures.push(this._albedoTexture);
  53263. }
  53264. if (this._ambientTexture) {
  53265. activeTextures.push(this._ambientTexture);
  53266. }
  53267. if (this._opacityTexture) {
  53268. activeTextures.push(this._opacityTexture);
  53269. }
  53270. if (this._reflectionTexture) {
  53271. activeTextures.push(this._reflectionTexture);
  53272. }
  53273. if (this._emissiveTexture) {
  53274. activeTextures.push(this._emissiveTexture);
  53275. }
  53276. if (this._reflectivityTexture) {
  53277. activeTextures.push(this._reflectivityTexture);
  53278. }
  53279. if (this._metallicTexture) {
  53280. activeTextures.push(this._metallicTexture);
  53281. }
  53282. if (this._microSurfaceTexture) {
  53283. activeTextures.push(this._microSurfaceTexture);
  53284. }
  53285. if (this._bumpTexture) {
  53286. activeTextures.push(this._bumpTexture);
  53287. }
  53288. if (this._lightmapTexture) {
  53289. activeTextures.push(this._lightmapTexture);
  53290. }
  53291. if (this._refractionTexture) {
  53292. activeTextures.push(this._refractionTexture);
  53293. }
  53294. this.clearCoat.getActiveTextures(activeTextures);
  53295. this.sheen.getActiveTextures(activeTextures);
  53296. this.anisotropy.getActiveTextures(activeTextures);
  53297. return activeTextures;
  53298. };
  53299. /**
  53300. * Checks to see if a texture is used in the material.
  53301. * @param texture - Base texture to use.
  53302. * @returns - Boolean specifying if a texture is used in the material.
  53303. */
  53304. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  53305. if (_super.prototype.hasTexture.call(this, texture)) {
  53306. return true;
  53307. }
  53308. if (this._albedoTexture === texture) {
  53309. return true;
  53310. }
  53311. if (this._ambientTexture === texture) {
  53312. return true;
  53313. }
  53314. if (this._opacityTexture === texture) {
  53315. return true;
  53316. }
  53317. if (this._reflectionTexture === texture) {
  53318. return true;
  53319. }
  53320. if (this._reflectivityTexture === texture) {
  53321. return true;
  53322. }
  53323. if (this._metallicTexture === texture) {
  53324. return true;
  53325. }
  53326. if (this._microSurfaceTexture === texture) {
  53327. return true;
  53328. }
  53329. if (this._bumpTexture === texture) {
  53330. return true;
  53331. }
  53332. if (this._lightmapTexture === texture) {
  53333. return true;
  53334. }
  53335. return this.clearCoat.hasTexture(texture) ||
  53336. this.sheen.hasTexture(texture) ||
  53337. this.anisotropy.hasTexture(texture);
  53338. };
  53339. /**
  53340. * Disposes the resources of the material.
  53341. * @param forceDisposeEffect - Forces the disposal of effects.
  53342. * @param forceDisposeTextures - Forces the disposal of all textures.
  53343. */
  53344. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  53345. if (forceDisposeTextures) {
  53346. if (this._albedoTexture) {
  53347. this._albedoTexture.dispose();
  53348. }
  53349. if (this._ambientTexture) {
  53350. this._ambientTexture.dispose();
  53351. }
  53352. if (this._opacityTexture) {
  53353. this._opacityTexture.dispose();
  53354. }
  53355. if (this._reflectionTexture) {
  53356. this._reflectionTexture.dispose();
  53357. }
  53358. if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
  53359. this._environmentBRDFTexture.dispose();
  53360. }
  53361. if (this._emissiveTexture) {
  53362. this._emissiveTexture.dispose();
  53363. }
  53364. if (this._metallicTexture) {
  53365. this._metallicTexture.dispose();
  53366. }
  53367. if (this._reflectivityTexture) {
  53368. this._reflectivityTexture.dispose();
  53369. }
  53370. if (this._bumpTexture) {
  53371. this._bumpTexture.dispose();
  53372. }
  53373. if (this._lightmapTexture) {
  53374. this._lightmapTexture.dispose();
  53375. }
  53376. if (this._refractionTexture) {
  53377. this._refractionTexture.dispose();
  53378. }
  53379. }
  53380. this.clearCoat.dispose(forceDisposeTextures);
  53381. this.sheen.dispose(forceDisposeTextures);
  53382. this.anisotropy.dispose(forceDisposeTextures);
  53383. this._renderTargets.dispose();
  53384. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  53385. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  53386. }
  53387. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  53388. };
  53389. /**
  53390. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53391. */
  53392. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  53393. /**
  53394. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53395. */
  53396. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  53397. /**
  53398. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53399. */
  53400. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  53401. /**
  53402. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53403. * They are also discarded below the alpha cutoff threshold to improve performances.
  53404. */
  53405. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  53406. /**
  53407. * Defines the default value of how much AO map is occluding the analytical lights
  53408. * (point spot...).
  53409. */
  53410. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  53411. /**
  53412. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53413. */
  53414. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  53415. /**
  53416. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53417. * to enhance interoperability with other engines.
  53418. */
  53419. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  53420. /**
  53421. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53422. * to enhance interoperability with other materials.
  53423. */
  53424. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  53425. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  53427. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  53428. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53430. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  53431. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53432. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53433. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  53434. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53436. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  53437. return PBRBaseMaterial;
  53438. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_15__["PushMaterial"]));
  53439. /***/ }),
  53440. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  53441. /*!************************************************!*\
  53442. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  53443. \************************************************/
  53444. /*! exports provided: PBRBaseSimpleMaterial */
  53445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53446. "use strict";
  53447. __webpack_require__.r(__webpack_exports__);
  53448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  53449. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53450. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53451. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53452. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53453. /**
  53454. * The Physically based simple base material of BJS.
  53455. *
  53456. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53457. * It is used as the base class for both the specGloss and metalRough conventions.
  53458. */
  53459. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  53460. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  53461. /**
  53462. * Instantiates a new PBRMaterial instance.
  53463. *
  53464. * @param name The material name
  53465. * @param scene The scene the material will be use in.
  53466. */
  53467. function PBRBaseSimpleMaterial(name, scene) {
  53468. var _this = _super.call(this, name, scene) || this;
  53469. /**
  53470. * Number of Simultaneous lights allowed on the material.
  53471. */
  53472. _this.maxSimultaneousLights = 4;
  53473. /**
  53474. * If sets to true, disables all the lights affecting the material.
  53475. */
  53476. _this.disableLighting = false;
  53477. /**
  53478. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53479. */
  53480. _this.invertNormalMapX = false;
  53481. /**
  53482. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53483. */
  53484. _this.invertNormalMapY = false;
  53485. /**
  53486. * Emissivie color used to self-illuminate the model.
  53487. */
  53488. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  53489. /**
  53490. * Occlusion Channel Strenght.
  53491. */
  53492. _this.occlusionStrength = 1.0;
  53493. /**
  53494. * If true, the light map contains occlusion information instead of lighting info.
  53495. */
  53496. _this.useLightmapAsShadowmap = false;
  53497. _this._useAlphaFromAlbedoTexture = true;
  53498. _this._useAmbientInGrayScale = true;
  53499. return _this;
  53500. }
  53501. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  53502. /**
  53503. * Gets the current double sided mode.
  53504. */
  53505. get: function () {
  53506. return this._twoSidedLighting;
  53507. },
  53508. /**
  53509. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53510. */
  53511. set: function (value) {
  53512. if (this._twoSidedLighting === value) {
  53513. return;
  53514. }
  53515. this._twoSidedLighting = value;
  53516. this.backFaceCulling = !value;
  53517. this._markAllSubMeshesAsTexturesDirty();
  53518. },
  53519. enumerable: true,
  53520. configurable: true
  53521. });
  53522. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  53523. return "PBRBaseSimpleMaterial";
  53524. };
  53525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53527. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53528. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  53529. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53530. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53532. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  53533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  53536. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  53537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53540. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  53541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53544. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  53545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  53548. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  53549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  53551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53552. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  53553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53556. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  53557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  53560. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  53561. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  53564. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  53565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  53568. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  53569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53571. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  53572. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53573. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53574. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  53575. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  53576. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53577. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53578. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53579. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  53580. return PBRBaseSimpleMaterial;
  53581. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  53582. /***/ }),
  53583. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  53584. /*!****************************************************!*\
  53585. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  53586. \****************************************************/
  53587. /*! exports provided: PBRClearCoatConfiguration */
  53588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53589. "use strict";
  53590. __webpack_require__.r(__webpack_exports__);
  53591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  53592. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53593. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53594. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53595. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53596. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53597. /**
  53598. * Define the code related to the clear coat parameters of the pbr material.
  53599. */
  53600. var PBRClearCoatConfiguration = /** @class */ (function () {
  53601. /**
  53602. * Instantiate a new istance of clear coat configuration.
  53603. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53604. */
  53605. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  53606. this._isEnabled = false;
  53607. /**
  53608. * Defines if the clear coat is enabled in the material.
  53609. */
  53610. this.isEnabled = false;
  53611. /**
  53612. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53613. */
  53614. this.intensity = 1;
  53615. /**
  53616. * Defines the clear coat layer roughness.
  53617. */
  53618. this.roughness = 0;
  53619. this._indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53620. /**
  53621. * Defines the indice of refraction of the clear coat.
  53622. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53623. * The default fits with a polyurethane material.
  53624. * Changing the default value is more performance intensive.
  53625. */
  53626. this.indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53627. this._texture = null;
  53628. /**
  53629. * Stores the clear coat values in a texture.
  53630. */
  53631. this.texture = null;
  53632. this._bumpTexture = null;
  53633. /**
  53634. * Define the clear coat specific bump texture.
  53635. */
  53636. this.bumpTexture = null;
  53637. this._isTintEnabled = false;
  53638. /**
  53639. * Defines if the clear coat tint is enabled in the material.
  53640. */
  53641. this.isTintEnabled = false;
  53642. /**
  53643. * Defines if the clear coat tint is enabled in the material.
  53644. * This is only use if tint is enabled
  53645. */
  53646. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  53647. /**
  53648. * Defines if the distance at which the tint color should be found in the
  53649. * clear coat media.
  53650. * This is only use if tint is enabled
  53651. */
  53652. this.tintColorAtDistance = 1;
  53653. /**
  53654. * Defines the clear coat layer thickness.
  53655. * This is only use if tint is enabled
  53656. */
  53657. this.tintThickness = 1;
  53658. this._tintTexture = null;
  53659. /**
  53660. * Stores the clear tint values in a texture.
  53661. * rgb is tint
  53662. * a is a thickness factor
  53663. */
  53664. this.tintTexture = null;
  53665. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  53666. }
  53667. /** @hidden */
  53668. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  53669. this._internalMarkAllSubMeshesAsTexturesDirty();
  53670. };
  53671. /**
  53672. * Specifies that the submesh is ready to be used.
  53673. * @param defines the list of "defines" to update.
  53674. * @param scene defines the scene the material belongs to.
  53675. * @param engine defines the engine the material belongs to.
  53676. * @param disableBumpMap defines wether the material disables bump or not.
  53677. * @returns - boolean indicating that the submesh is ready or not.
  53678. */
  53679. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  53680. if (defines._areTexturesDirty) {
  53681. if (scene.texturesEnabled) {
  53682. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53683. if (!this._texture.isReadyOrNotBlocking()) {
  53684. return false;
  53685. }
  53686. }
  53687. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53688. // Bump texture cannot be not blocking.
  53689. if (!this._bumpTexture.isReady()) {
  53690. return false;
  53691. }
  53692. }
  53693. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53694. if (!this._tintTexture.isReadyOrNotBlocking()) {
  53695. return false;
  53696. }
  53697. }
  53698. }
  53699. }
  53700. return true;
  53701. };
  53702. /**
  53703. * Checks to see if a texture is used in the material.
  53704. * @param defines the list of "defines" to update.
  53705. * @param scene defines the scene to the material belongs to.
  53706. */
  53707. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  53708. if (this._isEnabled) {
  53709. defines.CLEARCOAT = true;
  53710. if (defines._areTexturesDirty) {
  53711. if (scene.texturesEnabled) {
  53712. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53713. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  53714. }
  53715. else {
  53716. defines.CLEARCOAT_TEXTURE = false;
  53717. }
  53718. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  53719. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  53720. }
  53721. else {
  53722. defines.CLEARCOAT_BUMP = false;
  53723. }
  53724. defines.CLEARCOAT_DEFAULTIOR = this._indiceOfRefraction === PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53725. if (this._isTintEnabled) {
  53726. defines.CLEARCOAT_TINT = true;
  53727. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53728. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  53729. }
  53730. else {
  53731. defines.CLEARCOAT_TINT_TEXTURE = false;
  53732. }
  53733. }
  53734. else {
  53735. defines.CLEARCOAT_TINT = false;
  53736. defines.CLEARCOAT_TINT_TEXTURE = false;
  53737. }
  53738. }
  53739. }
  53740. }
  53741. else {
  53742. defines.CLEARCOAT = false;
  53743. defines.CLEARCOAT_TEXTURE = false;
  53744. defines.CLEARCOAT_BUMP = false;
  53745. defines.CLEARCOAT_TINT = false;
  53746. defines.CLEARCOAT_TINT_TEXTURE = false;
  53747. }
  53748. };
  53749. /**
  53750. * Binds the material data.
  53751. * @param uniformBuffer defines the Uniform buffer to fill in.
  53752. * @param scene defines the scene the material belongs to.
  53753. * @param engine defines the engine the material belongs to.
  53754. * @param disableBumpMap defines wether the material disables bump or not.
  53755. * @param isFrozen defines wether the material is frozen or not.
  53756. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53757. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53758. */
  53759. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  53760. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  53761. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53762. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  53763. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  53764. }
  53765. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  53766. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  53767. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  53768. if (scene._mirroredCameraPosition) {
  53769. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  53770. }
  53771. else {
  53772. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  53773. }
  53774. }
  53775. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53776. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  53777. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  53778. }
  53779. // Clear Coat General params
  53780. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  53781. // Clear Coat Refraction params
  53782. var a = 1 - this._indiceOfRefraction;
  53783. var b = 1 + this._indiceOfRefraction;
  53784. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  53785. var eta = 1 / this._indiceOfRefraction;
  53786. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  53787. if (this._isTintEnabled) {
  53788. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  53789. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  53790. }
  53791. }
  53792. // Textures
  53793. if (scene.texturesEnabled) {
  53794. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53795. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  53796. }
  53797. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53798. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  53799. }
  53800. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53801. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  53802. }
  53803. }
  53804. };
  53805. /**
  53806. * Checks to see if a texture is used in the material.
  53807. * @param texture - Base texture to use.
  53808. * @returns - Boolean specifying if a texture is used in the material.
  53809. */
  53810. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  53811. if (this._texture === texture) {
  53812. return true;
  53813. }
  53814. if (this._bumpTexture === texture) {
  53815. return true;
  53816. }
  53817. if (this._tintTexture === texture) {
  53818. return true;
  53819. }
  53820. return false;
  53821. };
  53822. /**
  53823. * Returns an array of the actively used textures.
  53824. * @param activeTextures Array of BaseTextures
  53825. */
  53826. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  53827. if (this._texture) {
  53828. activeTextures.push(this._texture);
  53829. }
  53830. if (this._bumpTexture) {
  53831. activeTextures.push(this._bumpTexture);
  53832. }
  53833. if (this._tintTexture) {
  53834. activeTextures.push(this._tintTexture);
  53835. }
  53836. };
  53837. /**
  53838. * Returns the animatable textures.
  53839. * @param animatables Array of animatable textures.
  53840. */
  53841. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  53842. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  53843. animatables.push(this._texture);
  53844. }
  53845. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53846. animatables.push(this._bumpTexture);
  53847. }
  53848. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  53849. animatables.push(this._tintTexture);
  53850. }
  53851. };
  53852. /**
  53853. * Disposes the resources of the material.
  53854. * @param forceDisposeTextures - Forces the disposal of all textures.
  53855. */
  53856. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  53857. if (forceDisposeTextures) {
  53858. if (this._texture) {
  53859. this._texture.dispose();
  53860. }
  53861. if (this._bumpTexture) {
  53862. this._bumpTexture.dispose();
  53863. }
  53864. if (this._tintTexture) {
  53865. this._tintTexture.dispose();
  53866. }
  53867. }
  53868. };
  53869. /**
  53870. * Get the current class name of the texture useful for serialization or dynamic coding.
  53871. * @returns "PBRClearCoatConfiguration"
  53872. */
  53873. PBRClearCoatConfiguration.prototype.getClassName = function () {
  53874. return "PBRClearCoatConfiguration";
  53875. };
  53876. /**
  53877. * Add fallbacks to the effect fallbacks list.
  53878. * @param defines defines the Base texture to use.
  53879. * @param fallbacks defines the current fallback list.
  53880. * @param currentRank defines the current fallback rank.
  53881. * @returns the new fallback rank.
  53882. */
  53883. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  53884. if (defines.CLEARCOAT_BUMP) {
  53885. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  53886. }
  53887. if (defines.CLEARCOAT_TINT) {
  53888. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  53889. }
  53890. if (defines.CLEARCOAT) {
  53891. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  53892. }
  53893. return currentRank;
  53894. };
  53895. /**
  53896. * Add the required uniforms to the current list.
  53897. * @param uniforms defines the current uniform list.
  53898. */
  53899. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  53900. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  53901. };
  53902. /**
  53903. * Add the required samplers to the current list.
  53904. * @param samplers defines the current sampler list.
  53905. */
  53906. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  53907. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  53908. };
  53909. /**
  53910. * Add the required uniforms to the current buffer.
  53911. * @param uniformBuffer defines the current uniform buffer.
  53912. */
  53913. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  53914. uniformBuffer.addUniform("vClearCoatParams", 2);
  53915. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  53916. uniformBuffer.addUniform("vClearCoatInfos", 2);
  53917. uniformBuffer.addUniform("clearCoatMatrix", 16);
  53918. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  53919. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  53920. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  53921. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  53922. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  53923. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  53924. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  53925. };
  53926. /**
  53927. * Makes a duplicate of the current configuration into another one.
  53928. * @param clearCoatConfiguration define the config where to copy the info
  53929. */
  53930. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  53931. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  53932. };
  53933. /**
  53934. * Serializes this clear coat configuration.
  53935. * @returns - An object with the serialized config.
  53936. */
  53937. PBRClearCoatConfiguration.prototype.serialize = function () {
  53938. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53939. };
  53940. /**
  53941. * Parses a Clear Coat Configuration from a serialized object.
  53942. * @param source - Serialized object.
  53943. */
  53944. PBRClearCoatConfiguration.prototype.parse = function (source) {
  53945. var _this = this;
  53946. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  53947. };
  53948. /**
  53949. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53950. * The default fits with a polyurethane material.
  53951. */
  53952. PBRClearCoatConfiguration._DefaultIndiceOfRefraction = 1.5;
  53953. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53954. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53955. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  53956. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53957. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53958. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  53959. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53960. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53961. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  53962. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53963. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53964. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  53965. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53967. ], PBRClearCoatConfiguration.prototype, "_indiceOfRefraction", void 0);
  53968. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53969. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53970. ], PBRClearCoatConfiguration.prototype, "indiceOfRefraction", void 0);
  53971. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53972. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53973. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  53974. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53976. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  53977. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53978. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53979. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  53980. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53981. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53982. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  53983. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53984. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53985. ], PBRClearCoatConfiguration.prototype, "_isTintEnabled", void 0);
  53986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53988. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  53989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  53991. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  53992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53994. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  53995. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53997. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  53998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54000. ], PBRClearCoatConfiguration.prototype, "_tintTexture", void 0);
  54001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54003. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  54004. return PBRClearCoatConfiguration;
  54005. }());
  54006. /***/ }),
  54007. /***/ "./Materials/PBR/pbrMaterial.ts":
  54008. /*!**************************************!*\
  54009. !*** ./Materials/PBR/pbrMaterial.ts ***!
  54010. \**************************************/
  54011. /*! exports provided: PBRMaterial */
  54012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54013. "use strict";
  54014. __webpack_require__.r(__webpack_exports__);
  54015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  54016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54017. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54018. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  54019. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54020. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  54021. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54022. /**
  54023. * The Physically based material of BJS.
  54024. *
  54025. * This offers the main features of a standard PBR material.
  54026. * For more information, please refer to the documentation :
  54027. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  54028. */
  54029. var PBRMaterial = /** @class */ (function (_super) {
  54030. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  54031. /**
  54032. * Instantiates a new PBRMaterial instance.
  54033. *
  54034. * @param name The material name
  54035. * @param scene The scene the material will be use in.
  54036. */
  54037. function PBRMaterial(name, scene) {
  54038. var _this = _super.call(this, name, scene) || this;
  54039. /**
  54040. * Intensity of the direct lights e.g. the four lights available in your scene.
  54041. * This impacts both the direct diffuse and specular highlights.
  54042. */
  54043. _this.directIntensity = 1.0;
  54044. /**
  54045. * Intensity of the emissive part of the material.
  54046. * This helps controlling the emissive effect without modifying the emissive color.
  54047. */
  54048. _this.emissiveIntensity = 1.0;
  54049. /**
  54050. * Intensity of the environment e.g. how much the environment will light the object
  54051. * either through harmonics for rough material or through the refelction for shiny ones.
  54052. */
  54053. _this.environmentIntensity = 1.0;
  54054. /**
  54055. * This is a special control allowing the reduction of the specular highlights coming from the
  54056. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54057. */
  54058. _this.specularIntensity = 1.0;
  54059. /**
  54060. * Debug Control allowing disabling the bump map on this material.
  54061. */
  54062. _this.disableBumpMap = false;
  54063. /**
  54064. * AKA Occlusion Texture Intensity in other nomenclature.
  54065. */
  54066. _this.ambientTextureStrength = 1.0;
  54067. /**
  54068. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54069. * 1 means it completely occludes it
  54070. * 0 mean it has no impact
  54071. */
  54072. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54073. /**
  54074. * The color of a material in ambient lighting.
  54075. */
  54076. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54077. /**
  54078. * AKA Diffuse Color in other nomenclature.
  54079. */
  54080. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54081. /**
  54082. * AKA Specular Color in other nomenclature.
  54083. */
  54084. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54085. /**
  54086. * The color reflected from the material.
  54087. */
  54088. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  54089. /**
  54090. * The color emitted from the material.
  54091. */
  54092. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54093. /**
  54094. * AKA Glossiness in other nomenclature.
  54095. */
  54096. _this.microSurface = 1.0;
  54097. /**
  54098. * source material index of refraction (IOR)' / 'destination material IOR.
  54099. */
  54100. _this.indexOfRefraction = 0.66;
  54101. /**
  54102. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54103. */
  54104. _this.invertRefractionY = false;
  54105. /**
  54106. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54107. * Materials half opaque for instance using refraction could benefit from this control.
  54108. */
  54109. _this.linkRefractionWithTransparency = false;
  54110. /**
  54111. * If true, the light map contains occlusion information instead of lighting info.
  54112. */
  54113. _this.useLightmapAsShadowmap = false;
  54114. /**
  54115. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54116. */
  54117. _this.useAlphaFromAlbedoTexture = false;
  54118. /**
  54119. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54120. */
  54121. _this.forceAlphaTest = false;
  54122. /**
  54123. * Defines the alpha limits in alpha test mode.
  54124. */
  54125. _this.alphaCutOff = 0.4;
  54126. /**
  54127. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54128. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54129. */
  54130. _this.useSpecularOverAlpha = true;
  54131. /**
  54132. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54133. */
  54134. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  54135. /**
  54136. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54137. */
  54138. _this.useRoughnessFromMetallicTextureAlpha = true;
  54139. /**
  54140. * Specifies if the metallic texture contains the roughness information in its green channel.
  54141. */
  54142. _this.useRoughnessFromMetallicTextureGreen = false;
  54143. /**
  54144. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54145. */
  54146. _this.useMetallnessFromMetallicTextureBlue = false;
  54147. /**
  54148. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54149. */
  54150. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  54151. /**
  54152. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54153. */
  54154. _this.useAmbientInGrayScale = false;
  54155. /**
  54156. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54157. * The material will try to infer what glossiness each pixel should be.
  54158. */
  54159. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  54160. /**
  54161. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54162. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54163. */
  54164. _this.useRadianceOverAlpha = true;
  54165. /**
  54166. * Allows using an object space normal map (instead of tangent space).
  54167. */
  54168. _this.useObjectSpaceNormalMap = false;
  54169. /**
  54170. * Allows using the bump map in parallax mode.
  54171. */
  54172. _this.useParallax = false;
  54173. /**
  54174. * Allows using the bump map in parallax occlusion mode.
  54175. */
  54176. _this.useParallaxOcclusion = false;
  54177. /**
  54178. * Controls the scale bias of the parallax mode.
  54179. */
  54180. _this.parallaxScaleBias = 0.05;
  54181. /**
  54182. * If sets to true, disables all the lights affecting the material.
  54183. */
  54184. _this.disableLighting = false;
  54185. /**
  54186. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54187. */
  54188. _this.forceIrradianceInFragment = false;
  54189. /**
  54190. * Number of Simultaneous lights allowed on the material.
  54191. */
  54192. _this.maxSimultaneousLights = 4;
  54193. /**
  54194. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54195. */
  54196. _this.invertNormalMapX = false;
  54197. /**
  54198. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54199. */
  54200. _this.invertNormalMapY = false;
  54201. /**
  54202. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54203. */
  54204. _this.twoSidedLighting = false;
  54205. /**
  54206. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54207. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54208. */
  54209. _this.useAlphaFresnel = false;
  54210. /**
  54211. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54212. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54213. */
  54214. _this.useLinearAlphaFresnel = false;
  54215. /**
  54216. * Let user defines the brdf lookup texture used for IBL.
  54217. * A default 8bit version is embedded but you could point at :
  54218. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  54219. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54220. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54221. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54222. */
  54223. _this.environmentBRDFTexture = null;
  54224. /**
  54225. * Force normal to face away from face.
  54226. */
  54227. _this.forceNormalForward = false;
  54228. /**
  54229. * Enables specular anti aliasing in the PBR shader.
  54230. * It will both interacts on the Geometry for analytical and IBL lighting.
  54231. * It also prefilter the roughness map based on the bump values.
  54232. */
  54233. _this.enableSpecularAntiAliasing = false;
  54234. /**
  54235. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54236. * makes the reflect vector face the model (under horizon).
  54237. */
  54238. _this.useHorizonOcclusion = true;
  54239. /**
  54240. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54241. * too much the area relying on ambient texture to define their ambient occlusion.
  54242. */
  54243. _this.useRadianceOcclusion = true;
  54244. /**
  54245. * If set to true, no lighting calculations will be applied.
  54246. */
  54247. _this.unlit = false;
  54248. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  54249. return _this;
  54250. }
  54251. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  54252. /**
  54253. * BJS is using an harcoded light falloff based on a manually sets up range.
  54254. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54255. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54256. */
  54257. get: function () {
  54258. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54259. },
  54260. /**
  54261. * BJS is using an harcoded light falloff based on a manually sets up range.
  54262. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54263. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54264. */
  54265. set: function (value) {
  54266. if (value !== this.usePhysicalLightFalloff) {
  54267. // Ensure the effect will be rebuilt.
  54268. this._markAllSubMeshesAsTexturesDirty();
  54269. if (value) {
  54270. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54271. }
  54272. else {
  54273. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54274. }
  54275. }
  54276. },
  54277. enumerable: true,
  54278. configurable: true
  54279. });
  54280. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  54281. /**
  54282. * In order to support the falloff compatibility with gltf, a special mode has been added
  54283. * to reproduce the gltf light falloff.
  54284. */
  54285. get: function () {
  54286. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54287. },
  54288. /**
  54289. * In order to support the falloff compatibility with gltf, a special mode has been added
  54290. * to reproduce the gltf light falloff.
  54291. */
  54292. set: function (value) {
  54293. if (value !== this.useGLTFLightFalloff) {
  54294. // Ensure the effect will be rebuilt.
  54295. this._markAllSubMeshesAsTexturesDirty();
  54296. if (value) {
  54297. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54298. }
  54299. else {
  54300. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54301. }
  54302. }
  54303. },
  54304. enumerable: true,
  54305. configurable: true
  54306. });
  54307. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  54308. /**
  54309. * Gets the image processing configuration used either in this material.
  54310. */
  54311. get: function () {
  54312. return this._imageProcessingConfiguration;
  54313. },
  54314. /**
  54315. * Sets the Default image processing configuration used either in the this material.
  54316. *
  54317. * If sets to null, the scene one is in use.
  54318. */
  54319. set: function (value) {
  54320. this._attachImageProcessingConfiguration(value);
  54321. // Ensure the effect will be rebuilt.
  54322. this._markAllSubMeshesAsTexturesDirty();
  54323. },
  54324. enumerable: true,
  54325. configurable: true
  54326. });
  54327. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  54328. /**
  54329. * Gets wether the color curves effect is enabled.
  54330. */
  54331. get: function () {
  54332. return this.imageProcessingConfiguration.colorCurvesEnabled;
  54333. },
  54334. /**
  54335. * Sets wether the color curves effect is enabled.
  54336. */
  54337. set: function (value) {
  54338. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  54339. },
  54340. enumerable: true,
  54341. configurable: true
  54342. });
  54343. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  54344. /**
  54345. * Gets wether the color grading effect is enabled.
  54346. */
  54347. get: function () {
  54348. return this.imageProcessingConfiguration.colorGradingEnabled;
  54349. },
  54350. /**
  54351. * Gets wether the color grading effect is enabled.
  54352. */
  54353. set: function (value) {
  54354. this.imageProcessingConfiguration.colorGradingEnabled = value;
  54355. },
  54356. enumerable: true,
  54357. configurable: true
  54358. });
  54359. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  54360. /**
  54361. * Gets wether tonemapping is enabled or not.
  54362. */
  54363. get: function () {
  54364. return this._imageProcessingConfiguration.toneMappingEnabled;
  54365. },
  54366. /**
  54367. * Sets wether tonemapping is enabled or not
  54368. */
  54369. set: function (value) {
  54370. this._imageProcessingConfiguration.toneMappingEnabled = value;
  54371. },
  54372. enumerable: true,
  54373. configurable: true
  54374. });
  54375. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  54376. /**
  54377. * The camera exposure used on this material.
  54378. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54379. * This corresponds to a photographic exposure.
  54380. */
  54381. get: function () {
  54382. return this._imageProcessingConfiguration.exposure;
  54383. },
  54384. /**
  54385. * The camera exposure used on this material.
  54386. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54387. * This corresponds to a photographic exposure.
  54388. */
  54389. set: function (value) {
  54390. this._imageProcessingConfiguration.exposure = value;
  54391. },
  54392. enumerable: true,
  54393. configurable: true
  54394. });
  54395. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  54396. /**
  54397. * Gets The camera contrast used on this material.
  54398. */
  54399. get: function () {
  54400. return this._imageProcessingConfiguration.contrast;
  54401. },
  54402. /**
  54403. * Sets The camera contrast used on this material.
  54404. */
  54405. set: function (value) {
  54406. this._imageProcessingConfiguration.contrast = value;
  54407. },
  54408. enumerable: true,
  54409. configurable: true
  54410. });
  54411. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  54412. /**
  54413. * Gets the Color Grading 2D Lookup Texture.
  54414. */
  54415. get: function () {
  54416. return this._imageProcessingConfiguration.colorGradingTexture;
  54417. },
  54418. /**
  54419. * Sets the Color Grading 2D Lookup Texture.
  54420. */
  54421. set: function (value) {
  54422. this._imageProcessingConfiguration.colorGradingTexture = value;
  54423. },
  54424. enumerable: true,
  54425. configurable: true
  54426. });
  54427. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  54428. /**
  54429. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54430. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54431. * 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;
  54432. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54433. */
  54434. get: function () {
  54435. return this._imageProcessingConfiguration.colorCurves;
  54436. },
  54437. /**
  54438. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54439. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54440. * 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;
  54441. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54442. */
  54443. set: function (value) {
  54444. this._imageProcessingConfiguration.colorCurves = value;
  54445. },
  54446. enumerable: true,
  54447. configurable: true
  54448. });
  54449. /**
  54450. * Returns the name of this material class.
  54451. */
  54452. PBRMaterial.prototype.getClassName = function () {
  54453. return "PBRMaterial";
  54454. };
  54455. /**
  54456. * Makes a duplicate of the current material.
  54457. * @param name - name to use for the new material.
  54458. */
  54459. PBRMaterial.prototype.clone = function (name) {
  54460. var _this = this;
  54461. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  54462. clone.id = name;
  54463. clone.name = name;
  54464. this.clearCoat.copyTo(clone.clearCoat);
  54465. this.anisotropy.copyTo(clone.anisotropy);
  54466. this.brdf.copyTo(clone.brdf);
  54467. this.sheen.copyTo(clone.sheen);
  54468. return clone;
  54469. };
  54470. /**
  54471. * Serializes this PBR Material.
  54472. * @returns - An object with the serialized material.
  54473. */
  54474. PBRMaterial.prototype.serialize = function () {
  54475. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54476. serializationObject.customType = "BABYLON.PBRMaterial";
  54477. serializationObject.clearCoat = this.clearCoat.serialize();
  54478. serializationObject.anisotropy = this.anisotropy.serialize();
  54479. serializationObject.brdf = this.brdf.serialize();
  54480. serializationObject.sheen = this.sheen.serialize();
  54481. return serializationObject;
  54482. };
  54483. // Statics
  54484. /**
  54485. * Parses a PBR Material from a serialized object.
  54486. * @param source - Serialized object.
  54487. * @param scene - BJS scene instance.
  54488. * @param rootUrl - url for the scene object
  54489. * @returns - PBRMaterial
  54490. */
  54491. PBRMaterial.Parse = function (source, scene, rootUrl) {
  54492. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  54493. if (source.clearCoat) {
  54494. material.clearCoat.parse(source.clearCoat);
  54495. }
  54496. if (source.anisotropy) {
  54497. material.anisotropy.parse(source.anisotropy);
  54498. }
  54499. if (source.brdf) {
  54500. material.brdf.parse(source.brdf);
  54501. }
  54502. if (source.sheen) {
  54503. material.sheen.parse(source.brdf);
  54504. }
  54505. return material;
  54506. };
  54507. /**
  54508. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54509. */
  54510. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  54511. /**
  54512. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54513. */
  54514. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  54515. /**
  54516. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54517. */
  54518. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  54519. /**
  54520. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54521. * They are also discarded below the alpha cutoff threshold to improve performances.
  54522. */
  54523. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  54524. /**
  54525. * Defines the default value of how much AO map is occluding the analytical lights
  54526. * (point spot...).
  54527. */
  54528. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54529. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54530. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54532. ], PBRMaterial.prototype, "directIntensity", void 0);
  54533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54536. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  54537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54540. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  54541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54544. ], PBRMaterial.prototype, "specularIntensity", void 0);
  54545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54548. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  54549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54552. ], PBRMaterial.prototype, "albedoTexture", void 0);
  54553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54556. ], PBRMaterial.prototype, "ambientTexture", void 0);
  54557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54560. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  54561. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54564. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  54565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54568. ], PBRMaterial.prototype, "opacityTexture", void 0);
  54569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54571. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54572. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  54573. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54574. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54576. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  54577. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54578. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54579. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54580. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  54581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54583. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54584. ], PBRMaterial.prototype, "metallicTexture", void 0);
  54585. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54586. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54587. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54588. ], PBRMaterial.prototype, "metallic", void 0);
  54589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54592. ], PBRMaterial.prototype, "roughness", void 0);
  54593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54595. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54596. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  54597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54598. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54600. ], PBRMaterial.prototype, "bumpTexture", void 0);
  54601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  54604. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  54605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54608. ], PBRMaterial.prototype, "refractionTexture", void 0);
  54609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  54611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54612. ], PBRMaterial.prototype, "ambientColor", void 0);
  54613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  54615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54616. ], PBRMaterial.prototype, "albedoColor", void 0);
  54617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  54619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54620. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  54621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  54623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54624. ], PBRMaterial.prototype, "reflectionColor", void 0);
  54625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  54627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54628. ], PBRMaterial.prototype, "emissiveColor", void 0);
  54629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54632. ], PBRMaterial.prototype, "microSurface", void 0);
  54633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54636. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  54637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54640. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  54641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54644. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  54645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54648. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  54649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54652. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  54653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54656. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  54657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54660. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  54661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54664. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  54665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54668. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  54669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54672. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  54673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54676. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  54677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54680. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  54681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54684. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  54685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54688. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  54689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54691. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54692. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  54693. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54694. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54695. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  54696. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54698. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  54699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54702. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  54703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54706. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  54707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54710. ], PBRMaterial.prototype, "useParallax", void 0);
  54711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54714. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  54715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54718. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  54719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54722. ], PBRMaterial.prototype, "disableLighting", void 0);
  54723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54725. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54726. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  54727. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54728. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54730. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  54731. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54733. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54734. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  54735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54736. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54737. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54738. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  54739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54742. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  54743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54745. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54746. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  54747. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54750. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  54751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54754. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  54755. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54758. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  54759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54762. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  54763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54765. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54766. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  54767. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54768. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54770. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  54771. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  54774. ], PBRMaterial.prototype, "unlit", void 0);
  54775. return PBRMaterial;
  54776. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  54777. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  54778. /***/ }),
  54779. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  54780. /*!*******************************************************!*\
  54781. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  54782. \*******************************************************/
  54783. /*! exports provided: PBRMetallicRoughnessMaterial */
  54784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54785. "use strict";
  54786. __webpack_require__.r(__webpack_exports__);
  54787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  54788. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54789. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54790. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  54791. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54792. /**
  54793. * The PBR material of BJS following the metal roughness convention.
  54794. *
  54795. * This fits to the PBR convention in the GLTF definition:
  54796. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54797. */
  54798. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  54799. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  54800. /**
  54801. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54802. *
  54803. * @param name The material name
  54804. * @param scene The scene the material will be use in.
  54805. */
  54806. function PBRMetallicRoughnessMaterial(name, scene) {
  54807. var _this = _super.call(this, name, scene) || this;
  54808. _this._useRoughnessFromMetallicTextureAlpha = false;
  54809. _this._useRoughnessFromMetallicTextureGreen = true;
  54810. _this._useMetallnessFromMetallicTextureBlue = true;
  54811. _this.metallic = 1.0;
  54812. _this.roughness = 1.0;
  54813. return _this;
  54814. }
  54815. /**
  54816. * Return the currrent class name of the material.
  54817. */
  54818. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  54819. return "PBRMetallicRoughnessMaterial";
  54820. };
  54821. /**
  54822. * Makes a duplicate of the current material.
  54823. * @param name - name to use for the new material.
  54824. */
  54825. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  54826. var _this = this;
  54827. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  54828. clone.id = name;
  54829. clone.name = name;
  54830. this.clearCoat.copyTo(clone.clearCoat);
  54831. this.anisotropy.copyTo(clone.anisotropy);
  54832. this.brdf.copyTo(clone.brdf);
  54833. this.sheen.copyTo(clone.sheen);
  54834. return clone;
  54835. };
  54836. /**
  54837. * Serialize the material to a parsable JSON object.
  54838. */
  54839. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  54840. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54841. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  54842. serializationObject.clearCoat = this.clearCoat.serialize();
  54843. serializationObject.anisotropy = this.anisotropy.serialize();
  54844. serializationObject.brdf = this.brdf.serialize();
  54845. serializationObject.sheen = this.sheen.serialize();
  54846. return serializationObject;
  54847. };
  54848. /**
  54849. * Parses a JSON object correponding to the serialize function.
  54850. */
  54851. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  54852. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  54853. if (source.clearCoat) {
  54854. material.clearCoat.parse(source.clearCoat);
  54855. }
  54856. if (source.anisotropy) {
  54857. material.anisotropy.parse(source.anisotropy);
  54858. }
  54859. if (source.brdf) {
  54860. material.brdf.parse(source.brdf);
  54861. }
  54862. if (source.sheen) {
  54863. material.sheen.parse(source.brdf);
  54864. }
  54865. return material;
  54866. };
  54867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  54869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  54870. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  54871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  54874. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  54875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54878. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  54879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54882. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  54883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  54886. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  54887. return PBRMetallicRoughnessMaterial;
  54888. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  54889. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  54890. /***/ }),
  54891. /***/ "./Materials/PBR/pbrSheenConfiguration.ts":
  54892. /*!************************************************!*\
  54893. !*** ./Materials/PBR/pbrSheenConfiguration.ts ***!
  54894. \************************************************/
  54895. /*! exports provided: PBRSheenConfiguration */
  54896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54897. "use strict";
  54898. __webpack_require__.r(__webpack_exports__);
  54899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSheenConfiguration", function() { return PBRSheenConfiguration; });
  54900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54901. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54902. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54903. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  54904. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  54905. /**
  54906. * Define the code related to the Sheen parameters of the pbr material.
  54907. */
  54908. var PBRSheenConfiguration = /** @class */ (function () {
  54909. /**
  54910. * Instantiate a new istance of clear coat configuration.
  54911. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54912. */
  54913. function PBRSheenConfiguration(markAllSubMeshesAsTexturesDirty) {
  54914. this._isEnabled = false;
  54915. /**
  54916. * Defines if the material uses sheen.
  54917. */
  54918. this.isEnabled = false;
  54919. this._linkSheenWithAlbedo = false;
  54920. /**
  54921. * Defines if the sheen is linked to the sheen color.
  54922. */
  54923. this.linkSheenWithAlbedo = false;
  54924. /**
  54925. * Defines the sheen intensity.
  54926. */
  54927. this.intensity = 1;
  54928. /**
  54929. * Defines the sheen color.
  54930. */
  54931. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  54932. this._texture = null;
  54933. /**
  54934. * Stores the sheen tint values in a texture.
  54935. * rgb is tint
  54936. * a is a intensity
  54937. */
  54938. this.texture = null;
  54939. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  54940. }
  54941. /** @hidden */
  54942. PBRSheenConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  54943. this._internalMarkAllSubMeshesAsTexturesDirty();
  54944. };
  54945. /**
  54946. * Specifies that the submesh is ready to be used.
  54947. * @param defines the list of "defines" to update.
  54948. * @param scene defines the scene the material belongs to.
  54949. * @returns - boolean indicating that the submesh is ready or not.
  54950. */
  54951. PBRSheenConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  54952. if (defines._areTexturesDirty) {
  54953. if (scene.texturesEnabled) {
  54954. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54955. if (!this._texture.isReadyOrNotBlocking()) {
  54956. return false;
  54957. }
  54958. }
  54959. }
  54960. }
  54961. return true;
  54962. };
  54963. /**
  54964. * Checks to see if a texture is used in the material.
  54965. * @param defines the list of "defines" to update.
  54966. * @param scene defines the scene the material belongs to.
  54967. */
  54968. PBRSheenConfiguration.prototype.prepareDefines = function (defines, scene) {
  54969. if (this._isEnabled) {
  54970. defines.SHEEN = this._isEnabled;
  54971. defines.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo;
  54972. if (defines._areTexturesDirty) {
  54973. if (scene.texturesEnabled) {
  54974. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54975. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "SHEEN_TEXTURE");
  54976. }
  54977. else {
  54978. defines.SHEEN_TEXTURE = false;
  54979. }
  54980. }
  54981. }
  54982. }
  54983. else {
  54984. defines.SHEEN = false;
  54985. defines.SHEEN_TEXTURE = false;
  54986. defines.SHEEN_LINKWITHALBEDO = false;
  54987. }
  54988. };
  54989. /**
  54990. * Binds the material data.
  54991. * @param uniformBuffer defines the Uniform buffer to fill in.
  54992. * @param scene defines the scene the material belongs to.
  54993. * @param isFrozen defines wether the material is frozen or not.
  54994. */
  54995. PBRSheenConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  54996. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  54997. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54998. uniformBuffer.updateFloat2("vSheenInfos", this._texture.coordinatesIndex, this._texture.level);
  54999. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "sheen");
  55000. }
  55001. // Sheen
  55002. uniformBuffer.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity);
  55003. }
  55004. // Textures
  55005. if (scene.texturesEnabled) {
  55006. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55007. uniformBuffer.setTexture("sheenSampler", this._texture);
  55008. }
  55009. }
  55010. };
  55011. /**
  55012. * Checks to see if a texture is used in the material.
  55013. * @param texture - Base texture to use.
  55014. * @returns - Boolean specifying if a texture is used in the material.
  55015. */
  55016. PBRSheenConfiguration.prototype.hasTexture = function (texture) {
  55017. if (this._texture === texture) {
  55018. return true;
  55019. }
  55020. return false;
  55021. };
  55022. /**
  55023. * Returns an array of the actively used textures.
  55024. * @param activeTextures Array of BaseTextures
  55025. */
  55026. PBRSheenConfiguration.prototype.getActiveTextures = function (activeTextures) {
  55027. if (this._texture) {
  55028. activeTextures.push(this._texture);
  55029. }
  55030. };
  55031. /**
  55032. * Returns the animatable textures.
  55033. * @param animatables Array of animatable textures.
  55034. */
  55035. PBRSheenConfiguration.prototype.getAnimatables = function (animatables) {
  55036. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  55037. animatables.push(this._texture);
  55038. }
  55039. };
  55040. /**
  55041. * Disposes the resources of the material.
  55042. * @param forceDisposeTextures - Forces the disposal of all textures.
  55043. */
  55044. PBRSheenConfiguration.prototype.dispose = function (forceDisposeTextures) {
  55045. if (forceDisposeTextures) {
  55046. if (this._texture) {
  55047. this._texture.dispose();
  55048. }
  55049. }
  55050. };
  55051. /**
  55052. * Get the current class name of the texture useful for serialization or dynamic coding.
  55053. * @returns "PBRSheenConfiguration"
  55054. */
  55055. PBRSheenConfiguration.prototype.getClassName = function () {
  55056. return "PBRSheenConfiguration";
  55057. };
  55058. /**
  55059. * Add fallbacks to the effect fallbacks list.
  55060. * @param defines defines the Base texture to use.
  55061. * @param fallbacks defines the current fallback list.
  55062. * @param currentRank defines the current fallback rank.
  55063. * @returns the new fallback rank.
  55064. */
  55065. PBRSheenConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  55066. if (defines.SHEEN) {
  55067. fallbacks.addFallback(currentRank++, "SHEEN");
  55068. }
  55069. return currentRank;
  55070. };
  55071. /**
  55072. * Add the required uniforms to the current list.
  55073. * @param uniforms defines the current uniform list.
  55074. */
  55075. PBRSheenConfiguration.AddUniforms = function (uniforms) {
  55076. uniforms.push("vSheenColor", "vSheenInfos", "sheenMatrix");
  55077. };
  55078. /**
  55079. * Add the required uniforms to the current buffer.
  55080. * @param uniformBuffer defines the current uniform buffer.
  55081. */
  55082. PBRSheenConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  55083. uniformBuffer.addUniform("vSheenColor", 4);
  55084. uniformBuffer.addUniform("vSheenInfos", 2);
  55085. uniformBuffer.addUniform("sheenMatrix", 16);
  55086. };
  55087. /**
  55088. * Add the required samplers to the current list.
  55089. * @param samplers defines the current sampler list.
  55090. */
  55091. PBRSheenConfiguration.AddSamplers = function (samplers) {
  55092. samplers.push("sheenSampler");
  55093. };
  55094. /**
  55095. * Makes a duplicate of the current configuration into another one.
  55096. * @param sheenConfiguration define the config where to copy the info
  55097. */
  55098. PBRSheenConfiguration.prototype.copyTo = function (sheenConfiguration) {
  55099. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return sheenConfiguration; }, this);
  55100. };
  55101. /**
  55102. * Serializes this BRDF configuration.
  55103. * @returns - An object with the serialized config.
  55104. */
  55105. PBRSheenConfiguration.prototype.serialize = function () {
  55106. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55107. };
  55108. /**
  55109. * Parses a Sheen Configuration from a serialized object.
  55110. * @param source - Serialized object.
  55111. */
  55112. PBRSheenConfiguration.prototype.parse = function (source) {
  55113. var _this = this;
  55114. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  55115. };
  55116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55118. ], PBRSheenConfiguration.prototype, "_isEnabled", void 0);
  55119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55121. ], PBRSheenConfiguration.prototype, "isEnabled", void 0);
  55122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55124. ], PBRSheenConfiguration.prototype, "_linkSheenWithAlbedo", void 0);
  55125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55127. ], PBRSheenConfiguration.prototype, "linkSheenWithAlbedo", void 0);
  55128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55130. ], PBRSheenConfiguration.prototype, "intensity", void 0);
  55131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  55133. ], PBRSheenConfiguration.prototype, "color", void 0);
  55134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  55136. ], PBRSheenConfiguration.prototype, "_texture", void 0);
  55137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55139. ], PBRSheenConfiguration.prototype, "texture", void 0);
  55140. return PBRSheenConfiguration;
  55141. }());
  55142. /***/ }),
  55143. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  55144. /*!********************************************************!*\
  55145. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  55146. \********************************************************/
  55147. /*! exports provided: PBRSpecularGlossinessMaterial */
  55148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55149. "use strict";
  55150. __webpack_require__.r(__webpack_exports__);
  55151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  55152. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55153. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55154. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  55155. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55156. /**
  55157. * The PBR material of BJS following the specular glossiness convention.
  55158. *
  55159. * This fits to the PBR convention in the GLTF definition:
  55160. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55161. */
  55162. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  55163. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  55164. /**
  55165. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55166. *
  55167. * @param name The material name
  55168. * @param scene The scene the material will be use in.
  55169. */
  55170. function PBRSpecularGlossinessMaterial(name, scene) {
  55171. var _this = _super.call(this, name, scene) || this;
  55172. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  55173. return _this;
  55174. }
  55175. /**
  55176. * Return the currrent class name of the material.
  55177. */
  55178. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  55179. return "PBRSpecularGlossinessMaterial";
  55180. };
  55181. /**
  55182. * Makes a duplicate of the current material.
  55183. * @param name - name to use for the new material.
  55184. */
  55185. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  55186. var _this = this;
  55187. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  55188. clone.id = name;
  55189. clone.name = name;
  55190. this.clearCoat.copyTo(clone.clearCoat);
  55191. this.anisotropy.copyTo(clone.anisotropy);
  55192. this.brdf.copyTo(clone.brdf);
  55193. this.sheen.copyTo(clone.sheen);
  55194. return clone;
  55195. };
  55196. /**
  55197. * Serialize the material to a parsable JSON object.
  55198. */
  55199. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  55200. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55201. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  55202. serializationObject.clearCoat = this.clearCoat.serialize();
  55203. serializationObject.anisotropy = this.anisotropy.serialize();
  55204. serializationObject.brdf = this.brdf.serialize();
  55205. serializationObject.sheen = this.sheen.serialize();
  55206. return serializationObject;
  55207. };
  55208. /**
  55209. * Parses a JSON object correponding to the serialize function.
  55210. */
  55211. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  55212. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  55213. if (source.clearCoat) {
  55214. material.clearCoat.parse(source.clearCoat);
  55215. }
  55216. if (source.anisotropy) {
  55217. material.anisotropy.parse(source.anisotropy);
  55218. }
  55219. if (source.brdf) {
  55220. material.brdf.parse(source.brdf);
  55221. }
  55222. if (source.sheen) {
  55223. material.sheen.parse(source.brdf);
  55224. }
  55225. return material;
  55226. };
  55227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  55229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55230. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  55231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55234. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  55235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  55237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  55238. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  55239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  55242. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  55243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  55246. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  55247. return PBRSpecularGlossinessMaterial;
  55248. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55249. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  55250. /***/ }),
  55251. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  55252. /*!********************************************************!*\
  55253. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  55254. \********************************************************/
  55255. /*! exports provided: _DDSTextureLoader */
  55256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55257. "use strict";
  55258. __webpack_require__.r(__webpack_exports__);
  55259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  55260. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  55261. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55262. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  55263. /**
  55264. * Implementation of the DDS Texture Loader.
  55265. * @hidden
  55266. */
  55267. var _DDSTextureLoader = /** @class */ (function () {
  55268. function _DDSTextureLoader() {
  55269. /**
  55270. * Defines wether the loader supports cascade loading the different faces.
  55271. */
  55272. this.supportCascades = true;
  55273. }
  55274. /**
  55275. * This returns if the loader support the current file information.
  55276. * @param extension defines the file extension of the file being loaded
  55277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55278. * @param fallback defines the fallback internal texture if any
  55279. * @param isBase64 defines whether the texture is encoded as a base64
  55280. * @param isBuffer defines whether the texture data are stored as a buffer
  55281. * @returns true if the loader can load the specified file
  55282. */
  55283. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55284. return extension.indexOf(".dds") === 0;
  55285. };
  55286. /**
  55287. * Transform the url before loading if required.
  55288. * @param rootUrl the url of the texture
  55289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55290. * @returns the transformed texture
  55291. */
  55292. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55293. return rootUrl;
  55294. };
  55295. /**
  55296. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55297. * @param rootUrl the url of the texture
  55298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55299. * @returns the fallback texture
  55300. */
  55301. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55302. return null;
  55303. };
  55304. /**
  55305. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55306. * @param data contains the texture data
  55307. * @param texture defines the BabylonJS internal texture
  55308. * @param createPolynomials will be true if polynomials have been requested
  55309. * @param onLoad defines the callback to trigger once the texture is ready
  55310. * @param onError defines the callback to trigger in case of error
  55311. */
  55312. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  55313. var engine = texture.getEngine();
  55314. var info;
  55315. var loadMipmap = false;
  55316. if (Array.isArray(imgs)) {
  55317. for (var index = 0; index < imgs.length; index++) {
  55318. var data_1 = imgs[index];
  55319. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  55320. texture.width = info.width;
  55321. texture.height = info.height;
  55322. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  55323. engine._unpackFlipY(info.isCompressed);
  55324. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  55325. if (!info.isFourCC && info.mipmapCount === 1) {
  55326. engine.generateMipMapsForCubemap(texture);
  55327. }
  55328. }
  55329. }
  55330. else {
  55331. var data = imgs;
  55332. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  55333. texture.width = info.width;
  55334. texture.height = info.height;
  55335. if (createPolynomials) {
  55336. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  55337. }
  55338. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  55339. engine._unpackFlipY(info.isCompressed);
  55340. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  55341. if (!info.isFourCC && info.mipmapCount === 1) {
  55342. engine.generateMipMapsForCubemap(texture);
  55343. }
  55344. }
  55345. engine._setCubeMapTextureParams(loadMipmap);
  55346. texture.isReady = true;
  55347. if (onLoad) {
  55348. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  55349. }
  55350. };
  55351. /**
  55352. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55353. * @param data contains the texture data
  55354. * @param texture defines the BabylonJS internal texture
  55355. * @param callback defines the method to call once ready to upload
  55356. */
  55357. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  55358. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  55359. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  55360. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  55361. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  55362. });
  55363. };
  55364. return _DDSTextureLoader;
  55365. }());
  55366. // Register the loader.
  55367. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  55368. /***/ }),
  55369. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  55370. /*!********************************************************!*\
  55371. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  55372. \********************************************************/
  55373. /*! exports provided: _ENVTextureLoader */
  55374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55375. "use strict";
  55376. __webpack_require__.r(__webpack_exports__);
  55377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  55378. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  55379. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55380. /**
  55381. * Implementation of the ENV Texture Loader.
  55382. * @hidden
  55383. */
  55384. var _ENVTextureLoader = /** @class */ (function () {
  55385. function _ENVTextureLoader() {
  55386. /**
  55387. * Defines wether the loader supports cascade loading the different faces.
  55388. */
  55389. this.supportCascades = false;
  55390. }
  55391. /**
  55392. * This returns if the loader support the current file information.
  55393. * @param extension defines the file extension of the file being loaded
  55394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55395. * @param fallback defines the fallback internal texture if any
  55396. * @param isBase64 defines whether the texture is encoded as a base64
  55397. * @param isBuffer defines whether the texture data are stored as a buffer
  55398. * @returns true if the loader can load the specified file
  55399. */
  55400. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55401. return extension.indexOf(".env") === 0;
  55402. };
  55403. /**
  55404. * Transform the url before loading if required.
  55405. * @param rootUrl the url of the texture
  55406. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55407. * @returns the transformed texture
  55408. */
  55409. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55410. return rootUrl;
  55411. };
  55412. /**
  55413. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55414. * @param rootUrl the url of the texture
  55415. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55416. * @returns the fallback texture
  55417. */
  55418. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55419. return null;
  55420. };
  55421. /**
  55422. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55423. * @param data contains the texture data
  55424. * @param texture defines the BabylonJS internal texture
  55425. * @param createPolynomials will be true if polynomials have been requested
  55426. * @param onLoad defines the callback to trigger once the texture is ready
  55427. * @param onError defines the callback to trigger in case of error
  55428. */
  55429. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55430. if (Array.isArray(data)) {
  55431. return;
  55432. }
  55433. data = data;
  55434. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  55435. if (info) {
  55436. texture.width = info.width;
  55437. texture.height = info.width;
  55438. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  55439. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  55440. texture.isReady = true;
  55441. if (onLoad) {
  55442. onLoad();
  55443. }
  55444. });
  55445. }
  55446. else if (onError) {
  55447. onError("Can not parse the environment file", null);
  55448. }
  55449. };
  55450. /**
  55451. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55452. * @param data contains the texture data
  55453. * @param texture defines the BabylonJS internal texture
  55454. * @param callback defines the method to call once ready to upload
  55455. */
  55456. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  55457. throw ".env not supported in 2d.";
  55458. };
  55459. return _ENVTextureLoader;
  55460. }());
  55461. // Register the loader.
  55462. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  55463. /***/ }),
  55464. /***/ "./Materials/Textures/Loaders/index.ts":
  55465. /*!*********************************************!*\
  55466. !*** ./Materials/Textures/Loaders/index.ts ***!
  55467. \*********************************************/
  55468. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  55469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55470. "use strict";
  55471. __webpack_require__.r(__webpack_exports__);
  55472. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  55473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  55474. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  55475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  55476. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  55477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  55478. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  55479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  55480. /***/ }),
  55481. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  55482. /*!********************************************************!*\
  55483. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  55484. \********************************************************/
  55485. /*! exports provided: _KTXTextureLoader */
  55486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55487. "use strict";
  55488. __webpack_require__.r(__webpack_exports__);
  55489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  55490. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  55491. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55492. /**
  55493. * Implementation of the KTX Texture Loader.
  55494. * @hidden
  55495. */
  55496. var _KTXTextureLoader = /** @class */ (function () {
  55497. function _KTXTextureLoader() {
  55498. /**
  55499. * Defines wether the loader supports cascade loading the different faces.
  55500. */
  55501. this.supportCascades = false;
  55502. }
  55503. /**
  55504. * This returns if the loader support the current file information.
  55505. * @param extension defines the file extension of the file being loaded
  55506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55507. * @param fallback defines the fallback internal texture if any
  55508. * @param isBase64 defines whether the texture is encoded as a base64
  55509. * @param isBuffer defines whether the texture data are stored as a buffer
  55510. * @returns true if the loader can load the specified file
  55511. */
  55512. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55513. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  55514. return true;
  55515. }
  55516. return false;
  55517. };
  55518. /**
  55519. * Transform the url before loading if required.
  55520. * @param rootUrl the url of the texture
  55521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55522. * @returns the transformed texture
  55523. */
  55524. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55525. var lastDot = rootUrl.lastIndexOf('.');
  55526. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  55527. // Already transformed
  55528. return rootUrl;
  55529. }
  55530. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  55531. };
  55532. /**
  55533. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55534. * @param rootUrl the url of the texture
  55535. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55536. * @returns the fallback texture
  55537. */
  55538. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55539. // remove the format appended to the rootUrl in the original createCubeTexture call.
  55540. var exp = new RegExp("" + textureFormatInUse + "$");
  55541. return rootUrl.replace(exp, "");
  55542. };
  55543. /**
  55544. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55545. * @param data contains the texture data
  55546. * @param texture defines the BabylonJS internal texture
  55547. * @param createPolynomials will be true if polynomials have been requested
  55548. * @param onLoad defines the callback to trigger once the texture is ready
  55549. * @param onError defines the callback to trigger in case of error
  55550. */
  55551. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55552. if (Array.isArray(data)) {
  55553. return;
  55554. }
  55555. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  55556. texture._invertVScale = !texture.invertY;
  55557. var engine = texture.getEngine();
  55558. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  55559. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  55560. engine._unpackFlipY(true);
  55561. ktx.uploadLevels(texture, texture.generateMipMaps);
  55562. texture.width = ktx.pixelWidth;
  55563. texture.height = ktx.pixelHeight;
  55564. engine._setCubeMapTextureParams(loadMipmap);
  55565. texture.isReady = true;
  55566. };
  55567. /**
  55568. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55569. * @param data contains the texture data
  55570. * @param texture defines the BabylonJS internal texture
  55571. * @param callback defines the method to call once ready to upload
  55572. */
  55573. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  55574. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  55575. texture._invertVScale = !texture.invertY;
  55576. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  55577. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  55578. ktx.uploadLevels(texture, texture.generateMipMaps);
  55579. }, ktx.isInvalid);
  55580. };
  55581. return _KTXTextureLoader;
  55582. }());
  55583. // Register the loader.
  55584. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  55585. /***/ }),
  55586. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  55587. /*!********************************************************!*\
  55588. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  55589. \********************************************************/
  55590. /*! exports provided: _TGATextureLoader */
  55591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55592. "use strict";
  55593. __webpack_require__.r(__webpack_exports__);
  55594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  55595. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  55596. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55597. /**
  55598. * Implementation of the TGA Texture Loader.
  55599. * @hidden
  55600. */
  55601. var _TGATextureLoader = /** @class */ (function () {
  55602. function _TGATextureLoader() {
  55603. /**
  55604. * Defines wether the loader supports cascade loading the different faces.
  55605. */
  55606. this.supportCascades = false;
  55607. }
  55608. /**
  55609. * This returns if the loader support the current file information.
  55610. * @param extension defines the file extension of the file being loaded
  55611. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55612. * @param fallback defines the fallback internal texture if any
  55613. * @param isBase64 defines whether the texture is encoded as a base64
  55614. * @param isBuffer defines whether the texture data are stored as a buffer
  55615. * @returns true if the loader can load the specified file
  55616. */
  55617. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55618. return extension.indexOf(".tga") === 0;
  55619. };
  55620. /**
  55621. * Transform the url before loading if required.
  55622. * @param rootUrl the url of the texture
  55623. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55624. * @returns the transformed texture
  55625. */
  55626. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55627. return rootUrl;
  55628. };
  55629. /**
  55630. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55631. * @param rootUrl the url of the texture
  55632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55633. * @returns the fallback texture
  55634. */
  55635. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55636. return null;
  55637. };
  55638. /**
  55639. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55640. * @param data contains the texture data
  55641. * @param texture defines the BabylonJS internal texture
  55642. * @param createPolynomials will be true if polynomials have been requested
  55643. * @param onLoad defines the callback to trigger once the texture is ready
  55644. * @param onError defines the callback to trigger in case of error
  55645. */
  55646. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55647. throw ".env not supported in Cube.";
  55648. };
  55649. /**
  55650. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55651. * @param data contains the texture data
  55652. * @param texture defines the BabylonJS internal texture
  55653. * @param callback defines the method to call once ready to upload
  55654. */
  55655. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  55656. var uintData = new Uint8Array(data);
  55657. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  55658. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  55659. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  55660. });
  55661. };
  55662. return _TGATextureLoader;
  55663. }());
  55664. // Register the loader.
  55665. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  55666. /***/ }),
  55667. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  55668. /*!*******************************************************************!*\
  55669. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  55670. \*******************************************************************/
  55671. /*! exports provided: CustomProceduralTexture */
  55672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55673. "use strict";
  55674. __webpack_require__.r(__webpack_exports__);
  55675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  55676. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55677. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  55678. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  55679. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55680. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55681. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Misc/webRequest */ "./Misc/webRequest.ts");
  55682. /**
  55683. * 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.
  55684. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55685. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55686. */
  55687. var CustomProceduralTexture = /** @class */ (function (_super) {
  55688. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  55689. /**
  55690. * Instantiates a new Custom Procedural Texture.
  55691. * 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.
  55692. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55693. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55694. * @param name Define the name of the texture
  55695. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55696. * @param size Define the size of the texture to create
  55697. * @param scene Define the scene the texture belongs to
  55698. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55699. * @param generateMipMaps Define if the texture should creates mip maps or not
  55700. */
  55701. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  55702. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  55703. _this._animate = true;
  55704. _this._time = 0;
  55705. _this._texturePath = texturePath;
  55706. //Try to load json
  55707. _this._loadJson(texturePath);
  55708. _this.refreshRate = 1;
  55709. return _this;
  55710. }
  55711. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  55712. var _this = this;
  55713. var noConfigFile = function () {
  55714. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  55715. try {
  55716. _this.setFragment(_this._texturePath);
  55717. }
  55718. catch (ex) {
  55719. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  55720. }
  55721. };
  55722. var configFileUrl = jsonUrl + "/config.json";
  55723. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__["WebRequest"]();
  55724. xhr.open("GET", configFileUrl);
  55725. xhr.addEventListener("load", function () {
  55726. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  55727. try {
  55728. _this._config = JSON.parse(xhr.response);
  55729. _this.updateShaderUniforms();
  55730. _this.updateTextures();
  55731. _this.setFragment(_this._texturePath + "/custom");
  55732. _this._animate = _this._config.animate;
  55733. _this.refreshRate = _this._config.refreshrate;
  55734. }
  55735. catch (ex) {
  55736. noConfigFile();
  55737. }
  55738. }
  55739. else {
  55740. noConfigFile();
  55741. }
  55742. }, false);
  55743. xhr.addEventListener("error", function () {
  55744. noConfigFile();
  55745. }, false);
  55746. try {
  55747. xhr.send();
  55748. }
  55749. catch (ex) {
  55750. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  55751. }
  55752. };
  55753. /**
  55754. * Is the texture ready to be used ? (rendered at least once)
  55755. * @returns true if ready, otherwise, false.
  55756. */
  55757. CustomProceduralTexture.prototype.isReady = function () {
  55758. if (!_super.prototype.isReady.call(this)) {
  55759. return false;
  55760. }
  55761. for (var name in this._textures) {
  55762. var texture = this._textures[name];
  55763. if (!texture.isReady()) {
  55764. return false;
  55765. }
  55766. }
  55767. return true;
  55768. };
  55769. /**
  55770. * Render the texture to its associated render target.
  55771. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55772. */
  55773. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  55774. var scene = this.getScene();
  55775. if (this._animate && scene) {
  55776. this._time += scene.getAnimationRatio() * 0.03;
  55777. this.updateShaderUniforms();
  55778. }
  55779. _super.prototype.render.call(this, useCameraPostProcess);
  55780. };
  55781. /**
  55782. * Update the list of dependant textures samplers in the shader.
  55783. */
  55784. CustomProceduralTexture.prototype.updateTextures = function () {
  55785. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  55786. this.setTexture(this._config.sampler2Ds[i].sample2Dname, new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"](this._texturePath + "/" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));
  55787. }
  55788. };
  55789. /**
  55790. * Update the uniform values of the procedural texture in the shader.
  55791. */
  55792. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  55793. if (this._config) {
  55794. for (var j = 0; j < this._config.uniforms.length; j++) {
  55795. var uniform = this._config.uniforms[j];
  55796. switch (uniform.type) {
  55797. case "float":
  55798. this.setFloat(uniform.name, uniform.value);
  55799. break;
  55800. case "color3":
  55801. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](uniform.r, uniform.g, uniform.b));
  55802. break;
  55803. case "color4":
  55804. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  55805. break;
  55806. case "vector2":
  55807. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](uniform.x, uniform.y));
  55808. break;
  55809. case "vector3":
  55810. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](uniform.x, uniform.y, uniform.z));
  55811. break;
  55812. }
  55813. }
  55814. }
  55815. this.setFloat("time", this._time);
  55816. };
  55817. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  55818. /**
  55819. * Define if the texture animates or not.
  55820. */
  55821. get: function () {
  55822. return this._animate;
  55823. },
  55824. set: function (value) {
  55825. this._animate = value;
  55826. },
  55827. enumerable: true,
  55828. configurable: true
  55829. });
  55830. return CustomProceduralTexture;
  55831. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_4__["ProceduralTexture"]));
  55832. /***/ }),
  55833. /***/ "./Materials/Textures/Procedurals/index.ts":
  55834. /*!*************************************************!*\
  55835. !*** ./Materials/Textures/Procedurals/index.ts ***!
  55836. \*************************************************/
  55837. /*! exports provided: CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  55838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55839. "use strict";
  55840. __webpack_require__.r(__webpack_exports__);
  55841. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  55842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  55843. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  55844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  55845. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  55847. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  55848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  55849. /***/ }),
  55850. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  55851. /*!******************************************************************!*\
  55852. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  55853. \******************************************************************/
  55854. /*! exports provided: NoiseProceduralTexture */
  55855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55856. "use strict";
  55857. __webpack_require__.r(__webpack_exports__);
  55858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  55859. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55860. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  55861. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55862. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55863. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  55864. /**
  55865. * Class used to generate noise procedural textures
  55866. */
  55867. var NoiseProceduralTexture = /** @class */ (function (_super) {
  55868. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  55869. /**
  55870. * Creates a new NoiseProceduralTexture
  55871. * @param name defines the name fo the texture
  55872. * @param size defines the size of the texture (default is 256)
  55873. * @param scene defines the hosting scene
  55874. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55875. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55876. */
  55877. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  55878. if (size === void 0) { size = 256; }
  55879. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  55880. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  55881. _this._time = 0;
  55882. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55883. _this.brightness = 0.2;
  55884. /** Defines the number of octaves to process */
  55885. _this.octaves = 3;
  55886. /** Defines the level of persistence (0.8 by default) */
  55887. _this.persistence = 0.8;
  55888. /** Gets or sets animation speed factor (default is 1) */
  55889. _this.animationSpeedFactor = 1;
  55890. _this.autoClear = false;
  55891. _this._updateShaderUniforms();
  55892. return _this;
  55893. }
  55894. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  55895. var scene = this.getScene();
  55896. if (!scene) {
  55897. return;
  55898. }
  55899. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  55900. this.setFloat("brightness", this.brightness);
  55901. this.setFloat("persistence", this.persistence);
  55902. this.setFloat("timeScale", this._time);
  55903. };
  55904. NoiseProceduralTexture.prototype._getDefines = function () {
  55905. return "#define OCTAVES " + (this.octaves | 0);
  55906. };
  55907. /** Generate the current state of the procedural texture */
  55908. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  55909. this._updateShaderUniforms();
  55910. _super.prototype.render.call(this, useCameraPostProcess);
  55911. };
  55912. /**
  55913. * Serializes this noise procedural texture
  55914. * @returns a serialized noise procedural texture object
  55915. */
  55916. NoiseProceduralTexture.prototype.serialize = function () {
  55917. var serializationObject = {};
  55918. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  55919. serializationObject.brightness = this.brightness;
  55920. serializationObject.octaves = this.octaves;
  55921. serializationObject.persistence = this.persistence;
  55922. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  55923. serializationObject.size = this.getSize().width;
  55924. serializationObject.generateMipMaps = this._generateMipMaps;
  55925. return serializationObject;
  55926. };
  55927. /**
  55928. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55929. * @param parsedTexture defines parsed texture data
  55930. * @param scene defines the current scene
  55931. * @param rootUrl defines the root URL containing noise procedural texture information
  55932. * @returns a parsed NoiseProceduralTexture
  55933. */
  55934. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  55935. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  55936. texture.brightness = parsedTexture.brightness;
  55937. texture.octaves = parsedTexture.octaves;
  55938. texture.persistence = parsedTexture.persistence;
  55939. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  55940. return texture;
  55941. };
  55942. return NoiseProceduralTexture;
  55943. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  55944. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  55945. /***/ }),
  55946. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  55947. /*!*************************************************************!*\
  55948. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  55949. \*************************************************************/
  55950. /*! exports provided: ProceduralTexture */
  55951. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55952. "use strict";
  55953. __webpack_require__.r(__webpack_exports__);
  55954. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  55955. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55956. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  55957. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  55958. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  55959. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  55960. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  55961. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55962. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  55963. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  55964. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  55965. /**
  55966. * 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.
  55967. * This is the base class of any Procedural texture and contains most of the shareable code.
  55968. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  55969. */
  55970. var ProceduralTexture = /** @class */ (function (_super) {
  55971. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  55972. /**
  55973. * Instantiates a new procedural texture.
  55974. * 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.
  55975. * This is the base class of any Procedural texture and contains most of the shareable code.
  55976. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  55977. * @param name Define the name of the texture
  55978. * @param size Define the size of the texture to create
  55979. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  55980. * @param scene Define the scene the texture belongs to
  55981. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55982. * @param generateMipMaps Define if the texture should creates mip maps or not
  55983. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  55984. */
  55985. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  55986. if (fallbackTexture === void 0) { fallbackTexture = null; }
  55987. if (generateMipMaps === void 0) { generateMipMaps = true; }
  55988. if (isCube === void 0) { isCube = false; }
  55989. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  55990. _this.isCube = isCube;
  55991. /**
  55992. * Define if the texture is enabled or not (disabled texture will not render)
  55993. */
  55994. _this.isEnabled = true;
  55995. /**
  55996. * Define if the texture must be cleared before rendering (default is true)
  55997. */
  55998. _this.autoClear = true;
  55999. /**
  56000. * Event raised when the texture is generated
  56001. */
  56002. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  56003. /** @hidden */
  56004. _this._textures = {};
  56005. _this._currentRefreshId = -1;
  56006. _this._refreshRate = 1;
  56007. _this._vertexBuffers = {};
  56008. _this._uniforms = new Array();
  56009. _this._samplers = new Array();
  56010. _this._floats = {};
  56011. _this._ints = {};
  56012. _this._floatsArrays = {};
  56013. _this._colors3 = {};
  56014. _this._colors4 = {};
  56015. _this._vectors2 = {};
  56016. _this._vectors3 = {};
  56017. _this._matrices = {};
  56018. _this._fallbackTextureUsed = false;
  56019. _this._cachedDefines = "";
  56020. _this._contentUpdateId = -1;
  56021. scene = _this.getScene();
  56022. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  56023. if (!component) {
  56024. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  56025. scene._addComponent(component);
  56026. }
  56027. scene.proceduralTextures.push(_this);
  56028. _this._engine = scene.getEngine();
  56029. _this.name = name;
  56030. _this.isRenderTarget = true;
  56031. _this._size = size;
  56032. _this._generateMipMaps = generateMipMaps;
  56033. _this.setFragment(fragment);
  56034. _this._fallbackTexture = fallbackTexture;
  56035. if (isCube) {
  56036. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56037. _this.setFloat("face", 0);
  56038. }
  56039. else {
  56040. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56041. }
  56042. // VBO
  56043. var vertices = [];
  56044. vertices.push(1, 1);
  56045. vertices.push(-1, 1);
  56046. vertices.push(-1, -1);
  56047. vertices.push(1, -1);
  56048. _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);
  56049. _this._createIndexBuffer();
  56050. return _this;
  56051. }
  56052. /**
  56053. * The effect that is created when initializing the post process.
  56054. * @returns The created effect corrisponding the the postprocess.
  56055. */
  56056. ProceduralTexture.prototype.getEffect = function () {
  56057. return this._effect;
  56058. };
  56059. /**
  56060. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  56061. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  56062. */
  56063. ProceduralTexture.prototype.getContent = function () {
  56064. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  56065. return this._contentData;
  56066. }
  56067. this._contentData = this.readPixels(0, 0, this._contentData);
  56068. this._contentUpdateId = this._currentRefreshId;
  56069. return this._contentData;
  56070. };
  56071. ProceduralTexture.prototype._createIndexBuffer = function () {
  56072. var engine = this._engine;
  56073. // Indices
  56074. var indices = [];
  56075. indices.push(0);
  56076. indices.push(1);
  56077. indices.push(2);
  56078. indices.push(0);
  56079. indices.push(2);
  56080. indices.push(3);
  56081. this._indexBuffer = engine.createIndexBuffer(indices);
  56082. };
  56083. /** @hidden */
  56084. ProceduralTexture.prototype._rebuild = function () {
  56085. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  56086. if (vb) {
  56087. vb._rebuild();
  56088. }
  56089. this._createIndexBuffer();
  56090. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  56091. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  56092. }
  56093. };
  56094. /**
  56095. * Resets the texture in order to recreate its associated resources.
  56096. * This can be called in case of context loss
  56097. */
  56098. ProceduralTexture.prototype.reset = function () {
  56099. if (this._effect === undefined) {
  56100. return;
  56101. }
  56102. var engine = this._engine;
  56103. engine._releaseEffect(this._effect);
  56104. };
  56105. ProceduralTexture.prototype._getDefines = function () {
  56106. return "";
  56107. };
  56108. /**
  56109. * Is the texture ready to be used ? (rendered at least once)
  56110. * @returns true if ready, otherwise, false.
  56111. */
  56112. ProceduralTexture.prototype.isReady = function () {
  56113. var _this = this;
  56114. var engine = this._engine;
  56115. var shaders;
  56116. if (!this._fragment) {
  56117. return false;
  56118. }
  56119. if (this._fallbackTextureUsed) {
  56120. return true;
  56121. }
  56122. var defines = this._getDefines();
  56123. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  56124. return true;
  56125. }
  56126. if (this._fragment.fragmentElement !== undefined) {
  56127. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  56128. }
  56129. else {
  56130. shaders = { vertex: "procedural", fragment: this._fragment };
  56131. }
  56132. this._cachedDefines = defines;
  56133. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  56134. _this.releaseInternalTexture();
  56135. if (_this._fallbackTexture) {
  56136. _this._texture = _this._fallbackTexture._texture;
  56137. if (_this._texture) {
  56138. _this._texture.incrementReferences();
  56139. }
  56140. }
  56141. _this._fallbackTextureUsed = true;
  56142. });
  56143. return this._effect.isReady();
  56144. };
  56145. /**
  56146. * Resets the refresh counter of the texture and start bak from scratch.
  56147. * Could be useful to regenerate the texture if it is setup to render only once.
  56148. */
  56149. ProceduralTexture.prototype.resetRefreshCounter = function () {
  56150. this._currentRefreshId = -1;
  56151. };
  56152. /**
  56153. * Set the fragment shader to use in order to render the texture.
  56154. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  56155. */
  56156. ProceduralTexture.prototype.setFragment = function (fragment) {
  56157. this._fragment = fragment;
  56158. };
  56159. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  56160. /**
  56161. * Define the refresh rate of the texture or the rendering frequency.
  56162. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  56163. */
  56164. get: function () {
  56165. return this._refreshRate;
  56166. },
  56167. set: function (value) {
  56168. this._refreshRate = value;
  56169. this.resetRefreshCounter();
  56170. },
  56171. enumerable: true,
  56172. configurable: true
  56173. });
  56174. /** @hidden */
  56175. ProceduralTexture.prototype._shouldRender = function () {
  56176. if (!this.isEnabled || !this.isReady() || !this._texture) {
  56177. if (this._texture) {
  56178. this._texture.isReady = false;
  56179. }
  56180. return false;
  56181. }
  56182. if (this._fallbackTextureUsed) {
  56183. return false;
  56184. }
  56185. if (this._currentRefreshId === -1) { // At least render once
  56186. this._currentRefreshId = 1;
  56187. return true;
  56188. }
  56189. if (this.refreshRate === this._currentRefreshId) {
  56190. this._currentRefreshId = 1;
  56191. return true;
  56192. }
  56193. this._currentRefreshId++;
  56194. return false;
  56195. };
  56196. /**
  56197. * Get the size the texture is rendering at.
  56198. * @returns the size (texture is always squared)
  56199. */
  56200. ProceduralTexture.prototype.getRenderSize = function () {
  56201. return this._size;
  56202. };
  56203. /**
  56204. * Resize the texture to new value.
  56205. * @param size Define the new size the texture should have
  56206. * @param generateMipMaps Define whether the new texture should create mip maps
  56207. */
  56208. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  56209. if (this._fallbackTextureUsed) {
  56210. return;
  56211. }
  56212. this.releaseInternalTexture();
  56213. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  56214. // Update properties
  56215. this._size = size;
  56216. this._generateMipMaps = generateMipMaps;
  56217. };
  56218. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  56219. if (this._uniforms.indexOf(uniformName) === -1) {
  56220. this._uniforms.push(uniformName);
  56221. }
  56222. };
  56223. /**
  56224. * Set a texture in the shader program used to render.
  56225. * @param name Define the name of the uniform samplers as defined in the shader
  56226. * @param texture Define the texture to bind to this sampler
  56227. * @return the texture itself allowing "fluent" like uniform updates
  56228. */
  56229. ProceduralTexture.prototype.setTexture = function (name, texture) {
  56230. if (this._samplers.indexOf(name) === -1) {
  56231. this._samplers.push(name);
  56232. }
  56233. this._textures[name] = texture;
  56234. return this;
  56235. };
  56236. /**
  56237. * Set a float in the shader.
  56238. * @param name Define the name of the uniform as defined in the shader
  56239. * @param value Define the value to give to the uniform
  56240. * @return the texture itself allowing "fluent" like uniform updates
  56241. */
  56242. ProceduralTexture.prototype.setFloat = function (name, value) {
  56243. this._checkUniform(name);
  56244. this._floats[name] = value;
  56245. return this;
  56246. };
  56247. /**
  56248. * Set a int in the shader.
  56249. * @param name Define the name of the uniform as defined in the shader
  56250. * @param value Define the value to give to the uniform
  56251. * @return the texture itself allowing "fluent" like uniform updates
  56252. */
  56253. ProceduralTexture.prototype.setInt = function (name, value) {
  56254. this._checkUniform(name);
  56255. this._ints[name] = value;
  56256. return this;
  56257. };
  56258. /**
  56259. * Set an array of floats in the shader.
  56260. * @param name Define the name of the uniform as defined in the shader
  56261. * @param value Define the value to give to the uniform
  56262. * @return the texture itself allowing "fluent" like uniform updates
  56263. */
  56264. ProceduralTexture.prototype.setFloats = function (name, value) {
  56265. this._checkUniform(name);
  56266. this._floatsArrays[name] = value;
  56267. return this;
  56268. };
  56269. /**
  56270. * Set a vec3 in the shader from a Color3.
  56271. * @param name Define the name of the uniform as defined in the shader
  56272. * @param value Define the value to give to the uniform
  56273. * @return the texture itself allowing "fluent" like uniform updates
  56274. */
  56275. ProceduralTexture.prototype.setColor3 = function (name, value) {
  56276. this._checkUniform(name);
  56277. this._colors3[name] = value;
  56278. return this;
  56279. };
  56280. /**
  56281. * Set a vec4 in the shader from a Color4.
  56282. * @param name Define the name of the uniform as defined in the shader
  56283. * @param value Define the value to give to the uniform
  56284. * @return the texture itself allowing "fluent" like uniform updates
  56285. */
  56286. ProceduralTexture.prototype.setColor4 = function (name, value) {
  56287. this._checkUniform(name);
  56288. this._colors4[name] = value;
  56289. return this;
  56290. };
  56291. /**
  56292. * Set a vec2 in the shader from a Vector2.
  56293. * @param name Define the name of the uniform as defined in the shader
  56294. * @param value Define the value to give to the uniform
  56295. * @return the texture itself allowing "fluent" like uniform updates
  56296. */
  56297. ProceduralTexture.prototype.setVector2 = function (name, value) {
  56298. this._checkUniform(name);
  56299. this._vectors2[name] = value;
  56300. return this;
  56301. };
  56302. /**
  56303. * Set a vec3 in the shader from a Vector3.
  56304. * @param name Define the name of the uniform as defined in the shader
  56305. * @param value Define the value to give to the uniform
  56306. * @return the texture itself allowing "fluent" like uniform updates
  56307. */
  56308. ProceduralTexture.prototype.setVector3 = function (name, value) {
  56309. this._checkUniform(name);
  56310. this._vectors3[name] = value;
  56311. return this;
  56312. };
  56313. /**
  56314. * Set a mat4 in the shader from a MAtrix.
  56315. * @param name Define the name of the uniform as defined in the shader
  56316. * @param value Define the value to give to the uniform
  56317. * @return the texture itself allowing "fluent" like uniform updates
  56318. */
  56319. ProceduralTexture.prototype.setMatrix = function (name, value) {
  56320. this._checkUniform(name);
  56321. this._matrices[name] = value;
  56322. return this;
  56323. };
  56324. /**
  56325. * Render the texture to its associated render target.
  56326. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56327. */
  56328. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56329. var scene = this.getScene();
  56330. if (!scene) {
  56331. return;
  56332. }
  56333. var engine = this._engine;
  56334. // Render
  56335. engine.enableEffect(this._effect);
  56336. engine.setState(false);
  56337. // Texture
  56338. for (var name in this._textures) {
  56339. this._effect.setTexture(name, this._textures[name]);
  56340. }
  56341. // Float
  56342. for (name in this._ints) {
  56343. this._effect.setInt(name, this._ints[name]);
  56344. }
  56345. // Float
  56346. for (name in this._floats) {
  56347. this._effect.setFloat(name, this._floats[name]);
  56348. }
  56349. // Floats
  56350. for (name in this._floatsArrays) {
  56351. this._effect.setArray(name, this._floatsArrays[name]);
  56352. }
  56353. // Color3
  56354. for (name in this._colors3) {
  56355. this._effect.setColor3(name, this._colors3[name]);
  56356. }
  56357. // Color4
  56358. for (name in this._colors4) {
  56359. var color = this._colors4[name];
  56360. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  56361. }
  56362. // Vector2
  56363. for (name in this._vectors2) {
  56364. this._effect.setVector2(name, this._vectors2[name]);
  56365. }
  56366. // Vector3
  56367. for (name in this._vectors3) {
  56368. this._effect.setVector3(name, this._vectors3[name]);
  56369. }
  56370. // Matrix
  56371. for (name in this._matrices) {
  56372. this._effect.setMatrix(name, this._matrices[name]);
  56373. }
  56374. if (!this._texture) {
  56375. return;
  56376. }
  56377. if (this.isCube) {
  56378. for (var face = 0; face < 6; face++) {
  56379. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  56380. // VBOs
  56381. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  56382. this._effect.setFloat("face", face);
  56383. // Clear
  56384. if (this.autoClear) {
  56385. engine.clear(scene.clearColor, true, false, false);
  56386. }
  56387. // Draw order
  56388. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  56389. // Mipmaps
  56390. if (face === 5) {
  56391. engine.generateMipMapsForCubemap(this._texture);
  56392. }
  56393. }
  56394. }
  56395. else {
  56396. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  56397. // VBOs
  56398. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  56399. // Clear
  56400. if (this.autoClear) {
  56401. engine.clear(scene.clearColor, true, false, false);
  56402. }
  56403. // Draw order
  56404. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  56405. }
  56406. // Unbind
  56407. engine.unBindFramebuffer(this._texture, this.isCube);
  56408. if (this.onGenerated) {
  56409. this.onGenerated();
  56410. }
  56411. this.onGeneratedObservable.notifyObservers(this);
  56412. };
  56413. /**
  56414. * Clone the texture.
  56415. * @returns the cloned texture
  56416. */
  56417. ProceduralTexture.prototype.clone = function () {
  56418. var textureSize = this.getSize();
  56419. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  56420. // Base texture
  56421. newTexture.hasAlpha = this.hasAlpha;
  56422. newTexture.level = this.level;
  56423. // RenderTarget Texture
  56424. newTexture.coordinatesMode = this.coordinatesMode;
  56425. return newTexture;
  56426. };
  56427. /**
  56428. * Dispose the texture and release its asoociated resources.
  56429. */
  56430. ProceduralTexture.prototype.dispose = function () {
  56431. var scene = this.getScene();
  56432. if (!scene) {
  56433. return;
  56434. }
  56435. var index = scene.proceduralTextures.indexOf(this);
  56436. if (index >= 0) {
  56437. scene.proceduralTextures.splice(index, 1);
  56438. }
  56439. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  56440. if (vertexBuffer) {
  56441. vertexBuffer.dispose();
  56442. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  56443. }
  56444. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  56445. this._indexBuffer = null;
  56446. }
  56447. _super.prototype.dispose.call(this);
  56448. };
  56449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56451. ], ProceduralTexture.prototype, "isEnabled", void 0);
  56452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56454. ], ProceduralTexture.prototype, "autoClear", void 0);
  56455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56457. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  56458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56460. ], ProceduralTexture.prototype, "_size", void 0);
  56461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56463. ], ProceduralTexture.prototype, "refreshRate", null);
  56464. return ProceduralTexture;
  56465. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  56466. /***/ }),
  56467. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  56468. /*!***************************************************************************!*\
  56469. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  56470. \***************************************************************************/
  56471. /*! exports provided: ProceduralTextureSceneComponent */
  56472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56473. "use strict";
  56474. __webpack_require__.r(__webpack_exports__);
  56475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  56476. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  56477. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  56478. /**
  56479. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  56480. * in a given scene.
  56481. */
  56482. var ProceduralTextureSceneComponent = /** @class */ (function () {
  56483. /**
  56484. * Creates a new instance of the component for the given scene
  56485. * @param scene Defines the scene to register the component in
  56486. */
  56487. function ProceduralTextureSceneComponent(scene) {
  56488. /**
  56489. * The component name helpfull to identify the component in the list of scene components.
  56490. */
  56491. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  56492. this.scene = scene;
  56493. this.scene.proceduralTextures = new Array();
  56494. scene.layers = new Array();
  56495. }
  56496. /**
  56497. * Registers the component in a given scene
  56498. */
  56499. ProceduralTextureSceneComponent.prototype.register = function () {
  56500. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  56501. };
  56502. /**
  56503. * Rebuilds the elements related to this component in case of
  56504. * context lost for instance.
  56505. */
  56506. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  56507. // Nothing to do here.
  56508. };
  56509. /**
  56510. * Disposes the component and the associated ressources.
  56511. */
  56512. ProceduralTextureSceneComponent.prototype.dispose = function () {
  56513. // Nothing to do here.
  56514. };
  56515. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  56516. if (this.scene.proceduralTexturesEnabled) {
  56517. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  56518. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  56519. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  56520. if (proceduralTexture._shouldRender()) {
  56521. proceduralTexture.render();
  56522. }
  56523. }
  56524. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  56525. }
  56526. };
  56527. return ProceduralTextureSceneComponent;
  56528. }());
  56529. /***/ }),
  56530. /***/ "./Materials/Textures/baseTexture.ts":
  56531. /*!*******************************************!*\
  56532. !*** ./Materials/Textures/baseTexture.ts ***!
  56533. \*******************************************/
  56534. /*! exports provided: BaseTexture */
  56535. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56536. "use strict";
  56537. __webpack_require__.r(__webpack_exports__);
  56538. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  56539. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56540. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56541. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56542. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  56543. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  56544. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56545. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  56546. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56547. /**
  56548. * Base class of all the textures in babylon.
  56549. * It groups all the common properties the materials, post process, lights... might need
  56550. * in order to make a correct use of the texture.
  56551. */
  56552. var BaseTexture = /** @class */ (function () {
  56553. /**
  56554. * Instantiates a new BaseTexture.
  56555. * Base class of all the textures in babylon.
  56556. * It groups all the common properties the materials, post process, lights... might need
  56557. * in order to make a correct use of the texture.
  56558. * @param scene Define the scene the texture blongs to
  56559. */
  56560. function BaseTexture(scene) {
  56561. /**
  56562. * Gets or sets an object used to store user defined information.
  56563. */
  56564. this.metadata = null;
  56565. /**
  56566. * For internal use only. Please do not use.
  56567. */
  56568. this.reservedDataStore = null;
  56569. this._hasAlpha = false;
  56570. /**
  56571. * Defines if the alpha value should be determined via the rgb values.
  56572. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  56573. */
  56574. this.getAlphaFromRGB = false;
  56575. /**
  56576. * Intensity or strength of the texture.
  56577. * It is commonly used by materials to fine tune the intensity of the texture
  56578. */
  56579. this.level = 1;
  56580. /**
  56581. * Define the UV chanel to use starting from 0 and defaulting to 0.
  56582. * This is part of the texture as textures usually maps to one uv set.
  56583. */
  56584. this.coordinatesIndex = 0;
  56585. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  56586. /**
  56587. * | Value | Type | Description |
  56588. * | ----- | ------------------ | ----------- |
  56589. * | 0 | CLAMP_ADDRESSMODE | |
  56590. * | 1 | WRAP_ADDRESSMODE | |
  56591. * | 2 | MIRROR_ADDRESSMODE | |
  56592. */
  56593. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56594. /**
  56595. * | Value | Type | Description |
  56596. * | ----- | ------------------ | ----------- |
  56597. * | 0 | CLAMP_ADDRESSMODE | |
  56598. * | 1 | WRAP_ADDRESSMODE | |
  56599. * | 2 | MIRROR_ADDRESSMODE | |
  56600. */
  56601. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56602. /**
  56603. * | Value | Type | Description |
  56604. * | ----- | ------------------ | ----------- |
  56605. * | 0 | CLAMP_ADDRESSMODE | |
  56606. * | 1 | WRAP_ADDRESSMODE | |
  56607. * | 2 | MIRROR_ADDRESSMODE | |
  56608. */
  56609. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56610. /**
  56611. * With compliant hardware and browser (supporting anisotropic filtering)
  56612. * this defines the level of anisotropic filtering in the texture.
  56613. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  56614. */
  56615. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  56616. /**
  56617. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  56618. * HDR texture are usually stored in linear space.
  56619. * This only impacts the PBR and Background materials
  56620. */
  56621. this.gammaSpace = true;
  56622. /**
  56623. * Is Z inverted in the texture (useful in a cube texture).
  56624. */
  56625. this.invertZ = false;
  56626. /**
  56627. * @hidden
  56628. */
  56629. this.lodLevelInAlpha = false;
  56630. /**
  56631. * Define if the texture is a render target.
  56632. */
  56633. this.isRenderTarget = false;
  56634. /**
  56635. * Define the list of animation attached to the texture.
  56636. */
  56637. this.animations = new Array();
  56638. /**
  56639. * An event triggered when the texture is disposed.
  56640. */
  56641. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  56642. /**
  56643. * Define the current state of the loading sequence when in delayed load mode.
  56644. */
  56645. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  56646. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  56647. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  56648. if (this._scene) {
  56649. this.uniqueId = this._scene.getUniqueId();
  56650. this._scene.addTexture(this);
  56651. }
  56652. this._uid = null;
  56653. }
  56654. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  56655. get: function () {
  56656. return this._hasAlpha;
  56657. },
  56658. /**
  56659. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  56660. */
  56661. set: function (value) {
  56662. if (this._hasAlpha === value) {
  56663. return;
  56664. }
  56665. this._hasAlpha = value;
  56666. if (this._scene) {
  56667. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  56668. }
  56669. },
  56670. enumerable: true,
  56671. configurable: true
  56672. });
  56673. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  56674. get: function () {
  56675. return this._coordinatesMode;
  56676. },
  56677. /**
  56678. * How a texture is mapped.
  56679. *
  56680. * | Value | Type | Description |
  56681. * | ----- | ----------------------------------- | ----------- |
  56682. * | 0 | EXPLICIT_MODE | |
  56683. * | 1 | SPHERICAL_MODE | |
  56684. * | 2 | PLANAR_MODE | |
  56685. * | 3 | CUBIC_MODE | |
  56686. * | 4 | PROJECTION_MODE | |
  56687. * | 5 | SKYBOX_MODE | |
  56688. * | 6 | INVCUBIC_MODE | |
  56689. * | 7 | EQUIRECTANGULAR_MODE | |
  56690. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  56691. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  56692. */
  56693. set: function (value) {
  56694. if (this._coordinatesMode === value) {
  56695. return;
  56696. }
  56697. this._coordinatesMode = value;
  56698. if (this._scene) {
  56699. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  56700. }
  56701. },
  56702. enumerable: true,
  56703. configurable: true
  56704. });
  56705. Object.defineProperty(BaseTexture.prototype, "isCube", {
  56706. /**
  56707. * Define if the texture is a cube texture or if false a 2d texture.
  56708. */
  56709. get: function () {
  56710. if (!this._texture) {
  56711. return false;
  56712. }
  56713. return this._texture.isCube;
  56714. },
  56715. set: function (value) {
  56716. if (!this._texture) {
  56717. return;
  56718. }
  56719. this._texture.isCube = value;
  56720. },
  56721. enumerable: true,
  56722. configurable: true
  56723. });
  56724. Object.defineProperty(BaseTexture.prototype, "is3D", {
  56725. /**
  56726. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  56727. */
  56728. get: function () {
  56729. if (!this._texture) {
  56730. return false;
  56731. }
  56732. return this._texture.is3D;
  56733. },
  56734. set: function (value) {
  56735. if (!this._texture) {
  56736. return;
  56737. }
  56738. this._texture.is3D = value;
  56739. },
  56740. enumerable: true,
  56741. configurable: true
  56742. });
  56743. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  56744. /**
  56745. * Gets whether or not the texture contains RGBD data.
  56746. */
  56747. get: function () {
  56748. return this._texture != null && this._texture._isRGBD;
  56749. },
  56750. enumerable: true,
  56751. configurable: true
  56752. });
  56753. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  56754. /**
  56755. * Are mip maps generated for this texture or not.
  56756. */
  56757. get: function () {
  56758. return false;
  56759. },
  56760. enumerable: true,
  56761. configurable: true
  56762. });
  56763. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  56764. /**
  56765. * With prefiltered texture, defined the offset used during the prefiltering steps.
  56766. */
  56767. get: function () {
  56768. if (this._texture) {
  56769. return this._texture._lodGenerationOffset;
  56770. }
  56771. return 0.0;
  56772. },
  56773. set: function (value) {
  56774. if (this._texture) {
  56775. this._texture._lodGenerationOffset = value;
  56776. }
  56777. },
  56778. enumerable: true,
  56779. configurable: true
  56780. });
  56781. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  56782. /**
  56783. * With prefiltered texture, defined the scale used during the prefiltering steps.
  56784. */
  56785. get: function () {
  56786. if (this._texture) {
  56787. return this._texture._lodGenerationScale;
  56788. }
  56789. return 0.0;
  56790. },
  56791. set: function (value) {
  56792. if (this._texture) {
  56793. this._texture._lodGenerationScale = value;
  56794. }
  56795. },
  56796. enumerable: true,
  56797. configurable: true
  56798. });
  56799. Object.defineProperty(BaseTexture.prototype, "uid", {
  56800. /**
  56801. * Define the unique id of the texture in the scene.
  56802. */
  56803. get: function () {
  56804. if (!this._uid) {
  56805. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  56806. }
  56807. return this._uid;
  56808. },
  56809. enumerable: true,
  56810. configurable: true
  56811. });
  56812. /**
  56813. * Return a string representation of the texture.
  56814. * @returns the texture as a string
  56815. */
  56816. BaseTexture.prototype.toString = function () {
  56817. return this.name;
  56818. };
  56819. /**
  56820. * Get the class name of the texture.
  56821. * @returns "BaseTexture"
  56822. */
  56823. BaseTexture.prototype.getClassName = function () {
  56824. return "BaseTexture";
  56825. };
  56826. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  56827. /**
  56828. * Callback triggered when the texture has been disposed.
  56829. * Kept for back compatibility, you can use the onDisposeObservable instead.
  56830. */
  56831. set: function (callback) {
  56832. if (this._onDisposeObserver) {
  56833. this.onDisposeObservable.remove(this._onDisposeObserver);
  56834. }
  56835. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  56836. },
  56837. enumerable: true,
  56838. configurable: true
  56839. });
  56840. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  56841. /**
  56842. * Define if the texture is preventinga material to render or not.
  56843. * If not and the texture is not ready, the engine will use a default black texture instead.
  56844. */
  56845. get: function () {
  56846. return true;
  56847. },
  56848. enumerable: true,
  56849. configurable: true
  56850. });
  56851. /**
  56852. * Get the scene the texture belongs to.
  56853. * @returns the scene or null if undefined
  56854. */
  56855. BaseTexture.prototype.getScene = function () {
  56856. return this._scene;
  56857. };
  56858. /**
  56859. * Get the texture transform matrix used to offset tile the texture for istance.
  56860. * @returns the transformation matrix
  56861. */
  56862. BaseTexture.prototype.getTextureMatrix = function () {
  56863. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  56864. };
  56865. /**
  56866. * Get the texture reflection matrix used to rotate/transform the reflection.
  56867. * @returns the reflection matrix
  56868. */
  56869. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  56870. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  56871. };
  56872. /**
  56873. * Get the underlying lower level texture from Babylon.
  56874. * @returns the insternal texture
  56875. */
  56876. BaseTexture.prototype.getInternalTexture = function () {
  56877. return this._texture;
  56878. };
  56879. /**
  56880. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  56881. * @returns true if ready or not blocking
  56882. */
  56883. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  56884. return !this.isBlocking || this.isReady();
  56885. };
  56886. /**
  56887. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  56888. * @returns true if fully ready
  56889. */
  56890. BaseTexture.prototype.isReady = function () {
  56891. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  56892. this.delayLoad();
  56893. return false;
  56894. }
  56895. if (this._texture) {
  56896. return this._texture.isReady;
  56897. }
  56898. return false;
  56899. };
  56900. /**
  56901. * Get the size of the texture.
  56902. * @returns the texture size.
  56903. */
  56904. BaseTexture.prototype.getSize = function () {
  56905. if (this._texture) {
  56906. if (this._texture.width) {
  56907. this._cachedSize.width = this._texture.width;
  56908. this._cachedSize.height = this._texture.height;
  56909. return this._cachedSize;
  56910. }
  56911. if (this._texture._size) {
  56912. this._cachedSize.width = this._texture._size;
  56913. this._cachedSize.height = this._texture._size;
  56914. return this._cachedSize;
  56915. }
  56916. }
  56917. return this._cachedSize;
  56918. };
  56919. /**
  56920. * Get the base size of the texture.
  56921. * It can be different from the size if the texture has been resized for POT for instance
  56922. * @returns the base size
  56923. */
  56924. BaseTexture.prototype.getBaseSize = function () {
  56925. if (!this.isReady() || !this._texture) {
  56926. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  56927. }
  56928. if (this._texture._size) {
  56929. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  56930. }
  56931. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  56932. };
  56933. /**
  56934. * Update the sampling mode of the texture.
  56935. * Default is Trilinear mode.
  56936. *
  56937. * | Value | Type | Description |
  56938. * | ----- | ------------------ | ----------- |
  56939. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  56940. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  56941. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  56942. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  56943. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  56944. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  56945. * | 7 | NEAREST_LINEAR | |
  56946. * | 8 | NEAREST_NEAREST | |
  56947. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  56948. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  56949. * | 11 | LINEAR_LINEAR | |
  56950. * | 12 | LINEAR_NEAREST | |
  56951. *
  56952. * > _mag_: magnification filter (close to the viewer)
  56953. * > _min_: minification filter (far from the viewer)
  56954. * > _mip_: filter used between mip map levels
  56955. *@param samplingMode Define the new sampling mode of the texture
  56956. */
  56957. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  56958. if (!this._texture) {
  56959. return;
  56960. }
  56961. var scene = this.getScene();
  56962. if (!scene) {
  56963. return;
  56964. }
  56965. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  56966. };
  56967. /**
  56968. * Scales the texture if is `canRescale()`
  56969. * @param ratio the resize factor we want to use to rescale
  56970. */
  56971. BaseTexture.prototype.scale = function (ratio) {
  56972. };
  56973. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  56974. /**
  56975. * Get if the texture can rescale.
  56976. */
  56977. get: function () {
  56978. return false;
  56979. },
  56980. enumerable: true,
  56981. configurable: true
  56982. });
  56983. /** @hidden */
  56984. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  56985. if (!this._scene) {
  56986. return null;
  56987. }
  56988. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  56989. for (var index = 0; index < texturesCache.length; index++) {
  56990. var texturesCacheEntry = texturesCache[index];
  56991. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  56992. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  56993. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  56994. texturesCacheEntry.incrementReferences();
  56995. return texturesCacheEntry;
  56996. }
  56997. }
  56998. }
  56999. }
  57000. return null;
  57001. };
  57002. /** @hidden */
  57003. BaseTexture.prototype._rebuild = function () {
  57004. };
  57005. /**
  57006. * Triggers the load sequence in delayed load mode.
  57007. */
  57008. BaseTexture.prototype.delayLoad = function () {
  57009. };
  57010. /**
  57011. * Clones the texture.
  57012. * @returns the cloned texture
  57013. */
  57014. BaseTexture.prototype.clone = function () {
  57015. return null;
  57016. };
  57017. Object.defineProperty(BaseTexture.prototype, "textureType", {
  57018. /**
  57019. * Get the texture underlying type (INT, FLOAT...)
  57020. */
  57021. get: function () {
  57022. if (!this._texture) {
  57023. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57024. }
  57025. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57026. },
  57027. enumerable: true,
  57028. configurable: true
  57029. });
  57030. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  57031. /**
  57032. * Get the texture underlying format (RGB, RGBA...)
  57033. */
  57034. get: function () {
  57035. if (!this._texture) {
  57036. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57037. }
  57038. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57039. },
  57040. enumerable: true,
  57041. configurable: true
  57042. });
  57043. /**
  57044. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  57045. * This will returns an RGBA array buffer containing either in values (0-255) or
  57046. * float values (0-1) depending of the underlying buffer type.
  57047. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  57048. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  57049. * @param buffer defines a user defined buffer to fill with data (can be null)
  57050. * @returns The Array buffer containing the pixels data.
  57051. */
  57052. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  57053. if (faceIndex === void 0) { faceIndex = 0; }
  57054. if (level === void 0) { level = 0; }
  57055. if (buffer === void 0) { buffer = null; }
  57056. if (!this._texture) {
  57057. return null;
  57058. }
  57059. var size = this.getSize();
  57060. var width = size.width;
  57061. var height = size.height;
  57062. var scene = this.getScene();
  57063. if (!scene) {
  57064. return null;
  57065. }
  57066. var engine = scene.getEngine();
  57067. if (level != 0) {
  57068. width = width / Math.pow(2, level);
  57069. height = height / Math.pow(2, level);
  57070. width = Math.round(width);
  57071. height = Math.round(height);
  57072. }
  57073. if (this._texture.isCube) {
  57074. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  57075. }
  57076. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  57077. };
  57078. /**
  57079. * Release and destroy the underlying lower level texture aka internalTexture.
  57080. */
  57081. BaseTexture.prototype.releaseInternalTexture = function () {
  57082. if (this._texture) {
  57083. this._texture.dispose();
  57084. this._texture = null;
  57085. }
  57086. };
  57087. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  57088. /**
  57089. * Get the polynomial representation of the texture data.
  57090. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  57091. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  57092. */
  57093. get: function () {
  57094. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  57095. return null;
  57096. }
  57097. if (!this._texture._sphericalPolynomial) {
  57098. this._texture._sphericalPolynomial =
  57099. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  57100. }
  57101. return this._texture._sphericalPolynomial;
  57102. },
  57103. set: function (value) {
  57104. if (this._texture) {
  57105. this._texture._sphericalPolynomial = value;
  57106. }
  57107. },
  57108. enumerable: true,
  57109. configurable: true
  57110. });
  57111. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  57112. /** @hidden */
  57113. get: function () {
  57114. if (this._texture) {
  57115. return this._texture._lodTextureHigh;
  57116. }
  57117. return null;
  57118. },
  57119. enumerable: true,
  57120. configurable: true
  57121. });
  57122. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  57123. /** @hidden */
  57124. get: function () {
  57125. if (this._texture) {
  57126. return this._texture._lodTextureMid;
  57127. }
  57128. return null;
  57129. },
  57130. enumerable: true,
  57131. configurable: true
  57132. });
  57133. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  57134. /** @hidden */
  57135. get: function () {
  57136. if (this._texture) {
  57137. return this._texture._lodTextureLow;
  57138. }
  57139. return null;
  57140. },
  57141. enumerable: true,
  57142. configurable: true
  57143. });
  57144. /**
  57145. * Dispose the texture and release its associated resources.
  57146. */
  57147. BaseTexture.prototype.dispose = function () {
  57148. if (!this._scene) {
  57149. return;
  57150. }
  57151. // Animations
  57152. this._scene.stopAnimation(this);
  57153. // Remove from scene
  57154. this._scene._removePendingData(this);
  57155. var index = this._scene.textures.indexOf(this);
  57156. if (index >= 0) {
  57157. this._scene.textures.splice(index, 1);
  57158. }
  57159. this._scene.onTextureRemovedObservable.notifyObservers(this);
  57160. if (this._texture === undefined) {
  57161. return;
  57162. }
  57163. // Release
  57164. this.releaseInternalTexture();
  57165. // Callback
  57166. this.onDisposeObservable.notifyObservers(this);
  57167. this.onDisposeObservable.clear();
  57168. };
  57169. /**
  57170. * Serialize the texture into a JSON representation that can be parsed later on.
  57171. * @returns the JSON representation of the texture
  57172. */
  57173. BaseTexture.prototype.serialize = function () {
  57174. if (!this.name) {
  57175. return null;
  57176. }
  57177. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  57178. // Animations
  57179. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  57180. return serializationObject;
  57181. };
  57182. /**
  57183. * Helper function to be called back once a list of texture contains only ready textures.
  57184. * @param textures Define the list of textures to wait for
  57185. * @param callback Define the callback triggered once the entire list will be ready
  57186. */
  57187. BaseTexture.WhenAllReady = function (textures, callback) {
  57188. var numRemaining = textures.length;
  57189. if (numRemaining === 0) {
  57190. callback();
  57191. return;
  57192. }
  57193. var _loop_1 = function () {
  57194. texture = textures[i];
  57195. if (texture.isReady()) {
  57196. if (--numRemaining === 0) {
  57197. callback();
  57198. }
  57199. }
  57200. else {
  57201. onLoadObservable = texture.onLoadObservable;
  57202. var onLoadCallback_1 = function () {
  57203. onLoadObservable.removeCallback(onLoadCallback_1);
  57204. if (--numRemaining === 0) {
  57205. callback();
  57206. }
  57207. };
  57208. onLoadObservable.add(onLoadCallback_1);
  57209. }
  57210. };
  57211. var texture, onLoadObservable;
  57212. for (var i = 0; i < textures.length; i++) {
  57213. _loop_1();
  57214. }
  57215. };
  57216. /**
  57217. * Default anisotropic filtering level for the application.
  57218. * It is set to 4 as a good tradeoff between perf and quality.
  57219. */
  57220. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  57221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57223. ], BaseTexture.prototype, "uniqueId", void 0);
  57224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57226. ], BaseTexture.prototype, "name", void 0);
  57227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57229. ], BaseTexture.prototype, "metadata", void 0);
  57230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  57232. ], BaseTexture.prototype, "_hasAlpha", void 0);
  57233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57235. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  57236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57238. ], BaseTexture.prototype, "level", void 0);
  57239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57241. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  57242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  57244. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  57245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57247. ], BaseTexture.prototype, "wrapU", void 0);
  57248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57250. ], BaseTexture.prototype, "wrapV", void 0);
  57251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57253. ], BaseTexture.prototype, "wrapR", void 0);
  57254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57256. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  57257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57259. ], BaseTexture.prototype, "isCube", null);
  57260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57262. ], BaseTexture.prototype, "is3D", null);
  57263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57265. ], BaseTexture.prototype, "gammaSpace", void 0);
  57266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57268. ], BaseTexture.prototype, "invertZ", void 0);
  57269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57271. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  57272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57274. ], BaseTexture.prototype, "lodGenerationOffset", null);
  57275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57277. ], BaseTexture.prototype, "lodGenerationScale", null);
  57278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57280. ], BaseTexture.prototype, "isRenderTarget", void 0);
  57281. return BaseTexture;
  57282. }());
  57283. /***/ }),
  57284. /***/ "./Materials/Textures/colorGradingTexture.ts":
  57285. /*!***************************************************!*\
  57286. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  57287. \***************************************************/
  57288. /*! exports provided: ColorGradingTexture */
  57289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57290. "use strict";
  57291. __webpack_require__.r(__webpack_exports__);
  57292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  57293. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57294. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57295. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57296. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57297. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  57298. /**
  57299. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  57300. * It can help converting any input color in a desired output one. This can then be used to create effects
  57301. * from sepia, black and white to sixties or futuristic rendering...
  57302. *
  57303. * The only supported format is currently 3dl.
  57304. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  57305. */
  57306. var ColorGradingTexture = /** @class */ (function (_super) {
  57307. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  57308. /**
  57309. * Instantiates a ColorGradingTexture from the following parameters.
  57310. *
  57311. * @param url The location of the color gradind data (currently only supporting 3dl)
  57312. * @param scene The scene the texture will be used in
  57313. */
  57314. function ColorGradingTexture(url, scene) {
  57315. var _this = _super.call(this, scene) || this;
  57316. if (!url) {
  57317. return _this;
  57318. }
  57319. _this._engine = scene.getEngine();
  57320. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  57321. _this.name = url;
  57322. _this.url = url;
  57323. _this.hasAlpha = false;
  57324. _this.isCube = false;
  57325. _this.is3D = _this._engine.webGLVersion > 1;
  57326. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57327. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57328. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57329. _this.anisotropicFilteringLevel = 1;
  57330. _this._texture = _this._getFromCache(url, true);
  57331. if (!_this._texture) {
  57332. if (!scene.useDelayedTextureLoading) {
  57333. _this.loadTexture();
  57334. }
  57335. else {
  57336. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57337. }
  57338. }
  57339. return _this;
  57340. }
  57341. /**
  57342. * Returns the texture matrix used in most of the material.
  57343. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  57344. */
  57345. ColorGradingTexture.prototype.getTextureMatrix = function () {
  57346. return this._textureMatrix;
  57347. };
  57348. /**
  57349. * Occurs when the file being loaded is a .3dl LUT file.
  57350. */
  57351. ColorGradingTexture.prototype.load3dlTexture = function () {
  57352. var engine = this._engine;
  57353. var texture;
  57354. if (engine.webGLVersion === 1) {
  57355. 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);
  57356. }
  57357. else {
  57358. 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);
  57359. }
  57360. this._texture = texture;
  57361. var callback = function (text) {
  57362. if (typeof text !== "string") {
  57363. return;
  57364. }
  57365. var data = null;
  57366. var tempData = null;
  57367. var line;
  57368. var lines = text.split('\n');
  57369. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  57370. var maxColor = 0;
  57371. for (var i = 0; i < lines.length; i++) {
  57372. line = lines[i];
  57373. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  57374. continue;
  57375. }
  57376. if (line.indexOf('#') === 0) {
  57377. continue;
  57378. }
  57379. var words = line.split(" ");
  57380. if (size === 0) {
  57381. // Number of space + one
  57382. size = words.length;
  57383. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  57384. tempData = new Float32Array(size * size * size * 4);
  57385. continue;
  57386. }
  57387. if (size != 0) {
  57388. var r = Math.max(parseInt(words[0]), 0);
  57389. var g = Math.max(parseInt(words[1]), 0);
  57390. var b = Math.max(parseInt(words[2]), 0);
  57391. maxColor = Math.max(r, maxColor);
  57392. maxColor = Math.max(g, maxColor);
  57393. maxColor = Math.max(b, maxColor);
  57394. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  57395. if (tempData) {
  57396. tempData[pixelStorageIndex + 0] = r;
  57397. tempData[pixelStorageIndex + 1] = g;
  57398. tempData[pixelStorageIndex + 2] = b;
  57399. }
  57400. // Keep for reference in case of back compat problems.
  57401. // pixelIndexSlice++;
  57402. // if (pixelIndexSlice % size == 0) {
  57403. // pixelIndexH++;
  57404. // pixelIndexSlice = 0;
  57405. // if (pixelIndexH % size == 0) {
  57406. // pixelIndexW++;
  57407. // pixelIndexH = 0;
  57408. // }
  57409. // }
  57410. pixelIndexH++;
  57411. if (pixelIndexH % size == 0) {
  57412. pixelIndexSlice++;
  57413. pixelIndexH = 0;
  57414. if (pixelIndexSlice % size == 0) {
  57415. pixelIndexW++;
  57416. pixelIndexSlice = 0;
  57417. }
  57418. }
  57419. }
  57420. }
  57421. if (tempData && data) {
  57422. for (var i = 0; i < tempData.length; i++) {
  57423. if (i > 0 && (i + 1) % 4 === 0) {
  57424. data[i] = 255;
  57425. }
  57426. else {
  57427. var value = tempData[i];
  57428. data[i] = (value / maxColor * 255);
  57429. }
  57430. }
  57431. }
  57432. if (texture.is3D) {
  57433. texture.updateSize(size, size, size);
  57434. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  57435. }
  57436. else {
  57437. texture.updateSize(size * size, size);
  57438. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  57439. }
  57440. };
  57441. var scene = this.getScene();
  57442. if (scene) {
  57443. scene._loadFile(this.url, callback);
  57444. }
  57445. else {
  57446. this._engine._loadFile(this.url, callback);
  57447. }
  57448. return this._texture;
  57449. };
  57450. /**
  57451. * Starts the loading process of the texture.
  57452. */
  57453. ColorGradingTexture.prototype.loadTexture = function () {
  57454. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  57455. this.load3dlTexture();
  57456. }
  57457. };
  57458. /**
  57459. * Clones the color gradind texture.
  57460. */
  57461. ColorGradingTexture.prototype.clone = function () {
  57462. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  57463. // Base texture
  57464. newTexture.level = this.level;
  57465. return newTexture;
  57466. };
  57467. /**
  57468. * Called during delayed load for textures.
  57469. */
  57470. ColorGradingTexture.prototype.delayLoad = function () {
  57471. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57472. return;
  57473. }
  57474. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  57475. this._texture = this._getFromCache(this.url, true);
  57476. if (!this._texture) {
  57477. this.loadTexture();
  57478. }
  57479. };
  57480. /**
  57481. * Parses a color grading texture serialized by Babylon.
  57482. * @param parsedTexture The texture information being parsedTexture
  57483. * @param scene The scene to load the texture in
  57484. * @param rootUrl The root url of the data assets to load
  57485. * @return A color gradind texture
  57486. */
  57487. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  57488. var texture = null;
  57489. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  57490. texture = new ColorGradingTexture(parsedTexture.name, scene);
  57491. texture.name = parsedTexture.name;
  57492. texture.level = parsedTexture.level;
  57493. }
  57494. return texture;
  57495. };
  57496. /**
  57497. * Serializes the LUT texture to json format.
  57498. */
  57499. ColorGradingTexture.prototype.serialize = function () {
  57500. if (!this.name) {
  57501. return null;
  57502. }
  57503. var serializationObject = {};
  57504. serializationObject.name = this.name;
  57505. serializationObject.level = this.level;
  57506. serializationObject.customType = "BABYLON.ColorGradingTexture";
  57507. return serializationObject;
  57508. };
  57509. /**
  57510. * Empty line regex stored for GC.
  57511. */
  57512. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  57513. return ColorGradingTexture;
  57514. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  57515. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  57516. /***/ }),
  57517. /***/ "./Materials/Textures/cubeTexture.ts":
  57518. /*!*******************************************!*\
  57519. !*** ./Materials/Textures/cubeTexture.ts ***!
  57520. \*******************************************/
  57521. /*! exports provided: CubeTexture */
  57522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57523. "use strict";
  57524. __webpack_require__.r(__webpack_exports__);
  57525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  57526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57527. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57528. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57529. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57530. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57531. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57532. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57533. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  57534. /**
  57535. * Class for creating a cube texture
  57536. */
  57537. var CubeTexture = /** @class */ (function (_super) {
  57538. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  57539. /**
  57540. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  57541. * as prefiltered data.
  57542. * @param rootUrl defines the url of the texture or the root name of the six images
  57543. * @param scene defines the scene the texture is attached to
  57544. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  57545. * @param noMipmap defines if mipmaps should be created or not
  57546. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  57547. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  57548. * @param onError defines a callback triggered in case of error during load
  57549. * @param format defines the internal format to use for the texture once loaded
  57550. * @param prefiltered defines whether or not the texture is created from prefiltered data
  57551. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  57552. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  57553. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57554. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57555. * @return the cube texture
  57556. */
  57557. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  57558. if (extensions === void 0) { extensions = null; }
  57559. if (noMipmap === void 0) { noMipmap = false; }
  57560. if (files === void 0) { files = null; }
  57561. if (onLoad === void 0) { onLoad = null; }
  57562. if (onError === void 0) { onError = null; }
  57563. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  57564. if (prefiltered === void 0) { prefiltered = false; }
  57565. if (forcedExtension === void 0) { forcedExtension = null; }
  57566. if (createPolynomials === void 0) { createPolynomials = false; }
  57567. if (lodScale === void 0) { lodScale = 0.8; }
  57568. if (lodOffset === void 0) { lodOffset = 0; }
  57569. var _this = _super.call(this, scene) || this;
  57570. /**
  57571. * Gets or sets the center of the bounding box associated with the cube texture.
  57572. * It must define where the camera used to render the texture was set
  57573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  57574. */
  57575. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57576. _this._rotationY = 0;
  57577. /** @hidden */
  57578. _this._prefiltered = false;
  57579. _this.name = rootUrl;
  57580. _this.url = rootUrl;
  57581. _this._noMipmap = noMipmap;
  57582. _this.hasAlpha = false;
  57583. _this._format = format;
  57584. _this.isCube = true;
  57585. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57586. _this._createPolynomials = createPolynomials;
  57587. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  57588. if (!rootUrl && !files) {
  57589. return _this;
  57590. }
  57591. var lastDot = rootUrl.lastIndexOf(".");
  57592. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  57593. var isDDS = (extension === ".dds");
  57594. var isEnv = (extension === ".env");
  57595. if (isEnv) {
  57596. _this.gammaSpace = false;
  57597. _this._prefiltered = false;
  57598. }
  57599. else {
  57600. _this._prefiltered = prefiltered;
  57601. if (prefiltered) {
  57602. _this.gammaSpace = false;
  57603. }
  57604. }
  57605. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  57606. if (!files) {
  57607. if (!isEnv && !isDDS && !extensions) {
  57608. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  57609. }
  57610. files = [];
  57611. if (extensions) {
  57612. for (var index = 0; index < extensions.length; index++) {
  57613. files.push(rootUrl + extensions[index]);
  57614. }
  57615. }
  57616. }
  57617. _this._files = files;
  57618. if (!_this._texture) {
  57619. if (!scene.useDelayedTextureLoading) {
  57620. if (prefiltered) {
  57621. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  57622. }
  57623. else {
  57624. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  57625. }
  57626. }
  57627. else {
  57628. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57629. }
  57630. }
  57631. else if (onLoad) {
  57632. if (_this._texture.isReady) {
  57633. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  57634. }
  57635. else {
  57636. _this._texture.onLoadedObservable.add(onLoad);
  57637. }
  57638. }
  57639. return _this;
  57640. }
  57641. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  57642. /**
  57643. * Returns the bounding box size
  57644. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  57645. */
  57646. get: function () {
  57647. return this._boundingBoxSize;
  57648. },
  57649. /**
  57650. * Gets or sets the size of the bounding box associated with the cube texture
  57651. * When defined, the cubemap will switch to local mode
  57652. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57653. * @example https://www.babylonjs-playground.com/#RNASML
  57654. */
  57655. set: function (value) {
  57656. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57657. return;
  57658. }
  57659. this._boundingBoxSize = value;
  57660. var scene = this.getScene();
  57661. if (scene) {
  57662. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  57663. }
  57664. },
  57665. enumerable: true,
  57666. configurable: true
  57667. });
  57668. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  57669. /**
  57670. * Gets texture matrix rotation angle around Y axis radians.
  57671. */
  57672. get: function () {
  57673. return this._rotationY;
  57674. },
  57675. /**
  57676. * Sets texture matrix rotation angle around Y axis in radians.
  57677. */
  57678. set: function (value) {
  57679. this._rotationY = value;
  57680. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  57681. },
  57682. enumerable: true,
  57683. configurable: true
  57684. });
  57685. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  57686. /**
  57687. * Are mip maps generated for this texture or not.
  57688. */
  57689. get: function () {
  57690. return this._noMipmap;
  57691. },
  57692. enumerable: true,
  57693. configurable: true
  57694. });
  57695. /**
  57696. * Creates a cube texture from an array of image urls
  57697. * @param files defines an array of image urls
  57698. * @param scene defines the hosting scene
  57699. * @param noMipmap specifies if mip maps are not used
  57700. * @returns a cube texture
  57701. */
  57702. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  57703. var rootUrlKey = "";
  57704. files.forEach(function (url) { return rootUrlKey += url; });
  57705. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  57706. };
  57707. /**
  57708. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  57709. * @param url defines the url of the prefiltered texture
  57710. * @param scene defines the scene the texture is attached to
  57711. * @param forcedExtension defines the extension of the file if different from the url
  57712. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  57713. * @return the prefiltered texture
  57714. */
  57715. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  57716. if (forcedExtension === void 0) { forcedExtension = null; }
  57717. if (createPolynomials === void 0) { createPolynomials = true; }
  57718. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  57719. };
  57720. /**
  57721. * Get the current class name of the texture useful for serialization or dynamic coding.
  57722. * @returns "CubeTexture"
  57723. */
  57724. CubeTexture.prototype.getClassName = function () {
  57725. return "CubeTexture";
  57726. };
  57727. /**
  57728. * Update the url (and optional buffer) of this texture if url was null during construction.
  57729. * @param url the url of the texture
  57730. * @param forcedExtension defines the extension to use
  57731. * @param onLoad callback called when the texture is loaded (defaults to null)
  57732. */
  57733. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  57734. if (this.url) {
  57735. this.releaseInternalTexture();
  57736. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  57737. }
  57738. this.url = url;
  57739. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57740. this._prefiltered = false;
  57741. if (onLoad) {
  57742. this._delayedOnLoad = onLoad;
  57743. }
  57744. this.delayLoad(forcedExtension);
  57745. };
  57746. /**
  57747. * Delays loading of the cube texture
  57748. * @param forcedExtension defines the extension to use
  57749. */
  57750. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  57751. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57752. return;
  57753. }
  57754. var scene = this.getScene();
  57755. if (!scene) {
  57756. return;
  57757. }
  57758. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  57759. this._texture = this._getFromCache(this.url, this._noMipmap);
  57760. if (!this._texture) {
  57761. if (this._prefiltered) {
  57762. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  57763. }
  57764. else {
  57765. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  57766. }
  57767. }
  57768. };
  57769. /**
  57770. * Returns the reflection texture matrix
  57771. * @returns the reflection texture matrix
  57772. */
  57773. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  57774. return this._textureMatrix;
  57775. };
  57776. /**
  57777. * Sets the reflection texture matrix
  57778. * @param value Reflection texture matrix
  57779. */
  57780. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  57781. var _this = this;
  57782. if (value.updateFlag === this._textureMatrix.updateFlag) {
  57783. return;
  57784. }
  57785. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  57786. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  57787. }
  57788. this._textureMatrix = value;
  57789. };
  57790. /**
  57791. * Parses text to create a cube texture
  57792. * @param parsedTexture define the serialized text to read from
  57793. * @param scene defines the hosting scene
  57794. * @param rootUrl defines the root url of the cube texture
  57795. * @returns a cube texture
  57796. */
  57797. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  57798. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  57799. var prefiltered = false;
  57800. if (parsedTexture.prefiltered) {
  57801. prefiltered = parsedTexture.prefiltered;
  57802. }
  57803. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  57804. }, parsedTexture, scene);
  57805. // Local Cubemaps
  57806. if (parsedTexture.boundingBoxPosition) {
  57807. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  57808. }
  57809. if (parsedTexture.boundingBoxSize) {
  57810. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  57811. }
  57812. // Animations
  57813. if (parsedTexture.animations) {
  57814. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  57815. var parsedAnimation = parsedTexture.animations[animationIndex];
  57816. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  57817. if (internalClass) {
  57818. texture.animations.push(internalClass.Parse(parsedAnimation));
  57819. }
  57820. }
  57821. }
  57822. return texture;
  57823. };
  57824. /**
  57825. * Makes a clone, or deep copy, of the cube texture
  57826. * @returns a new cube texture
  57827. */
  57828. CubeTexture.prototype.clone = function () {
  57829. var _this = this;
  57830. var scene = this.getScene();
  57831. var uniqueId = 0;
  57832. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57833. if (!scene) {
  57834. return _this;
  57835. }
  57836. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  57837. uniqueId = cubeTexture.uniqueId;
  57838. return cubeTexture;
  57839. }, this);
  57840. newCubeTexture.uniqueId = uniqueId;
  57841. return newCubeTexture;
  57842. };
  57843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  57845. ], CubeTexture.prototype, "rotationY", null);
  57846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMatrix"])("textureMatrix")
  57848. ], CubeTexture.prototype, "_textureMatrix", void 0);
  57849. return CubeTexture;
  57850. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  57851. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  57852. // Some exporters relies on Tools.Instantiate
  57853. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  57854. /***/ }),
  57855. /***/ "./Materials/Textures/dynamicTexture.ts":
  57856. /*!**********************************************!*\
  57857. !*** ./Materials/Textures/dynamicTexture.ts ***!
  57858. \**********************************************/
  57859. /*! exports provided: DynamicTexture */
  57860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57861. "use strict";
  57862. __webpack_require__.r(__webpack_exports__);
  57863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  57864. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57865. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  57866. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57867. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57868. /**
  57869. * A class extending Texture allowing drawing on a texture
  57870. * @see http://doc.babylonjs.com/how_to/dynamictexture
  57871. */
  57872. var DynamicTexture = /** @class */ (function (_super) {
  57873. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  57874. /**
  57875. * Creates a DynamicTexture
  57876. * @param name defines the name of the texture
  57877. * @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
  57878. * @param scene defines the scene where you want the texture
  57879. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  57880. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57881. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  57882. */
  57883. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  57884. if (scene === void 0) { scene = null; }
  57885. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57886. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  57887. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  57888. _this.name = name;
  57889. _this._engine = _this.getScene().getEngine();
  57890. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  57891. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  57892. _this._generateMipMaps = generateMipMaps;
  57893. if (options.getContext) {
  57894. _this._canvas = options;
  57895. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  57896. }
  57897. else {
  57898. _this._canvas = document.createElement("canvas");
  57899. if (options.width || options.width === 0) {
  57900. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  57901. }
  57902. else {
  57903. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  57904. }
  57905. }
  57906. var textureSize = _this.getSize();
  57907. _this._canvas.width = textureSize.width;
  57908. _this._canvas.height = textureSize.height;
  57909. _this._context = _this._canvas.getContext("2d");
  57910. return _this;
  57911. }
  57912. /**
  57913. * Get the current class name of the texture useful for serialization or dynamic coding.
  57914. * @returns "DynamicTexture"
  57915. */
  57916. DynamicTexture.prototype.getClassName = function () {
  57917. return "DynamicTexture";
  57918. };
  57919. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  57920. /**
  57921. * Gets the current state of canRescale
  57922. */
  57923. get: function () {
  57924. return true;
  57925. },
  57926. enumerable: true,
  57927. configurable: true
  57928. });
  57929. DynamicTexture.prototype._recreate = function (textureSize) {
  57930. this._canvas.width = textureSize.width;
  57931. this._canvas.height = textureSize.height;
  57932. this.releaseInternalTexture();
  57933. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  57934. };
  57935. /**
  57936. * Scales the texture
  57937. * @param ratio the scale factor to apply to both width and height
  57938. */
  57939. DynamicTexture.prototype.scale = function (ratio) {
  57940. var textureSize = this.getSize();
  57941. textureSize.width *= ratio;
  57942. textureSize.height *= ratio;
  57943. this._recreate(textureSize);
  57944. };
  57945. /**
  57946. * Resizes the texture
  57947. * @param width the new width
  57948. * @param height the new height
  57949. */
  57950. DynamicTexture.prototype.scaleTo = function (width, height) {
  57951. var textureSize = this.getSize();
  57952. textureSize.width = width;
  57953. textureSize.height = height;
  57954. this._recreate(textureSize);
  57955. };
  57956. /**
  57957. * Gets the context of the canvas used by the texture
  57958. * @returns the canvas context of the dynamic texture
  57959. */
  57960. DynamicTexture.prototype.getContext = function () {
  57961. return this._context;
  57962. };
  57963. /**
  57964. * Clears the texture
  57965. */
  57966. DynamicTexture.prototype.clear = function () {
  57967. var size = this.getSize();
  57968. this._context.fillRect(0, 0, size.width, size.height);
  57969. };
  57970. /**
  57971. * Updates the texture
  57972. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  57973. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  57974. */
  57975. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  57976. if (premulAlpha === void 0) { premulAlpha = false; }
  57977. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  57978. };
  57979. /**
  57980. * Draws text onto the texture
  57981. * @param text defines the text to be drawn
  57982. * @param x defines the placement of the text from the left
  57983. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  57984. * @param font defines the font to be used with font-style, font-size, font-name
  57985. * @param color defines the color used for the text
  57986. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  57987. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  57988. * @param update defines whether texture is immediately update (default is true)
  57989. */
  57990. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  57991. if (update === void 0) { update = true; }
  57992. var size = this.getSize();
  57993. if (clearColor) {
  57994. this._context.fillStyle = clearColor;
  57995. this._context.fillRect(0, 0, size.width, size.height);
  57996. }
  57997. this._context.font = font;
  57998. if (x === null || x === undefined) {
  57999. var textSize = this._context.measureText(text);
  58000. x = (size.width - textSize.width) / 2;
  58001. }
  58002. if (y === null || y === undefined) {
  58003. var fontSize = parseInt((font.replace(/\D/g, '')));
  58004. y = (size.height / 2) + (fontSize / 3.65);
  58005. }
  58006. this._context.fillStyle = color;
  58007. this._context.fillText(text, x, y);
  58008. if (update) {
  58009. this.update(invertY);
  58010. }
  58011. };
  58012. /**
  58013. * Clones the texture
  58014. * @returns the clone of the texture.
  58015. */
  58016. DynamicTexture.prototype.clone = function () {
  58017. var scene = this.getScene();
  58018. if (!scene) {
  58019. return this;
  58020. }
  58021. var textureSize = this.getSize();
  58022. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  58023. // Base texture
  58024. newTexture.hasAlpha = this.hasAlpha;
  58025. newTexture.level = this.level;
  58026. // Dynamic Texture
  58027. newTexture.wrapU = this.wrapU;
  58028. newTexture.wrapV = this.wrapV;
  58029. return newTexture;
  58030. };
  58031. /**
  58032. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  58033. * @returns a serialized dynamic texture object
  58034. */
  58035. DynamicTexture.prototype.serialize = function () {
  58036. var scene = this.getScene();
  58037. if (scene && !scene.isReady()) {
  58038. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  58039. }
  58040. var serializationObject = _super.prototype.serialize.call(this);
  58041. serializationObject.base64String = this._canvas.toDataURL();
  58042. serializationObject.invertY = this._invertY;
  58043. serializationObject.samplingMode = this.samplingMode;
  58044. return serializationObject;
  58045. };
  58046. /** @hidden */
  58047. DynamicTexture.prototype._rebuild = function () {
  58048. this.update();
  58049. };
  58050. return DynamicTexture;
  58051. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  58052. /***/ }),
  58053. /***/ "./Materials/Textures/equiRectangularCubeTexture.ts":
  58054. /*!**********************************************************!*\
  58055. !*** ./Materials/Textures/equiRectangularCubeTexture.ts ***!
  58056. \**********************************************************/
  58057. /*! exports provided: EquiRectangularCubeTexture */
  58058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58059. "use strict";
  58060. __webpack_require__.r(__webpack_exports__);
  58061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return EquiRectangularCubeTexture; });
  58062. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58063. /* harmony import */ var _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  58064. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  58065. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  58066. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  58067. /**
  58068. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58069. */
  58070. var EquiRectangularCubeTexture = /** @class */ (function (_super) {
  58071. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTexture, _super);
  58072. /**
  58073. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58074. * @param url The location of the image
  58075. * @param scene The scene the texture will be used in
  58076. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58077. * @param noMipmap Forces to not generate the mipmap if true
  58078. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58079. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58080. * @param onLoad — defines a callback called when texture is loaded
  58081. * @param onError — defines a callback called if there is an error
  58082. */
  58083. function EquiRectangularCubeTexture(url, scene, size, noMipmap, gammaSpace, onLoad, onError) {
  58084. if (noMipmap === void 0) { noMipmap = false; }
  58085. if (gammaSpace === void 0) { gammaSpace = true; }
  58086. if (onLoad === void 0) { onLoad = null; }
  58087. if (onError === void 0) { onError = null; }
  58088. var _this = _super.call(this, scene) || this;
  58089. _this._onLoad = null;
  58090. _this._onError = null;
  58091. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58092. _this.coordinatesMode = _texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  58093. if (!url) {
  58094. throw new Error('Image url is not set');
  58095. }
  58096. _this.name = url;
  58097. _this.url = url;
  58098. _this._size = size;
  58099. _this._noMipmap = noMipmap;
  58100. _this.gammaSpace = gammaSpace;
  58101. _this._onLoad = onLoad;
  58102. _this._onError = onError;
  58103. _this.hasAlpha = false;
  58104. _this.isCube = true;
  58105. _this._texture = _this._getFromCache(url, _this._noMipmap);
  58106. if (!_this._texture) {
  58107. if (!scene.useDelayedTextureLoading) {
  58108. _this.loadImage(_this.loadTexture.bind(_this));
  58109. }
  58110. else {
  58111. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  58112. }
  58113. }
  58114. return _this;
  58115. }
  58116. /**
  58117. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58118. */
  58119. EquiRectangularCubeTexture.prototype.loadImage = function (loadTextureCallback) {
  58120. var _this = this;
  58121. var canvas = document.createElement('canvas');
  58122. var image = new Image();
  58123. image.addEventListener('load', function () {
  58124. _this._width = image.width;
  58125. _this._height = image.height;
  58126. canvas.width = _this._width;
  58127. canvas.height = _this._height;
  58128. var ctx = canvas.getContext('2d');
  58129. ctx.drawImage(image, 0, 0);
  58130. var imageData = ctx.getImageData(0, 0, image.width, image.height);
  58131. _this._buffer = imageData.data.buffer;
  58132. canvas.remove();
  58133. loadTextureCallback();
  58134. });
  58135. image.src = this.url;
  58136. };
  58137. /**
  58138. * Convert the image buffer into a cubemap and create a CubeTexture.
  58139. */
  58140. EquiRectangularCubeTexture.prototype.loadTexture = function () {
  58141. var _this = this;
  58142. var scene = this.getScene();
  58143. var callback = function () {
  58144. var imageData = _this.getFloat32ArrayFromArrayBuffer(_this._buffer);
  58145. // Extract the raw linear data.
  58146. var data = _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(imageData, _this._width, _this._height, _this._size);
  58147. var results = [];
  58148. // Push each faces.
  58149. for (var i = 0; i < 6; i++) {
  58150. var dataFace = data[EquiRectangularCubeTexture._FacesMapping[i]];
  58151. results.push(dataFace);
  58152. }
  58153. return results;
  58154. };
  58155. if (!scene) {
  58156. return;
  58157. }
  58158. this._texture = scene
  58159. .getEngine()
  58160. .createRawCubeTextureFromUrl(this.url, scene, this._size, _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat
  58161. ? _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_FLOAT
  58162. : _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, callback, null, this._onLoad, this._onError);
  58163. };
  58164. /**
  58165. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58166. * @param buffer The ArrayBuffer that should be converted.
  58167. * @returns The buffer as Float32Array.
  58168. */
  58169. EquiRectangularCubeTexture.prototype.getFloat32ArrayFromArrayBuffer = function (buffer) {
  58170. var dataView = new DataView(buffer);
  58171. var floatImageData = new Float32Array((buffer.byteLength * 3) / 4);
  58172. var k = 0;
  58173. for (var i = 0; i < buffer.byteLength; i++) {
  58174. // We drop the transparency channel, because we do not need/want it
  58175. if ((i + 1) % 4 !== 0) {
  58176. floatImageData[k++] = dataView.getUint8(i) / 255;
  58177. }
  58178. }
  58179. return floatImageData;
  58180. };
  58181. /**
  58182. * Get the current class name of the texture useful for serialization or dynamic coding.
  58183. * @returns "EquiRectangularCubeTexture"
  58184. */
  58185. EquiRectangularCubeTexture.prototype.getClassName = function () {
  58186. return "EquiRectangularCubeTexture";
  58187. };
  58188. /**
  58189. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58190. * @returns A clone of the current EquiRectangularCubeTexture.
  58191. */
  58192. EquiRectangularCubeTexture.prototype.clone = function () {
  58193. var scene = this.getScene();
  58194. if (!scene) {
  58195. return this;
  58196. }
  58197. var newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);
  58198. // Base texture
  58199. newTexture.level = this.level;
  58200. newTexture.wrapU = this.wrapU;
  58201. newTexture.wrapV = this.wrapV;
  58202. newTexture.coordinatesIndex = this.coordinatesIndex;
  58203. newTexture.coordinatesMode = this.coordinatesMode;
  58204. return newTexture;
  58205. };
  58206. /** The six faces of the cube. */
  58207. EquiRectangularCubeTexture._FacesMapping = ['right', 'left', 'up', 'down', 'front', 'back'];
  58208. return EquiRectangularCubeTexture;
  58209. }(_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  58210. /***/ }),
  58211. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  58212. /*!**********************************************!*\
  58213. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  58214. \**********************************************/
  58215. /*! exports provided: HDRCubeTexture */
  58216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58217. "use strict";
  58218. __webpack_require__.r(__webpack_exports__);
  58219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  58220. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58221. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58222. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  58223. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58224. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58225. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58226. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  58227. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  58228. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58229. /**
  58230. * This represents a texture coming from an HDR input.
  58231. *
  58232. * The only supported format is currently panorama picture stored in RGBE format.
  58233. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58234. */
  58235. var HDRCubeTexture = /** @class */ (function (_super) {
  58236. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  58237. /**
  58238. * Instantiates an HDRTexture from the following parameters.
  58239. *
  58240. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58241. * @param scene The scene the texture will be used in
  58242. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58243. * @param noMipmap Forces to not generate the mipmap if true
  58244. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58245. * @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)
  58246. * @param reserved Reserved flag for internal use.
  58247. */
  58248. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  58249. if (noMipmap === void 0) { noMipmap = false; }
  58250. if (generateHarmonics === void 0) { generateHarmonics = true; }
  58251. if (gammaSpace === void 0) { gammaSpace = false; }
  58252. if (reserved === void 0) { reserved = false; }
  58253. if (onLoad === void 0) { onLoad = null; }
  58254. if (onError === void 0) { onError = null; }
  58255. var _this = _super.call(this, scene) || this;
  58256. _this._generateHarmonics = true;
  58257. _this._onLoad = null;
  58258. _this._onError = null;
  58259. /**
  58260. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58261. */
  58262. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  58263. _this._isBlocking = true;
  58264. _this._rotationY = 0;
  58265. /**
  58266. * Gets or sets the center of the bounding box associated with the cube texture
  58267. * It must define where the camera used to render the texture was set
  58268. */
  58269. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  58270. if (!url) {
  58271. return _this;
  58272. }
  58273. _this.name = url;
  58274. _this.url = url;
  58275. _this.hasAlpha = false;
  58276. _this.isCube = true;
  58277. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  58278. _this._onLoad = onLoad;
  58279. _this._onError = onError;
  58280. _this.gammaSpace = gammaSpace;
  58281. _this._noMipmap = noMipmap;
  58282. _this._size = size;
  58283. _this._texture = _this._getFromCache(url, _this._noMipmap);
  58284. if (!_this._texture) {
  58285. if (!scene.useDelayedTextureLoading) {
  58286. _this.loadTexture();
  58287. }
  58288. else {
  58289. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  58290. }
  58291. }
  58292. return _this;
  58293. }
  58294. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  58295. /**
  58296. * Gets wether or not the texture is blocking during loading.
  58297. */
  58298. get: function () {
  58299. return this._isBlocking;
  58300. },
  58301. /**
  58302. * Sets wether or not the texture is blocking during loading.
  58303. */
  58304. set: function (value) {
  58305. this._isBlocking = value;
  58306. },
  58307. enumerable: true,
  58308. configurable: true
  58309. });
  58310. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  58311. /**
  58312. * Gets texture matrix rotation angle around Y axis radians.
  58313. */
  58314. get: function () {
  58315. return this._rotationY;
  58316. },
  58317. /**
  58318. * Sets texture matrix rotation angle around Y axis in radians.
  58319. */
  58320. set: function (value) {
  58321. this._rotationY = value;
  58322. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  58323. },
  58324. enumerable: true,
  58325. configurable: true
  58326. });
  58327. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  58328. get: function () {
  58329. return this._boundingBoxSize;
  58330. },
  58331. /**
  58332. * Gets or sets the size of the bounding box associated with the cube texture
  58333. * When defined, the cubemap will switch to local mode
  58334. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58335. * @example https://www.babylonjs-playground.com/#RNASML
  58336. */
  58337. set: function (value) {
  58338. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  58339. return;
  58340. }
  58341. this._boundingBoxSize = value;
  58342. var scene = this.getScene();
  58343. if (scene) {
  58344. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  58345. }
  58346. },
  58347. enumerable: true,
  58348. configurable: true
  58349. });
  58350. /**
  58351. * Get the current class name of the texture useful for serialization or dynamic coding.
  58352. * @returns "HDRCubeTexture"
  58353. */
  58354. HDRCubeTexture.prototype.getClassName = function () {
  58355. return "HDRCubeTexture";
  58356. };
  58357. /**
  58358. * Occurs when the file is raw .hdr file.
  58359. */
  58360. HDRCubeTexture.prototype.loadTexture = function () {
  58361. var _this = this;
  58362. var callback = function (buffer) {
  58363. _this.lodGenerationOffset = 0.0;
  58364. _this.lodGenerationScale = 0.8;
  58365. var scene = _this.getScene();
  58366. if (!scene) {
  58367. return null;
  58368. }
  58369. // Extract the raw linear data.
  58370. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  58371. // Generate harmonics if needed.
  58372. if (_this._generateHarmonics) {
  58373. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  58374. _this.sphericalPolynomial = sphericalPolynomial;
  58375. }
  58376. var results = [];
  58377. var byteArray = null;
  58378. // Push each faces.
  58379. for (var j = 0; j < 6; j++) {
  58380. // Create uintarray fallback.
  58381. if (!scene.getEngine().getCaps().textureFloat) {
  58382. // 3 channels of 1 bytes per pixel in bytes.
  58383. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  58384. byteArray = new Uint8Array(byteBuffer);
  58385. }
  58386. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  58387. // If special cases.
  58388. if (_this.gammaSpace || byteArray) {
  58389. for (var i = 0; i < _this._size * _this._size; i++) {
  58390. // Put in gamma space if requested.
  58391. if (_this.gammaSpace) {
  58392. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  58393. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  58394. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  58395. }
  58396. // Convert to int texture for fallback.
  58397. if (byteArray) {
  58398. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  58399. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  58400. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  58401. // May use luminance instead if the result is not accurate.
  58402. var max = Math.max(Math.max(r, g), b);
  58403. if (max > 255) {
  58404. var scale = 255 / max;
  58405. r *= scale;
  58406. g *= scale;
  58407. b *= scale;
  58408. }
  58409. byteArray[(i * 3) + 0] = r;
  58410. byteArray[(i * 3) + 1] = g;
  58411. byteArray[(i * 3) + 2] = b;
  58412. }
  58413. }
  58414. }
  58415. if (byteArray) {
  58416. results.push(byteArray);
  58417. }
  58418. else {
  58419. results.push(dataFace);
  58420. }
  58421. }
  58422. return results;
  58423. };
  58424. var scene = this.getScene();
  58425. if (scene) {
  58426. 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);
  58427. }
  58428. };
  58429. HDRCubeTexture.prototype.clone = function () {
  58430. var scene = this.getScene();
  58431. if (!scene) {
  58432. return this;
  58433. }
  58434. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  58435. // Base texture
  58436. newTexture.level = this.level;
  58437. newTexture.wrapU = this.wrapU;
  58438. newTexture.wrapV = this.wrapV;
  58439. newTexture.coordinatesIndex = this.coordinatesIndex;
  58440. newTexture.coordinatesMode = this.coordinatesMode;
  58441. return newTexture;
  58442. };
  58443. // Methods
  58444. HDRCubeTexture.prototype.delayLoad = function () {
  58445. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  58446. return;
  58447. }
  58448. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  58449. this._texture = this._getFromCache(this.url, this._noMipmap);
  58450. if (!this._texture) {
  58451. this.loadTexture();
  58452. }
  58453. };
  58454. /**
  58455. * Get the texture reflection matrix used to rotate/transform the reflection.
  58456. * @returns the reflection matrix
  58457. */
  58458. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  58459. return this._textureMatrix;
  58460. };
  58461. /**
  58462. * Set the texture reflection matrix used to rotate/transform the reflection.
  58463. * @param value Define the reflection matrix to set
  58464. */
  58465. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  58466. var _this = this;
  58467. this._textureMatrix = value;
  58468. if (value.updateFlag === this._textureMatrix.updateFlag) {
  58469. return;
  58470. }
  58471. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  58472. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  58473. }
  58474. };
  58475. /**
  58476. * Parses a JSON representation of an HDR Texture in order to create the texture
  58477. * @param parsedTexture Define the JSON representation
  58478. * @param scene Define the scene the texture should be created in
  58479. * @param rootUrl Define the root url in case we need to load relative dependencies
  58480. * @returns the newly created texture after parsing
  58481. */
  58482. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  58483. var texture = null;
  58484. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  58485. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  58486. texture.name = parsedTexture.name;
  58487. texture.hasAlpha = parsedTexture.hasAlpha;
  58488. texture.level = parsedTexture.level;
  58489. texture.coordinatesMode = parsedTexture.coordinatesMode;
  58490. texture.isBlocking = parsedTexture.isBlocking;
  58491. }
  58492. if (texture) {
  58493. if (parsedTexture.boundingBoxPosition) {
  58494. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  58495. }
  58496. if (parsedTexture.boundingBoxSize) {
  58497. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  58498. }
  58499. if (parsedTexture.rotationY) {
  58500. texture.rotationY = parsedTexture.rotationY;
  58501. }
  58502. }
  58503. return texture;
  58504. };
  58505. HDRCubeTexture.prototype.serialize = function () {
  58506. if (!this.name) {
  58507. return null;
  58508. }
  58509. var serializationObject = {};
  58510. serializationObject.name = this.name;
  58511. serializationObject.hasAlpha = this.hasAlpha;
  58512. serializationObject.isCube = true;
  58513. serializationObject.level = this.level;
  58514. serializationObject.size = this._size;
  58515. serializationObject.coordinatesMode = this.coordinatesMode;
  58516. serializationObject.useInGammaSpace = this.gammaSpace;
  58517. serializationObject.generateHarmonics = this._generateHarmonics;
  58518. serializationObject.customType = "BABYLON.HDRCubeTexture";
  58519. serializationObject.noMipmap = this._noMipmap;
  58520. serializationObject.isBlocking = this._isBlocking;
  58521. serializationObject.rotationY = this._rotationY;
  58522. return serializationObject;
  58523. };
  58524. HDRCubeTexture._facesMapping = [
  58525. "right",
  58526. "left",
  58527. "up",
  58528. "down",
  58529. "front",
  58530. "back"
  58531. ];
  58532. return HDRCubeTexture;
  58533. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  58534. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  58535. /***/ }),
  58536. /***/ "./Materials/Textures/index.ts":
  58537. /*!*************************************!*\
  58538. !*** ./Materials/Textures/index.ts ***!
  58539. \*************************************/
  58540. /*! exports provided: BaseTexture, CubeTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, MultiviewRenderTarget, Texture, ColorGradingTexture, DynamicTexture, EquiRectangularCubeTexture, HDRCubeTexture, DummyInternalTextureTracker, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  58541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58542. "use strict";
  58543. __webpack_require__.r(__webpack_exports__);
  58544. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  58545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  58546. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  58547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  58548. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  58549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  58550. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  58551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  58552. /* harmony import */ var _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  58553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__["EquiRectangularCubeTexture"]; });
  58554. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  58555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__["HDRCubeTexture"]; });
  58556. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  58557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_6__["InternalTexture"]; });
  58558. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  58559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_7__["DummyInternalTextureTracker"]; });
  58560. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  58561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_DDSTextureLoader"]; });
  58562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_ENVTextureLoader"]; });
  58563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_KTXTextureLoader"]; });
  58564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_TGATextureLoader"]; });
  58565. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  58566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_9__["MirrorTexture"]; });
  58567. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  58568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_10__["MultiRenderTarget"]; });
  58569. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  58570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["CustomProceduralTexture"]; });
  58571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["NoiseProceduralTexture"]; });
  58572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["ProceduralTexture"]; });
  58573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["ProceduralTextureSceneComponent"]; });
  58574. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  58575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_12__["RawCubeTexture"]; });
  58576. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  58577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  58578. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  58579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_14__["RawTexture3D"]; });
  58580. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  58581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_15__["RefractionTexture"]; });
  58582. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_16__["RenderTargetTexture"]; });
  58584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_16__["MultiviewRenderTarget"]; });
  58585. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  58586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_17__["Texture"]; });
  58587. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  58588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_18__["VideoTexture"]; });
  58589. /***/ }),
  58590. /***/ "./Materials/Textures/internalTexture.ts":
  58591. /*!***********************************************!*\
  58592. !*** ./Materials/Textures/internalTexture.ts ***!
  58593. \***********************************************/
  58594. /*! exports provided: InternalTexture */
  58595. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58596. "use strict";
  58597. __webpack_require__.r(__webpack_exports__);
  58598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  58599. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58600. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  58601. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58602. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  58603. /**
  58604. * Class used to store data associated with WebGL texture data for the engine
  58605. * This class should not be used directly
  58606. */
  58607. var InternalTexture = /** @class */ (function () {
  58608. /**
  58609. * Creates a new InternalTexture
  58610. * @param engine defines the engine to use
  58611. * @param dataSource defines the type of data that will be used
  58612. * @param delayAllocation if the texture allocation should be delayed (default: false)
  58613. */
  58614. function InternalTexture(engine, dataSource, delayAllocation) {
  58615. if (delayAllocation === void 0) { delayAllocation = false; }
  58616. /**
  58617. * Observable called when the texture is loaded
  58618. */
  58619. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  58620. /**
  58621. * Gets or set the previous tracker in the list
  58622. */
  58623. this.previous = null;
  58624. /**
  58625. * Gets or set the next tracker in the list
  58626. */
  58627. this.next = null;
  58628. // Private
  58629. /** @hidden */
  58630. this._invertVScale = false;
  58631. /** @hidden */
  58632. this._initialSlot = -1;
  58633. /** @hidden */
  58634. this._designatedSlot = -1;
  58635. /** @hidden */
  58636. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  58637. /** @hidden */
  58638. this._comparisonFunction = 0;
  58639. /** @hidden */
  58640. this._sphericalPolynomial = null;
  58641. /** @hidden */
  58642. this._lodGenerationScale = 0;
  58643. /** @hidden */
  58644. this._lodGenerationOffset = 0;
  58645. /** @hidden */
  58646. this._isRGBD = false;
  58647. /** @hidden */
  58648. this._references = 1;
  58649. this._engine = engine;
  58650. this._dataSource = dataSource;
  58651. if (!delayAllocation) {
  58652. this._webGLTexture = engine._createTexture();
  58653. }
  58654. }
  58655. /**
  58656. * Gets the Engine the texture belongs to.
  58657. * @returns The babylon engine
  58658. */
  58659. InternalTexture.prototype.getEngine = function () {
  58660. return this._engine;
  58661. };
  58662. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  58663. /**
  58664. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  58665. */
  58666. get: function () {
  58667. return this._dataSource;
  58668. },
  58669. enumerable: true,
  58670. configurable: true
  58671. });
  58672. /**
  58673. * Increments the number of references (ie. the number of Texture that point to it)
  58674. */
  58675. InternalTexture.prototype.incrementReferences = function () {
  58676. this._references++;
  58677. };
  58678. /**
  58679. * Change the size of the texture (not the size of the content)
  58680. * @param width defines the new width
  58681. * @param height defines the new height
  58682. * @param depth defines the new depth (1 by default)
  58683. */
  58684. InternalTexture.prototype.updateSize = function (width, height, depth) {
  58685. if (depth === void 0) { depth = 1; }
  58686. this.width = width;
  58687. this.height = height;
  58688. this.depth = depth;
  58689. this.baseWidth = width;
  58690. this.baseHeight = height;
  58691. this.baseDepth = depth;
  58692. this._size = width * height * depth;
  58693. };
  58694. /** @hidden */
  58695. InternalTexture.prototype._rebuild = function () {
  58696. var _this = this;
  58697. var proxy;
  58698. this.isReady = false;
  58699. this._cachedCoordinatesMode = null;
  58700. this._cachedWrapU = null;
  58701. this._cachedWrapV = null;
  58702. this._cachedAnisotropicFilteringLevel = null;
  58703. switch (this._dataSource) {
  58704. case InternalTexture.DATASOURCE_TEMP:
  58705. return;
  58706. case InternalTexture.DATASOURCE_URL:
  58707. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  58708. proxy._swapAndDie(_this);
  58709. _this.isReady = true;
  58710. }, null, this._buffer, undefined, this.format);
  58711. return;
  58712. case InternalTexture.DATASOURCE_RAW:
  58713. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58714. proxy._swapAndDie(this);
  58715. this.isReady = true;
  58716. return;
  58717. case InternalTexture.DATASOURCE_RAW3D:
  58718. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58719. proxy._swapAndDie(this);
  58720. this.isReady = true;
  58721. return;
  58722. case InternalTexture.DATASOURCE_DYNAMIC:
  58723. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  58724. proxy._swapAndDie(this);
  58725. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  58726. // The engine will make sure to update content so no need to flag it as isReady = true
  58727. return;
  58728. case InternalTexture.DATASOURCE_RENDERTARGET:
  58729. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  58730. options.generateDepthBuffer = this._generateDepthBuffer;
  58731. options.generateMipMaps = this.generateMipMaps;
  58732. options.generateStencilBuffer = this._generateStencilBuffer;
  58733. options.samplingMode = this.samplingMode;
  58734. options.type = this.type;
  58735. if (this.isCube) {
  58736. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  58737. }
  58738. else {
  58739. var size = {
  58740. width: this.width,
  58741. height: this.height
  58742. };
  58743. proxy = this._engine.createRenderTargetTexture(size, options);
  58744. }
  58745. proxy._swapAndDie(this);
  58746. this.isReady = true;
  58747. return;
  58748. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  58749. var depthTextureOptions = {
  58750. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  58751. comparisonFunction: this._comparisonFunction,
  58752. generateStencil: this._generateStencilBuffer,
  58753. isCube: this.isCube
  58754. };
  58755. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  58756. proxy._swapAndDie(this);
  58757. this.isReady = true;
  58758. return;
  58759. case InternalTexture.DATASOURCE_CUBE:
  58760. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  58761. proxy._swapAndDie(_this);
  58762. _this.isReady = true;
  58763. }, null, this.format, this._extension);
  58764. return;
  58765. case InternalTexture.DATASOURCE_CUBERAW:
  58766. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58767. proxy._swapAndDie(this);
  58768. this.isReady = true;
  58769. return;
  58770. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  58771. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58772. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  58773. proxy._swapAndDie(_this);
  58774. _this.isReady = true;
  58775. });
  58776. return;
  58777. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  58778. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  58779. if (proxy) {
  58780. proxy._swapAndDie(_this);
  58781. }
  58782. _this.isReady = true;
  58783. }, null, this.format, this._extension);
  58784. proxy._sphericalPolynomial = this._sphericalPolynomial;
  58785. return;
  58786. }
  58787. };
  58788. /** @hidden */
  58789. InternalTexture.prototype._swapAndDie = function (target) {
  58790. target._webGLTexture = this._webGLTexture;
  58791. target._isRGBD = this._isRGBD;
  58792. if (this._framebuffer) {
  58793. target._framebuffer = this._framebuffer;
  58794. }
  58795. if (this._depthStencilBuffer) {
  58796. target._depthStencilBuffer = this._depthStencilBuffer;
  58797. }
  58798. if (this._lodTextureHigh) {
  58799. if (target._lodTextureHigh) {
  58800. target._lodTextureHigh.dispose();
  58801. }
  58802. target._lodTextureHigh = this._lodTextureHigh;
  58803. }
  58804. if (this._lodTextureMid) {
  58805. if (target._lodTextureMid) {
  58806. target._lodTextureMid.dispose();
  58807. }
  58808. target._lodTextureMid = this._lodTextureMid;
  58809. }
  58810. if (this._lodTextureLow) {
  58811. if (target._lodTextureLow) {
  58812. target._lodTextureLow.dispose();
  58813. }
  58814. target._lodTextureLow = this._lodTextureLow;
  58815. }
  58816. var cache = this._engine.getLoadedTexturesCache();
  58817. var index = cache.indexOf(this);
  58818. if (index !== -1) {
  58819. cache.splice(index, 1);
  58820. }
  58821. };
  58822. /**
  58823. * Dispose the current allocated resources
  58824. */
  58825. InternalTexture.prototype.dispose = function () {
  58826. if (!this._webGLTexture) {
  58827. return;
  58828. }
  58829. this._references--;
  58830. if (this._references === 0) {
  58831. this._engine._releaseTexture(this);
  58832. this._webGLTexture = null;
  58833. this.previous = null;
  58834. this.next = null;
  58835. }
  58836. };
  58837. /** hidden */
  58838. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  58839. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  58840. };
  58841. /**
  58842. * The source of the texture data is unknown
  58843. */
  58844. InternalTexture.DATASOURCE_UNKNOWN = 0;
  58845. /**
  58846. * Texture data comes from an URL
  58847. */
  58848. InternalTexture.DATASOURCE_URL = 1;
  58849. /**
  58850. * Texture data is only used for temporary storage
  58851. */
  58852. InternalTexture.DATASOURCE_TEMP = 2;
  58853. /**
  58854. * Texture data comes from raw data (ArrayBuffer)
  58855. */
  58856. InternalTexture.DATASOURCE_RAW = 3;
  58857. /**
  58858. * Texture content is dynamic (video or dynamic texture)
  58859. */
  58860. InternalTexture.DATASOURCE_DYNAMIC = 4;
  58861. /**
  58862. * Texture content is generated by rendering to it
  58863. */
  58864. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  58865. /**
  58866. * Texture content is part of a multi render target process
  58867. */
  58868. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  58869. /**
  58870. * Texture data comes from a cube data file
  58871. */
  58872. InternalTexture.DATASOURCE_CUBE = 7;
  58873. /**
  58874. * Texture data comes from a raw cube data
  58875. */
  58876. InternalTexture.DATASOURCE_CUBERAW = 8;
  58877. /**
  58878. * Texture data come from a prefiltered cube data file
  58879. */
  58880. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  58881. /**
  58882. * Texture content is raw 3D data
  58883. */
  58884. InternalTexture.DATASOURCE_RAW3D = 10;
  58885. /**
  58886. * Texture content is a depth texture
  58887. */
  58888. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  58889. /**
  58890. * Texture data comes from a raw cube data encoded with RGBD
  58891. */
  58892. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  58893. return InternalTexture;
  58894. }());
  58895. /***/ }),
  58896. /***/ "./Materials/Textures/internalTextureTracker.ts":
  58897. /*!******************************************************!*\
  58898. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  58899. \******************************************************/
  58900. /*! exports provided: DummyInternalTextureTracker */
  58901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58902. "use strict";
  58903. __webpack_require__.r(__webpack_exports__);
  58904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  58905. /**
  58906. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  58907. */
  58908. var DummyInternalTextureTracker = /** @class */ (function () {
  58909. function DummyInternalTextureTracker() {
  58910. /**
  58911. * Gets or set the previous tracker in the list
  58912. */
  58913. this.previous = null;
  58914. /**
  58915. * Gets or set the next tracker in the list
  58916. */
  58917. this.next = null;
  58918. }
  58919. return DummyInternalTextureTracker;
  58920. }());
  58921. /***/ }),
  58922. /***/ "./Materials/Textures/mirrorTexture.ts":
  58923. /*!*********************************************!*\
  58924. !*** ./Materials/Textures/mirrorTexture.ts ***!
  58925. \*********************************************/
  58926. /*! exports provided: MirrorTexture */
  58927. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58928. "use strict";
  58929. __webpack_require__.r(__webpack_exports__);
  58930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  58931. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58932. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58933. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58934. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58935. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  58936. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58937. /**
  58938. * Mirror texture can be used to simulate the view from a mirror in a scene.
  58939. * It will dynamically be rendered every frame to adapt to the camera point of view.
  58940. * You can then easily use it as a reflectionTexture on a flat surface.
  58941. * In case the surface is not a plane, please consider relying on reflection probes.
  58942. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58943. */
  58944. var MirrorTexture = /** @class */ (function (_super) {
  58945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  58946. /**
  58947. * Instantiates a Mirror Texture.
  58948. * Mirror texture can be used to simulate the view from a mirror in a scene.
  58949. * It will dynamically be rendered every frame to adapt to the camera point of view.
  58950. * You can then easily use it as a reflectionTexture on a flat surface.
  58951. * In case the surface is not a plane, please consider relying on reflection probes.
  58952. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58953. * @param name
  58954. * @param size
  58955. * @param scene
  58956. * @param generateMipMaps
  58957. * @param type
  58958. * @param samplingMode
  58959. * @param generateDepthBuffer
  58960. */
  58961. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  58962. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58963. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  58964. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  58965. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  58966. _this.scene = scene;
  58967. /**
  58968. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  58969. * 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.
  58970. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58971. */
  58972. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  58973. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  58974. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  58975. _this._adaptiveBlurKernel = 0;
  58976. _this._blurKernelX = 0;
  58977. _this._blurKernelY = 0;
  58978. _this._blurRatio = 1.0;
  58979. _this.ignoreCameraViewport = true;
  58980. _this._updateGammaSpace();
  58981. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  58982. _this._updateGammaSpace;
  58983. });
  58984. _this.onBeforeRenderObservable.add(function () {
  58985. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  58986. _this._savedViewMatrix = scene.getViewMatrix();
  58987. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  58988. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  58989. scene.clipPlane = _this.mirrorPlane;
  58990. scene.getEngine().cullBackFaces = false;
  58991. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  58992. });
  58993. _this.onAfterRenderObservable.add(function () {
  58994. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  58995. scene.getEngine().cullBackFaces = true;
  58996. scene._mirroredCameraPosition = null;
  58997. delete scene.clipPlane;
  58998. });
  58999. return _this;
  59000. }
  59001. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  59002. get: function () {
  59003. return this._blurRatio;
  59004. },
  59005. /**
  59006. * Define the blur ratio used to blur the reflection if needed.
  59007. */
  59008. set: function (value) {
  59009. if (this._blurRatio === value) {
  59010. return;
  59011. }
  59012. this._blurRatio = value;
  59013. this._preparePostProcesses();
  59014. },
  59015. enumerable: true,
  59016. configurable: true
  59017. });
  59018. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  59019. /**
  59020. * Define the adaptive blur kernel used to blur the reflection if needed.
  59021. * This will autocompute the closest best match for the `blurKernel`
  59022. */
  59023. set: function (value) {
  59024. this._adaptiveBlurKernel = value;
  59025. this._autoComputeBlurKernel();
  59026. },
  59027. enumerable: true,
  59028. configurable: true
  59029. });
  59030. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  59031. /**
  59032. * Define the blur kernel used to blur the reflection if needed.
  59033. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59034. */
  59035. set: function (value) {
  59036. this.blurKernelX = value;
  59037. this.blurKernelY = value;
  59038. },
  59039. enumerable: true,
  59040. configurable: true
  59041. });
  59042. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  59043. get: function () {
  59044. return this._blurKernelX;
  59045. },
  59046. /**
  59047. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  59048. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59049. */
  59050. set: function (value) {
  59051. if (this._blurKernelX === value) {
  59052. return;
  59053. }
  59054. this._blurKernelX = value;
  59055. this._preparePostProcesses();
  59056. },
  59057. enumerable: true,
  59058. configurable: true
  59059. });
  59060. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  59061. get: function () {
  59062. return this._blurKernelY;
  59063. },
  59064. /**
  59065. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  59066. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59067. */
  59068. set: function (value) {
  59069. if (this._blurKernelY === value) {
  59070. return;
  59071. }
  59072. this._blurKernelY = value;
  59073. this._preparePostProcesses();
  59074. },
  59075. enumerable: true,
  59076. configurable: true
  59077. });
  59078. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  59079. var engine = this.getScene().getEngine();
  59080. var dw = this.getRenderWidth() / engine.getRenderWidth();
  59081. var dh = this.getRenderHeight() / engine.getRenderHeight();
  59082. this.blurKernelX = this._adaptiveBlurKernel * dw;
  59083. this.blurKernelY = this._adaptiveBlurKernel * dh;
  59084. };
  59085. MirrorTexture.prototype._onRatioRescale = function () {
  59086. if (this._sizeRatio) {
  59087. this.resize(this._initialSizeParameter);
  59088. if (!this._adaptiveBlurKernel) {
  59089. this._preparePostProcesses();
  59090. }
  59091. }
  59092. if (this._adaptiveBlurKernel) {
  59093. this._autoComputeBlurKernel();
  59094. }
  59095. };
  59096. MirrorTexture.prototype._updateGammaSpace = function () {
  59097. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  59098. };
  59099. MirrorTexture.prototype._preparePostProcesses = function () {
  59100. this.clearPostProcesses(true);
  59101. if (this._blurKernelX && this._blurKernelY) {
  59102. var engine = this.getScene().getEngine();
  59103. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  59104. 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);
  59105. this._blurX.autoClear = false;
  59106. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  59107. this._blurX.inputTexture = this._texture;
  59108. }
  59109. else {
  59110. this._blurX.alwaysForcePOT = true;
  59111. }
  59112. 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);
  59113. this._blurY.autoClear = false;
  59114. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  59115. this.addPostProcess(this._blurX);
  59116. this.addPostProcess(this._blurY);
  59117. }
  59118. else {
  59119. if (this._blurY) {
  59120. this.removePostProcess(this._blurY);
  59121. this._blurY.dispose();
  59122. this._blurY = null;
  59123. }
  59124. if (this._blurX) {
  59125. this.removePostProcess(this._blurX);
  59126. this._blurX.dispose();
  59127. this._blurX = null;
  59128. }
  59129. }
  59130. };
  59131. /**
  59132. * Clone the mirror texture.
  59133. * @returns the cloned texture
  59134. */
  59135. MirrorTexture.prototype.clone = function () {
  59136. var scene = this.getScene();
  59137. if (!scene) {
  59138. return this;
  59139. }
  59140. var textureSize = this.getSize();
  59141. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  59142. // Base texture
  59143. newTexture.hasAlpha = this.hasAlpha;
  59144. newTexture.level = this.level;
  59145. // Mirror Texture
  59146. newTexture.mirrorPlane = this.mirrorPlane.clone();
  59147. if (this.renderList) {
  59148. newTexture.renderList = this.renderList.slice(0);
  59149. }
  59150. return newTexture;
  59151. };
  59152. /**
  59153. * Serialize the texture to a JSON representation you could use in Parse later on
  59154. * @returns the serialized JSON representation
  59155. */
  59156. MirrorTexture.prototype.serialize = function () {
  59157. if (!this.name) {
  59158. return null;
  59159. }
  59160. var serializationObject = _super.prototype.serialize.call(this);
  59161. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  59162. return serializationObject;
  59163. };
  59164. /**
  59165. * Dispose the texture and release its associated resources.
  59166. */
  59167. MirrorTexture.prototype.dispose = function () {
  59168. _super.prototype.dispose.call(this);
  59169. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  59170. };
  59171. return MirrorTexture;
  59172. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  59173. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  59174. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  59175. };
  59176. /***/ }),
  59177. /***/ "./Materials/Textures/multiRenderTarget.ts":
  59178. /*!*************************************************!*\
  59179. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  59180. \*************************************************/
  59181. /*! exports provided: MultiRenderTarget */
  59182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59183. "use strict";
  59184. __webpack_require__.r(__webpack_exports__);
  59185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  59186. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59187. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59188. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59189. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59190. /**
  59191. * A multi render target, like a render target provides the ability to render to a texture.
  59192. * Unlike the render target, it can render to several draw buffers in one draw.
  59193. * This is specially interesting in deferred rendering or for any effects requiring more than
  59194. * just one color from a single pass.
  59195. */
  59196. var MultiRenderTarget = /** @class */ (function (_super) {
  59197. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  59198. /**
  59199. * Instantiate a new multi render target texture.
  59200. * A multi render target, like a render target provides the ability to render to a texture.
  59201. * Unlike the render target, it can render to several draw buffers in one draw.
  59202. * This is specially interesting in deferred rendering or for any effects requiring more than
  59203. * just one color from a single pass.
  59204. * @param name Define the name of the texture
  59205. * @param size Define the size of the buffers to render to
  59206. * @param count Define the number of target we are rendering into
  59207. * @param scene Define the scene the texture belongs to
  59208. * @param options Define the options used to create the multi render target
  59209. */
  59210. function MultiRenderTarget(name, size, count, scene, options) {
  59211. var _this = this;
  59212. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  59213. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  59214. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  59215. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  59216. _this._engine = scene.getEngine();
  59217. if (!_this.isSupported) {
  59218. _this.dispose();
  59219. return;
  59220. }
  59221. var types = [];
  59222. var samplingModes = [];
  59223. for (var i = 0; i < count; i++) {
  59224. if (options && options.types && options.types[i] !== undefined) {
  59225. types.push(options.types[i]);
  59226. }
  59227. else {
  59228. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  59229. }
  59230. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  59231. samplingModes.push(options.samplingModes[i]);
  59232. }
  59233. else {
  59234. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  59235. }
  59236. }
  59237. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  59238. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  59239. _this._size = size;
  59240. _this._multiRenderTargetOptions = {
  59241. samplingModes: samplingModes,
  59242. generateMipMaps: generateMipMaps,
  59243. generateDepthBuffer: generateDepthBuffer,
  59244. generateStencilBuffer: generateStencilBuffer,
  59245. generateDepthTexture: generateDepthTexture,
  59246. types: types,
  59247. textureCount: count
  59248. };
  59249. _this._createInternalTextures();
  59250. _this._createTextures();
  59251. return _this;
  59252. }
  59253. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  59254. /**
  59255. * Get if draw buffers are currently supported by the used hardware and browser.
  59256. */
  59257. get: function () {
  59258. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  59259. },
  59260. enumerable: true,
  59261. configurable: true
  59262. });
  59263. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  59264. /**
  59265. * Get the list of textures generated by the multi render target.
  59266. */
  59267. get: function () {
  59268. return this._textures;
  59269. },
  59270. enumerable: true,
  59271. configurable: true
  59272. });
  59273. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  59274. /**
  59275. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  59276. */
  59277. get: function () {
  59278. return this._textures[this._textures.length - 1];
  59279. },
  59280. enumerable: true,
  59281. configurable: true
  59282. });
  59283. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  59284. /**
  59285. * Set the wrapping mode on U of all the textures we are rendering to.
  59286. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  59287. */
  59288. set: function (wrap) {
  59289. if (this._textures) {
  59290. for (var i = 0; i < this._textures.length; i++) {
  59291. this._textures[i].wrapU = wrap;
  59292. }
  59293. }
  59294. },
  59295. enumerable: true,
  59296. configurable: true
  59297. });
  59298. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  59299. /**
  59300. * Set the wrapping mode on V of all the textures we are rendering to.
  59301. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  59302. */
  59303. set: function (wrap) {
  59304. if (this._textures) {
  59305. for (var i = 0; i < this._textures.length; i++) {
  59306. this._textures[i].wrapV = wrap;
  59307. }
  59308. }
  59309. },
  59310. enumerable: true,
  59311. configurable: true
  59312. });
  59313. /** @hidden */
  59314. MultiRenderTarget.prototype._rebuild = function () {
  59315. this.releaseInternalTextures();
  59316. this._createInternalTextures();
  59317. for (var i = 0; i < this._internalTextures.length; i++) {
  59318. var texture = this._textures[i];
  59319. texture._texture = this._internalTextures[i];
  59320. }
  59321. // Keeps references to frame buffer and stencil/depth buffer
  59322. this._texture = this._internalTextures[0];
  59323. };
  59324. MultiRenderTarget.prototype._createInternalTextures = function () {
  59325. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  59326. };
  59327. MultiRenderTarget.prototype._createTextures = function () {
  59328. this._textures = [];
  59329. for (var i = 0; i < this._internalTextures.length; i++) {
  59330. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  59331. texture._texture = this._internalTextures[i];
  59332. this._textures.push(texture);
  59333. }
  59334. // Keeps references to frame buffer and stencil/depth buffer
  59335. this._texture = this._internalTextures[0];
  59336. };
  59337. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  59338. /**
  59339. * Define the number of samples used if MSAA is enabled.
  59340. */
  59341. get: function () {
  59342. return this._samples;
  59343. },
  59344. set: function (value) {
  59345. if (this._samples === value) {
  59346. return;
  59347. }
  59348. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  59349. },
  59350. enumerable: true,
  59351. configurable: true
  59352. });
  59353. /**
  59354. * Resize all the textures in the multi render target.
  59355. * Be carrefull as it will recreate all the data in the new texture.
  59356. * @param size Define the new size
  59357. */
  59358. MultiRenderTarget.prototype.resize = function (size) {
  59359. this.releaseInternalTextures();
  59360. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  59361. this._createInternalTextures();
  59362. };
  59363. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  59364. var _this = this;
  59365. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  59366. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  59367. });
  59368. };
  59369. /**
  59370. * Dispose the render targets and their associated resources
  59371. */
  59372. MultiRenderTarget.prototype.dispose = function () {
  59373. this.releaseInternalTextures();
  59374. _super.prototype.dispose.call(this);
  59375. };
  59376. /**
  59377. * Release all the underlying texture used as draw buffers.
  59378. */
  59379. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  59380. if (!this._internalTextures) {
  59381. return;
  59382. }
  59383. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  59384. if (this._internalTextures[i] !== undefined) {
  59385. this._internalTextures[i].dispose();
  59386. this._internalTextures.splice(i, 1);
  59387. }
  59388. }
  59389. };
  59390. return MultiRenderTarget;
  59391. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  59392. /***/ }),
  59393. /***/ "./Materials/Textures/rawCubeTexture.ts":
  59394. /*!**********************************************!*\
  59395. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  59396. \**********************************************/
  59397. /*! exports provided: RawCubeTexture */
  59398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59399. "use strict";
  59400. __webpack_require__.r(__webpack_exports__);
  59401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  59402. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59403. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  59404. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  59405. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  59406. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  59407. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59408. /**
  59409. * Raw cube texture where the raw buffers are passed in
  59410. */
  59411. var RawCubeTexture = /** @class */ (function (_super) {
  59412. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  59413. /**
  59414. * Creates a cube texture where the raw buffers are passed in.
  59415. * @param scene defines the scene the texture is attached to
  59416. * @param data defines the array of data to use to create each face
  59417. * @param size defines the size of the textures
  59418. * @param format defines the format of the data
  59419. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59420. * @param generateMipMaps defines if the engine should generate the mip levels
  59421. * @param invertY defines if data must be stored with Y axis inverted
  59422. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59423. * @param compression defines the compression used (null by default)
  59424. */
  59425. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  59426. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  59427. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59428. if (generateMipMaps === void 0) { generateMipMaps = false; }
  59429. if (invertY === void 0) { invertY = false; }
  59430. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59431. if (compression === void 0) { compression = null; }
  59432. var _this = _super.call(this, "", scene) || this;
  59433. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  59434. return _this;
  59435. }
  59436. /**
  59437. * Updates the raw cube texture.
  59438. * @param data defines the data to store
  59439. * @param format defines the data format
  59440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59441. * @param invertY defines if data must be stored with Y axis inverted
  59442. * @param compression defines the compression used (null by default)
  59443. * @param level defines which level of the texture to update
  59444. */
  59445. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  59446. if (compression === void 0) { compression = null; }
  59447. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  59448. };
  59449. /**
  59450. * Updates a raw cube texture with RGBD encoded data.
  59451. * @param data defines the array of data [mipmap][face] to use to create each face
  59452. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59453. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59454. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59455. * @returns a promsie that resolves when the operation is complete
  59456. */
  59457. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  59458. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  59459. if (lodScale === void 0) { lodScale = 0.8; }
  59460. if (lodOffset === void 0) { lodOffset = 0; }
  59461. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  59462. };
  59463. /**
  59464. * Clones the raw cube texture.
  59465. * @return a new cube texture
  59466. */
  59467. RawCubeTexture.prototype.clone = function () {
  59468. var _this = this;
  59469. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  59470. var scene = _this.getScene();
  59471. var internalTexture = _this._texture;
  59472. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  59473. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  59474. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  59475. }
  59476. return texture;
  59477. }, this);
  59478. };
  59479. /** @hidden */
  59480. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  59481. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  59482. internalTexture._bufferViewArrayArray = data;
  59483. internalTexture._lodGenerationScale = lodScale;
  59484. internalTexture._lodGenerationOffset = lodOffset;
  59485. internalTexture._sphericalPolynomial = sphericalPolynomial;
  59486. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  59487. internalTexture.isReady = true;
  59488. });
  59489. };
  59490. return RawCubeTexture;
  59491. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  59492. /***/ }),
  59493. /***/ "./Materials/Textures/rawTexture.ts":
  59494. /*!******************************************!*\
  59495. !*** ./Materials/Textures/rawTexture.ts ***!
  59496. \******************************************/
  59497. /*! exports provided: RawTexture */
  59498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59499. "use strict";
  59500. __webpack_require__.r(__webpack_exports__);
  59501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  59502. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59503. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59504. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59505. /**
  59506. * Raw texture can help creating a texture directly from an array of data.
  59507. * This can be super useful if you either get the data from an uncompressed source or
  59508. * if you wish to create your texture pixel by pixel.
  59509. */
  59510. var RawTexture = /** @class */ (function (_super) {
  59511. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  59512. /**
  59513. * Instantiates a new RawTexture.
  59514. * Raw texture can help creating a texture directly from an array of data.
  59515. * This can be super useful if you either get the data from an uncompressed source or
  59516. * if you wish to create your texture pixel by pixel.
  59517. * @param data define the array of data to use to create the texture
  59518. * @param width define the width of the texture
  59519. * @param height define the height of the texture
  59520. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  59521. * @param scene define the scene the texture belongs to
  59522. * @param generateMipMaps define whether mip maps should be generated or not
  59523. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59524. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59525. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59526. */
  59527. function RawTexture(data, width, height,
  59528. /**
  59529. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  59530. */
  59531. format, scene, generateMipMaps, invertY, samplingMode, type) {
  59532. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59533. if (invertY === void 0) { invertY = false; }
  59534. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59535. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59536. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59537. _this.format = format;
  59538. _this._engine = scene.getEngine();
  59539. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  59540. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  59541. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  59542. return _this;
  59543. }
  59544. /**
  59545. * Updates the texture underlying data.
  59546. * @param data Define the new data of the texture
  59547. */
  59548. RawTexture.prototype.update = function (data) {
  59549. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  59550. };
  59551. /**
  59552. * Creates a luminance texture from some data.
  59553. * @param data Define the texture data
  59554. * @param width Define the width of the texture
  59555. * @param height Define the height of the texture
  59556. * @param scene Define the scene the texture belongs to
  59557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59560. * @returns the luminance texture
  59561. */
  59562. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59563. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59564. if (invertY === void 0) { invertY = false; }
  59565. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59566. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  59567. };
  59568. /**
  59569. * Creates a luminance alpha texture from some data.
  59570. * @param data Define the texture data
  59571. * @param width Define the width of the texture
  59572. * @param height Define the height of the texture
  59573. * @param scene Define the scene the texture belongs to
  59574. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59575. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59576. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59577. * @returns the luminance alpha texture
  59578. */
  59579. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59580. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59581. if (invertY === void 0) { invertY = false; }
  59582. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59583. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  59584. };
  59585. /**
  59586. * Creates an alpha texture from some data.
  59587. * @param data Define the texture data
  59588. * @param width Define the width of the texture
  59589. * @param height Define the height of the texture
  59590. * @param scene Define the scene the texture belongs to
  59591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59594. * @returns the alpha texture
  59595. */
  59596. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59597. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59598. if (invertY === void 0) { invertY = false; }
  59599. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59600. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  59601. };
  59602. /**
  59603. * Creates a RGB texture from some data.
  59604. * @param data Define the texture data
  59605. * @param width Define the width of the texture
  59606. * @param height Define the height of the texture
  59607. * @param scene Define the scene the texture belongs to
  59608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59611. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59612. * @returns the RGB alpha texture
  59613. */
  59614. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59615. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59616. if (invertY === void 0) { invertY = false; }
  59617. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59618. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59619. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  59620. };
  59621. /**
  59622. * Creates a RGBA texture from some data.
  59623. * @param data Define the texture data
  59624. * @param width Define the width of the texture
  59625. * @param height Define the height of the texture
  59626. * @param scene Define the scene the texture belongs to
  59627. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59630. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59631. * @returns the RGBA texture
  59632. */
  59633. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59634. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59635. if (invertY === void 0) { invertY = false; }
  59636. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59637. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59638. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  59639. };
  59640. /**
  59641. * Creates a R texture from some data.
  59642. * @param data Define the texture data
  59643. * @param width Define the width of the texture
  59644. * @param height Define the height of the texture
  59645. * @param scene Define the scene the texture belongs to
  59646. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59647. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59648. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59649. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59650. * @returns the R texture
  59651. */
  59652. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59653. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59654. if (invertY === void 0) { invertY = false; }
  59655. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59656. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  59657. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  59658. };
  59659. return RawTexture;
  59660. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  59661. /***/ }),
  59662. /***/ "./Materials/Textures/rawTexture3D.ts":
  59663. /*!********************************************!*\
  59664. !*** ./Materials/Textures/rawTexture3D.ts ***!
  59665. \********************************************/
  59666. /*! exports provided: RawTexture3D */
  59667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59668. "use strict";
  59669. __webpack_require__.r(__webpack_exports__);
  59670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  59671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59672. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59673. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59674. /**
  59675. * Class used to store 3D textures containing user data
  59676. */
  59677. var RawTexture3D = /** @class */ (function (_super) {
  59678. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  59679. /**
  59680. * Create a new RawTexture3D
  59681. * @param data defines the data of the texture
  59682. * @param width defines the width of the texture
  59683. * @param height defines the height of the texture
  59684. * @param depth defines the depth of the texture
  59685. * @param format defines the texture format to use
  59686. * @param scene defines the hosting scene
  59687. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59688. * @param invertY defines if texture must be stored with Y axis inverted
  59689. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59690. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59691. */
  59692. function RawTexture3D(data, width, height, depth,
  59693. /** Gets or sets the texture format to use */
  59694. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  59695. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59696. if (invertY === void 0) { invertY = false; }
  59697. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59698. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59699. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59700. _this.format = format;
  59701. _this._engine = scene.getEngine();
  59702. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  59703. _this.is3D = true;
  59704. return _this;
  59705. }
  59706. /**
  59707. * Update the texture with new data
  59708. * @param data defines the data to store in the texture
  59709. */
  59710. RawTexture3D.prototype.update = function (data) {
  59711. if (!this._texture) {
  59712. return;
  59713. }
  59714. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  59715. };
  59716. return RawTexture3D;
  59717. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  59718. /***/ }),
  59719. /***/ "./Materials/Textures/refractionTexture.ts":
  59720. /*!*************************************************!*\
  59721. !*** ./Materials/Textures/refractionTexture.ts ***!
  59722. \*************************************************/
  59723. /*! exports provided: RefractionTexture */
  59724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59725. "use strict";
  59726. __webpack_require__.r(__webpack_exports__);
  59727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  59728. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59729. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59730. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59731. /**
  59732. * Creates a refraction texture used by refraction channel of the standard material.
  59733. * It is like a mirror but to see through a material.
  59734. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59735. */
  59736. var RefractionTexture = /** @class */ (function (_super) {
  59737. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  59738. /**
  59739. * Creates a refraction texture used by refraction channel of the standard material.
  59740. * It is like a mirror but to see through a material.
  59741. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59742. * @param name Define the texture name
  59743. * @param size Define the size of the underlying texture
  59744. * @param scene Define the scene the refraction belongs to
  59745. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59746. */
  59747. function RefractionTexture(name, size, scene, generateMipMaps) {
  59748. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  59749. /**
  59750. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59751. * 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.
  59752. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59753. */
  59754. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  59755. /**
  59756. * Define how deep under the surface we should see.
  59757. */
  59758. _this.depth = 2.0;
  59759. _this.onBeforeRenderObservable.add(function () {
  59760. scene.clipPlane = _this.refractionPlane;
  59761. });
  59762. _this.onAfterRenderObservable.add(function () {
  59763. delete scene.clipPlane;
  59764. });
  59765. return _this;
  59766. }
  59767. /**
  59768. * Clone the refraction texture.
  59769. * @returns the cloned texture
  59770. */
  59771. RefractionTexture.prototype.clone = function () {
  59772. var scene = this.getScene();
  59773. if (!scene) {
  59774. return this;
  59775. }
  59776. var textureSize = this.getSize();
  59777. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  59778. // Base texture
  59779. newTexture.hasAlpha = this.hasAlpha;
  59780. newTexture.level = this.level;
  59781. // Refraction Texture
  59782. newTexture.refractionPlane = this.refractionPlane.clone();
  59783. if (this.renderList) {
  59784. newTexture.renderList = this.renderList.slice(0);
  59785. }
  59786. newTexture.depth = this.depth;
  59787. return newTexture;
  59788. };
  59789. /**
  59790. * Serialize the texture to a JSON representation you could use in Parse later on
  59791. * @returns the serialized JSON representation
  59792. */
  59793. RefractionTexture.prototype.serialize = function () {
  59794. if (!this.name) {
  59795. return null;
  59796. }
  59797. var serializationObject = _super.prototype.serialize.call(this);
  59798. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  59799. serializationObject.depth = this.depth;
  59800. return serializationObject;
  59801. };
  59802. return RefractionTexture;
  59803. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  59804. /***/ }),
  59805. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  59806. /*!***********************************************************!*\
  59807. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  59808. \***********************************************************/
  59809. /*! exports provided: RenderTargetCreationOptions */
  59810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59811. "use strict";
  59812. __webpack_require__.r(__webpack_exports__);
  59813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  59814. /**
  59815. * Define options used to create a render target texture
  59816. */
  59817. var RenderTargetCreationOptions = /** @class */ (function () {
  59818. function RenderTargetCreationOptions() {
  59819. }
  59820. return RenderTargetCreationOptions;
  59821. }());
  59822. /***/ }),
  59823. /***/ "./Materials/Textures/renderTargetTexture.ts":
  59824. /*!***************************************************!*\
  59825. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  59826. \***************************************************/
  59827. /*! exports provided: RenderTargetTexture, MultiviewRenderTarget */
  59828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59829. "use strict";
  59830. __webpack_require__.r(__webpack_exports__);
  59831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  59832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return MultiviewRenderTarget; });
  59833. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59834. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59835. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59836. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59837. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  59838. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59839. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  59840. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  59841. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59842. /**
  59843. * This Helps creating a texture that will be created from a camera in your scene.
  59844. * It is basically a dynamic texture that could be used to create special effects for instance.
  59845. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  59846. */
  59847. var RenderTargetTexture = /** @class */ (function (_super) {
  59848. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  59849. /**
  59850. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  59851. * or used a shadow, depth texture...
  59852. * @param name The friendly name of the texture
  59853. * @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)
  59854. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  59855. * @param generateMipMaps True if mip maps need to be generated after render.
  59856. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  59857. * @param type The type of the buffer in the RTT (int, half float, float...)
  59858. * @param isCube True if a cube texture needs to be created
  59859. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  59860. * @param generateDepthBuffer True to generate a depth buffer
  59861. * @param generateStencilBuffer True to generate a stencil buffer
  59862. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  59863. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  59864. * @param delayAllocation if the texture allocation should be delayed (default: false)
  59865. */
  59866. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  59867. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  59868. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59869. if (isCube === void 0) { isCube = false; }
  59870. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59871. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  59872. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  59873. if (isMulti === void 0) { isMulti = false; }
  59874. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].TEXTUREFORMAT_RGBA; }
  59875. if (delayAllocation === void 0) { delayAllocation = false; }
  59876. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  59877. _this.isCube = isCube;
  59878. /**
  59879. * Define if particles should be rendered in your texture.
  59880. */
  59881. _this.renderParticles = true;
  59882. /**
  59883. * Define if sprites should be rendered in your texture.
  59884. */
  59885. _this.renderSprites = false;
  59886. /**
  59887. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  59888. */
  59889. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].PROJECTION_MODE;
  59890. /**
  59891. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  59892. */
  59893. _this.ignoreCameraViewport = false;
  59894. /**
  59895. * An event triggered when the texture is unbind.
  59896. */
  59897. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59898. /**
  59899. * An event triggered when the texture is unbind.
  59900. */
  59901. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59902. /**
  59903. * An event triggered before rendering the texture
  59904. */
  59905. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59906. /**
  59907. * An event triggered after rendering the texture
  59908. */
  59909. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59910. /**
  59911. * An event triggered after the texture clear
  59912. */
  59913. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59914. _this._currentRefreshId = -1;
  59915. _this._refreshRate = 1;
  59916. _this._samples = 1;
  59917. /**
  59918. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  59919. * It must define where the camera used to render the texture is set
  59920. */
  59921. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  59922. scene = _this.getScene();
  59923. if (!scene) {
  59924. return _this;
  59925. }
  59926. _this.renderList = new Array();
  59927. _this._engine = scene.getEngine();
  59928. _this.name = name;
  59929. _this.isRenderTarget = true;
  59930. _this._initialSizeParameter = size;
  59931. _this._processSizeParameter(size);
  59932. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  59933. });
  59934. _this._generateMipMaps = generateMipMaps ? true : false;
  59935. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  59936. // Rendering groups
  59937. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_7__["RenderingManager"](scene);
  59938. _this._renderingManager._useSceneAutoClearSetup = true;
  59939. if (isMulti) {
  59940. return _this;
  59941. }
  59942. _this._renderTargetOptions = {
  59943. generateMipMaps: generateMipMaps,
  59944. type: type,
  59945. format: format,
  59946. samplingMode: samplingMode,
  59947. generateDepthBuffer: generateDepthBuffer,
  59948. generateStencilBuffer: generateStencilBuffer
  59949. };
  59950. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].NEAREST_SAMPLINGMODE) {
  59951. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  59952. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  59953. }
  59954. if (!delayAllocation) {
  59955. if (isCube) {
  59956. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  59957. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].INVCUBIC_MODE;
  59958. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  59959. }
  59960. else {
  59961. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  59962. }
  59963. }
  59964. return _this;
  59965. }
  59966. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  59967. /**
  59968. * Use this list to define the list of mesh you want to render.
  59969. */
  59970. get: function () {
  59971. return this._renderList;
  59972. },
  59973. set: function (value) {
  59974. this._renderList = value;
  59975. if (this._renderList) {
  59976. this._hookArray(this._renderList);
  59977. }
  59978. },
  59979. enumerable: true,
  59980. configurable: true
  59981. });
  59982. RenderTargetTexture.prototype._hookArray = function (array) {
  59983. var _this = this;
  59984. var oldPush = array.push;
  59985. array.push = function () {
  59986. var items = [];
  59987. for (var _i = 0; _i < arguments.length; _i++) {
  59988. items[_i] = arguments[_i];
  59989. }
  59990. var wasEmpty = array.length === 0;
  59991. var result = oldPush.apply(array, items);
  59992. if (wasEmpty) {
  59993. _this.getScene().meshes.forEach(function (mesh) {
  59994. mesh._markSubMeshesAsLightDirty();
  59995. });
  59996. }
  59997. return result;
  59998. };
  59999. var oldSplice = array.splice;
  60000. array.splice = function (index, deleteCount) {
  60001. var deleted = oldSplice.apply(array, [index, deleteCount]);
  60002. if (array.length === 0) {
  60003. _this.getScene().meshes.forEach(function (mesh) {
  60004. mesh._markSubMeshesAsLightDirty();
  60005. });
  60006. }
  60007. return deleted;
  60008. };
  60009. };
  60010. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  60011. /**
  60012. * Set a after unbind callback in the texture.
  60013. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  60014. */
  60015. set: function (callback) {
  60016. if (this._onAfterUnbindObserver) {
  60017. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  60018. }
  60019. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  60020. },
  60021. enumerable: true,
  60022. configurable: true
  60023. });
  60024. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  60025. /**
  60026. * Set a before render callback in the texture.
  60027. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  60028. */
  60029. set: function (callback) {
  60030. if (this._onBeforeRenderObserver) {
  60031. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  60032. }
  60033. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  60034. },
  60035. enumerable: true,
  60036. configurable: true
  60037. });
  60038. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  60039. /**
  60040. * Set a after render callback in the texture.
  60041. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  60042. */
  60043. set: function (callback) {
  60044. if (this._onAfterRenderObserver) {
  60045. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  60046. }
  60047. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  60048. },
  60049. enumerable: true,
  60050. configurable: true
  60051. });
  60052. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  60053. /**
  60054. * Set a clear callback in the texture.
  60055. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  60056. */
  60057. set: function (callback) {
  60058. if (this._onClearObserver) {
  60059. this.onClearObservable.remove(this._onClearObserver);
  60060. }
  60061. this._onClearObserver = this.onClearObservable.add(callback);
  60062. },
  60063. enumerable: true,
  60064. configurable: true
  60065. });
  60066. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  60067. /**
  60068. * Gets render target creation options that were used.
  60069. */
  60070. get: function () {
  60071. return this._renderTargetOptions;
  60072. },
  60073. enumerable: true,
  60074. configurable: true
  60075. });
  60076. RenderTargetTexture.prototype._onRatioRescale = function () {
  60077. if (this._sizeRatio) {
  60078. this.resize(this._initialSizeParameter);
  60079. }
  60080. };
  60081. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  60082. get: function () {
  60083. return this._boundingBoxSize;
  60084. },
  60085. /**
  60086. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  60087. * When defined, the cubemap will switch to local mode
  60088. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60089. * @example https://www.babylonjs-playground.com/#RNASML
  60090. */
  60091. set: function (value) {
  60092. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  60093. return;
  60094. }
  60095. this._boundingBoxSize = value;
  60096. var scene = this.getScene();
  60097. if (scene) {
  60098. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag);
  60099. }
  60100. },
  60101. enumerable: true,
  60102. configurable: true
  60103. });
  60104. /**
  60105. * Creates a depth stencil texture.
  60106. * This is only available in WebGL 2 or with the depth texture extension available.
  60107. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  60108. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  60109. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  60110. */
  60111. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  60112. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  60113. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  60114. if (generateStencil === void 0) { generateStencil = false; }
  60115. if (!this.getScene()) {
  60116. return;
  60117. }
  60118. var engine = this.getScene().getEngine();
  60119. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  60120. bilinearFiltering: bilinearFiltering,
  60121. comparisonFunction: comparisonFunction,
  60122. generateStencil: generateStencil,
  60123. isCube: this.isCube
  60124. });
  60125. engine.setFrameBufferDepthStencilTexture(this);
  60126. };
  60127. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  60128. if (size.ratio) {
  60129. this._sizeRatio = size.ratio;
  60130. this._size = {
  60131. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  60132. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  60133. };
  60134. }
  60135. else {
  60136. this._size = size;
  60137. }
  60138. };
  60139. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  60140. /**
  60141. * Define the number of samples to use in case of MSAA.
  60142. * It defaults to one meaning no MSAA has been enabled.
  60143. */
  60144. get: function () {
  60145. return this._samples;
  60146. },
  60147. set: function (value) {
  60148. if (this._samples === value) {
  60149. return;
  60150. }
  60151. var scene = this.getScene();
  60152. if (!scene) {
  60153. return;
  60154. }
  60155. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  60156. },
  60157. enumerable: true,
  60158. configurable: true
  60159. });
  60160. /**
  60161. * Resets the refresh counter of the texture and start bak from scratch.
  60162. * Could be useful to regenerate the texture if it is setup to render only once.
  60163. */
  60164. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  60165. this._currentRefreshId = -1;
  60166. };
  60167. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  60168. /**
  60169. * Define the refresh rate of the texture or the rendering frequency.
  60170. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  60171. */
  60172. get: function () {
  60173. return this._refreshRate;
  60174. },
  60175. set: function (value) {
  60176. this._refreshRate = value;
  60177. this.resetRefreshCounter();
  60178. },
  60179. enumerable: true,
  60180. configurable: true
  60181. });
  60182. /**
  60183. * Adds a post process to the render target rendering passes.
  60184. * @param postProcess define the post process to add
  60185. */
  60186. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  60187. if (!this._postProcessManager) {
  60188. var scene = this.getScene();
  60189. if (!scene) {
  60190. return;
  60191. }
  60192. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_6__["PostProcessManager"](scene);
  60193. this._postProcesses = new Array();
  60194. }
  60195. this._postProcesses.push(postProcess);
  60196. this._postProcesses[0].autoClear = false;
  60197. };
  60198. /**
  60199. * Clear all the post processes attached to the render target
  60200. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  60201. */
  60202. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  60203. if (dispose === void 0) { dispose = false; }
  60204. if (!this._postProcesses) {
  60205. return;
  60206. }
  60207. if (dispose) {
  60208. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  60209. var postProcess = _a[_i];
  60210. postProcess.dispose();
  60211. }
  60212. }
  60213. this._postProcesses = [];
  60214. };
  60215. /**
  60216. * Remove one of the post process from the list of attached post processes to the texture
  60217. * @param postProcess define the post process to remove from the list
  60218. */
  60219. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  60220. if (!this._postProcesses) {
  60221. return;
  60222. }
  60223. var index = this._postProcesses.indexOf(postProcess);
  60224. if (index === -1) {
  60225. return;
  60226. }
  60227. this._postProcesses.splice(index, 1);
  60228. if (this._postProcesses.length > 0) {
  60229. this._postProcesses[0].autoClear = false;
  60230. }
  60231. };
  60232. /** @hidden */
  60233. RenderTargetTexture.prototype._shouldRender = function () {
  60234. if (this._currentRefreshId === -1) { // At least render once
  60235. this._currentRefreshId = 1;
  60236. return true;
  60237. }
  60238. if (this.refreshRate === this._currentRefreshId) {
  60239. this._currentRefreshId = 1;
  60240. return true;
  60241. }
  60242. this._currentRefreshId++;
  60243. return false;
  60244. };
  60245. /**
  60246. * Gets the actual render size of the texture.
  60247. * @returns the width of the render size
  60248. */
  60249. RenderTargetTexture.prototype.getRenderSize = function () {
  60250. return this.getRenderWidth();
  60251. };
  60252. /**
  60253. * Gets the actual render width of the texture.
  60254. * @returns the width of the render size
  60255. */
  60256. RenderTargetTexture.prototype.getRenderWidth = function () {
  60257. if (this._size.width) {
  60258. return this._size.width;
  60259. }
  60260. return this._size;
  60261. };
  60262. /**
  60263. * Gets the actual render height of the texture.
  60264. * @returns the height of the render size
  60265. */
  60266. RenderTargetTexture.prototype.getRenderHeight = function () {
  60267. if (this._size.width) {
  60268. return this._size.height;
  60269. }
  60270. return this._size;
  60271. };
  60272. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  60273. /**
  60274. * Get if the texture can be rescaled or not.
  60275. */
  60276. get: function () {
  60277. return true;
  60278. },
  60279. enumerable: true,
  60280. configurable: true
  60281. });
  60282. /**
  60283. * Resize the texture using a ratio.
  60284. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  60285. */
  60286. RenderTargetTexture.prototype.scale = function (ratio) {
  60287. var newSize = this.getRenderSize() * ratio;
  60288. this.resize(newSize);
  60289. };
  60290. /**
  60291. * Get the texture reflection matrix used to rotate/transform the reflection.
  60292. * @returns the reflection matrix
  60293. */
  60294. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  60295. if (this.isCube) {
  60296. return this._textureMatrix;
  60297. }
  60298. return _super.prototype.getReflectionTextureMatrix.call(this);
  60299. };
  60300. /**
  60301. * Resize the texture to a new desired size.
  60302. * Be carrefull as it will recreate all the data in the new texture.
  60303. * @param size Define the new size. It can be:
  60304. * - a number for squared texture,
  60305. * - an object containing { width: number, height: number }
  60306. * - or an object containing a ratio { ratio: number }
  60307. */
  60308. RenderTargetTexture.prototype.resize = function (size) {
  60309. this.releaseInternalTexture();
  60310. var scene = this.getScene();
  60311. if (!scene) {
  60312. return;
  60313. }
  60314. this._processSizeParameter(size);
  60315. if (this.isCube) {
  60316. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  60317. }
  60318. else {
  60319. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  60320. }
  60321. };
  60322. /**
  60323. * Renders all the objects from the render list into the texture.
  60324. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  60325. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  60326. */
  60327. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  60328. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  60329. if (dumpForDebug === void 0) { dumpForDebug = false; }
  60330. var scene = this.getScene();
  60331. if (!scene) {
  60332. return;
  60333. }
  60334. var engine = scene.getEngine();
  60335. if (this.useCameraPostProcesses !== undefined) {
  60336. useCameraPostProcess = this.useCameraPostProcesses;
  60337. }
  60338. if (this._waitingRenderList) {
  60339. this.renderList = [];
  60340. for (var index = 0; index < this._waitingRenderList.length; index++) {
  60341. var id = this._waitingRenderList[index];
  60342. var mesh_1 = scene.getMeshByID(id);
  60343. if (mesh_1) {
  60344. this.renderList.push(mesh_1);
  60345. }
  60346. }
  60347. delete this._waitingRenderList;
  60348. }
  60349. // Is predicate defined?
  60350. if (this.renderListPredicate) {
  60351. if (this.renderList) {
  60352. this.renderList.length = 0; // Clear previous renderList
  60353. }
  60354. else {
  60355. this.renderList = [];
  60356. }
  60357. var scene = this.getScene();
  60358. if (!scene) {
  60359. return;
  60360. }
  60361. var sceneMeshes = scene.meshes;
  60362. for (var index = 0; index < sceneMeshes.length; index++) {
  60363. var mesh = sceneMeshes[index];
  60364. if (this.renderListPredicate(mesh)) {
  60365. this.renderList.push(mesh);
  60366. }
  60367. }
  60368. }
  60369. this.onBeforeBindObservable.notifyObservers(this);
  60370. // Set custom projection.
  60371. // Needs to be before binding to prevent changing the aspect ratio.
  60372. var camera;
  60373. if (this.activeCamera) {
  60374. camera = this.activeCamera;
  60375. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  60376. if (this.activeCamera !== scene.activeCamera) {
  60377. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  60378. }
  60379. }
  60380. else {
  60381. camera = scene.activeCamera;
  60382. if (camera) {
  60383. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  60384. }
  60385. }
  60386. // Prepare renderingManager
  60387. this._renderingManager.reset();
  60388. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  60389. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  60390. var sceneRenderId = scene.getRenderId();
  60391. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  60392. var mesh = currentRenderList[meshIndex];
  60393. if (mesh) {
  60394. if (!mesh.isReady(this.refreshRate === 0)) {
  60395. this.resetRefreshCounter();
  60396. continue;
  60397. }
  60398. mesh._preActivateForIntermediateRendering(sceneRenderId);
  60399. var isMasked = void 0;
  60400. if (!this.renderList && camera) {
  60401. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  60402. }
  60403. else {
  60404. isMasked = false;
  60405. }
  60406. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  60407. mesh._activate(sceneRenderId);
  60408. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  60409. var subMesh = mesh.subMeshes[subIndex];
  60410. scene._activeIndices.addCount(subMesh.indexCount, false);
  60411. this._renderingManager.dispatch(subMesh, mesh);
  60412. }
  60413. }
  60414. }
  60415. }
  60416. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  60417. var particleSystem = scene.particleSystems[particleIndex];
  60418. var emitter = particleSystem.emitter;
  60419. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  60420. continue;
  60421. }
  60422. if (currentRenderList.indexOf(emitter) >= 0) {
  60423. this._renderingManager.dispatchParticles(particleSystem);
  60424. }
  60425. }
  60426. if (this.isCube) {
  60427. for (var face = 0; face < 6; face++) {
  60428. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  60429. scene.incrementRenderId();
  60430. scene.resetCachedMaterial();
  60431. }
  60432. }
  60433. else {
  60434. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  60435. }
  60436. this.onAfterUnbindObservable.notifyObservers(this);
  60437. if (scene.activeCamera) {
  60438. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  60439. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  60440. }
  60441. engine.setViewport(scene.activeCamera.viewport);
  60442. }
  60443. scene.resetCachedMaterial();
  60444. };
  60445. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  60446. var minimum = 128;
  60447. var x = renderDimension * scale;
  60448. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  60449. // Ensure we don't exceed the render dimension (while staying POT)
  60450. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  60451. };
  60452. /**
  60453. * @hidden
  60454. * @param faceIndex face index to bind to if this is a cubetexture
  60455. */
  60456. RenderTargetTexture.prototype._bindFrameBuffer = function (faceIndex) {
  60457. if (faceIndex === void 0) { faceIndex = 0; }
  60458. var scene = this.getScene();
  60459. if (!scene) {
  60460. return;
  60461. }
  60462. var engine = scene.getEngine();
  60463. if (this._texture) {
  60464. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  60465. }
  60466. };
  60467. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  60468. var _this = this;
  60469. if (!this._texture) {
  60470. return;
  60471. }
  60472. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  60473. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  60474. });
  60475. };
  60476. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  60477. var scene = this.getScene();
  60478. if (!scene) {
  60479. return;
  60480. }
  60481. var engine = scene.getEngine();
  60482. if (!this._texture) {
  60483. return;
  60484. }
  60485. // Bind
  60486. if (this._postProcessManager) {
  60487. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  60488. }
  60489. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  60490. this._bindFrameBuffer(faceIndex);
  60491. }
  60492. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  60493. // Clear
  60494. if (this.onClearObservable.hasObservers()) {
  60495. this.onClearObservable.notifyObservers(engine);
  60496. }
  60497. else {
  60498. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  60499. }
  60500. if (!this._doNotChangeAspectRatio) {
  60501. scene.updateTransformMatrix(true);
  60502. }
  60503. // Before Camera Draw
  60504. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  60505. var step = _a[_i];
  60506. step.action(this);
  60507. }
  60508. // Render
  60509. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  60510. // After Camera Draw
  60511. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  60512. var step = _c[_b];
  60513. step.action(this);
  60514. }
  60515. if (this._postProcessManager) {
  60516. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  60517. }
  60518. else if (useCameraPostProcess) {
  60519. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  60520. }
  60521. if (!this._doNotChangeAspectRatio) {
  60522. scene.updateTransformMatrix(true);
  60523. }
  60524. // Dump ?
  60525. if (dumpForDebug) {
  60526. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  60527. }
  60528. // Unbind
  60529. if (!this.isCube || faceIndex === 5) {
  60530. if (this.isCube) {
  60531. if (faceIndex === 5) {
  60532. engine.generateMipMapsForCubemap(this._texture);
  60533. }
  60534. }
  60535. this.unbindFrameBuffer(engine, faceIndex);
  60536. }
  60537. else {
  60538. this.onAfterRenderObservable.notifyObservers(faceIndex);
  60539. }
  60540. };
  60541. /**
  60542. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  60543. * This allowed control for front to back rendering or reversly depending of the special needs.
  60544. *
  60545. * @param renderingGroupId The rendering group id corresponding to its index
  60546. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  60547. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  60548. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  60549. */
  60550. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  60551. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  60552. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  60553. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  60554. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  60555. };
  60556. /**
  60557. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  60558. *
  60559. * @param renderingGroupId The rendering group id corresponding to its index
  60560. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60561. */
  60562. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  60563. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  60564. this._renderingManager._useSceneAutoClearSetup = false;
  60565. };
  60566. /**
  60567. * Clones the texture.
  60568. * @returns the cloned texture
  60569. */
  60570. RenderTargetTexture.prototype.clone = function () {
  60571. var textureSize = this.getSize();
  60572. 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);
  60573. // Base texture
  60574. newTexture.hasAlpha = this.hasAlpha;
  60575. newTexture.level = this.level;
  60576. // RenderTarget Texture
  60577. newTexture.coordinatesMode = this.coordinatesMode;
  60578. if (this.renderList) {
  60579. newTexture.renderList = this.renderList.slice(0);
  60580. }
  60581. return newTexture;
  60582. };
  60583. /**
  60584. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  60585. * @returns The JSON representation of the texture
  60586. */
  60587. RenderTargetTexture.prototype.serialize = function () {
  60588. if (!this.name) {
  60589. return null;
  60590. }
  60591. var serializationObject = _super.prototype.serialize.call(this);
  60592. serializationObject.renderTargetSize = this.getRenderSize();
  60593. serializationObject.renderList = [];
  60594. if (this.renderList) {
  60595. for (var index = 0; index < this.renderList.length; index++) {
  60596. serializationObject.renderList.push(this.renderList[index].id);
  60597. }
  60598. }
  60599. return serializationObject;
  60600. };
  60601. /**
  60602. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  60603. */
  60604. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  60605. var objBuffer = this.getInternalTexture();
  60606. var scene = this.getScene();
  60607. if (objBuffer && scene) {
  60608. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  60609. }
  60610. };
  60611. /**
  60612. * Dispose the texture and release its associated resources.
  60613. */
  60614. RenderTargetTexture.prototype.dispose = function () {
  60615. if (this._postProcessManager) {
  60616. this._postProcessManager.dispose();
  60617. this._postProcessManager = null;
  60618. }
  60619. this.clearPostProcesses(true);
  60620. if (this._resizeObserver) {
  60621. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  60622. this._resizeObserver = null;
  60623. }
  60624. this.renderList = null;
  60625. // Remove from custom render targets
  60626. var scene = this.getScene();
  60627. if (!scene) {
  60628. return;
  60629. }
  60630. var index = scene.customRenderTargets.indexOf(this);
  60631. if (index >= 0) {
  60632. scene.customRenderTargets.splice(index, 1);
  60633. }
  60634. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  60635. var camera = _a[_i];
  60636. index = camera.customRenderTargets.indexOf(this);
  60637. if (index >= 0) {
  60638. camera.customRenderTargets.splice(index, 1);
  60639. }
  60640. }
  60641. _super.prototype.dispose.call(this);
  60642. };
  60643. /** @hidden */
  60644. RenderTargetTexture.prototype._rebuild = function () {
  60645. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  60646. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  60647. }
  60648. if (this._postProcessManager) {
  60649. this._postProcessManager._rebuild();
  60650. }
  60651. };
  60652. /**
  60653. * Clear the info related to rendering groups preventing retention point in material dispose.
  60654. */
  60655. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  60656. if (this._renderingManager) {
  60657. this._renderingManager.freeRenderingGroups();
  60658. }
  60659. };
  60660. /**
  60661. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  60662. * @returns the view count
  60663. */
  60664. RenderTargetTexture.prototype.getViewCount = function () {
  60665. return 1;
  60666. };
  60667. /**
  60668. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  60669. */
  60670. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  60671. /**
  60672. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  60673. */
  60674. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  60675. /**
  60676. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  60677. * the central point of your effect and can save a lot of performances.
  60678. */
  60679. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  60680. return RenderTargetTexture;
  60681. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]));
  60682. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  60683. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  60684. };
  60685. /**
  60686. * Renders to multiple views with a single draw call
  60687. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  60688. */
  60689. var MultiviewRenderTarget = /** @class */ (function (_super) {
  60690. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiviewRenderTarget, _super);
  60691. /**
  60692. * Creates a multiview render target
  60693. * @param scene scene used with the render target
  60694. * @param size the size of the render target (used for each view)
  60695. */
  60696. function MultiviewRenderTarget(scene, size) {
  60697. if (size === void 0) { size = 512; }
  60698. var _this = _super.call(this, "multiview rtt", size, scene, false, true, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_UNKNOWN, false, undefined, false, false, true, undefined, true) || this;
  60699. var internalTexture = scene.getEngine().createMultiviewRenderTargetTexture(_this.getRenderWidth(), _this.getRenderHeight());
  60700. internalTexture.isMultiview = true;
  60701. _this._texture = internalTexture;
  60702. return _this;
  60703. }
  60704. /**
  60705. * @hidden
  60706. * @param faceIndex the face index, if its a cube texture
  60707. */
  60708. MultiviewRenderTarget.prototype._bindFrameBuffer = function (faceIndex) {
  60709. if (faceIndex === void 0) { faceIndex = 0; }
  60710. if (!this._texture) {
  60711. return;
  60712. }
  60713. this.getScene().getEngine().bindMultiviewFramebuffer(this._texture);
  60714. };
  60715. /**
  60716. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  60717. * @returns the view count
  60718. */
  60719. MultiviewRenderTarget.prototype.getViewCount = function () {
  60720. return 2;
  60721. };
  60722. return MultiviewRenderTarget;
  60723. }(RenderTargetTexture));
  60724. /***/ }),
  60725. /***/ "./Materials/Textures/texture.ts":
  60726. /*!***************************************!*\
  60727. !*** ./Materials/Textures/texture.ts ***!
  60728. \***************************************/
  60729. /*! exports provided: Texture */
  60730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60731. "use strict";
  60732. __webpack_require__.r(__webpack_exports__);
  60733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  60734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60735. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  60736. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60737. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60738. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60739. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  60740. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60741. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  60742. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  60743. /**
  60744. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  60745. * @see http://doc.babylonjs.com/babylon101/materials#texture
  60746. */
  60747. var Texture = /** @class */ (function (_super) {
  60748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  60749. /**
  60750. * Instantiates a new texture.
  60751. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  60752. * @see http://doc.babylonjs.com/babylon101/materials#texture
  60753. * @param url define the url of the picture to load as a texture
  60754. * @param scene define the scene the texture will belong to
  60755. * @param noMipmap define if the texture will require mip maps or not
  60756. * @param invertY define if the texture needs to be inverted on the y axis during loading
  60757. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  60758. * @param onLoad define a callback triggered when the texture has been loaded
  60759. * @param onError define a callback triggered when an error occurred during the loading session
  60760. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  60761. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  60762. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  60763. */
  60764. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  60765. if (noMipmap === void 0) { noMipmap = false; }
  60766. if (invertY === void 0) { invertY = true; }
  60767. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  60768. if (onLoad === void 0) { onLoad = null; }
  60769. if (onError === void 0) { onError = null; }
  60770. if (buffer === void 0) { buffer = null; }
  60771. if (deleteBuffer === void 0) { deleteBuffer = false; }
  60772. var _this = _super.call(this, scene) || this;
  60773. /**
  60774. * Define an offset on the texture to offset the u coordinates of the UVs
  60775. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  60776. */
  60777. _this.uOffset = 0;
  60778. /**
  60779. * Define an offset on the texture to offset the v coordinates of the UVs
  60780. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  60781. */
  60782. _this.vOffset = 0;
  60783. /**
  60784. * Define an offset on the texture to scale the u coordinates of the UVs
  60785. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  60786. */
  60787. _this.uScale = 1.0;
  60788. /**
  60789. * Define an offset on the texture to scale the v coordinates of the UVs
  60790. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  60791. */
  60792. _this.vScale = 1.0;
  60793. /**
  60794. * Define an offset on the texture to rotate around the u coordinates of the UVs
  60795. * @see http://doc.babylonjs.com/how_to/more_materials
  60796. */
  60797. _this.uAng = 0;
  60798. /**
  60799. * Define an offset on the texture to rotate around the v coordinates of the UVs
  60800. * @see http://doc.babylonjs.com/how_to/more_materials
  60801. */
  60802. _this.vAng = 0;
  60803. /**
  60804. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  60805. * @see http://doc.babylonjs.com/how_to/more_materials
  60806. */
  60807. _this.wAng = 0;
  60808. /**
  60809. * Defines the center of rotation (U)
  60810. */
  60811. _this.uRotationCenter = 0.5;
  60812. /**
  60813. * Defines the center of rotation (V)
  60814. */
  60815. _this.vRotationCenter = 0.5;
  60816. /**
  60817. * Defines the center of rotation (W)
  60818. */
  60819. _this.wRotationCenter = 0.5;
  60820. /** @hidden */
  60821. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  60822. /**
  60823. * Observable triggered once the texture has been loaded.
  60824. */
  60825. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  60826. _this._isBlocking = true;
  60827. _this.name = url || "";
  60828. _this.url = url;
  60829. _this._noMipmap = noMipmap;
  60830. _this._invertY = invertY;
  60831. _this._initialSamplingMode = samplingMode;
  60832. _this._buffer = buffer;
  60833. _this._deleteBuffer = deleteBuffer;
  60834. if (format) {
  60835. _this._format = format;
  60836. }
  60837. scene = _this.getScene();
  60838. if (!scene) {
  60839. return _this;
  60840. }
  60841. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  60842. var load = function () {
  60843. if (_this._texture && _this._texture._invertVScale) {
  60844. _this.vScale = -1;
  60845. }
  60846. if (_this.onLoadObservable.hasObservers()) {
  60847. _this.onLoadObservable.notifyObservers(_this);
  60848. }
  60849. if (onLoad) {
  60850. onLoad();
  60851. }
  60852. if (!_this.isBlocking && scene) {
  60853. scene.resetCachedMaterial();
  60854. }
  60855. };
  60856. if (!_this.url) {
  60857. _this._delayedOnLoad = load;
  60858. _this._delayedOnError = onError;
  60859. return _this;
  60860. }
  60861. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  60862. if (!_this._texture) {
  60863. if (!scene.useDelayedTextureLoading) {
  60864. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  60865. if (deleteBuffer) {
  60866. delete _this._buffer;
  60867. }
  60868. }
  60869. else {
  60870. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  60871. _this._delayedOnLoad = load;
  60872. _this._delayedOnError = onError;
  60873. }
  60874. }
  60875. else {
  60876. if (_this._texture.isReady) {
  60877. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  60878. }
  60879. else {
  60880. _this._texture.onLoadedObservable.add(load);
  60881. }
  60882. }
  60883. return _this;
  60884. }
  60885. Object.defineProperty(Texture.prototype, "noMipmap", {
  60886. /**
  60887. * Are mip maps generated for this texture or not.
  60888. */
  60889. get: function () {
  60890. return this._noMipmap;
  60891. },
  60892. enumerable: true,
  60893. configurable: true
  60894. });
  60895. Object.defineProperty(Texture.prototype, "isBlocking", {
  60896. get: function () {
  60897. return this._isBlocking;
  60898. },
  60899. /**
  60900. * Is the texture preventing material to render while loading.
  60901. * If false, a default texture will be used instead of the loading one during the preparation step.
  60902. */
  60903. set: function (value) {
  60904. this._isBlocking = value;
  60905. },
  60906. enumerable: true,
  60907. configurable: true
  60908. });
  60909. Object.defineProperty(Texture.prototype, "samplingMode", {
  60910. /**
  60911. * Get the current sampling mode associated with the texture.
  60912. */
  60913. get: function () {
  60914. if (!this._texture) {
  60915. return this._initialSamplingMode;
  60916. }
  60917. return this._texture.samplingMode;
  60918. },
  60919. enumerable: true,
  60920. configurable: true
  60921. });
  60922. Object.defineProperty(Texture.prototype, "invertY", {
  60923. /**
  60924. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  60925. */
  60926. get: function () {
  60927. return this._invertY;
  60928. },
  60929. enumerable: true,
  60930. configurable: true
  60931. });
  60932. /**
  60933. * Update the url (and optional buffer) of this texture if url was null during construction.
  60934. * @param url the url of the texture
  60935. * @param buffer the buffer of the texture (defaults to null)
  60936. * @param onLoad callback called when the texture is loaded (defaults to null)
  60937. */
  60938. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  60939. if (buffer === void 0) { buffer = null; }
  60940. if (this.url) {
  60941. this.releaseInternalTexture();
  60942. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  60943. }
  60944. this.url = url;
  60945. this._buffer = buffer;
  60946. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  60947. if (onLoad) {
  60948. this._delayedOnLoad = onLoad;
  60949. }
  60950. this.delayLoad();
  60951. };
  60952. /**
  60953. * Finish the loading sequence of a texture flagged as delayed load.
  60954. * @hidden
  60955. */
  60956. Texture.prototype.delayLoad = function () {
  60957. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  60958. return;
  60959. }
  60960. var scene = this.getScene();
  60961. if (!scene) {
  60962. return;
  60963. }
  60964. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  60965. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  60966. if (!this._texture) {
  60967. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  60968. if (this._deleteBuffer) {
  60969. delete this._buffer;
  60970. }
  60971. }
  60972. else {
  60973. if (this._delayedOnLoad) {
  60974. if (this._texture.isReady) {
  60975. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  60976. }
  60977. else {
  60978. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  60979. }
  60980. }
  60981. }
  60982. this._delayedOnLoad = null;
  60983. this._delayedOnError = null;
  60984. };
  60985. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  60986. x *= this.uScale;
  60987. y *= this.vScale;
  60988. x -= this.uRotationCenter * this.uScale;
  60989. y -= this.vRotationCenter * this.vScale;
  60990. z -= this.wRotationCenter;
  60991. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  60992. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  60993. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  60994. t.z += this.wRotationCenter;
  60995. };
  60996. /**
  60997. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  60998. * @returns the transform matrix of the texture.
  60999. */
  61000. Texture.prototype.getTextureMatrix = function () {
  61001. var _this = this;
  61002. if (this.uOffset === this._cachedUOffset &&
  61003. this.vOffset === this._cachedVOffset &&
  61004. this.uScale === this._cachedUScale &&
  61005. this.vScale === this._cachedVScale &&
  61006. this.uAng === this._cachedUAng &&
  61007. this.vAng === this._cachedVAng &&
  61008. this.wAng === this._cachedWAng) {
  61009. return this._cachedTextureMatrix;
  61010. }
  61011. this._cachedUOffset = this.uOffset;
  61012. this._cachedVOffset = this.vOffset;
  61013. this._cachedUScale = this.uScale;
  61014. this._cachedVScale = this.vScale;
  61015. this._cachedUAng = this.uAng;
  61016. this._cachedVAng = this.vAng;
  61017. this._cachedWAng = this.wAng;
  61018. if (!this._cachedTextureMatrix) {
  61019. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61020. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  61021. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61022. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61023. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61024. }
  61025. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  61026. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  61027. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  61028. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  61029. this._t1.subtractInPlace(this._t0);
  61030. this._t2.subtractInPlace(this._t0);
  61031. _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);
  61032. var scene = this.getScene();
  61033. if (!scene) {
  61034. return this._cachedTextureMatrix;
  61035. }
  61036. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  61037. return mat.hasTexture(_this);
  61038. });
  61039. return this._cachedTextureMatrix;
  61040. };
  61041. /**
  61042. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  61043. * @returns The reflection texture transform
  61044. */
  61045. Texture.prototype.getReflectionTextureMatrix = function () {
  61046. var _this = this;
  61047. var scene = this.getScene();
  61048. if (!scene) {
  61049. return this._cachedTextureMatrix;
  61050. }
  61051. if (this.uOffset === this._cachedUOffset &&
  61052. this.vOffset === this._cachedVOffset &&
  61053. this.uScale === this._cachedUScale &&
  61054. this.vScale === this._cachedVScale &&
  61055. this.coordinatesMode === this._cachedCoordinatesMode) {
  61056. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  61057. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  61058. return this._cachedTextureMatrix;
  61059. }
  61060. }
  61061. else {
  61062. return this._cachedTextureMatrix;
  61063. }
  61064. }
  61065. if (!this._cachedTextureMatrix) {
  61066. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61067. }
  61068. if (!this._projectionModeMatrix) {
  61069. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61070. }
  61071. this._cachedUOffset = this.uOffset;
  61072. this._cachedVOffset = this.vOffset;
  61073. this._cachedUScale = this.uScale;
  61074. this._cachedVScale = this.vScale;
  61075. this._cachedCoordinatesMode = this.coordinatesMode;
  61076. switch (this.coordinatesMode) {
  61077. case Texture.PLANAR_MODE:
  61078. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  61079. this._cachedTextureMatrix[0] = this.uScale;
  61080. this._cachedTextureMatrix[5] = this.vScale;
  61081. this._cachedTextureMatrix[12] = this.uOffset;
  61082. this._cachedTextureMatrix[13] = this.vOffset;
  61083. break;
  61084. case Texture.PROJECTION_MODE:
  61085. _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);
  61086. var projectionMatrix = scene.getProjectionMatrix();
  61087. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  61088. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  61089. break;
  61090. default:
  61091. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  61092. break;
  61093. }
  61094. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  61095. return (mat.getActiveTextures().indexOf(_this) !== -1);
  61096. });
  61097. return this._cachedTextureMatrix;
  61098. };
  61099. /**
  61100. * Clones the texture.
  61101. * @returns the cloned texture
  61102. */
  61103. Texture.prototype.clone = function () {
  61104. var _this = this;
  61105. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  61106. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  61107. }, this);
  61108. };
  61109. /**
  61110. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  61111. * @returns The JSON representation of the texture
  61112. */
  61113. Texture.prototype.serialize = function () {
  61114. var serializationObject = _super.prototype.serialize.call(this);
  61115. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  61116. serializationObject.base64String = this._buffer;
  61117. serializationObject.name = serializationObject.name.replace("data:", "");
  61118. }
  61119. serializationObject.invertY = this._invertY;
  61120. serializationObject.samplingMode = this.samplingMode;
  61121. return serializationObject;
  61122. };
  61123. /**
  61124. * Get the current class name of the texture useful for serialization or dynamic coding.
  61125. * @returns "Texture"
  61126. */
  61127. Texture.prototype.getClassName = function () {
  61128. return "Texture";
  61129. };
  61130. /**
  61131. * Dispose the texture and release its associated resources.
  61132. */
  61133. Texture.prototype.dispose = function () {
  61134. _super.prototype.dispose.call(this);
  61135. this.onLoadObservable.clear();
  61136. this._delayedOnLoad = null;
  61137. this._delayedOnError = null;
  61138. };
  61139. /**
  61140. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  61141. * @param parsedTexture Define the JSON representation of the texture
  61142. * @param scene Define the scene the parsed texture should be instantiated in
  61143. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61144. * @returns The parsed texture if successful
  61145. */
  61146. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  61147. if (parsedTexture.customType) {
  61148. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  61149. // Update Sampling Mode
  61150. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  61151. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  61152. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  61153. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  61154. }
  61155. }
  61156. return parsedCustomTexture;
  61157. }
  61158. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  61159. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  61160. }
  61161. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  61162. return null;
  61163. }
  61164. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  61165. var generateMipMaps = true;
  61166. if (parsedTexture.noMipmap) {
  61167. generateMipMaps = false;
  61168. }
  61169. if (parsedTexture.mirrorPlane) {
  61170. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  61171. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  61172. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  61173. return mirrorTexture;
  61174. }
  61175. else if (parsedTexture.isRenderTarget) {
  61176. var renderTargetTexture = null;
  61177. if (parsedTexture.isCube) {
  61178. // Search for an existing reflection probe (which contains a cube render target texture)
  61179. if (scene.reflectionProbes) {
  61180. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  61181. var probe = scene.reflectionProbes[index];
  61182. if (probe.name === parsedTexture.name) {
  61183. return probe.cubeTexture;
  61184. }
  61185. }
  61186. }
  61187. }
  61188. else {
  61189. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  61190. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  61191. }
  61192. return renderTargetTexture;
  61193. }
  61194. else {
  61195. var texture;
  61196. if (parsedTexture.base64String) {
  61197. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  61198. }
  61199. else {
  61200. var url = rootUrl + parsedTexture.name;
  61201. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  61202. url = parsedTexture.url;
  61203. }
  61204. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  61205. }
  61206. return texture;
  61207. }
  61208. }, parsedTexture, scene);
  61209. // Update Sampling Mode
  61210. if (parsedTexture.samplingMode) {
  61211. var sampling = parsedTexture.samplingMode;
  61212. if (texture && texture.samplingMode !== sampling) {
  61213. texture.updateSamplingMode(sampling);
  61214. }
  61215. }
  61216. // Animations
  61217. if (texture && parsedTexture.animations) {
  61218. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  61219. var parsedAnimation = parsedTexture.animations[animationIndex];
  61220. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  61221. if (internalClass) {
  61222. texture.animations.push(internalClass.Parse(parsedAnimation));
  61223. }
  61224. }
  61225. }
  61226. return texture;
  61227. };
  61228. /**
  61229. * Creates a texture from its base 64 representation.
  61230. * @param data Define the base64 payload without the data: prefix
  61231. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  61232. * @param scene Define the scene the texture should belong to
  61233. * @param noMipmap Forces the texture to not create mip map information if true
  61234. * @param invertY define if the texture needs to be inverted on the y axis during loading
  61235. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  61236. * @param onLoad define a callback triggered when the texture has been loaded
  61237. * @param onError define a callback triggered when an error occurred during the loading session
  61238. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  61239. * @returns the created texture
  61240. */
  61241. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  61242. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  61243. if (onLoad === void 0) { onLoad = null; }
  61244. if (onError === void 0) { onError = null; }
  61245. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  61246. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  61247. };
  61248. /**
  61249. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  61250. * @param data Define the base64 payload without the data: prefix
  61251. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  61252. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  61253. * @param scene Define the scene the texture should belong to
  61254. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  61255. * @param noMipmap Forces the texture to not create mip map information if true
  61256. * @param invertY define if the texture needs to be inverted on the y axis during loading
  61257. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  61258. * @param onLoad define a callback triggered when the texture has been loaded
  61259. * @param onError define a callback triggered when an error occurred during the loading session
  61260. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  61261. * @returns the created texture
  61262. */
  61263. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  61264. if (deleteBuffer === void 0) { deleteBuffer = false; }
  61265. if (noMipmap === void 0) { noMipmap = false; }
  61266. if (invertY === void 0) { invertY = true; }
  61267. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  61268. if (onLoad === void 0) { onLoad = null; }
  61269. if (onError === void 0) { onError = null; }
  61270. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  61271. if (name.substr(0, 5) !== "data:") {
  61272. name = "data:" + name;
  61273. }
  61274. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  61275. };
  61276. /** @hidden */
  61277. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  61278. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  61279. };
  61280. /** @hidden */
  61281. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  61282. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  61283. };
  61284. /** @hidden */
  61285. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  61286. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  61287. };
  61288. /** nearest is mag = nearest and min = nearest and mip = linear */
  61289. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  61290. /** nearest is mag = nearest and min = nearest and mip = linear */
  61291. 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
  61292. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61293. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  61294. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61295. 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
  61296. /** Trilinear is mag = linear and min = linear and mip = linear */
  61297. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  61298. /** Trilinear is mag = linear and min = linear and mip = linear */
  61299. 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
  61300. /** mag = nearest and min = nearest and mip = nearest */
  61301. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  61302. /** mag = nearest and min = linear and mip = nearest */
  61303. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  61304. /** mag = nearest and min = linear and mip = linear */
  61305. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  61306. /** mag = nearest and min = linear and mip = none */
  61307. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  61308. /** mag = nearest and min = nearest and mip = none */
  61309. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  61310. /** mag = linear and min = nearest and mip = nearest */
  61311. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  61312. /** mag = linear and min = nearest and mip = linear */
  61313. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  61314. /** mag = linear and min = linear and mip = none */
  61315. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  61316. /** mag = linear and min = nearest and mip = none */
  61317. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  61318. /** Explicit coordinates mode */
  61319. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  61320. /** Spherical coordinates mode */
  61321. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  61322. /** Planar coordinates mode */
  61323. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  61324. /** Cubic coordinates mode */
  61325. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  61326. /** Projection coordinates mode */
  61327. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  61328. /** Inverse Cubic coordinates mode */
  61329. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  61330. /** Inverse Cubic coordinates mode */
  61331. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  61332. /** Equirectangular coordinates mode */
  61333. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  61334. /** Equirectangular Fixed coordinates mode */
  61335. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  61336. /** Equirectangular Fixed Mirrored coordinates mode */
  61337. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  61338. /** Texture is not repeating outside of 0..1 UVs */
  61339. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  61340. /** Texture is repeating outside of 0..1 UVs */
  61341. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  61342. /** Texture is repeating and mirrored */
  61343. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  61344. /**
  61345. * 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
  61346. */
  61347. Texture.UseSerializedUrlIfAny = false;
  61348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61350. ], Texture.prototype, "url", void 0);
  61351. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61352. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61353. ], Texture.prototype, "uOffset", void 0);
  61354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61356. ], Texture.prototype, "vOffset", void 0);
  61357. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61359. ], Texture.prototype, "uScale", void 0);
  61360. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61362. ], Texture.prototype, "vScale", void 0);
  61363. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61364. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61365. ], Texture.prototype, "uAng", void 0);
  61366. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61368. ], Texture.prototype, "vAng", void 0);
  61369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61371. ], Texture.prototype, "wAng", void 0);
  61372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61374. ], Texture.prototype, "uRotationCenter", void 0);
  61375. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61377. ], Texture.prototype, "vRotationCenter", void 0);
  61378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61380. ], Texture.prototype, "wRotationCenter", void 0);
  61381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61383. ], Texture.prototype, "isBlocking", null);
  61384. return Texture;
  61385. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  61386. // References the dependencies.
  61387. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  61388. /***/ }),
  61389. /***/ "./Materials/Textures/videoTexture.ts":
  61390. /*!********************************************!*\
  61391. !*** ./Materials/Textures/videoTexture.ts ***!
  61392. \********************************************/
  61393. /*! exports provided: VideoTexture */
  61394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61395. "use strict";
  61396. __webpack_require__.r(__webpack_exports__);
  61397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  61398. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61399. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  61400. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  61401. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  61402. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  61403. /**
  61404. * If you want to display a video in your scene, this is the special texture for that.
  61405. * This special texture works similar to other textures, with the exception of a few parameters.
  61406. * @see https://doc.babylonjs.com/how_to/video_texture
  61407. */
  61408. var VideoTexture = /** @class */ (function (_super) {
  61409. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  61410. /**
  61411. * Creates a video texture.
  61412. * If you want to display a video in your scene, this is the special texture for that.
  61413. * This special texture works similar to other textures, with the exception of a few parameters.
  61414. * @see https://doc.babylonjs.com/how_to/video_texture
  61415. * @param name optional name, will detect from video source, if not defined
  61416. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  61417. * @param scene is obviously the current scene.
  61418. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  61419. * @param invertY is false by default but can be used to invert video on Y axis
  61420. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  61421. * @param settings allows finer control over video usage
  61422. */
  61423. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  61424. if (generateMipMaps === void 0) { generateMipMaps = false; }
  61425. if (invertY === void 0) { invertY = false; }
  61426. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  61427. if (settings === void 0) { settings = {
  61428. autoPlay: true,
  61429. loop: true,
  61430. autoUpdateTexture: true,
  61431. }; }
  61432. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  61433. _this._onUserActionRequestedObservable = null;
  61434. _this._stillImageCaptured = false;
  61435. _this._displayingPosterTexture = false;
  61436. _this._createInternalTexture = function () {
  61437. if (_this._texture != null) {
  61438. if (_this._displayingPosterTexture) {
  61439. _this._texture.dispose();
  61440. _this._displayingPosterTexture = false;
  61441. }
  61442. else {
  61443. return;
  61444. }
  61445. }
  61446. if (!_this._engine.needPOTTextures ||
  61447. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  61448. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  61449. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  61450. }
  61451. else {
  61452. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  61453. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  61454. _this._generateMipMaps = false;
  61455. }
  61456. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  61457. if (!_this.video.autoplay && !_this._settings.poster) {
  61458. var oldHandler_1 = _this.video.onplaying;
  61459. var error_1 = false;
  61460. var oldMuted_1 = _this.video.muted;
  61461. _this.video.muted = true;
  61462. _this.video.onplaying = function () {
  61463. _this.video.muted = oldMuted_1;
  61464. _this.video.onplaying = oldHandler_1;
  61465. _this._texture.isReady = true;
  61466. _this._updateInternalTexture();
  61467. if (!error_1) {
  61468. _this.video.pause();
  61469. }
  61470. if (_this.onLoadObservable.hasObservers()) {
  61471. _this.onLoadObservable.notifyObservers(_this);
  61472. }
  61473. };
  61474. var playing = _this.video.play();
  61475. if (playing) {
  61476. playing.then(function () {
  61477. // Everything is good.
  61478. })
  61479. .catch(function () {
  61480. error_1 = true;
  61481. // On Chrome for instance, new policies might prevent playing without user interaction.
  61482. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  61483. _this._onUserActionRequestedObservable.notifyObservers(_this);
  61484. }
  61485. });
  61486. }
  61487. else {
  61488. _this.video.onplaying = oldHandler_1;
  61489. _this._texture.isReady = true;
  61490. _this._updateInternalTexture();
  61491. if (_this.onLoadObservable.hasObservers()) {
  61492. _this.onLoadObservable.notifyObservers(_this);
  61493. }
  61494. }
  61495. }
  61496. else {
  61497. _this._texture.isReady = true;
  61498. _this._updateInternalTexture();
  61499. if (_this.onLoadObservable.hasObservers()) {
  61500. _this.onLoadObservable.notifyObservers(_this);
  61501. }
  61502. }
  61503. };
  61504. _this.reset = function () {
  61505. if (_this._texture == null) {
  61506. return;
  61507. }
  61508. if (!_this._displayingPosterTexture) {
  61509. _this._texture.dispose();
  61510. _this._texture = null;
  61511. }
  61512. };
  61513. _this._updateInternalTexture = function () {
  61514. if (_this._texture == null || !_this._texture.isReady) {
  61515. return;
  61516. }
  61517. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  61518. return;
  61519. }
  61520. if (_this._displayingPosterTexture) {
  61521. return;
  61522. }
  61523. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  61524. };
  61525. _this._engine = _this.getScene().getEngine();
  61526. _this._generateMipMaps = generateMipMaps;
  61527. _this._initialSamplingMode = samplingMode;
  61528. _this.autoUpdateTexture = settings.autoUpdateTexture;
  61529. _this.name = name || _this._getName(src);
  61530. _this.video = _this._getVideo(src);
  61531. _this._settings = settings;
  61532. if (settings.poster) {
  61533. _this.video.poster = settings.poster;
  61534. }
  61535. if (settings.autoPlay !== undefined) {
  61536. _this.video.autoplay = settings.autoPlay;
  61537. }
  61538. if (settings.loop !== undefined) {
  61539. _this.video.loop = settings.loop;
  61540. }
  61541. _this.video.setAttribute("playsinline", "");
  61542. _this.video.addEventListener("paused", _this._updateInternalTexture);
  61543. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  61544. _this.video.addEventListener("emptied", _this.reset);
  61545. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  61546. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  61547. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  61548. if (settings.poster &&
  61549. (!settings.autoPlay || !videoHasEnoughData)) {
  61550. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  61551. _this._displayingPosterTexture = true;
  61552. }
  61553. else if (videoHasEnoughData) {
  61554. _this._createInternalTexture();
  61555. }
  61556. return _this;
  61557. }
  61558. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  61559. /**
  61560. * Event triggerd when a dom action is required by the user to play the video.
  61561. * This happens due to recent changes in browser policies preventing video to auto start.
  61562. */
  61563. get: function () {
  61564. if (!this._onUserActionRequestedObservable) {
  61565. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  61566. }
  61567. return this._onUserActionRequestedObservable;
  61568. },
  61569. enumerable: true,
  61570. configurable: true
  61571. });
  61572. VideoTexture.prototype._getName = function (src) {
  61573. if (src instanceof HTMLVideoElement) {
  61574. return src.currentSrc;
  61575. }
  61576. if (typeof src === "object") {
  61577. return src.toString();
  61578. }
  61579. return src;
  61580. };
  61581. VideoTexture.prototype._getVideo = function (src) {
  61582. if (src instanceof HTMLVideoElement) {
  61583. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  61584. return src;
  61585. }
  61586. var video = document.createElement("video");
  61587. if (typeof src === "string") {
  61588. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  61589. video.src = src;
  61590. }
  61591. else {
  61592. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  61593. src.forEach(function (url) {
  61594. var source = document.createElement("source");
  61595. source.src = url;
  61596. video.appendChild(source);
  61597. });
  61598. }
  61599. return video;
  61600. };
  61601. /**
  61602. * @hidden Internal method to initiate `update`.
  61603. */
  61604. VideoTexture.prototype._rebuild = function () {
  61605. this.update();
  61606. };
  61607. /**
  61608. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  61609. */
  61610. VideoTexture.prototype.update = function () {
  61611. if (!this.autoUpdateTexture) {
  61612. // Expecting user to call `updateTexture` manually
  61613. return;
  61614. }
  61615. this.updateTexture(true);
  61616. };
  61617. /**
  61618. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  61619. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  61620. */
  61621. VideoTexture.prototype.updateTexture = function (isVisible) {
  61622. if (!isVisible) {
  61623. return;
  61624. }
  61625. if (this.video.paused && this._stillImageCaptured) {
  61626. return;
  61627. }
  61628. this._stillImageCaptured = true;
  61629. this._updateInternalTexture();
  61630. };
  61631. /**
  61632. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  61633. * @param url New url.
  61634. */
  61635. VideoTexture.prototype.updateURL = function (url) {
  61636. this.video.src = url;
  61637. };
  61638. /**
  61639. * Dispose the texture and release its associated resources.
  61640. */
  61641. VideoTexture.prototype.dispose = function () {
  61642. _super.prototype.dispose.call(this);
  61643. if (this._onUserActionRequestedObservable) {
  61644. this._onUserActionRequestedObservable.clear();
  61645. this._onUserActionRequestedObservable = null;
  61646. }
  61647. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  61648. this.video.removeEventListener("paused", this._updateInternalTexture);
  61649. this.video.removeEventListener("seeked", this._updateInternalTexture);
  61650. this.video.removeEventListener("emptied", this.reset);
  61651. this.video.pause();
  61652. };
  61653. /**
  61654. * Creates a video texture straight from a stream.
  61655. * @param scene Define the scene the texture should be created in
  61656. * @param stream Define the stream the texture should be created from
  61657. * @returns The created video texture as a promise
  61658. */
  61659. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  61660. var video = document.createElement("video");
  61661. video.setAttribute('autoplay', '');
  61662. video.setAttribute('muted', 'true');
  61663. video.setAttribute('playsinline', '');
  61664. video.muted = true;
  61665. if (video.mozSrcObject !== undefined) {
  61666. // hack for Firefox < 19
  61667. video.mozSrcObject = stream;
  61668. }
  61669. else {
  61670. if (typeof video.srcObject == "object") {
  61671. video.srcObject = stream;
  61672. }
  61673. else {
  61674. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  61675. video.src = (window.URL && window.URL.createObjectURL(stream));
  61676. }
  61677. }
  61678. return new Promise(function (resolve) {
  61679. var onPlaying = function () {
  61680. resolve(new VideoTexture("video", video, scene, true, true));
  61681. video.removeEventListener("playing", onPlaying);
  61682. };
  61683. video.addEventListener("playing", onPlaying);
  61684. video.play();
  61685. });
  61686. };
  61687. /**
  61688. * Creates a video texture straight from your WebCam video feed.
  61689. * @param scene Define the scene the texture should be created in
  61690. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  61691. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  61692. * @returns The created video texture as a promise
  61693. */
  61694. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  61695. var _this = this;
  61696. if (audioConstaints === void 0) { audioConstaints = false; }
  61697. var constraintsDeviceId;
  61698. if (constraints && constraints.deviceId) {
  61699. constraintsDeviceId = {
  61700. exact: constraints.deviceId,
  61701. };
  61702. }
  61703. if (navigator.mediaDevices) {
  61704. return navigator.mediaDevices.getUserMedia({
  61705. video: constraints,
  61706. audio: audioConstaints
  61707. })
  61708. .then(function (stream) {
  61709. return _this.CreateFromStreamAsync(scene, stream);
  61710. });
  61711. }
  61712. else {
  61713. navigator.getUserMedia =
  61714. navigator.getUserMedia ||
  61715. navigator.webkitGetUserMedia ||
  61716. navigator.mozGetUserMedia ||
  61717. navigator.msGetUserMedia;
  61718. if (navigator.getUserMedia) {
  61719. navigator.getUserMedia({
  61720. video: {
  61721. deviceId: constraintsDeviceId,
  61722. width: {
  61723. min: (constraints && constraints.minWidth) || 256,
  61724. max: (constraints && constraints.maxWidth) || 640,
  61725. },
  61726. height: {
  61727. min: (constraints && constraints.minHeight) || 256,
  61728. max: (constraints && constraints.maxHeight) || 480,
  61729. },
  61730. },
  61731. audio: audioConstaints
  61732. }, function (stream) {
  61733. return _this.CreateFromStreamAsync(scene, stream);
  61734. }, function (e) {
  61735. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  61736. });
  61737. }
  61738. }
  61739. return Promise.reject("No support for userMedia on this device");
  61740. };
  61741. /**
  61742. * Creates a video texture straight from your WebCam video feed.
  61743. * @param scene Define the scene the texture should be created in
  61744. * @param onReady Define a callback to triggered once the texture will be ready
  61745. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  61746. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  61747. */
  61748. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  61749. if (audioConstaints === void 0) { audioConstaints = false; }
  61750. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  61751. .then(function (videoTexture) {
  61752. if (onReady) {
  61753. onReady(videoTexture);
  61754. }
  61755. })
  61756. .catch(function (err) {
  61757. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  61758. });
  61759. };
  61760. return VideoTexture;
  61761. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  61762. /***/ }),
  61763. /***/ "./Materials/colorCurves.ts":
  61764. /*!**********************************!*\
  61765. !*** ./Materials/colorCurves.ts ***!
  61766. \**********************************/
  61767. /*! exports provided: ColorCurves */
  61768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61769. "use strict";
  61770. __webpack_require__.r(__webpack_exports__);
  61771. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  61772. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61773. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61774. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61775. /**
  61776. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61777. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61778. * 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;
  61779. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61780. */
  61781. var ColorCurves = /** @class */ (function () {
  61782. function ColorCurves() {
  61783. this._dirty = true;
  61784. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61785. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61786. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61787. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61788. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61789. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61790. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61791. this._globalHue = 30;
  61792. this._globalDensity = 0;
  61793. this._globalSaturation = 0;
  61794. this._globalExposure = 0;
  61795. this._highlightsHue = 30;
  61796. this._highlightsDensity = 0;
  61797. this._highlightsSaturation = 0;
  61798. this._highlightsExposure = 0;
  61799. this._midtonesHue = 30;
  61800. this._midtonesDensity = 0;
  61801. this._midtonesSaturation = 0;
  61802. this._midtonesExposure = 0;
  61803. this._shadowsHue = 30;
  61804. this._shadowsDensity = 0;
  61805. this._shadowsSaturation = 0;
  61806. this._shadowsExposure = 0;
  61807. }
  61808. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  61809. /**
  61810. * Gets the global Hue value.
  61811. * 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).
  61812. */
  61813. get: function () {
  61814. return this._globalHue;
  61815. },
  61816. /**
  61817. * Sets the global Hue value.
  61818. * 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).
  61819. */
  61820. set: function (value) {
  61821. this._globalHue = value;
  61822. this._dirty = true;
  61823. },
  61824. enumerable: true,
  61825. configurable: true
  61826. });
  61827. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  61828. /**
  61829. * Gets the global Density value.
  61830. * 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.
  61831. * Values less than zero provide a filter of opposite hue.
  61832. */
  61833. get: function () {
  61834. return this._globalDensity;
  61835. },
  61836. /**
  61837. * Sets the global Density value.
  61838. * 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.
  61839. * Values less than zero provide a filter of opposite hue.
  61840. */
  61841. set: function (value) {
  61842. this._globalDensity = value;
  61843. this._dirty = true;
  61844. },
  61845. enumerable: true,
  61846. configurable: true
  61847. });
  61848. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  61849. /**
  61850. * Gets the global Saturation value.
  61851. * 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.
  61852. */
  61853. get: function () {
  61854. return this._globalSaturation;
  61855. },
  61856. /**
  61857. * Sets the global Saturation value.
  61858. * 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.
  61859. */
  61860. set: function (value) {
  61861. this._globalSaturation = value;
  61862. this._dirty = true;
  61863. },
  61864. enumerable: true,
  61865. configurable: true
  61866. });
  61867. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  61868. /**
  61869. * Gets the global Exposure value.
  61870. * 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.
  61871. */
  61872. get: function () {
  61873. return this._globalExposure;
  61874. },
  61875. /**
  61876. * Sets the global Exposure value.
  61877. * 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.
  61878. */
  61879. set: function (value) {
  61880. this._globalExposure = value;
  61881. this._dirty = true;
  61882. },
  61883. enumerable: true,
  61884. configurable: true
  61885. });
  61886. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  61887. /**
  61888. * Gets the highlights Hue value.
  61889. * 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).
  61890. */
  61891. get: function () {
  61892. return this._highlightsHue;
  61893. },
  61894. /**
  61895. * Sets the highlights Hue value.
  61896. * 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).
  61897. */
  61898. set: function (value) {
  61899. this._highlightsHue = value;
  61900. this._dirty = true;
  61901. },
  61902. enumerable: true,
  61903. configurable: true
  61904. });
  61905. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  61906. /**
  61907. * Gets the highlights Density value.
  61908. * 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.
  61909. * Values less than zero provide a filter of opposite hue.
  61910. */
  61911. get: function () {
  61912. return this._highlightsDensity;
  61913. },
  61914. /**
  61915. * Sets the highlights Density value.
  61916. * 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.
  61917. * Values less than zero provide a filter of opposite hue.
  61918. */
  61919. set: function (value) {
  61920. this._highlightsDensity = value;
  61921. this._dirty = true;
  61922. },
  61923. enumerable: true,
  61924. configurable: true
  61925. });
  61926. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  61927. /**
  61928. * Gets the highlights Saturation value.
  61929. * 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.
  61930. */
  61931. get: function () {
  61932. return this._highlightsSaturation;
  61933. },
  61934. /**
  61935. * Sets the highlights Saturation value.
  61936. * 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.
  61937. */
  61938. set: function (value) {
  61939. this._highlightsSaturation = value;
  61940. this._dirty = true;
  61941. },
  61942. enumerable: true,
  61943. configurable: true
  61944. });
  61945. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  61946. /**
  61947. * Gets the highlights Exposure value.
  61948. * 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.
  61949. */
  61950. get: function () {
  61951. return this._highlightsExposure;
  61952. },
  61953. /**
  61954. * Sets the highlights Exposure value.
  61955. * 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.
  61956. */
  61957. set: function (value) {
  61958. this._highlightsExposure = value;
  61959. this._dirty = true;
  61960. },
  61961. enumerable: true,
  61962. configurable: true
  61963. });
  61964. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  61965. /**
  61966. * Gets the midtones Hue value.
  61967. * 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).
  61968. */
  61969. get: function () {
  61970. return this._midtonesHue;
  61971. },
  61972. /**
  61973. * Sets the midtones Hue value.
  61974. * 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).
  61975. */
  61976. set: function (value) {
  61977. this._midtonesHue = value;
  61978. this._dirty = true;
  61979. },
  61980. enumerable: true,
  61981. configurable: true
  61982. });
  61983. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  61984. /**
  61985. * Gets the midtones Density value.
  61986. * 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.
  61987. * Values less than zero provide a filter of opposite hue.
  61988. */
  61989. get: function () {
  61990. return this._midtonesDensity;
  61991. },
  61992. /**
  61993. * Sets the midtones Density value.
  61994. * 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.
  61995. * Values less than zero provide a filter of opposite hue.
  61996. */
  61997. set: function (value) {
  61998. this._midtonesDensity = value;
  61999. this._dirty = true;
  62000. },
  62001. enumerable: true,
  62002. configurable: true
  62003. });
  62004. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  62005. /**
  62006. * Gets the midtones Saturation value.
  62007. * 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.
  62008. */
  62009. get: function () {
  62010. return this._midtonesSaturation;
  62011. },
  62012. /**
  62013. * Sets the midtones Saturation value.
  62014. * 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.
  62015. */
  62016. set: function (value) {
  62017. this._midtonesSaturation = value;
  62018. this._dirty = true;
  62019. },
  62020. enumerable: true,
  62021. configurable: true
  62022. });
  62023. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  62024. /**
  62025. * Gets the midtones Exposure value.
  62026. * 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.
  62027. */
  62028. get: function () {
  62029. return this._midtonesExposure;
  62030. },
  62031. /**
  62032. * Sets the midtones Exposure value.
  62033. * 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.
  62034. */
  62035. set: function (value) {
  62036. this._midtonesExposure = value;
  62037. this._dirty = true;
  62038. },
  62039. enumerable: true,
  62040. configurable: true
  62041. });
  62042. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  62043. /**
  62044. * Gets the shadows Hue value.
  62045. * 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).
  62046. */
  62047. get: function () {
  62048. return this._shadowsHue;
  62049. },
  62050. /**
  62051. * Sets the shadows Hue value.
  62052. * 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).
  62053. */
  62054. set: function (value) {
  62055. this._shadowsHue = value;
  62056. this._dirty = true;
  62057. },
  62058. enumerable: true,
  62059. configurable: true
  62060. });
  62061. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  62062. /**
  62063. * Gets the shadows Density value.
  62064. * 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.
  62065. * Values less than zero provide a filter of opposite hue.
  62066. */
  62067. get: function () {
  62068. return this._shadowsDensity;
  62069. },
  62070. /**
  62071. * Sets the shadows Density value.
  62072. * 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.
  62073. * Values less than zero provide a filter of opposite hue.
  62074. */
  62075. set: function (value) {
  62076. this._shadowsDensity = value;
  62077. this._dirty = true;
  62078. },
  62079. enumerable: true,
  62080. configurable: true
  62081. });
  62082. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  62083. /**
  62084. * Gets the shadows Saturation value.
  62085. * 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.
  62086. */
  62087. get: function () {
  62088. return this._shadowsSaturation;
  62089. },
  62090. /**
  62091. * Sets the shadows Saturation value.
  62092. * 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.
  62093. */
  62094. set: function (value) {
  62095. this._shadowsSaturation = value;
  62096. this._dirty = true;
  62097. },
  62098. enumerable: true,
  62099. configurable: true
  62100. });
  62101. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  62102. /**
  62103. * Gets the shadows Exposure value.
  62104. * 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.
  62105. */
  62106. get: function () {
  62107. return this._shadowsExposure;
  62108. },
  62109. /**
  62110. * Sets the shadows Exposure value.
  62111. * 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.
  62112. */
  62113. set: function (value) {
  62114. this._shadowsExposure = value;
  62115. this._dirty = true;
  62116. },
  62117. enumerable: true,
  62118. configurable: true
  62119. });
  62120. /**
  62121. * Returns the class name
  62122. * @returns The class name
  62123. */
  62124. ColorCurves.prototype.getClassName = function () {
  62125. return "ColorCurves";
  62126. };
  62127. /**
  62128. * Binds the color curves to the shader.
  62129. * @param colorCurves The color curve to bind
  62130. * @param effect The effect to bind to
  62131. * @param positiveUniform The positive uniform shader parameter
  62132. * @param neutralUniform The neutral uniform shader parameter
  62133. * @param negativeUniform The negative uniform shader parameter
  62134. */
  62135. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  62136. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  62137. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  62138. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  62139. if (colorCurves._dirty) {
  62140. colorCurves._dirty = false;
  62141. // Fill in global info.
  62142. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  62143. // Compute highlights info.
  62144. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  62145. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  62146. // Compute midtones info.
  62147. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  62148. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  62149. // Compute shadows info.
  62150. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  62151. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  62152. // Compute deltas (neutral is midtones).
  62153. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  62154. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  62155. }
  62156. if (effect) {
  62157. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  62158. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  62159. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  62160. }
  62161. };
  62162. /**
  62163. * Prepare the list of uniforms associated with the ColorCurves effects.
  62164. * @param uniformsList The list of uniforms used in the effect
  62165. */
  62166. ColorCurves.PrepareUniforms = function (uniformsList) {
  62167. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  62168. };
  62169. /**
  62170. * Returns color grading data based on a hue, density, saturation and exposure value.
  62171. * @param filterHue The hue of the color filter.
  62172. * @param filterDensity The density of the color filter.
  62173. * @param saturation The saturation.
  62174. * @param exposure The exposure.
  62175. * @param result The result data container.
  62176. */
  62177. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  62178. if (hue == null) {
  62179. return;
  62180. }
  62181. hue = ColorCurves.clamp(hue, 0, 360);
  62182. density = ColorCurves.clamp(density, -100, 100);
  62183. saturation = ColorCurves.clamp(saturation, -100, 100);
  62184. exposure = ColorCurves.clamp(exposure, -100, 100);
  62185. // Remap the slider/config filter density with non-linear mapping and also scale by half
  62186. // so that the maximum filter density is only 50% control. This provides fine control
  62187. // for small values and reasonable range.
  62188. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  62189. density *= 0.5;
  62190. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  62191. if (density < 0) {
  62192. density *= -1;
  62193. hue = (hue + 180) % 360;
  62194. }
  62195. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  62196. result.scaleToRef(2, result);
  62197. result.a = 1 + 0.01 * saturation;
  62198. };
  62199. /**
  62200. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  62201. * @param value The input slider value in range [-100,100].
  62202. * @returns Adjusted value.
  62203. */
  62204. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  62205. value /= 100;
  62206. var x = Math.abs(value);
  62207. x = Math.pow(x, 2);
  62208. if (value < 0) {
  62209. x *= -1;
  62210. }
  62211. x *= 100;
  62212. return x;
  62213. };
  62214. /**
  62215. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  62216. * @param hue The hue (H) input.
  62217. * @param saturation The saturation (S) input.
  62218. * @param brightness The brightness (B) input.
  62219. * @result An RGBA color represented as Vector4.
  62220. */
  62221. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  62222. var h = ColorCurves.clamp(hue, 0, 360);
  62223. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  62224. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  62225. if (s === 0) {
  62226. result.r = v;
  62227. result.g = v;
  62228. result.b = v;
  62229. }
  62230. else {
  62231. // sector 0 to 5
  62232. h /= 60;
  62233. var i = Math.floor(h);
  62234. // fractional part of h
  62235. var f = h - i;
  62236. var p = v * (1 - s);
  62237. var q = v * (1 - s * f);
  62238. var t = v * (1 - s * (1 - f));
  62239. switch (i) {
  62240. case 0:
  62241. result.r = v;
  62242. result.g = t;
  62243. result.b = p;
  62244. break;
  62245. case 1:
  62246. result.r = q;
  62247. result.g = v;
  62248. result.b = p;
  62249. break;
  62250. case 2:
  62251. result.r = p;
  62252. result.g = v;
  62253. result.b = t;
  62254. break;
  62255. case 3:
  62256. result.r = p;
  62257. result.g = q;
  62258. result.b = v;
  62259. break;
  62260. case 4:
  62261. result.r = t;
  62262. result.g = p;
  62263. result.b = v;
  62264. break;
  62265. default: // case 5:
  62266. result.r = v;
  62267. result.g = p;
  62268. result.b = q;
  62269. break;
  62270. }
  62271. }
  62272. result.a = 1;
  62273. };
  62274. /**
  62275. * Returns a value clamped between min and max
  62276. * @param value The value to clamp
  62277. * @param min The minimum of value
  62278. * @param max The maximum of value
  62279. * @returns The clamped value.
  62280. */
  62281. ColorCurves.clamp = function (value, min, max) {
  62282. return Math.min(Math.max(value, min), max);
  62283. };
  62284. /**
  62285. * Clones the current color curve instance.
  62286. * @return The cloned curves
  62287. */
  62288. ColorCurves.prototype.clone = function () {
  62289. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  62290. };
  62291. /**
  62292. * Serializes the current color curve instance to a json representation.
  62293. * @return a JSON representation
  62294. */
  62295. ColorCurves.prototype.serialize = function () {
  62296. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62297. };
  62298. /**
  62299. * Parses the color curve from a json representation.
  62300. * @param source the JSON source to parse
  62301. * @return The parsed curves
  62302. */
  62303. ColorCurves.Parse = function (source) {
  62304. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  62305. };
  62306. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62308. ], ColorCurves.prototype, "_globalHue", void 0);
  62309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62311. ], ColorCurves.prototype, "_globalDensity", void 0);
  62312. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62313. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62314. ], ColorCurves.prototype, "_globalSaturation", void 0);
  62315. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62316. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62317. ], ColorCurves.prototype, "_globalExposure", void 0);
  62318. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62319. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62320. ], ColorCurves.prototype, "_highlightsHue", void 0);
  62321. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62323. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  62324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62326. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  62327. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62328. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62329. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  62330. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62332. ], ColorCurves.prototype, "_midtonesHue", void 0);
  62333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62335. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  62336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62338. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  62339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62341. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  62342. return ColorCurves;
  62343. }());
  62344. // References the dependencies.
  62345. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  62346. /***/ }),
  62347. /***/ "./Materials/effect.ts":
  62348. /*!*****************************!*\
  62349. !*** ./Materials/effect.ts ***!
  62350. \*****************************/
  62351. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  62352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62353. "use strict";
  62354. __webpack_require__.r(__webpack_exports__);
  62355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  62356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  62357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  62358. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  62359. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62360. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  62361. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62362. /**
  62363. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  62364. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  62365. */
  62366. var EffectFallbacks = /** @class */ (function () {
  62367. function EffectFallbacks() {
  62368. this._defines = {};
  62369. this._currentRank = 32;
  62370. this._maxRank = -1;
  62371. }
  62372. /**
  62373. * Removes the fallback from the bound mesh.
  62374. */
  62375. EffectFallbacks.prototype.unBindMesh = function () {
  62376. this._mesh = null;
  62377. };
  62378. /**
  62379. * Adds a fallback on the specified property.
  62380. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  62381. * @param define The name of the define in the shader
  62382. */
  62383. EffectFallbacks.prototype.addFallback = function (rank, define) {
  62384. if (!this._defines[rank]) {
  62385. if (rank < this._currentRank) {
  62386. this._currentRank = rank;
  62387. }
  62388. if (rank > this._maxRank) {
  62389. this._maxRank = rank;
  62390. }
  62391. this._defines[rank] = new Array();
  62392. }
  62393. this._defines[rank].push(define);
  62394. };
  62395. /**
  62396. * Sets the mesh to use CPU skinning when needing to fallback.
  62397. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  62398. * @param mesh The mesh to use the fallbacks.
  62399. */
  62400. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  62401. this._mesh = mesh;
  62402. if (rank < this._currentRank) {
  62403. this._currentRank = rank;
  62404. }
  62405. if (rank > this._maxRank) {
  62406. this._maxRank = rank;
  62407. }
  62408. };
  62409. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  62410. /**
  62411. * Checks to see if more fallbacks are still availible.
  62412. */
  62413. get: function () {
  62414. return this._currentRank <= this._maxRank;
  62415. },
  62416. enumerable: true,
  62417. configurable: true
  62418. });
  62419. /**
  62420. * Removes the defines that shoould be removed when falling back.
  62421. * @param currentDefines defines the current define statements for the shader.
  62422. * @param effect defines the current effect we try to compile
  62423. * @returns The resulting defines with defines of the current rank removed.
  62424. */
  62425. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  62426. // First we try to switch to CPU skinning
  62427. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  62428. this._mesh.computeBonesUsingShaders = false;
  62429. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  62430. effect._bonesComputationForcedToCPU = true;
  62431. var scene = this._mesh.getScene();
  62432. for (var index = 0; index < scene.meshes.length; index++) {
  62433. var otherMesh = scene.meshes[index];
  62434. if (!otherMesh.material) {
  62435. continue;
  62436. }
  62437. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  62438. continue;
  62439. }
  62440. if (otherMesh.material.getEffect() === effect) {
  62441. otherMesh.computeBonesUsingShaders = false;
  62442. }
  62443. else if (otherMesh.subMeshes) {
  62444. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  62445. var subMesh = _a[_i];
  62446. var subMeshEffect = subMesh.effect;
  62447. if (subMeshEffect === effect) {
  62448. otherMesh.computeBonesUsingShaders = false;
  62449. break;
  62450. }
  62451. }
  62452. }
  62453. }
  62454. }
  62455. else {
  62456. var currentFallbacks = this._defines[this._currentRank];
  62457. if (currentFallbacks) {
  62458. for (var index = 0; index < currentFallbacks.length; index++) {
  62459. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  62460. }
  62461. }
  62462. this._currentRank++;
  62463. }
  62464. return currentDefines;
  62465. };
  62466. return EffectFallbacks;
  62467. }());
  62468. /**
  62469. * Options to be used when creating an effect.
  62470. */
  62471. var EffectCreationOptions = /** @class */ (function () {
  62472. function EffectCreationOptions() {
  62473. }
  62474. return EffectCreationOptions;
  62475. }());
  62476. /**
  62477. * Effect containing vertex and fragment shader that can be executed on an object.
  62478. */
  62479. var Effect = /** @class */ (function () {
  62480. /**
  62481. * Instantiates an effect.
  62482. * An effect can be used to create/manage/execute vertex and fragment shaders.
  62483. * @param baseName Name of the effect.
  62484. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  62485. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  62486. * @param samplers List of sampler variables that will be passed to the shader.
  62487. * @param engine Engine to be used to render the effect
  62488. * @param defines Define statements to be added to the shader.
  62489. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  62490. * @param onCompiled Callback that will be called when the shader is compiled.
  62491. * @param onError Callback that will be called if an error occurs during shader compilation.
  62492. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  62493. */
  62494. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  62495. if (samplers === void 0) { samplers = null; }
  62496. if (defines === void 0) { defines = null; }
  62497. if (fallbacks === void 0) { fallbacks = null; }
  62498. if (onCompiled === void 0) { onCompiled = null; }
  62499. if (onError === void 0) { onError = null; }
  62500. var _this = this;
  62501. /**
  62502. * Unique ID of the effect.
  62503. */
  62504. this.uniqueId = 0;
  62505. /**
  62506. * Observable that will be called when the shader is compiled.
  62507. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  62508. */
  62509. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62510. /**
  62511. * Observable that will be called if an error occurs during shader compilation.
  62512. */
  62513. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62514. /** @hidden */
  62515. this._bonesComputationForcedToCPU = false;
  62516. this._uniformBuffersNames = {};
  62517. this._isReady = false;
  62518. this._compilationError = "";
  62519. this.name = baseName;
  62520. if (attributesNamesOrOptions.attributes) {
  62521. var options = attributesNamesOrOptions;
  62522. this._engine = uniformsNamesOrEngine;
  62523. this._attributesNames = options.attributes;
  62524. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  62525. this._samplers = options.samplers.slice();
  62526. this.defines = options.defines;
  62527. this.onError = options.onError;
  62528. this.onCompiled = options.onCompiled;
  62529. this._fallbacks = options.fallbacks;
  62530. this._indexParameters = options.indexParameters;
  62531. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  62532. if (options.uniformBuffersNames) {
  62533. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  62534. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  62535. }
  62536. }
  62537. }
  62538. else {
  62539. this._engine = engine;
  62540. this.defines = (defines == null ? "" : defines);
  62541. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  62542. this._samplers = samplers ? samplers.slice() : [];
  62543. this._attributesNames = attributesNamesOrOptions;
  62544. this.onError = onError;
  62545. this.onCompiled = onCompiled;
  62546. this._indexParameters = indexParameters;
  62547. this._fallbacks = fallbacks;
  62548. }
  62549. this.uniqueId = Effect._uniqueIdSeed++;
  62550. var vertexSource;
  62551. var fragmentSource;
  62552. if (baseName.vertexElement) {
  62553. vertexSource = document.getElementById(baseName.vertexElement);
  62554. if (!vertexSource) {
  62555. vertexSource = baseName.vertexElement;
  62556. }
  62557. }
  62558. else {
  62559. vertexSource = baseName.vertex || baseName;
  62560. }
  62561. if (baseName.fragmentElement) {
  62562. fragmentSource = document.getElementById(baseName.fragmentElement);
  62563. if (!fragmentSource) {
  62564. fragmentSource = baseName.fragmentElement;
  62565. }
  62566. }
  62567. else {
  62568. fragmentSource = baseName.fragment || baseName;
  62569. }
  62570. this._loadVertexShader(vertexSource, function (vertexCode) {
  62571. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  62572. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  62573. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  62574. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  62575. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  62576. if (baseName) {
  62577. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  62578. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  62579. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  62580. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  62581. }
  62582. else {
  62583. _this._vertexSourceCode = migratedVertexCode;
  62584. _this._fragmentSourceCode = migratedFragmentCode;
  62585. }
  62586. _this._prepareEffect();
  62587. });
  62588. });
  62589. });
  62590. });
  62591. });
  62592. });
  62593. }
  62594. Object.defineProperty(Effect.prototype, "onBindObservable", {
  62595. /**
  62596. * Observable that will be called when effect is bound.
  62597. */
  62598. get: function () {
  62599. if (!this._onBindObservable) {
  62600. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62601. }
  62602. return this._onBindObservable;
  62603. },
  62604. enumerable: true,
  62605. configurable: true
  62606. });
  62607. Object.defineProperty(Effect.prototype, "key", {
  62608. /**
  62609. * Unique key for this effect
  62610. */
  62611. get: function () {
  62612. return this._key;
  62613. },
  62614. enumerable: true,
  62615. configurable: true
  62616. });
  62617. /**
  62618. * If the effect has been compiled and prepared.
  62619. * @returns if the effect is compiled and prepared.
  62620. */
  62621. Effect.prototype.isReady = function () {
  62622. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  62623. return this._engine._isProgramCompiled(this._program);
  62624. }
  62625. return this._isReady;
  62626. };
  62627. /**
  62628. * The engine the effect was initialized with.
  62629. * @returns the engine.
  62630. */
  62631. Effect.prototype.getEngine = function () {
  62632. return this._engine;
  62633. };
  62634. /**
  62635. * The compiled webGL program for the effect
  62636. * @returns the webGL program.
  62637. */
  62638. Effect.prototype.getProgram = function () {
  62639. return this._program;
  62640. };
  62641. /**
  62642. * The set of names of attribute variables for the shader.
  62643. * @returns An array of attribute names.
  62644. */
  62645. Effect.prototype.getAttributesNames = function () {
  62646. return this._attributesNames;
  62647. };
  62648. /**
  62649. * Returns the attribute at the given index.
  62650. * @param index The index of the attribute.
  62651. * @returns The location of the attribute.
  62652. */
  62653. Effect.prototype.getAttributeLocation = function (index) {
  62654. return this._attributes[index];
  62655. };
  62656. /**
  62657. * Returns the attribute based on the name of the variable.
  62658. * @param name of the attribute to look up.
  62659. * @returns the attribute location.
  62660. */
  62661. Effect.prototype.getAttributeLocationByName = function (name) {
  62662. var index = this._attributesNames.indexOf(name);
  62663. return this._attributes[index];
  62664. };
  62665. /**
  62666. * The number of attributes.
  62667. * @returns the numnber of attributes.
  62668. */
  62669. Effect.prototype.getAttributesCount = function () {
  62670. return this._attributes.length;
  62671. };
  62672. /**
  62673. * Gets the index of a uniform variable.
  62674. * @param uniformName of the uniform to look up.
  62675. * @returns the index.
  62676. */
  62677. Effect.prototype.getUniformIndex = function (uniformName) {
  62678. return this._uniformsNames.indexOf(uniformName);
  62679. };
  62680. /**
  62681. * Returns the attribute based on the name of the variable.
  62682. * @param uniformName of the uniform to look up.
  62683. * @returns the location of the uniform.
  62684. */
  62685. Effect.prototype.getUniform = function (uniformName) {
  62686. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  62687. };
  62688. /**
  62689. * Returns an array of sampler variable names
  62690. * @returns The array of sampler variable neames.
  62691. */
  62692. Effect.prototype.getSamplers = function () {
  62693. return this._samplers;
  62694. };
  62695. /**
  62696. * The error from the last compilation.
  62697. * @returns the error string.
  62698. */
  62699. Effect.prototype.getCompilationError = function () {
  62700. return this._compilationError;
  62701. };
  62702. /**
  62703. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  62704. * @param func The callback to be used.
  62705. */
  62706. Effect.prototype.executeWhenCompiled = function (func) {
  62707. var _this = this;
  62708. if (this.isReady()) {
  62709. func(this);
  62710. return;
  62711. }
  62712. this.onCompileObservable.add(function (effect) {
  62713. func(effect);
  62714. });
  62715. if (!this._program || this._program.isParallelCompiled) {
  62716. setTimeout(function () {
  62717. _this._checkIsReady();
  62718. }, 16);
  62719. }
  62720. };
  62721. Effect.prototype._checkIsReady = function () {
  62722. var _this = this;
  62723. if (this.isReady()) {
  62724. return;
  62725. }
  62726. setTimeout(function () {
  62727. _this._checkIsReady();
  62728. }, 16);
  62729. };
  62730. /** @hidden */
  62731. Effect.prototype._loadVertexShader = function (vertex, callback) {
  62732. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  62733. // DOM element ?
  62734. if (vertex instanceof HTMLElement) {
  62735. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  62736. callback(vertexCode);
  62737. return;
  62738. }
  62739. }
  62740. // Base64 encoded ?
  62741. if (vertex.substr(0, 7) === "base64:") {
  62742. var vertexBinary = window.atob(vertex.substr(7));
  62743. callback(vertexBinary);
  62744. return;
  62745. }
  62746. // Is in local store ?
  62747. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  62748. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  62749. return;
  62750. }
  62751. var vertexShaderUrl;
  62752. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  62753. vertexShaderUrl = vertex;
  62754. }
  62755. else {
  62756. vertexShaderUrl = Effect.ShadersRepository + vertex;
  62757. }
  62758. // Vertex shader
  62759. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  62760. };
  62761. /** @hidden */
  62762. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  62763. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  62764. // DOM element ?
  62765. if (fragment instanceof HTMLElement) {
  62766. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  62767. callback(fragmentCode);
  62768. return;
  62769. }
  62770. }
  62771. // Base64 encoded ?
  62772. if (fragment.substr(0, 7) === "base64:") {
  62773. var fragmentBinary = window.atob(fragment.substr(7));
  62774. callback(fragmentBinary);
  62775. return;
  62776. }
  62777. // Is in local store ?
  62778. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  62779. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  62780. return;
  62781. }
  62782. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  62783. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  62784. return;
  62785. }
  62786. var fragmentShaderUrl;
  62787. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  62788. fragmentShaderUrl = fragment;
  62789. }
  62790. else {
  62791. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  62792. }
  62793. // Fragment shader
  62794. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  62795. };
  62796. /** @hidden */
  62797. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  62798. // Rebuild shaders source code
  62799. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  62800. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  62801. vertexCode = prefix + vertexCode;
  62802. fragmentCode = prefix + fragmentCode;
  62803. // Number lines of shaders source code
  62804. var i = 2;
  62805. var regex = /\n/gm;
  62806. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  62807. i = 2;
  62808. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  62809. // Dump shaders name and formatted source code
  62810. if (this.name.vertexElement) {
  62811. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  62812. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  62813. }
  62814. else if (this.name.vertex) {
  62815. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  62816. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  62817. }
  62818. else {
  62819. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  62820. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  62821. }
  62822. };
  62823. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  62824. var preparedSourceCode = this._processPrecision(sourceCode);
  62825. if (this._engine.webGLVersion == 1) {
  62826. callback(preparedSourceCode);
  62827. return;
  62828. }
  62829. // Already converted
  62830. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  62831. callback(preparedSourceCode.replace("#version 300 es", ""));
  62832. return;
  62833. }
  62834. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  62835. // Remove extensions
  62836. // #extension GL_OES_standard_derivatives : enable
  62837. // #extension GL_EXT_shader_texture_lod : enable
  62838. // #extension GL_EXT_frag_depth : enable
  62839. // #extension GL_EXT_draw_buffers : require
  62840. var regex = /#extension.+(GL_OVR_multiview|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  62841. var result = preparedSourceCode.replace(regex, "");
  62842. // Migrate to GLSL v300
  62843. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  62844. result = result.replace(/attribute[ \t]/g, "in ");
  62845. result = result.replace(/[ \t]attribute/g, " in");
  62846. result = result.replace(/texture2D\s*\(/g, "texture(");
  62847. if (isFragment) {
  62848. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  62849. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  62850. result = result.replace(/textureCube\s*\(/g, "texture(");
  62851. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  62852. result = result.replace(/gl_FragColor/g, "glFragColor");
  62853. result = result.replace(/gl_FragData/g, "glFragData");
  62854. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  62855. }
  62856. // Add multiview setup to top of file when defined
  62857. var hasMultiviewExtension = this.defines.indexOf("#define MULTIVIEW\n") !== -1;
  62858. if (hasMultiviewExtension && !isFragment) {
  62859. result = "#extension GL_OVR_multiview : require\nlayout (num_views = 2) in;\n" + result;
  62860. }
  62861. callback(result);
  62862. };
  62863. Effect.prototype._processIncludes = function (sourceCode, callback) {
  62864. var _this = this;
  62865. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  62866. var match = regex.exec(sourceCode);
  62867. var returnValue = new String(sourceCode);
  62868. while (match != null) {
  62869. var includeFile = match[1];
  62870. // Uniform declaration
  62871. if (includeFile.indexOf("__decl__") !== -1) {
  62872. includeFile = includeFile.replace(/__decl__/, "");
  62873. if (this._engine.supportsUniformBuffers) {
  62874. includeFile = includeFile.replace(/Vertex/, "Ubo");
  62875. includeFile = includeFile.replace(/Fragment/, "Ubo");
  62876. }
  62877. includeFile = includeFile + "Declaration";
  62878. }
  62879. if (Effect.IncludesShadersStore[includeFile]) {
  62880. // Substitution
  62881. var includeContent = Effect.IncludesShadersStore[includeFile];
  62882. if (match[2]) {
  62883. var splits = match[3].split(",");
  62884. for (var index = 0; index < splits.length; index += 2) {
  62885. var source = new RegExp(splits[index], "g");
  62886. var dest = splits[index + 1];
  62887. includeContent = includeContent.replace(source, dest);
  62888. }
  62889. }
  62890. if (match[4]) {
  62891. var indexString = match[5];
  62892. if (indexString.indexOf("..") !== -1) {
  62893. var indexSplits = indexString.split("..");
  62894. var minIndex = parseInt(indexSplits[0]);
  62895. var maxIndex = parseInt(indexSplits[1]);
  62896. var sourceIncludeContent = includeContent.slice(0);
  62897. includeContent = "";
  62898. if (isNaN(maxIndex)) {
  62899. maxIndex = this._indexParameters[indexSplits[1]];
  62900. }
  62901. for (var i = minIndex; i < maxIndex; i++) {
  62902. if (!this._engine.supportsUniformBuffers) {
  62903. // Ubo replacement
  62904. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  62905. return p1 + "{X}";
  62906. });
  62907. }
  62908. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  62909. }
  62910. }
  62911. else {
  62912. if (!this._engine.supportsUniformBuffers) {
  62913. // Ubo replacement
  62914. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  62915. return p1 + "{X}";
  62916. });
  62917. }
  62918. includeContent = includeContent.replace(/\{X\}/g, indexString);
  62919. }
  62920. }
  62921. // Replace
  62922. returnValue = returnValue.replace(match[0], includeContent);
  62923. }
  62924. else {
  62925. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  62926. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  62927. Effect.IncludesShadersStore[includeFile] = fileContent;
  62928. _this._processIncludes(returnValue, callback);
  62929. });
  62930. return;
  62931. }
  62932. match = regex.exec(sourceCode);
  62933. }
  62934. callback(returnValue);
  62935. };
  62936. Effect.prototype._processPrecision = function (source) {
  62937. var shouldUseHighPrecisionShader = this._engine._shouldUseHighPrecisionShader;
  62938. if (source.indexOf("precision highp float") === -1) {
  62939. if (!shouldUseHighPrecisionShader) {
  62940. source = "precision mediump float;\n" + source;
  62941. }
  62942. else {
  62943. source = "precision highp float;\n" + source;
  62944. }
  62945. }
  62946. else {
  62947. if (!shouldUseHighPrecisionShader) { // Moving highp to mediump
  62948. source = source.replace("precision highp float", "precision mediump float");
  62949. }
  62950. }
  62951. return source;
  62952. };
  62953. /**
  62954. * Recompiles the webGL program
  62955. * @param vertexSourceCode The source code for the vertex shader.
  62956. * @param fragmentSourceCode The source code for the fragment shader.
  62957. * @param onCompiled Callback called when completed.
  62958. * @param onError Callback called on error.
  62959. * @hidden
  62960. */
  62961. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  62962. var _this = this;
  62963. this._isReady = false;
  62964. this._vertexSourceCodeOverride = vertexSourceCode;
  62965. this._fragmentSourceCodeOverride = fragmentSourceCode;
  62966. this.onError = function (effect, error) {
  62967. if (onError) {
  62968. onError(error);
  62969. }
  62970. };
  62971. this.onCompiled = function () {
  62972. var scenes = _this.getEngine().scenes;
  62973. for (var i = 0; i < scenes.length; i++) {
  62974. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  62975. }
  62976. if (onCompiled) {
  62977. onCompiled(_this._program);
  62978. }
  62979. };
  62980. this._fallbacks = null;
  62981. this._prepareEffect();
  62982. };
  62983. /**
  62984. * Gets the uniform locations of the the specified variable names
  62985. * @param names THe names of the variables to lookup.
  62986. * @returns Array of locations in the same order as variable names.
  62987. */
  62988. Effect.prototype.getSpecificUniformLocations = function (names) {
  62989. var engine = this._engine;
  62990. return engine.getUniforms(this._program, names);
  62991. };
  62992. /**
  62993. * Prepares the effect
  62994. * @hidden
  62995. */
  62996. Effect.prototype._prepareEffect = function () {
  62997. var _this = this;
  62998. var attributesNames = this._attributesNames;
  62999. var defines = this.defines;
  63000. var fallbacks = this._fallbacks;
  63001. this._valueCache = {};
  63002. var previousProgram = this._program;
  63003. try {
  63004. var engine_1 = this._engine;
  63005. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  63006. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  63007. }
  63008. else {
  63009. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  63010. }
  63011. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  63012. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  63013. if (engine_1.supportsUniformBuffers) {
  63014. for (var name in _this._uniformBuffersNames) {
  63015. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  63016. }
  63017. }
  63018. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  63019. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  63020. var index;
  63021. for (index = 0; index < _this._samplers.length; index++) {
  63022. var sampler = _this.getUniform(_this._samplers[index]);
  63023. if (sampler == null) {
  63024. _this._samplers.splice(index, 1);
  63025. index--;
  63026. }
  63027. }
  63028. engine_1.bindSamplers(_this);
  63029. _this._compilationError = "";
  63030. _this._isReady = true;
  63031. if (_this.onCompiled) {
  63032. _this.onCompiled(_this);
  63033. }
  63034. _this.onCompileObservable.notifyObservers(_this);
  63035. _this.onCompileObservable.clear();
  63036. // Unbind mesh reference in fallbacks
  63037. if (_this._fallbacks) {
  63038. _this._fallbacks.unBindMesh();
  63039. }
  63040. if (previousProgram) {
  63041. _this.getEngine()._deleteProgram(previousProgram);
  63042. }
  63043. });
  63044. if (this._program.isParallelCompiled) {
  63045. this._checkIsReady();
  63046. }
  63047. }
  63048. catch (e) {
  63049. this._compilationError = e.message;
  63050. // Let's go through fallbacks then
  63051. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  63052. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  63053. return " " + uniform;
  63054. }));
  63055. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  63056. return " " + attribute;
  63057. }));
  63058. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  63059. if (previousProgram) {
  63060. this._program = previousProgram;
  63061. this._isReady = true;
  63062. if (this.onError) {
  63063. this.onError(this, this._compilationError);
  63064. }
  63065. this.onErrorObservable.notifyObservers(this);
  63066. }
  63067. if (fallbacks && fallbacks.isMoreFallbacks) {
  63068. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  63069. this.defines = fallbacks.reduce(this.defines, this);
  63070. this._prepareEffect();
  63071. }
  63072. else { // Sorry we did everything we can
  63073. if (this.onError) {
  63074. this.onError(this, this._compilationError);
  63075. }
  63076. this.onErrorObservable.notifyObservers(this);
  63077. this.onErrorObservable.clear();
  63078. // Unbind mesh reference in fallbacks
  63079. if (this._fallbacks) {
  63080. this._fallbacks.unBindMesh();
  63081. }
  63082. }
  63083. }
  63084. };
  63085. Object.defineProperty(Effect.prototype, "isSupported", {
  63086. /**
  63087. * Checks if the effect is supported. (Must be called after compilation)
  63088. */
  63089. get: function () {
  63090. return this._compilationError === "";
  63091. },
  63092. enumerable: true,
  63093. configurable: true
  63094. });
  63095. /**
  63096. * Binds a texture to the engine to be used as output of the shader.
  63097. * @param channel Name of the output variable.
  63098. * @param texture Texture to bind.
  63099. * @hidden
  63100. */
  63101. Effect.prototype._bindTexture = function (channel, texture) {
  63102. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  63103. };
  63104. /**
  63105. * Sets a texture on the engine to be used in the shader.
  63106. * @param channel Name of the sampler variable.
  63107. * @param texture Texture to set.
  63108. */
  63109. Effect.prototype.setTexture = function (channel, texture) {
  63110. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  63111. };
  63112. /**
  63113. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  63114. * @param channel Name of the sampler variable.
  63115. * @param texture Texture to set.
  63116. */
  63117. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  63118. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  63119. };
  63120. /**
  63121. * Sets an array of textures on the engine to be used in the shader.
  63122. * @param channel Name of the variable.
  63123. * @param textures Textures to set.
  63124. */
  63125. Effect.prototype.setTextureArray = function (channel, textures) {
  63126. if (this._samplers.indexOf(channel + "Ex") === -1) {
  63127. var initialPos = this._samplers.indexOf(channel);
  63128. for (var index = 1; index < textures.length; index++) {
  63129. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  63130. }
  63131. }
  63132. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  63133. };
  63134. /**
  63135. * 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)
  63136. * @param channel Name of the sampler variable.
  63137. * @param postProcess Post process to get the input texture from.
  63138. */
  63139. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  63140. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  63141. };
  63142. /**
  63143. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  63144. * 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)
  63145. * @param channel Name of the sampler variable.
  63146. * @param postProcess Post process to get the output texture from.
  63147. */
  63148. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  63149. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  63150. };
  63151. /** @hidden */
  63152. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  63153. var cache = this._valueCache[uniformName];
  63154. var flag = matrix.updateFlag;
  63155. if (cache !== undefined && cache === flag) {
  63156. return false;
  63157. }
  63158. this._valueCache[uniformName] = flag;
  63159. return true;
  63160. };
  63161. /** @hidden */
  63162. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  63163. var cache = this._valueCache[uniformName];
  63164. if (!cache) {
  63165. cache = [x, y];
  63166. this._valueCache[uniformName] = cache;
  63167. return true;
  63168. }
  63169. var changed = false;
  63170. if (cache[0] !== x) {
  63171. cache[0] = x;
  63172. changed = true;
  63173. }
  63174. if (cache[1] !== y) {
  63175. cache[1] = y;
  63176. changed = true;
  63177. }
  63178. return changed;
  63179. };
  63180. /** @hidden */
  63181. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  63182. var cache = this._valueCache[uniformName];
  63183. if (!cache) {
  63184. cache = [x, y, z];
  63185. this._valueCache[uniformName] = cache;
  63186. return true;
  63187. }
  63188. var changed = false;
  63189. if (cache[0] !== x) {
  63190. cache[0] = x;
  63191. changed = true;
  63192. }
  63193. if (cache[1] !== y) {
  63194. cache[1] = y;
  63195. changed = true;
  63196. }
  63197. if (cache[2] !== z) {
  63198. cache[2] = z;
  63199. changed = true;
  63200. }
  63201. return changed;
  63202. };
  63203. /** @hidden */
  63204. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  63205. var cache = this._valueCache[uniformName];
  63206. if (!cache) {
  63207. cache = [x, y, z, w];
  63208. this._valueCache[uniformName] = cache;
  63209. return true;
  63210. }
  63211. var changed = false;
  63212. if (cache[0] !== x) {
  63213. cache[0] = x;
  63214. changed = true;
  63215. }
  63216. if (cache[1] !== y) {
  63217. cache[1] = y;
  63218. changed = true;
  63219. }
  63220. if (cache[2] !== z) {
  63221. cache[2] = z;
  63222. changed = true;
  63223. }
  63224. if (cache[3] !== w) {
  63225. cache[3] = w;
  63226. changed = true;
  63227. }
  63228. return changed;
  63229. };
  63230. /**
  63231. * Binds a buffer to a uniform.
  63232. * @param buffer Buffer to bind.
  63233. * @param name Name of the uniform variable to bind to.
  63234. */
  63235. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  63236. var bufferName = this._uniformBuffersNames[name];
  63237. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  63238. return;
  63239. }
  63240. Effect._baseCache[bufferName] = buffer;
  63241. this._engine.bindUniformBufferBase(buffer, bufferName);
  63242. };
  63243. /**
  63244. * Binds block to a uniform.
  63245. * @param blockName Name of the block to bind.
  63246. * @param index Index to bind.
  63247. */
  63248. Effect.prototype.bindUniformBlock = function (blockName, index) {
  63249. this._engine.bindUniformBlock(this._program, blockName, index);
  63250. };
  63251. /**
  63252. * Sets an interger value on a uniform variable.
  63253. * @param uniformName Name of the variable.
  63254. * @param value Value to be set.
  63255. * @returns this effect.
  63256. */
  63257. Effect.prototype.setInt = function (uniformName, value) {
  63258. var cache = this._valueCache[uniformName];
  63259. if (cache !== undefined && cache === value) {
  63260. return this;
  63261. }
  63262. this._valueCache[uniformName] = value;
  63263. this._engine.setInt(this.getUniform(uniformName), value);
  63264. return this;
  63265. };
  63266. /**
  63267. * Sets an int array on a uniform variable.
  63268. * @param uniformName Name of the variable.
  63269. * @param array array to be set.
  63270. * @returns this effect.
  63271. */
  63272. Effect.prototype.setIntArray = function (uniformName, array) {
  63273. this._valueCache[uniformName] = null;
  63274. this._engine.setIntArray(this.getUniform(uniformName), array);
  63275. return this;
  63276. };
  63277. /**
  63278. * 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)
  63279. * @param uniformName Name of the variable.
  63280. * @param array array to be set.
  63281. * @returns this effect.
  63282. */
  63283. Effect.prototype.setIntArray2 = function (uniformName, array) {
  63284. this._valueCache[uniformName] = null;
  63285. this._engine.setIntArray2(this.getUniform(uniformName), array);
  63286. return this;
  63287. };
  63288. /**
  63289. * 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)
  63290. * @param uniformName Name of the variable.
  63291. * @param array array to be set.
  63292. * @returns this effect.
  63293. */
  63294. Effect.prototype.setIntArray3 = function (uniformName, array) {
  63295. this._valueCache[uniformName] = null;
  63296. this._engine.setIntArray3(this.getUniform(uniformName), array);
  63297. return this;
  63298. };
  63299. /**
  63300. * 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)
  63301. * @param uniformName Name of the variable.
  63302. * @param array array to be set.
  63303. * @returns this effect.
  63304. */
  63305. Effect.prototype.setIntArray4 = function (uniformName, array) {
  63306. this._valueCache[uniformName] = null;
  63307. this._engine.setIntArray4(this.getUniform(uniformName), array);
  63308. return this;
  63309. };
  63310. /**
  63311. * Sets an float array on a uniform variable.
  63312. * @param uniformName Name of the variable.
  63313. * @param array array to be set.
  63314. * @returns this effect.
  63315. */
  63316. Effect.prototype.setFloatArray = function (uniformName, array) {
  63317. this._valueCache[uniformName] = null;
  63318. this._engine.setFloatArray(this.getUniform(uniformName), array);
  63319. return this;
  63320. };
  63321. /**
  63322. * 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)
  63323. * @param uniformName Name of the variable.
  63324. * @param array array to be set.
  63325. * @returns this effect.
  63326. */
  63327. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  63328. this._valueCache[uniformName] = null;
  63329. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  63330. return this;
  63331. };
  63332. /**
  63333. * 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)
  63334. * @param uniformName Name of the variable.
  63335. * @param array array to be set.
  63336. * @returns this effect.
  63337. */
  63338. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  63339. this._valueCache[uniformName] = null;
  63340. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  63341. return this;
  63342. };
  63343. /**
  63344. * 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)
  63345. * @param uniformName Name of the variable.
  63346. * @param array array to be set.
  63347. * @returns this effect.
  63348. */
  63349. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  63350. this._valueCache[uniformName] = null;
  63351. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  63352. return this;
  63353. };
  63354. /**
  63355. * Sets an array on a uniform variable.
  63356. * @param uniformName Name of the variable.
  63357. * @param array array to be set.
  63358. * @returns this effect.
  63359. */
  63360. Effect.prototype.setArray = function (uniformName, array) {
  63361. this._valueCache[uniformName] = null;
  63362. this._engine.setArray(this.getUniform(uniformName), array);
  63363. return this;
  63364. };
  63365. /**
  63366. * 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)
  63367. * @param uniformName Name of the variable.
  63368. * @param array array to be set.
  63369. * @returns this effect.
  63370. */
  63371. Effect.prototype.setArray2 = function (uniformName, array) {
  63372. this._valueCache[uniformName] = null;
  63373. this._engine.setArray2(this.getUniform(uniformName), array);
  63374. return this;
  63375. };
  63376. /**
  63377. * 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)
  63378. * @param uniformName Name of the variable.
  63379. * @param array array to be set.
  63380. * @returns this effect.
  63381. */
  63382. Effect.prototype.setArray3 = function (uniformName, array) {
  63383. this._valueCache[uniformName] = null;
  63384. this._engine.setArray3(this.getUniform(uniformName), array);
  63385. return this;
  63386. };
  63387. /**
  63388. * 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)
  63389. * @param uniformName Name of the variable.
  63390. * @param array array to be set.
  63391. * @returns this effect.
  63392. */
  63393. Effect.prototype.setArray4 = function (uniformName, array) {
  63394. this._valueCache[uniformName] = null;
  63395. this._engine.setArray4(this.getUniform(uniformName), array);
  63396. return this;
  63397. };
  63398. /**
  63399. * Sets matrices on a uniform variable.
  63400. * @param uniformName Name of the variable.
  63401. * @param matrices matrices to be set.
  63402. * @returns this effect.
  63403. */
  63404. Effect.prototype.setMatrices = function (uniformName, matrices) {
  63405. if (!matrices) {
  63406. return this;
  63407. }
  63408. this._valueCache[uniformName] = null;
  63409. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  63410. return this;
  63411. };
  63412. /**
  63413. * Sets matrix on a uniform variable.
  63414. * @param uniformName Name of the variable.
  63415. * @param matrix matrix to be set.
  63416. * @returns this effect.
  63417. */
  63418. Effect.prototype.setMatrix = function (uniformName, matrix) {
  63419. if (this._cacheMatrix(uniformName, matrix)) {
  63420. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  63421. }
  63422. return this;
  63423. };
  63424. /**
  63425. * 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)
  63426. * @param uniformName Name of the variable.
  63427. * @param matrix matrix to be set.
  63428. * @returns this effect.
  63429. */
  63430. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  63431. this._valueCache[uniformName] = null;
  63432. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  63433. return this;
  63434. };
  63435. /**
  63436. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  63437. * @param uniformName Name of the variable.
  63438. * @param matrix matrix to be set.
  63439. * @returns this effect.
  63440. */
  63441. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  63442. this._valueCache[uniformName] = null;
  63443. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  63444. return this;
  63445. };
  63446. /**
  63447. * Sets a float on a uniform variable.
  63448. * @param uniformName Name of the variable.
  63449. * @param value value to be set.
  63450. * @returns this effect.
  63451. */
  63452. Effect.prototype.setFloat = function (uniformName, value) {
  63453. var cache = this._valueCache[uniformName];
  63454. if (cache !== undefined && cache === value) {
  63455. return this;
  63456. }
  63457. this._valueCache[uniformName] = value;
  63458. this._engine.setFloat(this.getUniform(uniformName), value);
  63459. return this;
  63460. };
  63461. /**
  63462. * Sets a boolean on a uniform variable.
  63463. * @param uniformName Name of the variable.
  63464. * @param bool value to be set.
  63465. * @returns this effect.
  63466. */
  63467. Effect.prototype.setBool = function (uniformName, bool) {
  63468. var cache = this._valueCache[uniformName];
  63469. if (cache !== undefined && cache === bool) {
  63470. return this;
  63471. }
  63472. this._valueCache[uniformName] = bool;
  63473. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  63474. return this;
  63475. };
  63476. /**
  63477. * Sets a Vector2 on a uniform variable.
  63478. * @param uniformName Name of the variable.
  63479. * @param vector2 vector2 to be set.
  63480. * @returns this effect.
  63481. */
  63482. Effect.prototype.setVector2 = function (uniformName, vector2) {
  63483. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  63484. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  63485. }
  63486. return this;
  63487. };
  63488. /**
  63489. * Sets a float2 on a uniform variable.
  63490. * @param uniformName Name of the variable.
  63491. * @param x First float in float2.
  63492. * @param y Second float in float2.
  63493. * @returns this effect.
  63494. */
  63495. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  63496. if (this._cacheFloat2(uniformName, x, y)) {
  63497. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  63498. }
  63499. return this;
  63500. };
  63501. /**
  63502. * Sets a Vector3 on a uniform variable.
  63503. * @param uniformName Name of the variable.
  63504. * @param vector3 Value to be set.
  63505. * @returns this effect.
  63506. */
  63507. Effect.prototype.setVector3 = function (uniformName, vector3) {
  63508. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  63509. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  63510. }
  63511. return this;
  63512. };
  63513. /**
  63514. * Sets a float3 on a uniform variable.
  63515. * @param uniformName Name of the variable.
  63516. * @param x First float in float3.
  63517. * @param y Second float in float3.
  63518. * @param z Third float in float3.
  63519. * @returns this effect.
  63520. */
  63521. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  63522. if (this._cacheFloat3(uniformName, x, y, z)) {
  63523. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  63524. }
  63525. return this;
  63526. };
  63527. /**
  63528. * Sets a Vector4 on a uniform variable.
  63529. * @param uniformName Name of the variable.
  63530. * @param vector4 Value to be set.
  63531. * @returns this effect.
  63532. */
  63533. Effect.prototype.setVector4 = function (uniformName, vector4) {
  63534. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  63535. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  63536. }
  63537. return this;
  63538. };
  63539. /**
  63540. * Sets a float4 on a uniform variable.
  63541. * @param uniformName Name of the variable.
  63542. * @param x First float in float4.
  63543. * @param y Second float in float4.
  63544. * @param z Third float in float4.
  63545. * @param w Fourth float in float4.
  63546. * @returns this effect.
  63547. */
  63548. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  63549. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  63550. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  63551. }
  63552. return this;
  63553. };
  63554. /**
  63555. * Sets a Color3 on a uniform variable.
  63556. * @param uniformName Name of the variable.
  63557. * @param color3 Value to be set.
  63558. * @returns this effect.
  63559. */
  63560. Effect.prototype.setColor3 = function (uniformName, color3) {
  63561. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  63562. this._engine.setColor3(this.getUniform(uniformName), color3);
  63563. }
  63564. return this;
  63565. };
  63566. /**
  63567. * Sets a Color4 on a uniform variable.
  63568. * @param uniformName Name of the variable.
  63569. * @param color3 Value to be set.
  63570. * @param alpha Alpha value to be set.
  63571. * @returns this effect.
  63572. */
  63573. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  63574. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  63575. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  63576. }
  63577. return this;
  63578. };
  63579. /**
  63580. * Sets a Color4 on a uniform variable
  63581. * @param uniformName defines the name of the variable
  63582. * @param color4 defines the value to be set
  63583. * @returns this effect.
  63584. */
  63585. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  63586. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  63587. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  63588. }
  63589. return this;
  63590. };
  63591. /**
  63592. * This function will add a new shader to the shader store
  63593. * @param name the name of the shader
  63594. * @param pixelShader optional pixel shader content
  63595. * @param vertexShader optional vertex shader content
  63596. */
  63597. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  63598. if (pixelShader) {
  63599. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  63600. }
  63601. if (vertexShader) {
  63602. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  63603. }
  63604. };
  63605. /**
  63606. * Resets the cache of effects.
  63607. */
  63608. Effect.ResetCache = function () {
  63609. Effect._baseCache = {};
  63610. };
  63611. /**
  63612. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  63613. */
  63614. Effect.ShadersRepository = "src/Shaders/";
  63615. Effect._uniqueIdSeed = 0;
  63616. Effect._baseCache = {};
  63617. /**
  63618. * Store of each shader (The can be looked up using effect.key)
  63619. */
  63620. Effect.ShadersStore = {};
  63621. /**
  63622. * Store of each included file for a shader (The can be looked up using effect.key)
  63623. */
  63624. Effect.IncludesShadersStore = {};
  63625. return Effect;
  63626. }());
  63627. /***/ }),
  63628. /***/ "./Materials/fresnelParameters.ts":
  63629. /*!****************************************!*\
  63630. !*** ./Materials/fresnelParameters.ts ***!
  63631. \****************************************/
  63632. /*! exports provided: FresnelParameters */
  63633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63634. "use strict";
  63635. __webpack_require__.r(__webpack_exports__);
  63636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  63637. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  63638. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63639. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63640. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63641. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63642. /**
  63643. * This represents all the required information to add a fresnel effect on a material:
  63644. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  63645. */
  63646. var FresnelParameters = /** @class */ (function () {
  63647. function FresnelParameters() {
  63648. this._isEnabled = true;
  63649. /**
  63650. * Define the color used on edges (grazing angle)
  63651. */
  63652. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  63653. /**
  63654. * Define the color used on center
  63655. */
  63656. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  63657. /**
  63658. * Define bias applied to computed fresnel term
  63659. */
  63660. this.bias = 0;
  63661. /**
  63662. * Defined the power exponent applied to fresnel term
  63663. */
  63664. this.power = 1;
  63665. }
  63666. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  63667. /**
  63668. * Define if the fresnel effect is enable or not.
  63669. */
  63670. get: function () {
  63671. return this._isEnabled;
  63672. },
  63673. set: function (value) {
  63674. if (this._isEnabled === value) {
  63675. return;
  63676. }
  63677. this._isEnabled = value;
  63678. _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);
  63679. },
  63680. enumerable: true,
  63681. configurable: true
  63682. });
  63683. /**
  63684. * Clones the current fresnel and its valuues
  63685. * @returns a clone fresnel configuration
  63686. */
  63687. FresnelParameters.prototype.clone = function () {
  63688. var newFresnelParameters = new FresnelParameters();
  63689. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  63690. return newFresnelParameters;
  63691. };
  63692. /**
  63693. * Serializes the current fresnel parameters to a JSON representation.
  63694. * @return the JSON serialization
  63695. */
  63696. FresnelParameters.prototype.serialize = function () {
  63697. var serializationObject = {};
  63698. serializationObject.isEnabled = this.isEnabled;
  63699. serializationObject.leftColor = this.leftColor.asArray();
  63700. serializationObject.rightColor = this.rightColor.asArray();
  63701. serializationObject.bias = this.bias;
  63702. serializationObject.power = this.power;
  63703. return serializationObject;
  63704. };
  63705. /**
  63706. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  63707. * @param parsedFresnelParameters Define the JSON representation
  63708. * @returns the parsed parameters
  63709. */
  63710. FresnelParameters.Parse = function (parsedFresnelParameters) {
  63711. var fresnelParameters = new FresnelParameters();
  63712. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  63713. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  63714. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  63715. fresnelParameters.bias = parsedFresnelParameters.bias;
  63716. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  63717. return fresnelParameters;
  63718. };
  63719. return FresnelParameters;
  63720. }());
  63721. // References the dependencies.
  63722. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  63723. /***/ }),
  63724. /***/ "./Materials/imageProcessingConfiguration.ts":
  63725. /*!***************************************************!*\
  63726. !*** ./Materials/imageProcessingConfiguration.ts ***!
  63727. \***************************************************/
  63728. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  63729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63730. "use strict";
  63731. __webpack_require__.r(__webpack_exports__);
  63732. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  63733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  63734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63735. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63736. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  63737. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  63738. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63739. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  63740. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  63741. /**
  63742. * @hidden
  63743. */
  63744. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  63745. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  63746. function ImageProcessingConfigurationDefines() {
  63747. var _this = _super.call(this) || this;
  63748. _this.IMAGEPROCESSING = false;
  63749. _this.VIGNETTE = false;
  63750. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  63751. _this.VIGNETTEBLENDMODEOPAQUE = false;
  63752. _this.TONEMAPPING = false;
  63753. _this.TONEMAPPING_ACES = false;
  63754. _this.CONTRAST = false;
  63755. _this.COLORCURVES = false;
  63756. _this.COLORGRADING = false;
  63757. _this.COLORGRADING3D = false;
  63758. _this.SAMPLER3DGREENDEPTH = false;
  63759. _this.SAMPLER3DBGRMAP = false;
  63760. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  63761. _this.EXPOSURE = false;
  63762. _this.rebuild();
  63763. return _this;
  63764. }
  63765. return ImageProcessingConfigurationDefines;
  63766. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  63767. /**
  63768. * This groups together the common properties used for image processing either in direct forward pass
  63769. * or through post processing effect depending on the use of the image processing pipeline in your scene
  63770. * or not.
  63771. */
  63772. var ImageProcessingConfiguration = /** @class */ (function () {
  63773. function ImageProcessingConfiguration() {
  63774. /**
  63775. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  63776. */
  63777. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  63778. this._colorCurvesEnabled = false;
  63779. this._colorGradingEnabled = false;
  63780. this._colorGradingWithGreenDepth = true;
  63781. this._colorGradingBGR = true;
  63782. /** @hidden */
  63783. this._exposure = 1.0;
  63784. this._toneMappingEnabled = false;
  63785. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  63786. this._contrast = 1.0;
  63787. /**
  63788. * Vignette stretch size.
  63789. */
  63790. this.vignetteStretch = 0;
  63791. /**
  63792. * Vignette centre X Offset.
  63793. */
  63794. this.vignetteCentreX = 0;
  63795. /**
  63796. * Vignette centre Y Offset.
  63797. */
  63798. this.vignetteCentreY = 0;
  63799. /**
  63800. * Vignette weight or intensity of the vignette effect.
  63801. */
  63802. this.vignetteWeight = 1.5;
  63803. /**
  63804. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  63805. * if vignetteEnabled is set to true.
  63806. */
  63807. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  63808. /**
  63809. * Camera field of view used by the Vignette effect.
  63810. */
  63811. this.vignetteCameraFov = 0.5;
  63812. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  63813. this._vignetteEnabled = false;
  63814. this._applyByPostProcess = false;
  63815. this._isEnabled = true;
  63816. /**
  63817. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  63818. */
  63819. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  63820. }
  63821. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  63822. /**
  63823. * Gets wether the color curves effect is enabled.
  63824. */
  63825. get: function () {
  63826. return this._colorCurvesEnabled;
  63827. },
  63828. /**
  63829. * Sets wether the color curves effect is enabled.
  63830. */
  63831. set: function (value) {
  63832. if (this._colorCurvesEnabled === value) {
  63833. return;
  63834. }
  63835. this._colorCurvesEnabled = value;
  63836. this._updateParameters();
  63837. },
  63838. enumerable: true,
  63839. configurable: true
  63840. });
  63841. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  63842. /**
  63843. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  63844. */
  63845. get: function () {
  63846. return this._colorGradingTexture;
  63847. },
  63848. /**
  63849. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  63850. */
  63851. set: function (value) {
  63852. if (this._colorGradingTexture === value) {
  63853. return;
  63854. }
  63855. this._colorGradingTexture = value;
  63856. this._updateParameters();
  63857. },
  63858. enumerable: true,
  63859. configurable: true
  63860. });
  63861. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  63862. /**
  63863. * Gets wether the color grading effect is enabled.
  63864. */
  63865. get: function () {
  63866. return this._colorGradingEnabled;
  63867. },
  63868. /**
  63869. * Sets wether the color grading effect is enabled.
  63870. */
  63871. set: function (value) {
  63872. if (this._colorGradingEnabled === value) {
  63873. return;
  63874. }
  63875. this._colorGradingEnabled = value;
  63876. this._updateParameters();
  63877. },
  63878. enumerable: true,
  63879. configurable: true
  63880. });
  63881. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  63882. /**
  63883. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  63884. */
  63885. get: function () {
  63886. return this._colorGradingWithGreenDepth;
  63887. },
  63888. /**
  63889. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  63890. */
  63891. set: function (value) {
  63892. if (this._colorGradingWithGreenDepth === value) {
  63893. return;
  63894. }
  63895. this._colorGradingWithGreenDepth = value;
  63896. this._updateParameters();
  63897. },
  63898. enumerable: true,
  63899. configurable: true
  63900. });
  63901. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  63902. /**
  63903. * Gets wether the color grading texture contains BGR values.
  63904. */
  63905. get: function () {
  63906. return this._colorGradingBGR;
  63907. },
  63908. /**
  63909. * Sets wether the color grading texture contains BGR values.
  63910. */
  63911. set: function (value) {
  63912. if (this._colorGradingBGR === value) {
  63913. return;
  63914. }
  63915. this._colorGradingBGR = value;
  63916. this._updateParameters();
  63917. },
  63918. enumerable: true,
  63919. configurable: true
  63920. });
  63921. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  63922. /**
  63923. * Gets the Exposure used in the effect.
  63924. */
  63925. get: function () {
  63926. return this._exposure;
  63927. },
  63928. /**
  63929. * Sets the Exposure used in the effect.
  63930. */
  63931. set: function (value) {
  63932. if (this._exposure === value) {
  63933. return;
  63934. }
  63935. this._exposure = value;
  63936. this._updateParameters();
  63937. },
  63938. enumerable: true,
  63939. configurable: true
  63940. });
  63941. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  63942. /**
  63943. * Gets wether the tone mapping effect is enabled.
  63944. */
  63945. get: function () {
  63946. return this._toneMappingEnabled;
  63947. },
  63948. /**
  63949. * Sets wether the tone mapping effect is enabled.
  63950. */
  63951. set: function (value) {
  63952. if (this._toneMappingEnabled === value) {
  63953. return;
  63954. }
  63955. this._toneMappingEnabled = value;
  63956. this._updateParameters();
  63957. },
  63958. enumerable: true,
  63959. configurable: true
  63960. });
  63961. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  63962. /**
  63963. * Gets the type of tone mapping effect.
  63964. */
  63965. get: function () {
  63966. return this._toneMappingType;
  63967. },
  63968. /**
  63969. * Sets the type of tone mapping effect used in BabylonJS.
  63970. */
  63971. set: function (value) {
  63972. if (this._toneMappingType === value) {
  63973. return;
  63974. }
  63975. this._toneMappingType = value;
  63976. this._updateParameters();
  63977. },
  63978. enumerable: true,
  63979. configurable: true
  63980. });
  63981. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  63982. /**
  63983. * Gets the contrast used in the effect.
  63984. */
  63985. get: function () {
  63986. return this._contrast;
  63987. },
  63988. /**
  63989. * Sets the contrast used in the effect.
  63990. */
  63991. set: function (value) {
  63992. if (this._contrast === value) {
  63993. return;
  63994. }
  63995. this._contrast = value;
  63996. this._updateParameters();
  63997. },
  63998. enumerable: true,
  63999. configurable: true
  64000. });
  64001. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  64002. /**
  64003. * Gets the vignette blend mode allowing different kind of effect.
  64004. */
  64005. get: function () {
  64006. return this._vignetteBlendMode;
  64007. },
  64008. /**
  64009. * Sets the vignette blend mode allowing different kind of effect.
  64010. */
  64011. set: function (value) {
  64012. if (this._vignetteBlendMode === value) {
  64013. return;
  64014. }
  64015. this._vignetteBlendMode = value;
  64016. this._updateParameters();
  64017. },
  64018. enumerable: true,
  64019. configurable: true
  64020. });
  64021. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  64022. /**
  64023. * Gets wether the vignette effect is enabled.
  64024. */
  64025. get: function () {
  64026. return this._vignetteEnabled;
  64027. },
  64028. /**
  64029. * Sets wether the vignette effect is enabled.
  64030. */
  64031. set: function (value) {
  64032. if (this._vignetteEnabled === value) {
  64033. return;
  64034. }
  64035. this._vignetteEnabled = value;
  64036. this._updateParameters();
  64037. },
  64038. enumerable: true,
  64039. configurable: true
  64040. });
  64041. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  64042. /**
  64043. * Gets wether the image processing is applied through a post process or not.
  64044. */
  64045. get: function () {
  64046. return this._applyByPostProcess;
  64047. },
  64048. /**
  64049. * Sets wether the image processing is applied through a post process or not.
  64050. */
  64051. set: function (value) {
  64052. if (this._applyByPostProcess === value) {
  64053. return;
  64054. }
  64055. this._applyByPostProcess = value;
  64056. this._updateParameters();
  64057. },
  64058. enumerable: true,
  64059. configurable: true
  64060. });
  64061. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  64062. /**
  64063. * Gets wether the image processing is enabled or not.
  64064. */
  64065. get: function () {
  64066. return this._isEnabled;
  64067. },
  64068. /**
  64069. * Sets wether the image processing is enabled or not.
  64070. */
  64071. set: function (value) {
  64072. if (this._isEnabled === value) {
  64073. return;
  64074. }
  64075. this._isEnabled = value;
  64076. this._updateParameters();
  64077. },
  64078. enumerable: true,
  64079. configurable: true
  64080. });
  64081. /**
  64082. * Method called each time the image processing information changes requires to recompile the effect.
  64083. */
  64084. ImageProcessingConfiguration.prototype._updateParameters = function () {
  64085. this.onUpdateParameters.notifyObservers(this);
  64086. };
  64087. /**
  64088. * Gets the current class name.
  64089. * @return "ImageProcessingConfiguration"
  64090. */
  64091. ImageProcessingConfiguration.prototype.getClassName = function () {
  64092. return "ImageProcessingConfiguration";
  64093. };
  64094. /**
  64095. * Prepare the list of uniforms associated with the Image Processing effects.
  64096. * @param uniforms The list of uniforms used in the effect
  64097. * @param defines the list of defines currently in use
  64098. */
  64099. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  64100. if (defines.EXPOSURE) {
  64101. uniforms.push("exposureLinear");
  64102. }
  64103. if (defines.CONTRAST) {
  64104. uniforms.push("contrast");
  64105. }
  64106. if (defines.COLORGRADING) {
  64107. uniforms.push("colorTransformSettings");
  64108. }
  64109. if (defines.VIGNETTE) {
  64110. uniforms.push("vInverseScreenSize");
  64111. uniforms.push("vignetteSettings1");
  64112. uniforms.push("vignetteSettings2");
  64113. }
  64114. if (defines.COLORCURVES) {
  64115. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  64116. }
  64117. };
  64118. /**
  64119. * Prepare the list of samplers associated with the Image Processing effects.
  64120. * @param samplersList The list of uniforms used in the effect
  64121. * @param defines the list of defines currently in use
  64122. */
  64123. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  64124. if (defines.COLORGRADING) {
  64125. samplersList.push("txColorTransform");
  64126. }
  64127. };
  64128. /**
  64129. * Prepare the list of defines associated to the shader.
  64130. * @param defines the list of defines to complete
  64131. * @param forPostProcess Define if we are currently in post process mode or not
  64132. */
  64133. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  64134. if (forPostProcess === void 0) { forPostProcess = false; }
  64135. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  64136. defines.VIGNETTE = false;
  64137. defines.TONEMAPPING = false;
  64138. defines.TONEMAPPING_ACES = false;
  64139. defines.CONTRAST = false;
  64140. defines.EXPOSURE = false;
  64141. defines.COLORCURVES = false;
  64142. defines.COLORGRADING = false;
  64143. defines.COLORGRADING3D = false;
  64144. defines.IMAGEPROCESSING = false;
  64145. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  64146. return;
  64147. }
  64148. defines.VIGNETTE = this.vignetteEnabled;
  64149. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  64150. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  64151. defines.TONEMAPPING = this.toneMappingEnabled;
  64152. switch (this._toneMappingType) {
  64153. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  64154. defines.TONEMAPPING_ACES = true;
  64155. break;
  64156. default:
  64157. defines.TONEMAPPING_ACES = false;
  64158. break;
  64159. }
  64160. defines.CONTRAST = (this.contrast !== 1.0);
  64161. defines.EXPOSURE = (this.exposure !== 1.0);
  64162. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  64163. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  64164. if (defines.COLORGRADING) {
  64165. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  64166. }
  64167. else {
  64168. defines.COLORGRADING3D = false;
  64169. }
  64170. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  64171. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  64172. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  64173. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  64174. };
  64175. /**
  64176. * Returns true if all the image processing information are ready.
  64177. * @returns True if ready, otherwise, false
  64178. */
  64179. ImageProcessingConfiguration.prototype.isReady = function () {
  64180. // Color Grading texure can not be none blocking.
  64181. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  64182. };
  64183. /**
  64184. * Binds the image processing to the shader.
  64185. * @param effect The effect to bind to
  64186. * @param aspectRatio Define the current aspect ratio of the effect
  64187. */
  64188. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  64189. if (aspectRatio === void 0) { aspectRatio = 1; }
  64190. // Color Curves
  64191. if (this._colorCurvesEnabled && this.colorCurves) {
  64192. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  64193. }
  64194. // Vignette
  64195. if (this._vignetteEnabled) {
  64196. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  64197. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  64198. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  64199. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  64200. var vignetteScaleX = vignetteScaleY * aspectRatio;
  64201. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  64202. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  64203. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  64204. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  64205. var vignettePower = -2.0 * this.vignetteWeight;
  64206. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  64207. }
  64208. // Exposure
  64209. effect.setFloat("exposureLinear", this.exposure);
  64210. // Contrast
  64211. effect.setFloat("contrast", this.contrast);
  64212. // Color transform settings
  64213. if (this.colorGradingTexture) {
  64214. effect.setTexture("txColorTransform", this.colorGradingTexture);
  64215. var textureSize = this.colorGradingTexture.getSize().height;
  64216. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  64217. 0.5 / textureSize, // textureOffset
  64218. textureSize, // textureSize
  64219. this.colorGradingTexture.level // weight
  64220. );
  64221. }
  64222. };
  64223. /**
  64224. * Clones the current image processing instance.
  64225. * @return The cloned image processing
  64226. */
  64227. ImageProcessingConfiguration.prototype.clone = function () {
  64228. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  64229. };
  64230. /**
  64231. * Serializes the current image processing instance to a json representation.
  64232. * @return a JSON representation
  64233. */
  64234. ImageProcessingConfiguration.prototype.serialize = function () {
  64235. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64236. };
  64237. /**
  64238. * Parses the image processing from a json representation.
  64239. * @param source the JSON source to parse
  64240. * @return The parsed image processing
  64241. */
  64242. ImageProcessingConfiguration.Parse = function (source) {
  64243. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  64244. };
  64245. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  64246. /**
  64247. * Used to apply the vignette as a mix with the pixel color.
  64248. */
  64249. get: function () {
  64250. return this._VIGNETTEMODE_MULTIPLY;
  64251. },
  64252. enumerable: true,
  64253. configurable: true
  64254. });
  64255. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  64256. /**
  64257. * Used to apply the vignette as a replacement of the pixel color.
  64258. */
  64259. get: function () {
  64260. return this._VIGNETTEMODE_OPAQUE;
  64261. },
  64262. enumerable: true,
  64263. configurable: true
  64264. });
  64265. /**
  64266. * Default tone mapping applied in BabylonJS.
  64267. */
  64268. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  64269. /**
  64270. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  64271. * to other engines rendering to increase portability.
  64272. */
  64273. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  64274. // Static constants associated to the image processing.
  64275. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  64276. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  64277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  64279. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  64280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64282. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  64283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  64285. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  64286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64288. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  64289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64291. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  64292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64294. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  64295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64297. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  64298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64300. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  64301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64303. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  64304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64306. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  64307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64309. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  64310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64312. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  64313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64315. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  64316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64318. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  64319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  64321. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  64322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64324. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  64325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64327. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  64328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64330. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  64331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64333. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  64334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64336. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  64337. return ImageProcessingConfiguration;
  64338. }());
  64339. // References the dependencies.
  64340. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  64341. /***/ }),
  64342. /***/ "./Materials/index.ts":
  64343. /*!****************************!*\
  64344. !*** ./Materials/index.ts ***!
  64345. \****************************/
  64346. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, MultiviewRenderTarget, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, EquiRectangularCubeTexture, HDRCubeTexture, DummyInternalTextureTracker, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  64347. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64348. "use strict";
  64349. __webpack_require__.r(__webpack_exports__);
  64350. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  64351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  64352. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  64353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  64354. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  64356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  64357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  64358. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  64359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  64360. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  64361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  64362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  64363. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  64364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  64365. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  64366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  64367. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  64369. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  64370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  64371. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  64372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  64373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  64374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  64375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  64376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  64377. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  64378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  64379. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  64380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  64381. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  64382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  64383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  64384. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  64385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  64386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  64387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  64388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  64389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  64390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  64391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiviewRenderTarget"]; });
  64392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  64393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  64394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  64395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["EquiRectangularCubeTexture"]; });
  64396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  64397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  64398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  64399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  64400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  64401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  64402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  64403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  64404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  64405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  64406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  64407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  64408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  64409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  64410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  64411. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  64412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  64413. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  64414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  64415. /***/ }),
  64416. /***/ "./Materials/material.ts":
  64417. /*!*******************************!*\
  64418. !*** ./Materials/material.ts ***!
  64419. \*******************************/
  64420. /*! exports provided: Material */
  64421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64422. "use strict";
  64423. __webpack_require__.r(__webpack_exports__);
  64424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  64425. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64426. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64427. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  64428. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  64429. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64430. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  64431. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  64432. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  64433. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64434. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  64435. /**
  64436. * Base class for the main features of a material in Babylon.js
  64437. */
  64438. var Material = /** @class */ (function () {
  64439. /**
  64440. * Creates a material instance
  64441. * @param name defines the name of the material
  64442. * @param scene defines the scene to reference
  64443. * @param doNotAdd specifies if the material should be added to the scene
  64444. */
  64445. function Material(name, scene, doNotAdd) {
  64446. /**
  64447. * Gets or sets user defined metadata
  64448. */
  64449. this.metadata = null;
  64450. /**
  64451. * For internal use only. Please do not use.
  64452. */
  64453. this.reservedDataStore = null;
  64454. /**
  64455. * Specifies if the ready state should be checked on each call
  64456. */
  64457. this.checkReadyOnEveryCall = false;
  64458. /**
  64459. * Specifies if the ready state should be checked once
  64460. */
  64461. this.checkReadyOnlyOnce = false;
  64462. /**
  64463. * The state of the material
  64464. */
  64465. this.state = "";
  64466. /**
  64467. * The alpha value of the material
  64468. */
  64469. this._alpha = 1.0;
  64470. /**
  64471. * Specifies if back face culling is enabled
  64472. */
  64473. this._backFaceCulling = true;
  64474. /**
  64475. * Specifies if the material should be serialized
  64476. */
  64477. this.doNotSerialize = false;
  64478. /**
  64479. * @hidden
  64480. */
  64481. this._storeEffectOnSubMeshes = false;
  64482. /**
  64483. * An event triggered when the material is disposed
  64484. */
  64485. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64486. /**
  64487. * Stores the value of the alpha mode
  64488. */
  64489. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  64490. /**
  64491. * Stores the state of the need depth pre-pass value
  64492. */
  64493. this._needDepthPrePass = false;
  64494. /**
  64495. * Specifies if depth writing should be disabled
  64496. */
  64497. this.disableDepthWrite = false;
  64498. /**
  64499. * Specifies if depth writing should be forced
  64500. */
  64501. this.forceDepthWrite = false;
  64502. /**
  64503. * Specifies if there should be a separate pass for culling
  64504. */
  64505. this.separateCullingPass = false;
  64506. /**
  64507. * Stores the state specifing if fog should be enabled
  64508. */
  64509. this._fogEnabled = true;
  64510. /**
  64511. * Stores the size of points
  64512. */
  64513. this.pointSize = 1.0;
  64514. /**
  64515. * Stores the z offset value
  64516. */
  64517. this.zOffset = 0;
  64518. /**
  64519. * @hidden
  64520. * Specifies if the material was previously ready
  64521. */
  64522. this._wasPreviouslyReady = false;
  64523. /**
  64524. * Stores the fill mode state
  64525. */
  64526. this._fillMode = Material.TriangleFillMode;
  64527. /** @hidden */
  64528. this._indexInSceneMaterialArray = -1;
  64529. this.name = name;
  64530. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  64531. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  64532. this.uniqueId = this._scene.getUniqueId();
  64533. if (this._scene.useRightHandedSystem) {
  64534. this.sideOrientation = Material.ClockWiseSideOrientation;
  64535. }
  64536. else {
  64537. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  64538. }
  64539. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  64540. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  64541. if (!doNotAdd) {
  64542. this._scene.addMaterial(this);
  64543. }
  64544. if (this._scene.useMaterialMeshMap) {
  64545. this.meshMap = {};
  64546. }
  64547. }
  64548. Object.defineProperty(Material.prototype, "alpha", {
  64549. /**
  64550. * Gets the alpha value of the material
  64551. */
  64552. get: function () {
  64553. return this._alpha;
  64554. },
  64555. /**
  64556. * Sets the alpha value of the material
  64557. */
  64558. set: function (value) {
  64559. if (this._alpha === value) {
  64560. return;
  64561. }
  64562. this._alpha = value;
  64563. this.markAsDirty(Material.MiscDirtyFlag);
  64564. },
  64565. enumerable: true,
  64566. configurable: true
  64567. });
  64568. Object.defineProperty(Material.prototype, "backFaceCulling", {
  64569. /**
  64570. * Gets the back-face culling state
  64571. */
  64572. get: function () {
  64573. return this._backFaceCulling;
  64574. },
  64575. /**
  64576. * Sets the back-face culling state
  64577. */
  64578. set: function (value) {
  64579. if (this._backFaceCulling === value) {
  64580. return;
  64581. }
  64582. this._backFaceCulling = value;
  64583. this.markAsDirty(Material.TextureDirtyFlag);
  64584. },
  64585. enumerable: true,
  64586. configurable: true
  64587. });
  64588. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  64589. /**
  64590. * Gets a boolean indicating that current material needs to register RTT
  64591. */
  64592. get: function () {
  64593. return false;
  64594. },
  64595. enumerable: true,
  64596. configurable: true
  64597. });
  64598. Object.defineProperty(Material.prototype, "onDispose", {
  64599. /**
  64600. * Called during a dispose event
  64601. */
  64602. set: function (callback) {
  64603. if (this._onDisposeObserver) {
  64604. this.onDisposeObservable.remove(this._onDisposeObserver);
  64605. }
  64606. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  64607. },
  64608. enumerable: true,
  64609. configurable: true
  64610. });
  64611. Object.defineProperty(Material.prototype, "onBindObservable", {
  64612. /**
  64613. * An event triggered when the material is bound
  64614. */
  64615. get: function () {
  64616. if (!this._onBindObservable) {
  64617. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64618. }
  64619. return this._onBindObservable;
  64620. },
  64621. enumerable: true,
  64622. configurable: true
  64623. });
  64624. Object.defineProperty(Material.prototype, "onBind", {
  64625. /**
  64626. * Called during a bind event
  64627. */
  64628. set: function (callback) {
  64629. if (this._onBindObserver) {
  64630. this.onBindObservable.remove(this._onBindObserver);
  64631. }
  64632. this._onBindObserver = this.onBindObservable.add(callback);
  64633. },
  64634. enumerable: true,
  64635. configurable: true
  64636. });
  64637. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  64638. /**
  64639. * An event triggered when the material is unbound
  64640. */
  64641. get: function () {
  64642. if (!this._onUnBindObservable) {
  64643. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64644. }
  64645. return this._onUnBindObservable;
  64646. },
  64647. enumerable: true,
  64648. configurable: true
  64649. });
  64650. Object.defineProperty(Material.prototype, "alphaMode", {
  64651. /**
  64652. * Gets the value of the alpha mode
  64653. */
  64654. get: function () {
  64655. return this._alphaMode;
  64656. },
  64657. /**
  64658. * Sets the value of the alpha mode.
  64659. *
  64660. * | Value | Type | Description |
  64661. * | --- | --- | --- |
  64662. * | 0 | ALPHA_DISABLE | |
  64663. * | 1 | ALPHA_ADD | |
  64664. * | 2 | ALPHA_COMBINE | |
  64665. * | 3 | ALPHA_SUBTRACT | |
  64666. * | 4 | ALPHA_MULTIPLY | |
  64667. * | 5 | ALPHA_MAXIMIZED | |
  64668. * | 6 | ALPHA_ONEONE | |
  64669. * | 7 | ALPHA_PREMULTIPLIED | |
  64670. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  64671. * | 9 | ALPHA_INTERPOLATE | |
  64672. * | 10 | ALPHA_SCREENMODE | |
  64673. *
  64674. */
  64675. set: function (value) {
  64676. if (this._alphaMode === value) {
  64677. return;
  64678. }
  64679. this._alphaMode = value;
  64680. this.markAsDirty(Material.TextureDirtyFlag);
  64681. },
  64682. enumerable: true,
  64683. configurable: true
  64684. });
  64685. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  64686. /**
  64687. * Gets the depth pre-pass value
  64688. */
  64689. get: function () {
  64690. return this._needDepthPrePass;
  64691. },
  64692. /**
  64693. * Sets the need depth pre-pass value
  64694. */
  64695. set: function (value) {
  64696. if (this._needDepthPrePass === value) {
  64697. return;
  64698. }
  64699. this._needDepthPrePass = value;
  64700. if (this._needDepthPrePass) {
  64701. this.checkReadyOnEveryCall = true;
  64702. }
  64703. },
  64704. enumerable: true,
  64705. configurable: true
  64706. });
  64707. Object.defineProperty(Material.prototype, "fogEnabled", {
  64708. /**
  64709. * Gets the value of the fog enabled state
  64710. */
  64711. get: function () {
  64712. return this._fogEnabled;
  64713. },
  64714. /**
  64715. * Sets the state for enabling fog
  64716. */
  64717. set: function (value) {
  64718. if (this._fogEnabled === value) {
  64719. return;
  64720. }
  64721. this._fogEnabled = value;
  64722. this.markAsDirty(Material.MiscDirtyFlag);
  64723. },
  64724. enumerable: true,
  64725. configurable: true
  64726. });
  64727. Object.defineProperty(Material.prototype, "wireframe", {
  64728. /**
  64729. * Gets a value specifying if wireframe mode is enabled
  64730. */
  64731. get: function () {
  64732. switch (this._fillMode) {
  64733. case Material.WireFrameFillMode:
  64734. case Material.LineListDrawMode:
  64735. case Material.LineLoopDrawMode:
  64736. case Material.LineStripDrawMode:
  64737. return true;
  64738. }
  64739. return this._scene.forceWireframe;
  64740. },
  64741. /**
  64742. * Sets the state of wireframe mode
  64743. */
  64744. set: function (value) {
  64745. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  64746. },
  64747. enumerable: true,
  64748. configurable: true
  64749. });
  64750. Object.defineProperty(Material.prototype, "pointsCloud", {
  64751. /**
  64752. * Gets the value specifying if point clouds are enabled
  64753. */
  64754. get: function () {
  64755. switch (this._fillMode) {
  64756. case Material.PointFillMode:
  64757. case Material.PointListDrawMode:
  64758. return true;
  64759. }
  64760. return this._scene.forcePointsCloud;
  64761. },
  64762. /**
  64763. * Sets the state of point cloud mode
  64764. */
  64765. set: function (value) {
  64766. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  64767. },
  64768. enumerable: true,
  64769. configurable: true
  64770. });
  64771. Object.defineProperty(Material.prototype, "fillMode", {
  64772. /**
  64773. * Gets the material fill mode
  64774. */
  64775. get: function () {
  64776. return this._fillMode;
  64777. },
  64778. /**
  64779. * Sets the material fill mode
  64780. */
  64781. set: function (value) {
  64782. if (this._fillMode === value) {
  64783. return;
  64784. }
  64785. this._fillMode = value;
  64786. this.markAsDirty(Material.MiscDirtyFlag);
  64787. },
  64788. enumerable: true,
  64789. configurable: true
  64790. });
  64791. /**
  64792. * Returns a string representation of the current material
  64793. * @param fullDetails defines a boolean indicating which levels of logging is desired
  64794. * @returns a string with material information
  64795. */
  64796. Material.prototype.toString = function (fullDetails) {
  64797. var ret = "Name: " + this.name;
  64798. if (fullDetails) {
  64799. }
  64800. return ret;
  64801. };
  64802. /**
  64803. * Gets the class name of the material
  64804. * @returns a string with the class name of the material
  64805. */
  64806. Material.prototype.getClassName = function () {
  64807. return "Material";
  64808. };
  64809. Object.defineProperty(Material.prototype, "isFrozen", {
  64810. /**
  64811. * Specifies if updates for the material been locked
  64812. */
  64813. get: function () {
  64814. return this.checkReadyOnlyOnce;
  64815. },
  64816. enumerable: true,
  64817. configurable: true
  64818. });
  64819. /**
  64820. * Locks updates for the material
  64821. */
  64822. Material.prototype.freeze = function () {
  64823. this.checkReadyOnlyOnce = true;
  64824. };
  64825. /**
  64826. * Unlocks updates for the material
  64827. */
  64828. Material.prototype.unfreeze = function () {
  64829. this.checkReadyOnlyOnce = false;
  64830. };
  64831. /**
  64832. * Specifies if the material is ready to be used
  64833. * @param mesh defines the mesh to check
  64834. * @param useInstances specifies if instances should be used
  64835. * @returns a boolean indicating if the material is ready to be used
  64836. */
  64837. Material.prototype.isReady = function (mesh, useInstances) {
  64838. return true;
  64839. };
  64840. /**
  64841. * Specifies that the submesh is ready to be used
  64842. * @param mesh defines the mesh to check
  64843. * @param subMesh defines which submesh to check
  64844. * @param useInstances specifies that instances should be used
  64845. * @returns a boolean indicating that the submesh is ready or not
  64846. */
  64847. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64848. return false;
  64849. };
  64850. /**
  64851. * Returns the material effect
  64852. * @returns the effect associated with the material
  64853. */
  64854. Material.prototype.getEffect = function () {
  64855. return this._effect;
  64856. };
  64857. /**
  64858. * Returns the current scene
  64859. * @returns a Scene
  64860. */
  64861. Material.prototype.getScene = function () {
  64862. return this._scene;
  64863. };
  64864. /**
  64865. * Specifies if the material will require alpha blending
  64866. * @returns a boolean specifying if alpha blending is needed
  64867. */
  64868. Material.prototype.needAlphaBlending = function () {
  64869. return (this.alpha < 1.0);
  64870. };
  64871. /**
  64872. * Specifies if the mesh will require alpha blending
  64873. * @param mesh defines the mesh to check
  64874. * @returns a boolean specifying if alpha blending is needed for the mesh
  64875. */
  64876. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  64877. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  64878. };
  64879. /**
  64880. * Specifies if this material should be rendered in alpha test mode
  64881. * @returns a boolean specifying if an alpha test is needed.
  64882. */
  64883. Material.prototype.needAlphaTesting = function () {
  64884. return false;
  64885. };
  64886. /**
  64887. * Gets the texture used for the alpha test
  64888. * @returns the texture to use for alpha testing
  64889. */
  64890. Material.prototype.getAlphaTestTexture = function () {
  64891. return null;
  64892. };
  64893. /**
  64894. * Marks the material to indicate that it needs to be re-calculated
  64895. */
  64896. Material.prototype.markDirty = function () {
  64897. this._wasPreviouslyReady = false;
  64898. };
  64899. /** @hidden */
  64900. Material.prototype._preBind = function (effect, overrideOrientation) {
  64901. if (overrideOrientation === void 0) { overrideOrientation = null; }
  64902. var engine = this._scene.getEngine();
  64903. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  64904. var reverse = orientation === Material.ClockWiseSideOrientation;
  64905. engine.enableEffect(effect ? effect : this._effect);
  64906. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  64907. return reverse;
  64908. };
  64909. /**
  64910. * Binds the material to the mesh
  64911. * @param world defines the world transformation matrix
  64912. * @param mesh defines the mesh to bind the material to
  64913. */
  64914. Material.prototype.bind = function (world, mesh) {
  64915. };
  64916. /**
  64917. * Binds the submesh to the material
  64918. * @param world defines the world transformation matrix
  64919. * @param mesh defines the mesh containing the submesh
  64920. * @param subMesh defines the submesh to bind the material to
  64921. */
  64922. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  64923. };
  64924. /**
  64925. * Binds the world matrix to the material
  64926. * @param world defines the world transformation matrix
  64927. */
  64928. Material.prototype.bindOnlyWorldMatrix = function (world) {
  64929. };
  64930. /**
  64931. * Binds the scene's uniform buffer to the effect.
  64932. * @param effect defines the effect to bind to the scene uniform buffer
  64933. * @param sceneUbo defines the uniform buffer storing scene data
  64934. */
  64935. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  64936. sceneUbo.bindToEffect(effect, "Scene");
  64937. };
  64938. /**
  64939. * Binds the view matrix to the effect
  64940. * @param effect defines the effect to bind the view matrix to
  64941. */
  64942. Material.prototype.bindView = function (effect) {
  64943. if (!this._useUBO) {
  64944. effect.setMatrix("view", this.getScene().getViewMatrix());
  64945. }
  64946. else {
  64947. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  64948. }
  64949. };
  64950. /**
  64951. * Binds the view projection matrix to the effect
  64952. * @param effect defines the effect to bind the view projection matrix to
  64953. */
  64954. Material.prototype.bindViewProjection = function (effect) {
  64955. if (!this._useUBO) {
  64956. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64957. }
  64958. else {
  64959. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  64960. }
  64961. };
  64962. /**
  64963. * Specifies if material alpha testing should be turned on for the mesh
  64964. * @param mesh defines the mesh to check
  64965. */
  64966. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  64967. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  64968. };
  64969. /**
  64970. * Processes to execute after binding the material to a mesh
  64971. * @param mesh defines the rendered mesh
  64972. */
  64973. Material.prototype._afterBind = function (mesh) {
  64974. this._scene._cachedMaterial = this;
  64975. if (mesh) {
  64976. this._scene._cachedVisibility = mesh.visibility;
  64977. }
  64978. else {
  64979. this._scene._cachedVisibility = 1;
  64980. }
  64981. if (this._onBindObservable && mesh) {
  64982. this._onBindObservable.notifyObservers(mesh);
  64983. }
  64984. if (this.disableDepthWrite) {
  64985. var engine = this._scene.getEngine();
  64986. this._cachedDepthWriteState = engine.getDepthWrite();
  64987. engine.setDepthWrite(false);
  64988. }
  64989. };
  64990. /**
  64991. * Unbinds the material from the mesh
  64992. */
  64993. Material.prototype.unbind = function () {
  64994. if (this._onUnBindObservable) {
  64995. this._onUnBindObservable.notifyObservers(this);
  64996. }
  64997. if (this.disableDepthWrite) {
  64998. var engine = this._scene.getEngine();
  64999. engine.setDepthWrite(this._cachedDepthWriteState);
  65000. }
  65001. };
  65002. /**
  65003. * Gets the active textures from the material
  65004. * @returns an array of textures
  65005. */
  65006. Material.prototype.getActiveTextures = function () {
  65007. return [];
  65008. };
  65009. /**
  65010. * Specifies if the material uses a texture
  65011. * @param texture defines the texture to check against the material
  65012. * @returns a boolean specifying if the material uses the texture
  65013. */
  65014. Material.prototype.hasTexture = function (texture) {
  65015. return false;
  65016. };
  65017. /**
  65018. * Makes a duplicate of the material, and gives it a new name
  65019. * @param name defines the new name for the duplicated material
  65020. * @returns the cloned material
  65021. */
  65022. Material.prototype.clone = function (name) {
  65023. return null;
  65024. };
  65025. /**
  65026. * Gets the meshes bound to the material
  65027. * @returns an array of meshes bound to the material
  65028. */
  65029. Material.prototype.getBindedMeshes = function () {
  65030. var _this = this;
  65031. if (this.meshMap) {
  65032. var result = new Array();
  65033. for (var meshId in this.meshMap) {
  65034. var mesh = this.meshMap[meshId];
  65035. if (mesh) {
  65036. result.push(mesh);
  65037. }
  65038. }
  65039. return result;
  65040. }
  65041. else {
  65042. var meshes = this._scene.meshes;
  65043. return meshes.filter(function (mesh) { return mesh.material === _this; });
  65044. }
  65045. };
  65046. /**
  65047. * Force shader compilation
  65048. * @param mesh defines the mesh associated with this material
  65049. * @param onCompiled defines a function to execute once the material is compiled
  65050. * @param options defines the options to configure the compilation
  65051. */
  65052. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  65053. var _this = this;
  65054. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  65055. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  65056. var scene = this.getScene();
  65057. var checkReady = function () {
  65058. if (!_this._scene || !_this._scene.getEngine()) {
  65059. return;
  65060. }
  65061. if (subMesh._materialDefines) {
  65062. subMesh._materialDefines._renderId = -1;
  65063. }
  65064. var clipPlaneState = scene.clipPlane;
  65065. if (localOptions.clipPlane) {
  65066. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  65067. }
  65068. if (_this._storeEffectOnSubMeshes) {
  65069. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  65070. if (onCompiled) {
  65071. onCompiled(_this);
  65072. }
  65073. }
  65074. else {
  65075. setTimeout(checkReady, 16);
  65076. }
  65077. }
  65078. else {
  65079. if (_this.isReady()) {
  65080. if (onCompiled) {
  65081. onCompiled(_this);
  65082. }
  65083. }
  65084. else {
  65085. setTimeout(checkReady, 16);
  65086. }
  65087. }
  65088. if (localOptions.clipPlane) {
  65089. scene.clipPlane = clipPlaneState;
  65090. }
  65091. };
  65092. checkReady();
  65093. };
  65094. /**
  65095. * Force shader compilation
  65096. * @param mesh defines the mesh that will use this material
  65097. * @param options defines additional options for compiling the shaders
  65098. * @returns a promise that resolves when the compilation completes
  65099. */
  65100. Material.prototype.forceCompilationAsync = function (mesh, options) {
  65101. var _this = this;
  65102. return new Promise(function (resolve) {
  65103. _this.forceCompilation(mesh, function () {
  65104. resolve();
  65105. }, options);
  65106. });
  65107. };
  65108. /**
  65109. * Marks a define in the material to indicate that it needs to be re-computed
  65110. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  65111. */
  65112. Material.prototype.markAsDirty = function (flag) {
  65113. if (this.getScene().blockMaterialDirtyMechanism) {
  65114. return;
  65115. }
  65116. Material._DirtyCallbackArray.length = 0;
  65117. if (flag & Material.TextureDirtyFlag) {
  65118. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  65119. }
  65120. if (flag & Material.LightDirtyFlag) {
  65121. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  65122. }
  65123. if (flag & Material.FresnelDirtyFlag) {
  65124. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  65125. }
  65126. if (flag & Material.AttributesDirtyFlag) {
  65127. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  65128. }
  65129. if (flag & Material.MiscDirtyFlag) {
  65130. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  65131. }
  65132. if (Material._DirtyCallbackArray.length) {
  65133. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  65134. }
  65135. this.getScene().resetCachedMaterial();
  65136. };
  65137. /**
  65138. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  65139. * @param func defines a function which checks material defines against the submeshes
  65140. */
  65141. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  65142. if (this.getScene().blockMaterialDirtyMechanism) {
  65143. return;
  65144. }
  65145. var meshes = this.getScene().meshes;
  65146. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  65147. var mesh = meshes_1[_i];
  65148. if (!mesh.subMeshes) {
  65149. continue;
  65150. }
  65151. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  65152. var subMesh = _b[_a];
  65153. if (subMesh.getMaterial() !== this) {
  65154. continue;
  65155. }
  65156. if (!subMesh._materialDefines) {
  65157. continue;
  65158. }
  65159. func(subMesh._materialDefines);
  65160. }
  65161. }
  65162. };
  65163. /**
  65164. * Indicates that image processing needs to be re-calculated for all submeshes
  65165. */
  65166. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  65167. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  65168. };
  65169. /**
  65170. * Indicates that textures need to be re-calculated for all submeshes
  65171. */
  65172. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  65173. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  65174. };
  65175. /**
  65176. * Indicates that fresnel needs to be re-calculated for all submeshes
  65177. */
  65178. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  65179. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  65180. };
  65181. /**
  65182. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  65183. */
  65184. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  65185. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  65186. };
  65187. /**
  65188. * Indicates that lights need to be re-calculated for all submeshes
  65189. */
  65190. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  65191. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  65192. };
  65193. /**
  65194. * Indicates that attributes need to be re-calculated for all submeshes
  65195. */
  65196. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  65197. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  65198. };
  65199. /**
  65200. * Indicates that misc needs to be re-calculated for all submeshes
  65201. */
  65202. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  65203. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  65204. };
  65205. /**
  65206. * Indicates that textures and misc need to be re-calculated for all submeshes
  65207. */
  65208. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  65209. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  65210. };
  65211. /**
  65212. * Disposes the material
  65213. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  65214. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  65215. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  65216. */
  65217. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  65218. var scene = this.getScene();
  65219. // Animations
  65220. scene.stopAnimation(this);
  65221. scene.freeProcessedMaterials();
  65222. // Remove from scene
  65223. scene.removeMaterial(this);
  65224. if (notBoundToMesh !== true) {
  65225. // Remove from meshes
  65226. if (this.meshMap) {
  65227. for (var meshId in this.meshMap) {
  65228. var mesh = this.meshMap[meshId];
  65229. if (mesh) {
  65230. mesh.material = null; // will set the entry in the map to undefined
  65231. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  65232. }
  65233. }
  65234. }
  65235. else {
  65236. var meshes = scene.meshes;
  65237. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  65238. var mesh = meshes_2[_i];
  65239. if (mesh.material === this) {
  65240. mesh.material = null;
  65241. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  65242. }
  65243. }
  65244. }
  65245. }
  65246. this._uniformBuffer.dispose();
  65247. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  65248. if (forceDisposeEffect && this._effect) {
  65249. if (!this._storeEffectOnSubMeshes) {
  65250. scene.getEngine()._releaseEffect(this._effect);
  65251. }
  65252. this._effect = null;
  65253. }
  65254. // Callback
  65255. this.onDisposeObservable.notifyObservers(this);
  65256. this.onDisposeObservable.clear();
  65257. if (this._onBindObservable) {
  65258. this._onBindObservable.clear();
  65259. }
  65260. if (this._onUnBindObservable) {
  65261. this._onUnBindObservable.clear();
  65262. }
  65263. };
  65264. /** @hidden */
  65265. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  65266. if (mesh.geometry) {
  65267. var geometry = (mesh.geometry);
  65268. var scene = this.getScene();
  65269. if (this._storeEffectOnSubMeshes) {
  65270. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  65271. var subMesh = _a[_i];
  65272. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  65273. if (forceDisposeEffect && subMesh._materialEffect) {
  65274. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  65275. }
  65276. }
  65277. }
  65278. else {
  65279. geometry._releaseVertexArrayObject(this._effect);
  65280. }
  65281. }
  65282. };
  65283. /**
  65284. * Serializes this material
  65285. * @returns the serialized material object
  65286. */
  65287. Material.prototype.serialize = function () {
  65288. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65289. };
  65290. /**
  65291. * Creates a material from parsed material data
  65292. * @param parsedMaterial defines parsed material data
  65293. * @param scene defines the hosting scene
  65294. * @param rootUrl defines the root URL to use to load textures
  65295. * @returns a new material
  65296. */
  65297. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  65298. if (!parsedMaterial.customType) {
  65299. parsedMaterial.customType = "BABYLON.StandardMaterial";
  65300. }
  65301. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  65302. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  65303. if (!BABYLON.LegacyPBRMaterial) {
  65304. _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.");
  65305. return;
  65306. }
  65307. }
  65308. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  65309. return materialType.Parse(parsedMaterial, scene, rootUrl);
  65310. };
  65311. /**
  65312. * Returns the triangle fill mode
  65313. */
  65314. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  65315. /**
  65316. * Returns the wireframe mode
  65317. */
  65318. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  65319. /**
  65320. * Returns the point fill mode
  65321. */
  65322. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  65323. /**
  65324. * Returns the point list draw mode
  65325. */
  65326. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  65327. /**
  65328. * Returns the line list draw mode
  65329. */
  65330. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  65331. /**
  65332. * Returns the line loop draw mode
  65333. */
  65334. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  65335. /**
  65336. * Returns the line strip draw mode
  65337. */
  65338. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  65339. /**
  65340. * Returns the triangle strip draw mode
  65341. */
  65342. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  65343. /**
  65344. * Returns the triangle fan draw mode
  65345. */
  65346. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  65347. /**
  65348. * Stores the clock-wise side orientation
  65349. */
  65350. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  65351. /**
  65352. * Stores the counter clock-wise side orientation
  65353. */
  65354. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  65355. /**
  65356. * The dirty texture flag value
  65357. */
  65358. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  65359. /**
  65360. * The dirty light flag value
  65361. */
  65362. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  65363. /**
  65364. * The dirty fresnel flag value
  65365. */
  65366. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  65367. /**
  65368. * The dirty attribute flag value
  65369. */
  65370. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  65371. /**
  65372. * The dirty misc flag value
  65373. */
  65374. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  65375. /**
  65376. * The all dirty flag value
  65377. */
  65378. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  65379. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  65380. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  65381. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  65382. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  65383. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  65384. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  65385. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  65386. Material._FresnelDirtyCallBack(defines);
  65387. Material._MiscDirtyCallBack(defines);
  65388. };
  65389. Material._TextureAndMiscDirtyCallBack = function (defines) {
  65390. Material._TextureDirtyCallBack(defines);
  65391. Material._MiscDirtyCallBack(defines);
  65392. };
  65393. Material._DirtyCallbackArray = [];
  65394. Material._RunDirtyCallBacks = function (defines) {
  65395. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  65396. var cb = _a[_i];
  65397. cb(defines);
  65398. }
  65399. };
  65400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65402. ], Material.prototype, "id", void 0);
  65403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65405. ], Material.prototype, "uniqueId", void 0);
  65406. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65407. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65408. ], Material.prototype, "name", void 0);
  65409. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65410. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65411. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  65412. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65413. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65414. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  65415. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65417. ], Material.prototype, "state", void 0);
  65418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  65420. ], Material.prototype, "_alpha", void 0);
  65421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  65423. ], Material.prototype, "_backFaceCulling", void 0);
  65424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65426. ], Material.prototype, "sideOrientation", void 0);
  65427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  65429. ], Material.prototype, "_alphaMode", void 0);
  65430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65432. ], Material.prototype, "_needDepthPrePass", void 0);
  65433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65435. ], Material.prototype, "disableDepthWrite", void 0);
  65436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65438. ], Material.prototype, "forceDepthWrite", void 0);
  65439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65441. ], Material.prototype, "separateCullingPass", void 0);
  65442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  65444. ], Material.prototype, "_fogEnabled", void 0);
  65445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65447. ], Material.prototype, "pointSize", void 0);
  65448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65450. ], Material.prototype, "zOffset", void 0);
  65451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65453. ], Material.prototype, "wireframe", null);
  65454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65456. ], Material.prototype, "pointsCloud", null);
  65457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65459. ], Material.prototype, "fillMode", null);
  65460. return Material;
  65461. }());
  65462. /***/ }),
  65463. /***/ "./Materials/materialDefines.ts":
  65464. /*!**************************************!*\
  65465. !*** ./Materials/materialDefines.ts ***!
  65466. \**************************************/
  65467. /*! exports provided: MaterialDefines */
  65468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65469. "use strict";
  65470. __webpack_require__.r(__webpack_exports__);
  65471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  65472. /**
  65473. * Manages the defines for the Material
  65474. */
  65475. var MaterialDefines = /** @class */ (function () {
  65476. function MaterialDefines() {
  65477. this._isDirty = true;
  65478. /** @hidden */
  65479. this._areLightsDirty = true;
  65480. /** @hidden */
  65481. this._areAttributesDirty = true;
  65482. /** @hidden */
  65483. this._areTexturesDirty = true;
  65484. /** @hidden */
  65485. this._areFresnelDirty = true;
  65486. /** @hidden */
  65487. this._areMiscDirty = true;
  65488. /** @hidden */
  65489. this._areImageProcessingDirty = true;
  65490. /** @hidden */
  65491. this._normals = false;
  65492. /** @hidden */
  65493. this._uvs = false;
  65494. /** @hidden */
  65495. this._needNormals = false;
  65496. /** @hidden */
  65497. this._needUVs = false;
  65498. }
  65499. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  65500. /**
  65501. * Specifies if the material needs to be re-calculated
  65502. */
  65503. get: function () {
  65504. return this._isDirty;
  65505. },
  65506. enumerable: true,
  65507. configurable: true
  65508. });
  65509. /**
  65510. * Marks the material to indicate that it has been re-calculated
  65511. */
  65512. MaterialDefines.prototype.markAsProcessed = function () {
  65513. this._isDirty = false;
  65514. this._areAttributesDirty = false;
  65515. this._areTexturesDirty = false;
  65516. this._areFresnelDirty = false;
  65517. this._areLightsDirty = false;
  65518. this._areMiscDirty = false;
  65519. this._areImageProcessingDirty = false;
  65520. };
  65521. /**
  65522. * Marks the material to indicate that it needs to be re-calculated
  65523. */
  65524. MaterialDefines.prototype.markAsUnprocessed = function () {
  65525. this._isDirty = true;
  65526. };
  65527. /**
  65528. * Marks the material to indicate all of its defines need to be re-calculated
  65529. */
  65530. MaterialDefines.prototype.markAllAsDirty = function () {
  65531. this._areTexturesDirty = true;
  65532. this._areAttributesDirty = true;
  65533. this._areLightsDirty = true;
  65534. this._areFresnelDirty = true;
  65535. this._areMiscDirty = true;
  65536. this._areImageProcessingDirty = true;
  65537. this._isDirty = true;
  65538. };
  65539. /**
  65540. * Marks the material to indicate that image processing needs to be re-calculated
  65541. */
  65542. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  65543. this._areImageProcessingDirty = true;
  65544. this._isDirty = true;
  65545. };
  65546. /**
  65547. * Marks the material to indicate the lights need to be re-calculated
  65548. */
  65549. MaterialDefines.prototype.markAsLightDirty = function () {
  65550. this._areLightsDirty = true;
  65551. this._isDirty = true;
  65552. };
  65553. /**
  65554. * Marks the attribute state as changed
  65555. */
  65556. MaterialDefines.prototype.markAsAttributesDirty = function () {
  65557. this._areAttributesDirty = true;
  65558. this._isDirty = true;
  65559. };
  65560. /**
  65561. * Marks the texture state as changed
  65562. */
  65563. MaterialDefines.prototype.markAsTexturesDirty = function () {
  65564. this._areTexturesDirty = true;
  65565. this._isDirty = true;
  65566. };
  65567. /**
  65568. * Marks the fresnel state as changed
  65569. */
  65570. MaterialDefines.prototype.markAsFresnelDirty = function () {
  65571. this._areFresnelDirty = true;
  65572. this._isDirty = true;
  65573. };
  65574. /**
  65575. * Marks the misc state as changed
  65576. */
  65577. MaterialDefines.prototype.markAsMiscDirty = function () {
  65578. this._areMiscDirty = true;
  65579. this._isDirty = true;
  65580. };
  65581. /**
  65582. * Rebuilds the material defines
  65583. */
  65584. MaterialDefines.prototype.rebuild = function () {
  65585. if (this._keys) {
  65586. delete this._keys;
  65587. }
  65588. this._keys = [];
  65589. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  65590. var key = _a[_i];
  65591. if (key[0] === "_") {
  65592. continue;
  65593. }
  65594. this._keys.push(key);
  65595. }
  65596. };
  65597. /**
  65598. * Specifies if two material defines are equal
  65599. * @param other - A material define instance to compare to
  65600. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65601. */
  65602. MaterialDefines.prototype.isEqual = function (other) {
  65603. if (this._keys.length !== other._keys.length) {
  65604. return false;
  65605. }
  65606. for (var index = 0; index < this._keys.length; index++) {
  65607. var prop = this._keys[index];
  65608. if (this[prop] !== other[prop]) {
  65609. return false;
  65610. }
  65611. }
  65612. return true;
  65613. };
  65614. /**
  65615. * Clones this instance's defines to another instance
  65616. * @param other - material defines to clone values to
  65617. */
  65618. MaterialDefines.prototype.cloneTo = function (other) {
  65619. if (this._keys.length !== other._keys.length) {
  65620. other._keys = this._keys.slice(0);
  65621. }
  65622. for (var index = 0; index < this._keys.length; index++) {
  65623. var prop = this._keys[index];
  65624. other[prop] = this[prop];
  65625. }
  65626. };
  65627. /**
  65628. * Resets the material define values
  65629. */
  65630. MaterialDefines.prototype.reset = function () {
  65631. for (var index = 0; index < this._keys.length; index++) {
  65632. var prop = this._keys[index];
  65633. var type = typeof this[prop];
  65634. switch (type) {
  65635. case "number":
  65636. this[prop] = 0;
  65637. break;
  65638. case "string":
  65639. this[prop] = "";
  65640. break;
  65641. default:
  65642. this[prop] = false;
  65643. break;
  65644. }
  65645. }
  65646. };
  65647. /**
  65648. * Converts the material define values to a string
  65649. * @returns - String of material define information
  65650. */
  65651. MaterialDefines.prototype.toString = function () {
  65652. var result = "";
  65653. for (var index = 0; index < this._keys.length; index++) {
  65654. var prop = this._keys[index];
  65655. var value = this[prop];
  65656. var type = typeof value;
  65657. switch (type) {
  65658. case "number":
  65659. case "string":
  65660. result += "#define " + prop + " " + value + "\n";
  65661. break;
  65662. default:
  65663. if (value) {
  65664. result += "#define " + prop + "\n";
  65665. }
  65666. break;
  65667. }
  65668. }
  65669. return result;
  65670. };
  65671. return MaterialDefines;
  65672. }());
  65673. /***/ }),
  65674. /***/ "./Materials/materialFlags.ts":
  65675. /*!************************************!*\
  65676. !*** ./Materials/materialFlags.ts ***!
  65677. \************************************/
  65678. /*! exports provided: MaterialFlags */
  65679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65680. "use strict";
  65681. __webpack_require__.r(__webpack_exports__);
  65682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  65683. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  65684. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65685. /**
  65686. * This groups all the flags used to control the materials channel.
  65687. */
  65688. var MaterialFlags = /** @class */ (function () {
  65689. function MaterialFlags() {
  65690. }
  65691. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  65692. /**
  65693. * Are diffuse textures enabled in the application.
  65694. */
  65695. get: function () {
  65696. return this._DiffuseTextureEnabled;
  65697. },
  65698. set: function (value) {
  65699. if (this._DiffuseTextureEnabled === value) {
  65700. return;
  65701. }
  65702. this._DiffuseTextureEnabled = value;
  65703. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65704. },
  65705. enumerable: true,
  65706. configurable: true
  65707. });
  65708. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  65709. /**
  65710. * Are ambient textures enabled in the application.
  65711. */
  65712. get: function () {
  65713. return this._AmbientTextureEnabled;
  65714. },
  65715. set: function (value) {
  65716. if (this._AmbientTextureEnabled === value) {
  65717. return;
  65718. }
  65719. this._AmbientTextureEnabled = value;
  65720. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65721. },
  65722. enumerable: true,
  65723. configurable: true
  65724. });
  65725. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  65726. /**
  65727. * Are opacity textures enabled in the application.
  65728. */
  65729. get: function () {
  65730. return this._OpacityTextureEnabled;
  65731. },
  65732. set: function (value) {
  65733. if (this._OpacityTextureEnabled === value) {
  65734. return;
  65735. }
  65736. this._OpacityTextureEnabled = value;
  65737. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65738. },
  65739. enumerable: true,
  65740. configurable: true
  65741. });
  65742. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  65743. /**
  65744. * Are reflection textures enabled in the application.
  65745. */
  65746. get: function () {
  65747. return this._ReflectionTextureEnabled;
  65748. },
  65749. set: function (value) {
  65750. if (this._ReflectionTextureEnabled === value) {
  65751. return;
  65752. }
  65753. this._ReflectionTextureEnabled = value;
  65754. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65755. },
  65756. enumerable: true,
  65757. configurable: true
  65758. });
  65759. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  65760. /**
  65761. * Are emissive textures enabled in the application.
  65762. */
  65763. get: function () {
  65764. return this._EmissiveTextureEnabled;
  65765. },
  65766. set: function (value) {
  65767. if (this._EmissiveTextureEnabled === value) {
  65768. return;
  65769. }
  65770. this._EmissiveTextureEnabled = value;
  65771. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65772. },
  65773. enumerable: true,
  65774. configurable: true
  65775. });
  65776. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  65777. /**
  65778. * Are specular textures enabled in the application.
  65779. */
  65780. get: function () {
  65781. return this._SpecularTextureEnabled;
  65782. },
  65783. set: function (value) {
  65784. if (this._SpecularTextureEnabled === value) {
  65785. return;
  65786. }
  65787. this._SpecularTextureEnabled = value;
  65788. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65789. },
  65790. enumerable: true,
  65791. configurable: true
  65792. });
  65793. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  65794. /**
  65795. * Are bump textures enabled in the application.
  65796. */
  65797. get: function () {
  65798. return this._BumpTextureEnabled;
  65799. },
  65800. set: function (value) {
  65801. if (this._BumpTextureEnabled === value) {
  65802. return;
  65803. }
  65804. this._BumpTextureEnabled = value;
  65805. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65806. },
  65807. enumerable: true,
  65808. configurable: true
  65809. });
  65810. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  65811. /**
  65812. * Are lightmap textures enabled in the application.
  65813. */
  65814. get: function () {
  65815. return this._LightmapTextureEnabled;
  65816. },
  65817. set: function (value) {
  65818. if (this._LightmapTextureEnabled === value) {
  65819. return;
  65820. }
  65821. this._LightmapTextureEnabled = value;
  65822. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65823. },
  65824. enumerable: true,
  65825. configurable: true
  65826. });
  65827. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  65828. /**
  65829. * Are refraction textures enabled in the application.
  65830. */
  65831. get: function () {
  65832. return this._RefractionTextureEnabled;
  65833. },
  65834. set: function (value) {
  65835. if (this._RefractionTextureEnabled === value) {
  65836. return;
  65837. }
  65838. this._RefractionTextureEnabled = value;
  65839. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65840. },
  65841. enumerable: true,
  65842. configurable: true
  65843. });
  65844. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  65845. /**
  65846. * Are color grading textures enabled in the application.
  65847. */
  65848. get: function () {
  65849. return this._ColorGradingTextureEnabled;
  65850. },
  65851. set: function (value) {
  65852. if (this._ColorGradingTextureEnabled === value) {
  65853. return;
  65854. }
  65855. this._ColorGradingTextureEnabled = value;
  65856. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65857. },
  65858. enumerable: true,
  65859. configurable: true
  65860. });
  65861. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  65862. /**
  65863. * Are fresnels enabled in the application.
  65864. */
  65865. get: function () {
  65866. return this._FresnelEnabled;
  65867. },
  65868. set: function (value) {
  65869. if (this._FresnelEnabled === value) {
  65870. return;
  65871. }
  65872. this._FresnelEnabled = value;
  65873. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  65874. },
  65875. enumerable: true,
  65876. configurable: true
  65877. });
  65878. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  65879. /**
  65880. * Are clear coat textures enabled in the application.
  65881. */
  65882. get: function () {
  65883. return this._ClearCoatTextureEnabled;
  65884. },
  65885. set: function (value) {
  65886. if (this._ClearCoatTextureEnabled === value) {
  65887. return;
  65888. }
  65889. this._ClearCoatTextureEnabled = value;
  65890. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65891. },
  65892. enumerable: true,
  65893. configurable: true
  65894. });
  65895. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  65896. /**
  65897. * Are clear coat bump textures enabled in the application.
  65898. */
  65899. get: function () {
  65900. return this._ClearCoatBumpTextureEnabled;
  65901. },
  65902. set: function (value) {
  65903. if (this._ClearCoatBumpTextureEnabled === value) {
  65904. return;
  65905. }
  65906. this._ClearCoatBumpTextureEnabled = value;
  65907. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65908. },
  65909. enumerable: true,
  65910. configurable: true
  65911. });
  65912. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  65913. /**
  65914. * Are clear coat tint textures enabled in the application.
  65915. */
  65916. get: function () {
  65917. return this._ClearCoatTintTextureEnabled;
  65918. },
  65919. set: function (value) {
  65920. if (this._ClearCoatTintTextureEnabled === value) {
  65921. return;
  65922. }
  65923. this._ClearCoatTintTextureEnabled = value;
  65924. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65925. },
  65926. enumerable: true,
  65927. configurable: true
  65928. });
  65929. Object.defineProperty(MaterialFlags, "SheenTextureEnabled", {
  65930. /**
  65931. * Are sheen textures enabled in the application.
  65932. */
  65933. get: function () {
  65934. return this._SheenTextureEnabled;
  65935. },
  65936. set: function (value) {
  65937. if (this._SheenTextureEnabled === value) {
  65938. return;
  65939. }
  65940. this._SheenTextureEnabled = value;
  65941. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65942. },
  65943. enumerable: true,
  65944. configurable: true
  65945. });
  65946. Object.defineProperty(MaterialFlags, "AnisotropicTextureEnabled", {
  65947. /**
  65948. * Are anisotropic textures enabled in the application.
  65949. */
  65950. get: function () {
  65951. return this._AnisotropicTextureEnabled;
  65952. },
  65953. set: function (value) {
  65954. if (this._AnisotropicTextureEnabled === value) {
  65955. return;
  65956. }
  65957. this._AnisotropicTextureEnabled = value;
  65958. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65959. },
  65960. enumerable: true,
  65961. configurable: true
  65962. });
  65963. // Flags used to enable or disable a type of texture for all Standard Materials
  65964. MaterialFlags._DiffuseTextureEnabled = true;
  65965. MaterialFlags._AmbientTextureEnabled = true;
  65966. MaterialFlags._OpacityTextureEnabled = true;
  65967. MaterialFlags._ReflectionTextureEnabled = true;
  65968. MaterialFlags._EmissiveTextureEnabled = true;
  65969. MaterialFlags._SpecularTextureEnabled = true;
  65970. MaterialFlags._BumpTextureEnabled = true;
  65971. MaterialFlags._LightmapTextureEnabled = true;
  65972. MaterialFlags._RefractionTextureEnabled = true;
  65973. MaterialFlags._ColorGradingTextureEnabled = true;
  65974. MaterialFlags._FresnelEnabled = true;
  65975. MaterialFlags._ClearCoatTextureEnabled = true;
  65976. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  65977. MaterialFlags._ClearCoatTintTextureEnabled = true;
  65978. MaterialFlags._SheenTextureEnabled = true;
  65979. MaterialFlags._AnisotropicTextureEnabled = true;
  65980. return MaterialFlags;
  65981. }());
  65982. /***/ }),
  65983. /***/ "./Materials/materialHelper.ts":
  65984. /*!*************************************!*\
  65985. !*** ./Materials/materialHelper.ts ***!
  65986. \*************************************/
  65987. /*! exports provided: MaterialHelper */
  65988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65989. "use strict";
  65990. __webpack_require__.r(__webpack_exports__);
  65991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  65992. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  65993. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  65994. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65995. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  65996. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65997. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  65998. /**
  65999. * "Static Class" containing the most commonly used helper while dealing with material for
  66000. * rendering purpose.
  66001. *
  66002. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66003. *
  66004. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66005. */
  66006. var MaterialHelper = /** @class */ (function () {
  66007. function MaterialHelper() {
  66008. }
  66009. /**
  66010. * Bind the current view position to an effect.
  66011. * @param effect The effect to be bound
  66012. * @param scene The scene the eyes position is used from
  66013. */
  66014. MaterialHelper.BindEyePosition = function (effect, scene) {
  66015. if (scene._forcedViewPosition) {
  66016. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  66017. return;
  66018. }
  66019. var globalPosition = scene.activeCamera.globalPosition;
  66020. if (!globalPosition) {
  66021. // Use WebVRFreecamera's device position as global position is not it's actual position in babylon space
  66022. globalPosition = scene.activeCamera.devicePosition;
  66023. }
  66024. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : globalPosition);
  66025. };
  66026. /**
  66027. * Helps preparing the defines values about the UVs in used in the effect.
  66028. * UVs are shared as much as we can accross channels in the shaders.
  66029. * @param texture The texture we are preparing the UVs for
  66030. * @param defines The defines to update
  66031. * @param key The channel key "diffuse", "specular"... used in the shader
  66032. */
  66033. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  66034. defines._needUVs = true;
  66035. defines[key] = true;
  66036. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  66037. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  66038. if (texture.coordinatesIndex === 0) {
  66039. defines["MAINUV1"] = true;
  66040. }
  66041. else {
  66042. defines["MAINUV2"] = true;
  66043. }
  66044. }
  66045. else {
  66046. defines[key + "DIRECTUV"] = 0;
  66047. }
  66048. };
  66049. /**
  66050. * Binds a texture matrix value to its corrsponding uniform
  66051. * @param texture The texture to bind the matrix for
  66052. * @param uniformBuffer The uniform buffer receivin the data
  66053. * @param key The channel key "diffuse", "specular"... used in the shader
  66054. */
  66055. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  66056. var matrix = texture.getTextureMatrix();
  66057. if (!matrix.isIdentityAs3x2()) {
  66058. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  66059. }
  66060. };
  66061. /**
  66062. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66063. * @param mesh defines the current mesh
  66064. * @param scene defines the current scene
  66065. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66066. * @param pointsCloud defines if point cloud rendering has to be turned on
  66067. * @param fogEnabled defines if fog has to be turned on
  66068. * @param alphaTest defines if alpha testing has to be turned on
  66069. * @param defines defines the current list of defines
  66070. */
  66071. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  66072. if (defines._areMiscDirty) {
  66073. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  66074. defines["POINTSIZE"] = pointsCloud;
  66075. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  66076. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  66077. defines["ALPHATEST"] = alphaTest;
  66078. }
  66079. };
  66080. /**
  66081. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66082. * @param scene defines the current scene
  66083. * @param engine defines the current engine
  66084. * @param defines specifies the list of active defines
  66085. * @param useInstances defines if instances have to be turned on
  66086. * @param useClipPlane defines if clip plane have to be turned on
  66087. */
  66088. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  66089. if (useClipPlane === void 0) { useClipPlane = null; }
  66090. var changed = false;
  66091. var useClipPlane1 = false;
  66092. var useClipPlane2 = false;
  66093. var useClipPlane3 = false;
  66094. var useClipPlane4 = false;
  66095. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  66096. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  66097. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  66098. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  66099. if (defines["CLIPPLANE"] !== useClipPlane1) {
  66100. defines["CLIPPLANE"] = useClipPlane1;
  66101. changed = true;
  66102. }
  66103. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  66104. defines["CLIPPLANE2"] = useClipPlane2;
  66105. changed = true;
  66106. }
  66107. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  66108. defines["CLIPPLANE3"] = useClipPlane3;
  66109. changed = true;
  66110. }
  66111. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  66112. defines["CLIPPLANE4"] = useClipPlane4;
  66113. changed = true;
  66114. }
  66115. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  66116. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  66117. changed = true;
  66118. }
  66119. if (defines["INSTANCES"] !== useInstances) {
  66120. defines["INSTANCES"] = useInstances;
  66121. changed = true;
  66122. }
  66123. if (changed) {
  66124. defines.markAsUnprocessed();
  66125. }
  66126. };
  66127. /**
  66128. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66129. * @param mesh The mesh containing the geometry data we will draw
  66130. * @param defines The defines to update
  66131. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66132. * @param useBones Precise whether bones should be used or not (override mesh info)
  66133. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66134. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66135. * @returns false if defines are considered not dirty and have not been checked
  66136. */
  66137. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  66138. if (useMorphTargets === void 0) { useMorphTargets = false; }
  66139. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  66140. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  66141. return false;
  66142. }
  66143. defines._normals = defines._needNormals;
  66144. defines._uvs = defines._needUVs;
  66145. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  66146. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  66147. defines["TANGENT"] = true;
  66148. }
  66149. if (defines._needUVs) {
  66150. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  66151. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  66152. }
  66153. else {
  66154. defines["UV1"] = false;
  66155. defines["UV2"] = false;
  66156. }
  66157. if (useVertexColor) {
  66158. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  66159. defines["VERTEXCOLOR"] = hasVertexColors;
  66160. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  66161. }
  66162. if (useBones) {
  66163. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66164. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  66165. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  66166. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  66167. defines["BONETEXTURE"] = true;
  66168. }
  66169. else {
  66170. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  66171. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  66172. }
  66173. }
  66174. else {
  66175. defines["NUM_BONE_INFLUENCERS"] = 0;
  66176. defines["BonesPerMesh"] = 0;
  66177. }
  66178. }
  66179. if (useMorphTargets) {
  66180. var manager = mesh.morphTargetManager;
  66181. if (manager) {
  66182. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  66183. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  66184. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  66185. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  66186. }
  66187. else {
  66188. defines["MORPHTARGETS_TANGENT"] = false;
  66189. defines["MORPHTARGETS_NORMAL"] = false;
  66190. defines["MORPHTARGETS"] = false;
  66191. defines["NUM_MORPH_INFLUENCERS"] = 0;
  66192. }
  66193. }
  66194. return true;
  66195. };
  66196. /**
  66197. * Prepares the defines related to the light information passed in parameter
  66198. * @param scene The scene we are intending to draw
  66199. * @param mesh The mesh the effect is compiling for
  66200. * @param defines The defines to update
  66201. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66202. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66203. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66204. * @returns true if normals will be required for the rest of the effect
  66205. */
  66206. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  66207. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66208. if (disableLighting === void 0) { disableLighting = false; }
  66209. if (!defines._areLightsDirty) {
  66210. return defines._needNormals;
  66211. }
  66212. var lightIndex = 0;
  66213. var needNormals = false;
  66214. var needRebuild = false;
  66215. var lightmapMode = false;
  66216. var shadowEnabled = false;
  66217. var specularEnabled = false;
  66218. if (scene.lightsEnabled && !disableLighting) {
  66219. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  66220. var light = _a[_i];
  66221. needNormals = true;
  66222. if (defines["LIGHT" + lightIndex] === undefined) {
  66223. needRebuild = true;
  66224. }
  66225. defines["LIGHT" + lightIndex] = true;
  66226. defines["SPOTLIGHT" + lightIndex] = false;
  66227. defines["HEMILIGHT" + lightIndex] = false;
  66228. defines["POINTLIGHT" + lightIndex] = false;
  66229. defines["DIRLIGHT" + lightIndex] = false;
  66230. light.prepareLightSpecificDefines(defines, lightIndex);
  66231. // FallOff.
  66232. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  66233. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  66234. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  66235. switch (light.falloffType) {
  66236. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  66237. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  66238. break;
  66239. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  66240. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  66241. break;
  66242. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  66243. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  66244. break;
  66245. }
  66246. // Specular
  66247. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  66248. specularEnabled = true;
  66249. }
  66250. // Shadows
  66251. defines["SHADOW" + lightIndex] = false;
  66252. defines["SHADOWPCF" + lightIndex] = false;
  66253. defines["SHADOWPCSS" + lightIndex] = false;
  66254. defines["SHADOWPOISSON" + lightIndex] = false;
  66255. defines["SHADOWESM" + lightIndex] = false;
  66256. defines["SHADOWCUBE" + lightIndex] = false;
  66257. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  66258. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  66259. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  66260. var shadowGenerator = light.getShadowGenerator();
  66261. if (shadowGenerator) {
  66262. var shadowMap = shadowGenerator.getShadowMap();
  66263. if (shadowMap) {
  66264. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  66265. shadowEnabled = true;
  66266. shadowGenerator.prepareDefines(defines, lightIndex);
  66267. }
  66268. }
  66269. }
  66270. }
  66271. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  66272. lightmapMode = true;
  66273. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  66274. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  66275. }
  66276. else {
  66277. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  66278. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  66279. }
  66280. lightIndex++;
  66281. if (lightIndex === maxSimultaneousLights) {
  66282. break;
  66283. }
  66284. }
  66285. }
  66286. defines["SPECULARTERM"] = specularEnabled;
  66287. defines["SHADOWS"] = shadowEnabled;
  66288. // Resetting all other lights if any
  66289. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  66290. if (defines["LIGHT" + index] !== undefined) {
  66291. defines["LIGHT" + index] = false;
  66292. defines["HEMILIGHT" + index] = false;
  66293. defines["POINTLIGHT" + index] = false;
  66294. defines["DIRLIGHT" + index] = false;
  66295. defines["SPOTLIGHT" + index] = false;
  66296. defines["SHADOW" + index] = false;
  66297. defines["SHADOWPCF" + index] = false;
  66298. defines["SHADOWPCSS" + index] = false;
  66299. defines["SHADOWPOISSON" + index] = false;
  66300. defines["SHADOWESM" + index] = false;
  66301. defines["SHADOWCUBE" + index] = false;
  66302. defines["SHADOWLOWQUALITY" + index] = false;
  66303. defines["SHADOWMEDIUMQUALITY" + index] = false;
  66304. }
  66305. }
  66306. var caps = scene.getEngine().getCaps();
  66307. if (defines["SHADOWFLOAT"] === undefined) {
  66308. needRebuild = true;
  66309. }
  66310. defines["SHADOWFLOAT"] = shadowEnabled &&
  66311. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  66312. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  66313. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  66314. if (needRebuild) {
  66315. defines.rebuild();
  66316. }
  66317. return needNormals;
  66318. };
  66319. /**
  66320. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66321. * that won t be acctive due to defines being turned off.
  66322. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66323. * @param samplersList The samplers list
  66324. * @param defines The defines helping in the list generation
  66325. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66326. */
  66327. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  66328. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66329. var uniformsList;
  66330. var uniformBuffersList = null;
  66331. if (uniformsListOrOptions.uniformsNames) {
  66332. var options = uniformsListOrOptions;
  66333. uniformsList = options.uniformsNames;
  66334. uniformBuffersList = options.uniformBuffersNames;
  66335. samplersList = options.samplers;
  66336. defines = options.defines;
  66337. maxSimultaneousLights = options.maxSimultaneousLights;
  66338. }
  66339. else {
  66340. uniformsList = uniformsListOrOptions;
  66341. if (!samplersList) {
  66342. samplersList = [];
  66343. }
  66344. }
  66345. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  66346. if (!defines["LIGHT" + lightIndex]) {
  66347. break;
  66348. }
  66349. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  66350. if (uniformBuffersList) {
  66351. uniformBuffersList.push("Light" + lightIndex);
  66352. }
  66353. samplersList.push("shadowSampler" + lightIndex);
  66354. samplersList.push("depthSampler" + lightIndex);
  66355. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  66356. samplersList.push("projectionLightSampler" + lightIndex);
  66357. uniformsList.push("textureProjectionMatrix" + lightIndex);
  66358. }
  66359. }
  66360. if (defines["NUM_MORPH_INFLUENCERS"]) {
  66361. uniformsList.push("morphTargetInfluences");
  66362. }
  66363. };
  66364. /**
  66365. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66366. * @param defines The defines to update while falling back
  66367. * @param fallbacks The authorized effect fallbacks
  66368. * @param maxSimultaneousLights The maximum number of lights allowed
  66369. * @param rank the current rank of the Effect
  66370. * @returns The newly affected rank
  66371. */
  66372. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  66373. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66374. if (rank === void 0) { rank = 0; }
  66375. var lightFallbackRank = 0;
  66376. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  66377. if (!defines["LIGHT" + lightIndex]) {
  66378. break;
  66379. }
  66380. if (lightIndex > 0) {
  66381. lightFallbackRank = rank + lightIndex;
  66382. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  66383. }
  66384. if (!defines["SHADOWS"]) {
  66385. if (defines["SHADOW" + lightIndex]) {
  66386. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  66387. }
  66388. if (defines["SHADOWPCF" + lightIndex]) {
  66389. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  66390. }
  66391. if (defines["SHADOWPCSS" + lightIndex]) {
  66392. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  66393. }
  66394. if (defines["SHADOWPOISSON" + lightIndex]) {
  66395. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  66396. }
  66397. if (defines["SHADOWESM" + lightIndex]) {
  66398. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  66399. }
  66400. }
  66401. }
  66402. return lightFallbackRank++;
  66403. };
  66404. /**
  66405. * Prepares the list of attributes required for morph targets according to the effect defines.
  66406. * @param attribs The current list of supported attribs
  66407. * @param mesh The mesh to prepare the morph targets attributes for
  66408. * @param defines The current Defines of the effect
  66409. */
  66410. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  66411. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  66412. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  66413. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  66414. var manager = mesh.morphTargetManager;
  66415. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  66416. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  66417. for (var index = 0; index < influencers; index++) {
  66418. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  66419. if (normal) {
  66420. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  66421. }
  66422. if (tangent) {
  66423. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  66424. }
  66425. if (attribs.length > maxAttributesCount) {
  66426. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  66427. }
  66428. }
  66429. }
  66430. };
  66431. /**
  66432. * Prepares the list of attributes required for bones according to the effect defines.
  66433. * @param attribs The current list of supported attribs
  66434. * @param mesh The mesh to prepare the bones attributes for
  66435. * @param defines The current Defines of the effect
  66436. * @param fallbacks The current efffect fallback strategy
  66437. */
  66438. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  66439. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  66440. fallbacks.addCPUSkinningFallback(0, mesh);
  66441. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  66442. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  66443. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  66444. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  66445. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  66446. }
  66447. }
  66448. };
  66449. /**
  66450. * Prepares the list of attributes required for instances according to the effect defines.
  66451. * @param attribs The current list of supported attribs
  66452. * @param defines The current Defines of the effect
  66453. */
  66454. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  66455. if (defines["INSTANCES"]) {
  66456. attribs.push("world0");
  66457. attribs.push("world1");
  66458. attribs.push("world2");
  66459. attribs.push("world3");
  66460. }
  66461. };
  66462. /**
  66463. * Binds the light shadow information to the effect for the given mesh.
  66464. * @param light The light containing the generator
  66465. * @param scene The scene the lights belongs to
  66466. * @param mesh The mesh we are binding the information to render
  66467. * @param lightIndex The light index in the effect used to render the mesh
  66468. * @param effect The effect we are binding the data to
  66469. */
  66470. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  66471. if (light.shadowEnabled && mesh.receiveShadows) {
  66472. var shadowGenerator = light.getShadowGenerator();
  66473. if (shadowGenerator) {
  66474. shadowGenerator.bindShadowLight(lightIndex, effect);
  66475. }
  66476. }
  66477. };
  66478. /**
  66479. * Binds the light information to the effect.
  66480. * @param light The light containing the generator
  66481. * @param effect The effect we are binding the data to
  66482. * @param lightIndex The light index in the effect used to render
  66483. */
  66484. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  66485. light.transferToEffect(effect, lightIndex + "");
  66486. };
  66487. /**
  66488. * Binds the lights information from the scene to the effect for the given mesh.
  66489. * @param scene The scene the lights belongs to
  66490. * @param mesh The mesh we are binding the information to render
  66491. * @param effect The effect we are binding the data to
  66492. * @param defines The generated defines for the effect
  66493. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66494. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66495. */
  66496. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  66497. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66498. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  66499. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  66500. for (var i = 0; i < len; i++) {
  66501. var light = mesh._lightSources[i];
  66502. var iAsString = i.toString();
  66503. var scaledIntensity = light.getScaledIntensity();
  66504. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  66505. MaterialHelper.BindLightProperties(light, effect, i);
  66506. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  66507. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  66508. if (defines["SPECULARTERM"]) {
  66509. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  66510. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  66511. }
  66512. // Shadows
  66513. if (scene.shadowsEnabled) {
  66514. this.BindLightShadow(light, mesh, iAsString, effect);
  66515. }
  66516. light._uniformBuffer.update();
  66517. }
  66518. };
  66519. /**
  66520. * Binds the fog information from the scene to the effect for the given mesh.
  66521. * @param scene The scene the lights belongs to
  66522. * @param mesh The mesh we are binding the information to render
  66523. * @param effect The effect we are binding the data to
  66524. * @param linearSpace Defines if the fog effect is applied in linear space
  66525. */
  66526. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  66527. if (linearSpace === void 0) { linearSpace = false; }
  66528. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  66529. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  66530. // Convert fog color to linear space if used in a linear space computed shader.
  66531. if (linearSpace) {
  66532. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  66533. effect.setColor3("vFogColor", this._tempFogColor);
  66534. }
  66535. else {
  66536. effect.setColor3("vFogColor", scene.fogColor);
  66537. }
  66538. }
  66539. };
  66540. /**
  66541. * Binds the bones information from the mesh to the effect.
  66542. * @param mesh The mesh we are binding the information to render
  66543. * @param effect The effect we are binding the data to
  66544. */
  66545. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  66546. if (!effect || !mesh) {
  66547. return;
  66548. }
  66549. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  66550. mesh.computeBonesUsingShaders = false;
  66551. }
  66552. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66553. var skeleton = mesh.skeleton;
  66554. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  66555. var boneTexture = skeleton.getTransformMatrixTexture();
  66556. effect.setTexture("boneSampler", boneTexture);
  66557. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  66558. }
  66559. else {
  66560. var matrices = skeleton.getTransformMatrices(mesh);
  66561. if (matrices) {
  66562. effect.setMatrices("mBones", matrices);
  66563. }
  66564. }
  66565. }
  66566. };
  66567. /**
  66568. * Binds the morph targets information from the mesh to the effect.
  66569. * @param abstractMesh The mesh we are binding the information to render
  66570. * @param effect The effect we are binding the data to
  66571. */
  66572. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  66573. var manager = abstractMesh.morphTargetManager;
  66574. if (!abstractMesh || !manager) {
  66575. return;
  66576. }
  66577. effect.setFloatArray("morphTargetInfluences", manager.influences);
  66578. };
  66579. /**
  66580. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66581. * @param defines The generated defines used in the effect
  66582. * @param effect The effect we are binding the data to
  66583. * @param scene The scene we are willing to render with logarithmic scale for
  66584. */
  66585. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  66586. if (defines["LOGARITHMICDEPTH"]) {
  66587. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  66588. }
  66589. };
  66590. /**
  66591. * Binds the clip plane information from the scene to the effect.
  66592. * @param scene The scene the clip plane information are extracted from
  66593. * @param effect The effect we are binding the data to
  66594. */
  66595. MaterialHelper.BindClipPlane = function (effect, scene) {
  66596. if (scene.clipPlane) {
  66597. var clipPlane = scene.clipPlane;
  66598. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66599. }
  66600. if (scene.clipPlane2) {
  66601. var clipPlane = scene.clipPlane2;
  66602. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66603. }
  66604. if (scene.clipPlane3) {
  66605. var clipPlane = scene.clipPlane3;
  66606. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66607. }
  66608. if (scene.clipPlane4) {
  66609. var clipPlane = scene.clipPlane4;
  66610. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66611. }
  66612. };
  66613. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  66614. return MaterialHelper;
  66615. }());
  66616. /***/ }),
  66617. /***/ "./Materials/multiMaterial.ts":
  66618. /*!************************************!*\
  66619. !*** ./Materials/multiMaterial.ts ***!
  66620. \************************************/
  66621. /*! exports provided: MultiMaterial */
  66622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66623. "use strict";
  66624. __webpack_require__.r(__webpack_exports__);
  66625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  66626. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66627. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  66628. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  66629. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  66630. /**
  66631. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66632. * separate meshes. This can be use to improve performances.
  66633. * @see http://doc.babylonjs.com/how_to/multi_materials
  66634. */
  66635. var MultiMaterial = /** @class */ (function (_super) {
  66636. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  66637. /**
  66638. * Instantiates a new Multi Material
  66639. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66640. * separate meshes. This can be use to improve performances.
  66641. * @see http://doc.babylonjs.com/how_to/multi_materials
  66642. * @param name Define the name in the scene
  66643. * @param scene Define the scene the material belongs to
  66644. */
  66645. function MultiMaterial(name, scene) {
  66646. var _this = _super.call(this, name, scene, true) || this;
  66647. scene.multiMaterials.push(_this);
  66648. _this.subMaterials = new Array();
  66649. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  66650. return _this;
  66651. }
  66652. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  66653. /**
  66654. * Gets or Sets the list of Materials used within the multi material.
  66655. * They need to be ordered according to the submeshes order in the associated mesh
  66656. */
  66657. get: function () {
  66658. return this._subMaterials;
  66659. },
  66660. set: function (value) {
  66661. this._subMaterials = value;
  66662. this._hookArray(value);
  66663. },
  66664. enumerable: true,
  66665. configurable: true
  66666. });
  66667. /**
  66668. * Function used to align with Node.getChildren()
  66669. * @returns the list of Materials used within the multi material
  66670. */
  66671. MultiMaterial.prototype.getChildren = function () {
  66672. return this.subMaterials;
  66673. };
  66674. MultiMaterial.prototype._hookArray = function (array) {
  66675. var _this = this;
  66676. var oldPush = array.push;
  66677. array.push = function () {
  66678. var items = [];
  66679. for (var _i = 0; _i < arguments.length; _i++) {
  66680. items[_i] = arguments[_i];
  66681. }
  66682. var result = oldPush.apply(array, items);
  66683. _this._markAllSubMeshesAsTexturesDirty();
  66684. return result;
  66685. };
  66686. var oldSplice = array.splice;
  66687. array.splice = function (index, deleteCount) {
  66688. var deleted = oldSplice.apply(array, [index, deleteCount]);
  66689. _this._markAllSubMeshesAsTexturesDirty();
  66690. return deleted;
  66691. };
  66692. };
  66693. /**
  66694. * Get one of the submaterial by its index in the submaterials array
  66695. * @param index The index to look the sub material at
  66696. * @returns The Material if the index has been defined
  66697. */
  66698. MultiMaterial.prototype.getSubMaterial = function (index) {
  66699. if (index < 0 || index >= this.subMaterials.length) {
  66700. return this.getScene().defaultMaterial;
  66701. }
  66702. return this.subMaterials[index];
  66703. };
  66704. /**
  66705. * Get the list of active textures for the whole sub materials list.
  66706. * @returns All the textures that will be used during the rendering
  66707. */
  66708. MultiMaterial.prototype.getActiveTextures = function () {
  66709. var _a;
  66710. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  66711. if (subMaterial) {
  66712. return subMaterial.getActiveTextures();
  66713. }
  66714. else {
  66715. return [];
  66716. }
  66717. }));
  66718. };
  66719. /**
  66720. * Gets the current class name of the material e.g. "MultiMaterial"
  66721. * Mainly use in serialization.
  66722. * @returns the class name
  66723. */
  66724. MultiMaterial.prototype.getClassName = function () {
  66725. return "MultiMaterial";
  66726. };
  66727. /**
  66728. * Checks if the material is ready to render the requested sub mesh
  66729. * @param mesh Define the mesh the submesh belongs to
  66730. * @param subMesh Define the sub mesh to look readyness for
  66731. * @param useInstances Define whether or not the material is used with instances
  66732. * @returns true if ready, otherwise false
  66733. */
  66734. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  66735. for (var index = 0; index < this.subMaterials.length; index++) {
  66736. var subMaterial = this.subMaterials[index];
  66737. if (subMaterial) {
  66738. if (subMaterial._storeEffectOnSubMeshes) {
  66739. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  66740. return false;
  66741. }
  66742. continue;
  66743. }
  66744. if (!subMaterial.isReady(mesh)) {
  66745. return false;
  66746. }
  66747. }
  66748. }
  66749. return true;
  66750. };
  66751. /**
  66752. * Clones the current material and its related sub materials
  66753. * @param name Define the name of the newly cloned material
  66754. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66755. * @returns the cloned material
  66756. */
  66757. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  66758. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  66759. for (var index = 0; index < this.subMaterials.length; index++) {
  66760. var subMaterial = null;
  66761. var current = this.subMaterials[index];
  66762. if (cloneChildren && current) {
  66763. subMaterial = current.clone(name + "-" + current.name);
  66764. }
  66765. else {
  66766. subMaterial = this.subMaterials[index];
  66767. }
  66768. newMultiMaterial.subMaterials.push(subMaterial);
  66769. }
  66770. return newMultiMaterial;
  66771. };
  66772. /**
  66773. * Serializes the materials into a JSON representation.
  66774. * @returns the JSON representation
  66775. */
  66776. MultiMaterial.prototype.serialize = function () {
  66777. var serializationObject = {};
  66778. serializationObject.name = this.name;
  66779. serializationObject.id = this.id;
  66780. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  66781. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  66782. }
  66783. serializationObject.materials = [];
  66784. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  66785. var subMat = this.subMaterials[matIndex];
  66786. if (subMat) {
  66787. serializationObject.materials.push(subMat.id);
  66788. }
  66789. else {
  66790. serializationObject.materials.push(null);
  66791. }
  66792. }
  66793. return serializationObject;
  66794. };
  66795. /**
  66796. * Dispose the material and release its associated resources
  66797. * @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)
  66798. * @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)
  66799. * @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)
  66800. */
  66801. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  66802. var scene = this.getScene();
  66803. if (!scene) {
  66804. return;
  66805. }
  66806. if (forceDisposeChildren) {
  66807. for (var index = 0; index < this.subMaterials.length; index++) {
  66808. var subMaterial = this.subMaterials[index];
  66809. if (subMaterial) {
  66810. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  66811. }
  66812. }
  66813. }
  66814. var index = scene.multiMaterials.indexOf(this);
  66815. if (index >= 0) {
  66816. scene.multiMaterials.splice(index, 1);
  66817. }
  66818. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  66819. };
  66820. /**
  66821. * Creates a MultiMaterial from parsed MultiMaterial data.
  66822. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66823. * @param scene defines the hosting scene
  66824. * @returns a new MultiMaterial
  66825. */
  66826. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  66827. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  66828. multiMaterial.id = parsedMultiMaterial.id;
  66829. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  66830. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  66831. }
  66832. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  66833. var subMatId = parsedMultiMaterial.materials[matIndex];
  66834. if (subMatId) {
  66835. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  66836. }
  66837. else {
  66838. multiMaterial.subMaterials.push(null);
  66839. }
  66840. }
  66841. return multiMaterial;
  66842. };
  66843. return MultiMaterial;
  66844. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  66845. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  66846. /***/ }),
  66847. /***/ "./Materials/pushMaterial.ts":
  66848. /*!***********************************!*\
  66849. !*** ./Materials/pushMaterial.ts ***!
  66850. \***********************************/
  66851. /*! exports provided: PushMaterial */
  66852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66853. "use strict";
  66854. __webpack_require__.r(__webpack_exports__);
  66855. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  66856. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66857. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66858. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  66859. /**
  66860. * Base class of materials working in push mode in babylon JS
  66861. * @hidden
  66862. */
  66863. var PushMaterial = /** @class */ (function (_super) {
  66864. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  66865. function PushMaterial(name, scene) {
  66866. var _this = _super.call(this, name, scene) || this;
  66867. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  66868. /**
  66869. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  66870. * This means that the material can keep using a previous shader while a new one is being compiled.
  66871. * This is mostly used when shader parallel compilation is supported (true by default)
  66872. */
  66873. _this.allowShaderHotSwapping = true;
  66874. _this._storeEffectOnSubMeshes = true;
  66875. return _this;
  66876. }
  66877. PushMaterial.prototype.getEffect = function () {
  66878. return this._activeEffect;
  66879. };
  66880. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  66881. if (!mesh) {
  66882. return false;
  66883. }
  66884. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  66885. return true;
  66886. }
  66887. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  66888. };
  66889. /**
  66890. * Binds the given world matrix to the active effect
  66891. *
  66892. * @param world the matrix to bind
  66893. */
  66894. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  66895. this._activeEffect.setMatrix("world", world);
  66896. };
  66897. /**
  66898. * Binds the given normal matrix to the active effect
  66899. *
  66900. * @param normalMatrix the matrix to bind
  66901. */
  66902. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  66903. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  66904. };
  66905. PushMaterial.prototype.bind = function (world, mesh) {
  66906. if (!mesh) {
  66907. return;
  66908. }
  66909. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  66910. };
  66911. PushMaterial.prototype._afterBind = function (mesh, effect) {
  66912. if (effect === void 0) { effect = null; }
  66913. _super.prototype._afterBind.call(this, mesh);
  66914. this.getScene()._cachedEffect = effect;
  66915. };
  66916. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  66917. if (visibility === void 0) { visibility = 1; }
  66918. return scene.isCachedMaterialInvalid(this, effect, visibility);
  66919. };
  66920. return PushMaterial;
  66921. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  66922. /***/ }),
  66923. /***/ "./Materials/shaderMaterial.ts":
  66924. /*!*************************************!*\
  66925. !*** ./Materials/shaderMaterial.ts ***!
  66926. \*************************************/
  66927. /*! exports provided: ShaderMaterial */
  66928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66929. "use strict";
  66930. __webpack_require__.r(__webpack_exports__);
  66931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  66932. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66933. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  66934. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66935. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  66936. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  66937. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  66938. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  66939. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  66940. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  66941. /**
  66942. * 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.
  66943. *
  66944. * This returned material effects how the mesh will look based on the code in the shaders.
  66945. *
  66946. * @see http://doc.babylonjs.com/how_to/shader_material
  66947. */
  66948. var ShaderMaterial = /** @class */ (function (_super) {
  66949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  66950. /**
  66951. * Instantiate a new shader material.
  66952. * 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.
  66953. * This returned material effects how the mesh will look based on the code in the shaders.
  66954. * @see http://doc.babylonjs.com/how_to/shader_material
  66955. * @param name Define the name of the material in the scene
  66956. * @param scene Define the scene the material belongs to
  66957. * @param shaderPath Defines the route to the shader code in one of three ways:
  66958. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  66959. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  66960. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  66961. * @param options Define the options used to create the shader
  66962. */
  66963. function ShaderMaterial(name, scene, shaderPath, options) {
  66964. if (options === void 0) { options = {}; }
  66965. var _this = _super.call(this, name, scene) || this;
  66966. _this._textures = {};
  66967. _this._textureArrays = {};
  66968. _this._floats = {};
  66969. _this._ints = {};
  66970. _this._floatsArrays = {};
  66971. _this._colors3 = {};
  66972. _this._colors3Arrays = {};
  66973. _this._colors4 = {};
  66974. _this._vectors2 = {};
  66975. _this._vectors3 = {};
  66976. _this._vectors4 = {};
  66977. _this._matrices = {};
  66978. _this._matrices3x3 = {};
  66979. _this._matrices2x2 = {};
  66980. _this._vectors2Arrays = {};
  66981. _this._vectors3Arrays = {};
  66982. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  66983. _this._shaderPath = shaderPath;
  66984. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  66985. return _this;
  66986. }
  66987. Object.defineProperty(ShaderMaterial.prototype, "options", {
  66988. /**
  66989. * Gets the options used to compile the shader.
  66990. * They can be modified to trigger a new compilation
  66991. */
  66992. get: function () {
  66993. return this._options;
  66994. },
  66995. enumerable: true,
  66996. configurable: true
  66997. });
  66998. /**
  66999. * Gets the current class name of the material e.g. "ShaderMaterial"
  67000. * Mainly use in serialization.
  67001. * @returns the class name
  67002. */
  67003. ShaderMaterial.prototype.getClassName = function () {
  67004. return "ShaderMaterial";
  67005. };
  67006. /**
  67007. * Specifies if the material will require alpha blending
  67008. * @returns a boolean specifying if alpha blending is needed
  67009. */
  67010. ShaderMaterial.prototype.needAlphaBlending = function () {
  67011. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  67012. };
  67013. /**
  67014. * Specifies if this material should be rendered in alpha test mode
  67015. * @returns a boolean specifying if an alpha test is needed.
  67016. */
  67017. ShaderMaterial.prototype.needAlphaTesting = function () {
  67018. return this._options.needAlphaTesting;
  67019. };
  67020. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  67021. if (this._options.uniforms.indexOf(uniformName) === -1) {
  67022. this._options.uniforms.push(uniformName);
  67023. }
  67024. };
  67025. /**
  67026. * Set a texture in the shader.
  67027. * @param name Define the name of the uniform samplers as defined in the shader
  67028. * @param texture Define the texture to bind to this sampler
  67029. * @return the material itself allowing "fluent" like uniform updates
  67030. */
  67031. ShaderMaterial.prototype.setTexture = function (name, texture) {
  67032. if (this._options.samplers.indexOf(name) === -1) {
  67033. this._options.samplers.push(name);
  67034. }
  67035. this._textures[name] = texture;
  67036. return this;
  67037. };
  67038. /**
  67039. * Set a texture array in the shader.
  67040. * @param name Define the name of the uniform sampler array as defined in the shader
  67041. * @param textures Define the list of textures to bind to this sampler
  67042. * @return the material itself allowing "fluent" like uniform updates
  67043. */
  67044. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  67045. if (this._options.samplers.indexOf(name) === -1) {
  67046. this._options.samplers.push(name);
  67047. }
  67048. this._checkUniform(name);
  67049. this._textureArrays[name] = textures;
  67050. return this;
  67051. };
  67052. /**
  67053. * Set a float in the shader.
  67054. * @param name Define the name of the uniform as defined in the shader
  67055. * @param value Define the value to give to the uniform
  67056. * @return the material itself allowing "fluent" like uniform updates
  67057. */
  67058. ShaderMaterial.prototype.setFloat = function (name, value) {
  67059. this._checkUniform(name);
  67060. this._floats[name] = value;
  67061. return this;
  67062. };
  67063. /**
  67064. * Set a int in the shader.
  67065. * @param name Define the name of the uniform as defined in the shader
  67066. * @param value Define the value to give to the uniform
  67067. * @return the material itself allowing "fluent" like uniform updates
  67068. */
  67069. ShaderMaterial.prototype.setInt = function (name, value) {
  67070. this._checkUniform(name);
  67071. this._ints[name] = value;
  67072. return this;
  67073. };
  67074. /**
  67075. * Set an array of floats in the shader.
  67076. * @param name Define the name of the uniform as defined in the shader
  67077. * @param value Define the value to give to the uniform
  67078. * @return the material itself allowing "fluent" like uniform updates
  67079. */
  67080. ShaderMaterial.prototype.setFloats = function (name, value) {
  67081. this._checkUniform(name);
  67082. this._floatsArrays[name] = value;
  67083. return this;
  67084. };
  67085. /**
  67086. * Set a vec3 in the shader from a Color3.
  67087. * @param name Define the name of the uniform as defined in the shader
  67088. * @param value Define the value to give to the uniform
  67089. * @return the material itself allowing "fluent" like uniform updates
  67090. */
  67091. ShaderMaterial.prototype.setColor3 = function (name, value) {
  67092. this._checkUniform(name);
  67093. this._colors3[name] = value;
  67094. return this;
  67095. };
  67096. /**
  67097. * Set a vec3 array in the shader from a Color3 array.
  67098. * @param name Define the name of the uniform as defined in the shader
  67099. * @param value Define the value to give to the uniform
  67100. * @return the material itself allowing "fluent" like uniform updates
  67101. */
  67102. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  67103. this._checkUniform(name);
  67104. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  67105. color.toArray(arr, arr.length);
  67106. return arr;
  67107. }, []);
  67108. return this;
  67109. };
  67110. /**
  67111. * Set a vec4 in the shader from a Color4.
  67112. * @param name Define the name of the uniform as defined in the shader
  67113. * @param value Define the value to give to the uniform
  67114. * @return the material itself allowing "fluent" like uniform updates
  67115. */
  67116. ShaderMaterial.prototype.setColor4 = function (name, value) {
  67117. this._checkUniform(name);
  67118. this._colors4[name] = value;
  67119. return this;
  67120. };
  67121. /**
  67122. * Set a vec2 in the shader from a Vector2.
  67123. * @param name Define the name of the uniform as defined in the shader
  67124. * @param value Define the value to give to the uniform
  67125. * @return the material itself allowing "fluent" like uniform updates
  67126. */
  67127. ShaderMaterial.prototype.setVector2 = function (name, value) {
  67128. this._checkUniform(name);
  67129. this._vectors2[name] = value;
  67130. return this;
  67131. };
  67132. /**
  67133. * Set a vec3 in the shader from a Vector3.
  67134. * @param name Define the name of the uniform as defined in the shader
  67135. * @param value Define the value to give to the uniform
  67136. * @return the material itself allowing "fluent" like uniform updates
  67137. */
  67138. ShaderMaterial.prototype.setVector3 = function (name, value) {
  67139. this._checkUniform(name);
  67140. this._vectors3[name] = value;
  67141. return this;
  67142. };
  67143. /**
  67144. * Set a vec4 in the shader from a Vector4.
  67145. * @param name Define the name of the uniform as defined in the shader
  67146. * @param value Define the value to give to the uniform
  67147. * @return the material itself allowing "fluent" like uniform updates
  67148. */
  67149. ShaderMaterial.prototype.setVector4 = function (name, value) {
  67150. this._checkUniform(name);
  67151. this._vectors4[name] = value;
  67152. return this;
  67153. };
  67154. /**
  67155. * Set a mat4 in the shader from a Matrix.
  67156. * @param name Define the name of the uniform as defined in the shader
  67157. * @param value Define the value to give to the uniform
  67158. * @return the material itself allowing "fluent" like uniform updates
  67159. */
  67160. ShaderMaterial.prototype.setMatrix = function (name, value) {
  67161. this._checkUniform(name);
  67162. this._matrices[name] = value;
  67163. return this;
  67164. };
  67165. /**
  67166. * Set a mat3 in the shader from a Float32Array.
  67167. * @param name Define the name of the uniform as defined in the shader
  67168. * @param value Define the value to give to the uniform
  67169. * @return the material itself allowing "fluent" like uniform updates
  67170. */
  67171. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  67172. this._checkUniform(name);
  67173. this._matrices3x3[name] = value;
  67174. return this;
  67175. };
  67176. /**
  67177. * Set a mat2 in the shader from a Float32Array.
  67178. * @param name Define the name of the uniform as defined in the shader
  67179. * @param value Define the value to give to the uniform
  67180. * @return the material itself allowing "fluent" like uniform updates
  67181. */
  67182. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  67183. this._checkUniform(name);
  67184. this._matrices2x2[name] = value;
  67185. return this;
  67186. };
  67187. /**
  67188. * Set a vec2 array in the shader from a number array.
  67189. * @param name Define the name of the uniform as defined in the shader
  67190. * @param value Define the value to give to the uniform
  67191. * @return the material itself allowing "fluent" like uniform updates
  67192. */
  67193. ShaderMaterial.prototype.setArray2 = function (name, value) {
  67194. this._checkUniform(name);
  67195. this._vectors2Arrays[name] = value;
  67196. return this;
  67197. };
  67198. /**
  67199. * Set a vec3 array in the shader from a number array.
  67200. * @param name Define the name of the uniform as defined in the shader
  67201. * @param value Define the value to give to the uniform
  67202. * @return the material itself allowing "fluent" like uniform updates
  67203. */
  67204. ShaderMaterial.prototype.setArray3 = function (name, value) {
  67205. this._checkUniform(name);
  67206. this._vectors3Arrays[name] = value;
  67207. return this;
  67208. };
  67209. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  67210. if (!mesh) {
  67211. return true;
  67212. }
  67213. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  67214. return false;
  67215. }
  67216. return false;
  67217. };
  67218. /**
  67219. * Specifies that the submesh is ready to be used
  67220. * @param mesh defines the mesh to check
  67221. * @param subMesh defines which submesh to check
  67222. * @param useInstances specifies that instances should be used
  67223. * @returns a boolean indicating that the submesh is ready or not
  67224. */
  67225. ShaderMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67226. return this.isReady(mesh, useInstances);
  67227. };
  67228. /**
  67229. * Checks if the material is ready to render the requested mesh
  67230. * @param mesh Define the mesh to render
  67231. * @param useInstances Define whether or not the material is used with instances
  67232. * @returns true if ready, otherwise false
  67233. */
  67234. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  67235. var scene = this.getScene();
  67236. var engine = scene.getEngine();
  67237. if (!this.checkReadyOnEveryCall) {
  67238. if (this._renderId === scene.getRenderId()) {
  67239. if (this._checkCache(mesh, useInstances)) {
  67240. return true;
  67241. }
  67242. }
  67243. }
  67244. // Instances
  67245. var defines = [];
  67246. var attribs = [];
  67247. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  67248. for (var index = 0; index < this._options.defines.length; index++) {
  67249. defines.push(this._options.defines[index]);
  67250. }
  67251. for (var index = 0; index < this._options.attributes.length; index++) {
  67252. attribs.push(this._options.attributes[index]);
  67253. }
  67254. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  67255. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  67256. defines.push("#define VERTEXCOLOR");
  67257. }
  67258. if (useInstances) {
  67259. defines.push("#define INSTANCES");
  67260. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  67261. }
  67262. // Bones
  67263. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  67264. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  67265. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  67266. if (mesh.numBoneInfluencers > 4) {
  67267. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  67268. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  67269. }
  67270. var skeleton = mesh.skeleton;
  67271. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  67272. fallbacks.addCPUSkinningFallback(0, mesh);
  67273. if (skeleton.isUsingTextureForMatrices) {
  67274. defines.push("#define BONETEXTURE");
  67275. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  67276. this._options.uniforms.push("boneTextureWidth");
  67277. }
  67278. if (this._options.samplers.indexOf("boneSampler") === -1) {
  67279. this._options.samplers.push("boneSampler");
  67280. }
  67281. }
  67282. else {
  67283. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  67284. if (this._options.uniforms.indexOf("mBones") === -1) {
  67285. this._options.uniforms.push("mBones");
  67286. }
  67287. }
  67288. }
  67289. else {
  67290. defines.push("#define NUM_BONE_INFLUENCERS 0");
  67291. }
  67292. // Textures
  67293. for (var name in this._textures) {
  67294. if (!this._textures[name].isReady()) {
  67295. return false;
  67296. }
  67297. }
  67298. // Alpha test
  67299. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  67300. defines.push("#define ALPHATEST");
  67301. }
  67302. var previousEffect = this._effect;
  67303. var join = defines.join("\n");
  67304. this._effect = engine.createEffect(this._shaderPath, {
  67305. attributes: attribs,
  67306. uniformsNames: this._options.uniforms,
  67307. uniformBuffersNames: this._options.uniformBuffers,
  67308. samplers: this._options.samplers,
  67309. defines: join,
  67310. fallbacks: fallbacks,
  67311. onCompiled: this.onCompiled,
  67312. onError: this.onError
  67313. }, engine);
  67314. if (!this._effect.isReady()) {
  67315. return false;
  67316. }
  67317. if (previousEffect !== this._effect) {
  67318. scene.resetCachedMaterial();
  67319. }
  67320. this._renderId = scene.getRenderId();
  67321. return true;
  67322. };
  67323. /**
  67324. * Binds the world matrix to the material
  67325. * @param world defines the world transformation matrix
  67326. */
  67327. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  67328. var scene = this.getScene();
  67329. if (!this._effect) {
  67330. return;
  67331. }
  67332. if (this._options.uniforms.indexOf("world") !== -1) {
  67333. this._effect.setMatrix("world", world);
  67334. }
  67335. if (this._options.uniforms.indexOf("worldView") !== -1) {
  67336. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  67337. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  67338. }
  67339. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  67340. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  67341. }
  67342. };
  67343. /**
  67344. * Binds the material to the mesh
  67345. * @param world defines the world transformation matrix
  67346. * @param mesh defines the mesh to bind the material to
  67347. */
  67348. ShaderMaterial.prototype.bind = function (world, mesh) {
  67349. // Std values
  67350. this.bindOnlyWorldMatrix(world);
  67351. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  67352. if (this._options.uniforms.indexOf("view") !== -1) {
  67353. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  67354. }
  67355. if (this._options.uniforms.indexOf("projection") !== -1) {
  67356. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  67357. }
  67358. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  67359. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  67360. }
  67361. // Bones
  67362. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  67363. var name;
  67364. // Texture
  67365. for (name in this._textures) {
  67366. this._effect.setTexture(name, this._textures[name]);
  67367. }
  67368. // Texture arrays
  67369. for (name in this._textureArrays) {
  67370. this._effect.setTextureArray(name, this._textureArrays[name]);
  67371. }
  67372. // Int
  67373. for (name in this._ints) {
  67374. this._effect.setInt(name, this._ints[name]);
  67375. }
  67376. // Float
  67377. for (name in this._floats) {
  67378. this._effect.setFloat(name, this._floats[name]);
  67379. }
  67380. // Floats
  67381. for (name in this._floatsArrays) {
  67382. this._effect.setArray(name, this._floatsArrays[name]);
  67383. }
  67384. // Color3
  67385. for (name in this._colors3) {
  67386. this._effect.setColor3(name, this._colors3[name]);
  67387. }
  67388. for (name in this._colors3Arrays) {
  67389. this._effect.setArray3(name, this._colors3Arrays[name]);
  67390. }
  67391. // Color4
  67392. for (name in this._colors4) {
  67393. var color = this._colors4[name];
  67394. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  67395. }
  67396. // Vector2
  67397. for (name in this._vectors2) {
  67398. this._effect.setVector2(name, this._vectors2[name]);
  67399. }
  67400. // Vector3
  67401. for (name in this._vectors3) {
  67402. this._effect.setVector3(name, this._vectors3[name]);
  67403. }
  67404. // Vector4
  67405. for (name in this._vectors4) {
  67406. this._effect.setVector4(name, this._vectors4[name]);
  67407. }
  67408. // Matrix
  67409. for (name in this._matrices) {
  67410. this._effect.setMatrix(name, this._matrices[name]);
  67411. }
  67412. // Matrix 3x3
  67413. for (name in this._matrices3x3) {
  67414. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  67415. }
  67416. // Matrix 2x2
  67417. for (name in this._matrices2x2) {
  67418. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  67419. }
  67420. // Vector2Array
  67421. for (name in this._vectors2Arrays) {
  67422. this._effect.setArray2(name, this._vectors2Arrays[name]);
  67423. }
  67424. // Vector3Array
  67425. for (name in this._vectors3Arrays) {
  67426. this._effect.setArray3(name, this._vectors3Arrays[name]);
  67427. }
  67428. }
  67429. this._afterBind(mesh);
  67430. };
  67431. /**
  67432. * Gets the active textures from the material
  67433. * @returns an array of textures
  67434. */
  67435. ShaderMaterial.prototype.getActiveTextures = function () {
  67436. var activeTextures = _super.prototype.getActiveTextures.call(this);
  67437. for (var name in this._textures) {
  67438. activeTextures.push(this._textures[name]);
  67439. }
  67440. for (var name in this._textureArrays) {
  67441. var array = this._textureArrays[name];
  67442. for (var index = 0; index < array.length; index++) {
  67443. activeTextures.push(array[index]);
  67444. }
  67445. }
  67446. return activeTextures;
  67447. };
  67448. /**
  67449. * Specifies if the material uses a texture
  67450. * @param texture defines the texture to check against the material
  67451. * @returns a boolean specifying if the material uses the texture
  67452. */
  67453. ShaderMaterial.prototype.hasTexture = function (texture) {
  67454. if (_super.prototype.hasTexture.call(this, texture)) {
  67455. return true;
  67456. }
  67457. for (var name in this._textures) {
  67458. if (this._textures[name] === texture) {
  67459. return true;
  67460. }
  67461. }
  67462. for (var name in this._textureArrays) {
  67463. var array = this._textureArrays[name];
  67464. for (var index = 0; index < array.length; index++) {
  67465. if (array[index] === texture) {
  67466. return true;
  67467. }
  67468. }
  67469. }
  67470. return false;
  67471. };
  67472. /**
  67473. * Makes a duplicate of the material, and gives it a new name
  67474. * @param name defines the new name for the duplicated material
  67475. * @returns the cloned material
  67476. */
  67477. ShaderMaterial.prototype.clone = function (name) {
  67478. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  67479. return newShaderMaterial;
  67480. };
  67481. /**
  67482. * Disposes the material
  67483. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67484. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  67485. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  67486. */
  67487. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  67488. if (forceDisposeTextures) {
  67489. var name;
  67490. for (name in this._textures) {
  67491. this._textures[name].dispose();
  67492. }
  67493. for (name in this._textureArrays) {
  67494. var array = this._textureArrays[name];
  67495. for (var index = 0; index < array.length; index++) {
  67496. array[index].dispose();
  67497. }
  67498. }
  67499. }
  67500. this._textures = {};
  67501. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  67502. };
  67503. /**
  67504. * Serializes this material in a JSON representation
  67505. * @returns the serialized material object
  67506. */
  67507. ShaderMaterial.prototype.serialize = function () {
  67508. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  67509. serializationObject.customType = "ShaderMaterial";
  67510. serializationObject.options = this._options;
  67511. serializationObject.shaderPath = this._shaderPath;
  67512. var name;
  67513. // Texture
  67514. serializationObject.textures = {};
  67515. for (name in this._textures) {
  67516. serializationObject.textures[name] = this._textures[name].serialize();
  67517. }
  67518. // Texture arrays
  67519. serializationObject.textureArrays = {};
  67520. for (name in this._textureArrays) {
  67521. serializationObject.textureArrays[name] = [];
  67522. var array = this._textureArrays[name];
  67523. for (var index = 0; index < array.length; index++) {
  67524. serializationObject.textureArrays[name].push(array[index].serialize());
  67525. }
  67526. }
  67527. // Float
  67528. serializationObject.floats = {};
  67529. for (name in this._floats) {
  67530. serializationObject.floats[name] = this._floats[name];
  67531. }
  67532. // Float s
  67533. serializationObject.FloatArrays = {};
  67534. for (name in this._floatsArrays) {
  67535. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  67536. }
  67537. // Color3
  67538. serializationObject.colors3 = {};
  67539. for (name in this._colors3) {
  67540. serializationObject.colors3[name] = this._colors3[name].asArray();
  67541. }
  67542. // Color3 array
  67543. serializationObject.colors3Arrays = {};
  67544. for (name in this._colors3Arrays) {
  67545. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  67546. }
  67547. // Color4
  67548. serializationObject.colors4 = {};
  67549. for (name in this._colors4) {
  67550. serializationObject.colors4[name] = this._colors4[name].asArray();
  67551. }
  67552. // Vector2
  67553. serializationObject.vectors2 = {};
  67554. for (name in this._vectors2) {
  67555. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  67556. }
  67557. // Vector3
  67558. serializationObject.vectors3 = {};
  67559. for (name in this._vectors3) {
  67560. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  67561. }
  67562. // Vector4
  67563. serializationObject.vectors4 = {};
  67564. for (name in this._vectors4) {
  67565. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  67566. }
  67567. // Matrix
  67568. serializationObject.matrices = {};
  67569. for (name in this._matrices) {
  67570. serializationObject.matrices[name] = this._matrices[name].asArray();
  67571. }
  67572. // Matrix 3x3
  67573. serializationObject.matrices3x3 = {};
  67574. for (name in this._matrices3x3) {
  67575. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  67576. }
  67577. // Matrix 2x2
  67578. serializationObject.matrices2x2 = {};
  67579. for (name in this._matrices2x2) {
  67580. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  67581. }
  67582. // Vector2Array
  67583. serializationObject.vectors2Arrays = {};
  67584. for (name in this._vectors2Arrays) {
  67585. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  67586. }
  67587. // Vector3Array
  67588. serializationObject.vectors3Arrays = {};
  67589. for (name in this._vectors3Arrays) {
  67590. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  67591. }
  67592. return serializationObject;
  67593. };
  67594. /**
  67595. * Creates a shader material from parsed shader material data
  67596. * @param source defines the JSON represnetation of the material
  67597. * @param scene defines the hosting scene
  67598. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67599. * @returns a new material
  67600. */
  67601. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  67602. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  67603. var name;
  67604. // Texture
  67605. for (name in source.textures) {
  67606. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  67607. }
  67608. // Texture arrays
  67609. for (name in source.textureArrays) {
  67610. var array = source.textureArrays[name];
  67611. var textureArray = new Array();
  67612. for (var index = 0; index < array.length; index++) {
  67613. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  67614. }
  67615. material.setTextureArray(name, textureArray);
  67616. }
  67617. // Float
  67618. for (name in source.floats) {
  67619. material.setFloat(name, source.floats[name]);
  67620. }
  67621. // Float s
  67622. for (name in source.floatsArrays) {
  67623. material.setFloats(name, source.floatsArrays[name]);
  67624. }
  67625. // Color3
  67626. for (name in source.colors3) {
  67627. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  67628. }
  67629. // Color3 arrays
  67630. for (name in source.colors3Arrays) {
  67631. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  67632. if (i % 3 === 0) {
  67633. arr.push([num]);
  67634. }
  67635. else {
  67636. arr[arr.length - 1].push(num);
  67637. }
  67638. return arr;
  67639. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  67640. material.setColor3Array(name, colors);
  67641. }
  67642. // Color4
  67643. for (name in source.colors4) {
  67644. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  67645. }
  67646. // Vector2
  67647. for (name in source.vectors2) {
  67648. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  67649. }
  67650. // Vector3
  67651. for (name in source.vectors3) {
  67652. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  67653. }
  67654. // Vector4
  67655. for (name in source.vectors4) {
  67656. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  67657. }
  67658. // Matrix
  67659. for (name in source.matrices) {
  67660. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  67661. }
  67662. // Matrix 3x3
  67663. for (name in source.matrices3x3) {
  67664. material.setMatrix3x3(name, source.matrices3x3[name]);
  67665. }
  67666. // Matrix 2x2
  67667. for (name in source.matrices2x2) {
  67668. material.setMatrix2x2(name, source.matrices2x2[name]);
  67669. }
  67670. // Vector2Array
  67671. for (name in source.vectors2Arrays) {
  67672. material.setArray2(name, source.vectors2Arrays[name]);
  67673. }
  67674. // Vector3Array
  67675. for (name in source.vectors3Arrays) {
  67676. material.setArray3(name, source.vectors3Arrays[name]);
  67677. }
  67678. return material;
  67679. };
  67680. return ShaderMaterial;
  67681. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  67682. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  67683. /***/ }),
  67684. /***/ "./Materials/standardMaterial.ts":
  67685. /*!***************************************!*\
  67686. !*** ./Materials/standardMaterial.ts ***!
  67687. \***************************************/
  67688. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  67689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67690. "use strict";
  67691. __webpack_require__.r(__webpack_exports__);
  67692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  67693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  67694. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67695. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  67696. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  67697. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  67698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67699. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  67700. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  67701. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  67702. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  67703. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  67704. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  67705. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  67706. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  67707. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  67708. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  67709. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  67710. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  67711. /** @hidden */
  67712. var StandardMaterialDefines = /** @class */ (function (_super) {
  67713. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  67714. function StandardMaterialDefines() {
  67715. var _this = _super.call(this) || this;
  67716. _this.MAINUV1 = false;
  67717. _this.MAINUV2 = false;
  67718. _this.DIFFUSE = false;
  67719. _this.DIFFUSEDIRECTUV = 0;
  67720. _this.AMBIENT = false;
  67721. _this.AMBIENTDIRECTUV = 0;
  67722. _this.OPACITY = false;
  67723. _this.OPACITYDIRECTUV = 0;
  67724. _this.OPACITYRGB = false;
  67725. _this.REFLECTION = false;
  67726. _this.EMISSIVE = false;
  67727. _this.EMISSIVEDIRECTUV = 0;
  67728. _this.SPECULAR = false;
  67729. _this.SPECULARDIRECTUV = 0;
  67730. _this.BUMP = false;
  67731. _this.BUMPDIRECTUV = 0;
  67732. _this.PARALLAX = false;
  67733. _this.PARALLAXOCCLUSION = false;
  67734. _this.SPECULAROVERALPHA = false;
  67735. _this.CLIPPLANE = false;
  67736. _this.CLIPPLANE2 = false;
  67737. _this.CLIPPLANE3 = false;
  67738. _this.CLIPPLANE4 = false;
  67739. _this.ALPHATEST = false;
  67740. _this.DEPTHPREPASS = false;
  67741. _this.ALPHAFROMDIFFUSE = false;
  67742. _this.POINTSIZE = false;
  67743. _this.FOG = false;
  67744. _this.SPECULARTERM = false;
  67745. _this.DIFFUSEFRESNEL = false;
  67746. _this.OPACITYFRESNEL = false;
  67747. _this.REFLECTIONFRESNEL = false;
  67748. _this.REFRACTIONFRESNEL = false;
  67749. _this.EMISSIVEFRESNEL = false;
  67750. _this.FRESNEL = false;
  67751. _this.NORMAL = false;
  67752. _this.UV1 = false;
  67753. _this.UV2 = false;
  67754. _this.VERTEXCOLOR = false;
  67755. _this.VERTEXALPHA = false;
  67756. _this.NUM_BONE_INFLUENCERS = 0;
  67757. _this.BonesPerMesh = 0;
  67758. _this.BONETEXTURE = false;
  67759. _this.INSTANCES = false;
  67760. _this.GLOSSINESS = false;
  67761. _this.ROUGHNESS = false;
  67762. _this.EMISSIVEASILLUMINATION = false;
  67763. _this.LINKEMISSIVEWITHDIFFUSE = false;
  67764. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  67765. _this.LIGHTMAP = false;
  67766. _this.LIGHTMAPDIRECTUV = 0;
  67767. _this.OBJECTSPACE_NORMALMAP = false;
  67768. _this.USELIGHTMAPASSHADOWMAP = false;
  67769. _this.REFLECTIONMAP_3D = false;
  67770. _this.REFLECTIONMAP_SPHERICAL = false;
  67771. _this.REFLECTIONMAP_PLANAR = false;
  67772. _this.REFLECTIONMAP_CUBIC = false;
  67773. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  67774. _this.REFLECTIONMAP_PROJECTION = false;
  67775. _this.REFLECTIONMAP_SKYBOX = false;
  67776. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  67777. _this.REFLECTIONMAP_EXPLICIT = false;
  67778. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  67779. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  67780. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  67781. _this.INVERTCUBICMAP = false;
  67782. _this.LOGARITHMICDEPTH = false;
  67783. _this.REFRACTION = false;
  67784. _this.REFRACTIONMAP_3D = false;
  67785. _this.REFLECTIONOVERALPHA = false;
  67786. _this.TWOSIDEDLIGHTING = false;
  67787. _this.SHADOWFLOAT = false;
  67788. _this.MORPHTARGETS = false;
  67789. _this.MORPHTARGETS_NORMAL = false;
  67790. _this.MORPHTARGETS_TANGENT = false;
  67791. _this.NUM_MORPH_INFLUENCERS = 0;
  67792. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  67793. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  67794. _this.IMAGEPROCESSING = false;
  67795. _this.VIGNETTE = false;
  67796. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  67797. _this.VIGNETTEBLENDMODEOPAQUE = false;
  67798. _this.TONEMAPPING = false;
  67799. _this.TONEMAPPING_ACES = false;
  67800. _this.CONTRAST = false;
  67801. _this.COLORCURVES = false;
  67802. _this.COLORGRADING = false;
  67803. _this.COLORGRADING3D = false;
  67804. _this.SAMPLER3DGREENDEPTH = false;
  67805. _this.SAMPLER3DBGRMAP = false;
  67806. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  67807. _this.MULTIVIEW = false;
  67808. /**
  67809. * If the reflection texture on this material is in linear color space
  67810. * @hidden
  67811. */
  67812. _this.IS_REFLECTION_LINEAR = false;
  67813. /**
  67814. * If the refraction texture on this material is in linear color space
  67815. * @hidden
  67816. */
  67817. _this.IS_REFRACTION_LINEAR = false;
  67818. _this.EXPOSURE = false;
  67819. _this.rebuild();
  67820. return _this;
  67821. }
  67822. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  67823. var modes = [
  67824. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  67825. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  67826. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  67827. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  67828. ];
  67829. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  67830. var mode = modes_1[_i];
  67831. this[mode] = (mode === modeToEnable);
  67832. }
  67833. };
  67834. return StandardMaterialDefines;
  67835. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  67836. /**
  67837. * This is the default material used in Babylon. It is the best trade off between quality
  67838. * and performances.
  67839. * @see http://doc.babylonjs.com/babylon101/materials
  67840. */
  67841. var StandardMaterial = /** @class */ (function (_super) {
  67842. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  67843. /**
  67844. * Instantiates a new standard material.
  67845. * This is the default material used in Babylon. It is the best trade off between quality
  67846. * and performances.
  67847. * @see http://doc.babylonjs.com/babylon101/materials
  67848. * @param name Define the name of the material in the scene
  67849. * @param scene Define the scene the material belong to
  67850. */
  67851. function StandardMaterial(name, scene) {
  67852. var _this = _super.call(this, name, scene) || this;
  67853. /**
  67854. * The color of the material lit by the environmental background lighting.
  67855. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  67856. */
  67857. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  67858. /**
  67859. * The basic color of the material as viewed under a light.
  67860. */
  67861. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  67862. /**
  67863. * Define how the color and intensity of the highlight given by the light in the material.
  67864. */
  67865. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  67866. /**
  67867. * Define the color of the material as if self lit.
  67868. * This will be mixed in the final result even in the absence of light.
  67869. */
  67870. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  67871. /**
  67872. * Defines how sharp are the highlights in the material.
  67873. * The bigger the value the sharper giving a more glossy feeling to the result.
  67874. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  67875. */
  67876. _this.specularPower = 64;
  67877. _this._useAlphaFromDiffuseTexture = false;
  67878. _this._useEmissiveAsIllumination = false;
  67879. _this._linkEmissiveWithDiffuse = false;
  67880. _this._useSpecularOverAlpha = false;
  67881. _this._useReflectionOverAlpha = false;
  67882. _this._disableLighting = false;
  67883. _this._useObjectSpaceNormalMap = false;
  67884. _this._useParallax = false;
  67885. _this._useParallaxOcclusion = false;
  67886. /**
  67887. * 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.
  67888. */
  67889. _this.parallaxScaleBias = 0.05;
  67890. _this._roughness = 0;
  67891. /**
  67892. * In case of refraction, define the value of the indice of refraction.
  67893. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  67894. */
  67895. _this.indexOfRefraction = 0.98;
  67896. /**
  67897. * Invert the refraction texture alongside the y axis.
  67898. * It can be useful with procedural textures or probe for instance.
  67899. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  67900. */
  67901. _this.invertRefractionY = true;
  67902. /**
  67903. * Defines the alpha limits in alpha test mode.
  67904. */
  67905. _this.alphaCutOff = 0.4;
  67906. _this._useLightmapAsShadowmap = false;
  67907. _this._useReflectionFresnelFromSpecular = false;
  67908. _this._useGlossinessFromSpecularMapAlpha = false;
  67909. _this._maxSimultaneousLights = 4;
  67910. _this._invertNormalMapX = false;
  67911. _this._invertNormalMapY = false;
  67912. _this._twoSidedLighting = false;
  67913. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  67914. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  67915. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  67916. // Setup the default processing configuration to the scene.
  67917. _this._attachImageProcessingConfiguration(null);
  67918. _this.getRenderTargetTextures = function () {
  67919. _this._renderTargets.reset();
  67920. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  67921. _this._renderTargets.push(_this._reflectionTexture);
  67922. }
  67923. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  67924. _this._renderTargets.push(_this._refractionTexture);
  67925. }
  67926. return _this._renderTargets;
  67927. };
  67928. return _this;
  67929. }
  67930. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  67931. /**
  67932. * Gets the image processing configuration used either in this material.
  67933. */
  67934. get: function () {
  67935. return this._imageProcessingConfiguration;
  67936. },
  67937. /**
  67938. * Sets the Default image processing configuration used either in the this material.
  67939. *
  67940. * If sets to null, the scene one is in use.
  67941. */
  67942. set: function (value) {
  67943. this._attachImageProcessingConfiguration(value);
  67944. // Ensure the effect will be rebuilt.
  67945. this._markAllSubMeshesAsTexturesDirty();
  67946. },
  67947. enumerable: true,
  67948. configurable: true
  67949. });
  67950. /**
  67951. * Attaches a new image processing configuration to the Standard Material.
  67952. * @param configuration
  67953. */
  67954. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  67955. var _this = this;
  67956. if (configuration === this._imageProcessingConfiguration) {
  67957. return;
  67958. }
  67959. // Detaches observer.
  67960. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  67961. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  67962. }
  67963. // Pick the scene configuration if needed.
  67964. if (!configuration) {
  67965. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  67966. }
  67967. else {
  67968. this._imageProcessingConfiguration = configuration;
  67969. }
  67970. // Attaches observer.
  67971. if (this._imageProcessingConfiguration) {
  67972. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  67973. _this._markAllSubMeshesAsImageProcessingDirty();
  67974. });
  67975. }
  67976. };
  67977. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  67978. /**
  67979. * Gets wether the color curves effect is enabled.
  67980. */
  67981. get: function () {
  67982. return this.imageProcessingConfiguration.colorCurvesEnabled;
  67983. },
  67984. /**
  67985. * Sets wether the color curves effect is enabled.
  67986. */
  67987. set: function (value) {
  67988. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  67989. },
  67990. enumerable: true,
  67991. configurable: true
  67992. });
  67993. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  67994. /**
  67995. * Gets wether the color grading effect is enabled.
  67996. */
  67997. get: function () {
  67998. return this.imageProcessingConfiguration.colorGradingEnabled;
  67999. },
  68000. /**
  68001. * Gets wether the color grading effect is enabled.
  68002. */
  68003. set: function (value) {
  68004. this.imageProcessingConfiguration.colorGradingEnabled = value;
  68005. },
  68006. enumerable: true,
  68007. configurable: true
  68008. });
  68009. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  68010. /**
  68011. * Gets wether tonemapping is enabled or not.
  68012. */
  68013. get: function () {
  68014. return this._imageProcessingConfiguration.toneMappingEnabled;
  68015. },
  68016. /**
  68017. * Sets wether tonemapping is enabled or not
  68018. */
  68019. set: function (value) {
  68020. this._imageProcessingConfiguration.toneMappingEnabled = value;
  68021. },
  68022. enumerable: true,
  68023. configurable: true
  68024. });
  68025. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  68026. /**
  68027. * The camera exposure used on this material.
  68028. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  68029. * This corresponds to a photographic exposure.
  68030. */
  68031. get: function () {
  68032. return this._imageProcessingConfiguration.exposure;
  68033. },
  68034. /**
  68035. * The camera exposure used on this material.
  68036. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  68037. * This corresponds to a photographic exposure.
  68038. */
  68039. set: function (value) {
  68040. this._imageProcessingConfiguration.exposure = value;
  68041. },
  68042. enumerable: true,
  68043. configurable: true
  68044. });
  68045. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  68046. /**
  68047. * Gets The camera contrast used on this material.
  68048. */
  68049. get: function () {
  68050. return this._imageProcessingConfiguration.contrast;
  68051. },
  68052. /**
  68053. * Sets The camera contrast used on this material.
  68054. */
  68055. set: function (value) {
  68056. this._imageProcessingConfiguration.contrast = value;
  68057. },
  68058. enumerable: true,
  68059. configurable: true
  68060. });
  68061. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  68062. /**
  68063. * Gets the Color Grading 2D Lookup Texture.
  68064. */
  68065. get: function () {
  68066. return this._imageProcessingConfiguration.colorGradingTexture;
  68067. },
  68068. /**
  68069. * Sets the Color Grading 2D Lookup Texture.
  68070. */
  68071. set: function (value) {
  68072. this._imageProcessingConfiguration.colorGradingTexture = value;
  68073. },
  68074. enumerable: true,
  68075. configurable: true
  68076. });
  68077. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  68078. /**
  68079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  68080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  68081. * 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;
  68082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  68083. */
  68084. get: function () {
  68085. return this._imageProcessingConfiguration.colorCurves;
  68086. },
  68087. /**
  68088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  68089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  68090. * 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;
  68091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  68092. */
  68093. set: function (value) {
  68094. this._imageProcessingConfiguration.colorCurves = value;
  68095. },
  68096. enumerable: true,
  68097. configurable: true
  68098. });
  68099. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  68100. /**
  68101. * Gets a boolean indicating that current material needs to register RTT
  68102. */
  68103. get: function () {
  68104. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  68105. return true;
  68106. }
  68107. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  68108. return true;
  68109. }
  68110. return false;
  68111. },
  68112. enumerable: true,
  68113. configurable: true
  68114. });
  68115. /**
  68116. * Gets the current class name of the material e.g. "StandardMaterial"
  68117. * Mainly use in serialization.
  68118. * @returns the class name
  68119. */
  68120. StandardMaterial.prototype.getClassName = function () {
  68121. return "StandardMaterial";
  68122. };
  68123. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  68124. /**
  68125. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  68126. * You can try switching to logarithmic depth.
  68127. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  68128. */
  68129. get: function () {
  68130. return this._useLogarithmicDepth;
  68131. },
  68132. set: function (value) {
  68133. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  68134. this._markAllSubMeshesAsMiscDirty();
  68135. },
  68136. enumerable: true,
  68137. configurable: true
  68138. });
  68139. /**
  68140. * Specifies if the material will require alpha blending
  68141. * @returns a boolean specifying if alpha blending is needed
  68142. */
  68143. StandardMaterial.prototype.needAlphaBlending = function () {
  68144. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  68145. };
  68146. /**
  68147. * Specifies if this material should be rendered in alpha test mode
  68148. * @returns a boolean specifying if an alpha test is needed.
  68149. */
  68150. StandardMaterial.prototype.needAlphaTesting = function () {
  68151. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  68152. };
  68153. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  68154. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  68155. };
  68156. /**
  68157. * Get the texture used for alpha test purpose.
  68158. * @returns the diffuse texture in case of the standard material.
  68159. */
  68160. StandardMaterial.prototype.getAlphaTestTexture = function () {
  68161. return this._diffuseTexture;
  68162. };
  68163. /**
  68164. * Get if the submesh is ready to be used and all its information available.
  68165. * Child classes can use it to update shaders
  68166. * @param mesh defines the mesh to check
  68167. * @param subMesh defines which submesh to check
  68168. * @param useInstances specifies that instances should be used
  68169. * @returns a boolean indicating that the submesh is ready or not
  68170. */
  68171. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  68172. if (useInstances === void 0) { useInstances = false; }
  68173. if (subMesh.effect && this.isFrozen) {
  68174. if (this._wasPreviouslyReady) {
  68175. return true;
  68176. }
  68177. }
  68178. if (!subMesh._materialDefines) {
  68179. subMesh._materialDefines = new StandardMaterialDefines();
  68180. }
  68181. var scene = this.getScene();
  68182. var defines = subMesh._materialDefines;
  68183. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  68184. if (defines._renderId === scene.getRenderId()) {
  68185. return true;
  68186. }
  68187. }
  68188. var engine = scene.getEngine();
  68189. // Lights
  68190. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  68191. if (scene.activeCamera) {
  68192. var previousMultiview = defines.MULTIVIEW;
  68193. defines.MULTIVIEW = (scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1);
  68194. if (defines.MULTIVIEW != previousMultiview) {
  68195. defines.markAsUnprocessed();
  68196. }
  68197. }
  68198. // Textures
  68199. if (defines._areTexturesDirty) {
  68200. defines._needUVs = false;
  68201. defines.MAINUV1 = false;
  68202. defines.MAINUV2 = false;
  68203. if (scene.texturesEnabled) {
  68204. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  68205. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  68206. return false;
  68207. }
  68208. else {
  68209. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  68210. }
  68211. }
  68212. else {
  68213. defines.DIFFUSE = false;
  68214. }
  68215. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  68216. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  68217. return false;
  68218. }
  68219. else {
  68220. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  68221. }
  68222. }
  68223. else {
  68224. defines.AMBIENT = false;
  68225. }
  68226. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  68227. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  68228. return false;
  68229. }
  68230. else {
  68231. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  68232. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  68233. }
  68234. }
  68235. else {
  68236. defines.OPACITY = false;
  68237. }
  68238. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  68239. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  68240. return false;
  68241. }
  68242. else {
  68243. defines._needNormals = true;
  68244. defines.REFLECTION = true;
  68245. defines.ROUGHNESS = (this._roughness > 0);
  68246. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  68247. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  68248. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  68249. switch (this._reflectionTexture.coordinatesMode) {
  68250. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  68251. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  68252. break;
  68253. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  68254. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  68255. break;
  68256. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  68257. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  68258. break;
  68259. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  68260. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  68261. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  68262. break;
  68263. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  68264. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  68265. break;
  68266. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  68267. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  68268. break;
  68269. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  68270. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  68271. break;
  68272. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  68273. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  68274. break;
  68275. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  68276. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  68277. default:
  68278. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  68279. break;
  68280. }
  68281. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  68282. }
  68283. }
  68284. else {
  68285. defines.REFLECTION = false;
  68286. }
  68287. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  68288. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  68289. return false;
  68290. }
  68291. else {
  68292. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  68293. }
  68294. }
  68295. else {
  68296. defines.EMISSIVE = false;
  68297. }
  68298. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  68299. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  68300. return false;
  68301. }
  68302. else {
  68303. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  68304. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  68305. }
  68306. }
  68307. else {
  68308. defines.LIGHTMAP = false;
  68309. }
  68310. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  68311. if (!this._specularTexture.isReadyOrNotBlocking()) {
  68312. return false;
  68313. }
  68314. else {
  68315. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  68316. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  68317. }
  68318. }
  68319. else {
  68320. defines.SPECULAR = false;
  68321. }
  68322. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  68323. // Bump texure can not be not blocking.
  68324. if (!this._bumpTexture.isReady()) {
  68325. return false;
  68326. }
  68327. else {
  68328. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  68329. defines.PARALLAX = this._useParallax;
  68330. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  68331. }
  68332. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  68333. }
  68334. else {
  68335. defines.BUMP = false;
  68336. }
  68337. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  68338. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  68339. return false;
  68340. }
  68341. else {
  68342. defines._needUVs = true;
  68343. defines.REFRACTION = true;
  68344. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  68345. }
  68346. }
  68347. else {
  68348. defines.REFRACTION = false;
  68349. }
  68350. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  68351. }
  68352. else {
  68353. defines.DIFFUSE = false;
  68354. defines.AMBIENT = false;
  68355. defines.OPACITY = false;
  68356. defines.REFLECTION = false;
  68357. defines.EMISSIVE = false;
  68358. defines.LIGHTMAP = false;
  68359. defines.BUMP = false;
  68360. defines.REFRACTION = false;
  68361. }
  68362. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  68363. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  68364. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  68365. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  68366. 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);
  68367. }
  68368. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  68369. if (!this._imageProcessingConfiguration.isReady()) {
  68370. return false;
  68371. }
  68372. this._imageProcessingConfiguration.prepareDefines(defines);
  68373. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  68374. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  68375. }
  68376. if (defines._areFresnelDirty) {
  68377. if (StandardMaterial.FresnelEnabled) {
  68378. // Fresnel
  68379. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  68380. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  68381. this._reflectionFresnelParameters) {
  68382. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  68383. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  68384. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  68385. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  68386. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  68387. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  68388. defines._needNormals = true;
  68389. defines.FRESNEL = true;
  68390. }
  68391. }
  68392. else {
  68393. defines.FRESNEL = false;
  68394. }
  68395. }
  68396. // Misc.
  68397. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  68398. // Attribs
  68399. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  68400. // Values that need to be evaluated on every frame
  68401. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  68402. // Get correct effect
  68403. if (defines.isDirty) {
  68404. defines.markAsProcessed();
  68405. // Fallbacks
  68406. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  68407. if (defines.REFLECTION) {
  68408. fallbacks.addFallback(0, "REFLECTION");
  68409. }
  68410. if (defines.SPECULAR) {
  68411. fallbacks.addFallback(0, "SPECULAR");
  68412. }
  68413. if (defines.BUMP) {
  68414. fallbacks.addFallback(0, "BUMP");
  68415. }
  68416. if (defines.PARALLAX) {
  68417. fallbacks.addFallback(1, "PARALLAX");
  68418. }
  68419. if (defines.PARALLAXOCCLUSION) {
  68420. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  68421. }
  68422. if (defines.SPECULAROVERALPHA) {
  68423. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  68424. }
  68425. if (defines.FOG) {
  68426. fallbacks.addFallback(1, "FOG");
  68427. }
  68428. if (defines.POINTSIZE) {
  68429. fallbacks.addFallback(0, "POINTSIZE");
  68430. }
  68431. if (defines.LOGARITHMICDEPTH) {
  68432. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  68433. }
  68434. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  68435. if (defines.SPECULARTERM) {
  68436. fallbacks.addFallback(0, "SPECULARTERM");
  68437. }
  68438. if (defines.DIFFUSEFRESNEL) {
  68439. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  68440. }
  68441. if (defines.OPACITYFRESNEL) {
  68442. fallbacks.addFallback(2, "OPACITYFRESNEL");
  68443. }
  68444. if (defines.REFLECTIONFRESNEL) {
  68445. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  68446. }
  68447. if (defines.EMISSIVEFRESNEL) {
  68448. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  68449. }
  68450. if (defines.FRESNEL) {
  68451. fallbacks.addFallback(4, "FRESNEL");
  68452. }
  68453. if (defines.MULTIVIEW) {
  68454. fallbacks.addFallback(0, "MULTIVIEW");
  68455. }
  68456. //Attributes
  68457. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  68458. if (defines.NORMAL) {
  68459. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  68460. }
  68461. if (defines.UV1) {
  68462. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  68463. }
  68464. if (defines.UV2) {
  68465. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  68466. }
  68467. if (defines.VERTEXCOLOR) {
  68468. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  68469. }
  68470. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  68471. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  68472. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  68473. var shaderName = "default";
  68474. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility",
  68475. "vFogInfos", "vFogColor", "pointSize",
  68476. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  68477. "mBones",
  68478. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  68479. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  68480. "vReflectionPosition", "vReflectionSize",
  68481. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  68482. ];
  68483. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  68484. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  68485. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  68486. var uniformBuffers = ["Material", "Scene"];
  68487. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  68488. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  68489. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  68490. }
  68491. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  68492. uniformsNames: uniforms,
  68493. uniformBuffersNames: uniformBuffers,
  68494. samplers: samplers,
  68495. defines: defines,
  68496. maxSimultaneousLights: this._maxSimultaneousLights
  68497. });
  68498. if (this.customShaderNameResolve) {
  68499. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  68500. }
  68501. var join = defines.toString();
  68502. var previousEffect = subMesh.effect;
  68503. var effect = scene.getEngine().createEffect(shaderName, {
  68504. attributes: attribs,
  68505. uniformsNames: uniforms,
  68506. uniformBuffersNames: uniformBuffers,
  68507. samplers: samplers,
  68508. defines: join,
  68509. fallbacks: fallbacks,
  68510. onCompiled: this.onCompiled,
  68511. onError: this.onError,
  68512. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  68513. }, engine);
  68514. if (effect) {
  68515. // Use previous effect while new one is compiling
  68516. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  68517. effect = previousEffect;
  68518. defines.markAsUnprocessed();
  68519. }
  68520. else {
  68521. scene.resetCachedMaterial();
  68522. subMesh.setEffect(effect, defines);
  68523. this.buildUniformLayout();
  68524. }
  68525. }
  68526. }
  68527. if (!subMesh.effect || !subMesh.effect.isReady()) {
  68528. return false;
  68529. }
  68530. defines._renderId = scene.getRenderId();
  68531. this._wasPreviouslyReady = true;
  68532. return true;
  68533. };
  68534. /**
  68535. * Builds the material UBO layouts.
  68536. * Used internally during the effect preparation.
  68537. */
  68538. StandardMaterial.prototype.buildUniformLayout = function () {
  68539. // Order is important !
  68540. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  68541. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  68542. this._uniformBuffer.addUniform("opacityParts", 4);
  68543. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  68544. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  68545. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  68546. this._uniformBuffer.addUniform("refractionRightColor", 4);
  68547. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  68548. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  68549. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  68550. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  68551. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  68552. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  68553. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  68554. this._uniformBuffer.addUniform("vReflectionSize", 3);
  68555. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  68556. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  68557. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  68558. this._uniformBuffer.addUniform("vBumpInfos", 3);
  68559. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  68560. this._uniformBuffer.addUniform("ambientMatrix", 16);
  68561. this._uniformBuffer.addUniform("opacityMatrix", 16);
  68562. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  68563. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  68564. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  68565. this._uniformBuffer.addUniform("specularMatrix", 16);
  68566. this._uniformBuffer.addUniform("bumpMatrix", 16);
  68567. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  68568. this._uniformBuffer.addUniform("pointSize", 1);
  68569. this._uniformBuffer.addUniform("refractionMatrix", 16);
  68570. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  68571. this._uniformBuffer.addUniform("vSpecularColor", 4);
  68572. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  68573. this._uniformBuffer.addUniform("visibility", 1);
  68574. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  68575. this._uniformBuffer.create();
  68576. };
  68577. /**
  68578. * Unbinds the material from the mesh
  68579. */
  68580. StandardMaterial.prototype.unbind = function () {
  68581. if (this._activeEffect) {
  68582. var needFlag = false;
  68583. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  68584. this._activeEffect.setTexture("reflection2DSampler", null);
  68585. needFlag = true;
  68586. }
  68587. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  68588. this._activeEffect.setTexture("refraction2DSampler", null);
  68589. needFlag = true;
  68590. }
  68591. if (needFlag) {
  68592. this._markAllSubMeshesAsTexturesDirty();
  68593. }
  68594. }
  68595. _super.prototype.unbind.call(this);
  68596. };
  68597. /**
  68598. * Binds the submesh to this material by preparing the effect and shader to draw
  68599. * @param world defines the world transformation matrix
  68600. * @param mesh defines the mesh containing the submesh
  68601. * @param subMesh defines the submesh to bind the material to
  68602. */
  68603. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  68604. var scene = this.getScene();
  68605. var defines = subMesh._materialDefines;
  68606. if (!defines) {
  68607. return;
  68608. }
  68609. var effect = subMesh.effect;
  68610. if (!effect) {
  68611. return;
  68612. }
  68613. this._activeEffect = effect;
  68614. // Matrices
  68615. this.bindOnlyWorldMatrix(world);
  68616. // Normal Matrix
  68617. if (defines.OBJECTSPACE_NORMALMAP) {
  68618. world.toNormalMatrix(this._normalMatrix);
  68619. this.bindOnlyNormalMatrix(this._normalMatrix);
  68620. }
  68621. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  68622. // Bones
  68623. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  68624. if (mustRebind) {
  68625. this._uniformBuffer.bindToEffect(effect, "Material");
  68626. this.bindViewProjection(effect);
  68627. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  68628. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  68629. // Fresnel
  68630. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  68631. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  68632. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  68633. }
  68634. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  68635. 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);
  68636. }
  68637. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  68638. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  68639. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  68640. }
  68641. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  68642. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  68643. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  68644. }
  68645. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  68646. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  68647. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  68648. }
  68649. }
  68650. // Textures
  68651. if (scene.texturesEnabled) {
  68652. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  68653. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  68654. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  68655. if (this._diffuseTexture.hasAlpha) {
  68656. effect.setFloat("alphaCutOff", this.alphaCutOff);
  68657. }
  68658. }
  68659. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  68660. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  68661. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  68662. }
  68663. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  68664. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  68665. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  68666. }
  68667. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  68668. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  68669. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  68670. if (this._reflectionTexture.boundingBoxSize) {
  68671. var cubeTexture = this._reflectionTexture;
  68672. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  68673. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  68674. }
  68675. }
  68676. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  68677. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  68678. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  68679. }
  68680. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  68681. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  68682. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  68683. }
  68684. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  68685. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  68686. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  68687. }
  68688. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  68689. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  68690. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  68691. if (scene._mirroredCameraPosition) {
  68692. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  68693. }
  68694. else {
  68695. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  68696. }
  68697. }
  68698. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  68699. var depth = 1.0;
  68700. if (!this._refractionTexture.isCube) {
  68701. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  68702. if (this._refractionTexture.depth) {
  68703. depth = this._refractionTexture.depth;
  68704. }
  68705. }
  68706. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  68707. }
  68708. }
  68709. // Point size
  68710. if (this.pointsCloud) {
  68711. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  68712. }
  68713. if (defines.SPECULARTERM) {
  68714. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  68715. }
  68716. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  68717. // Visibility
  68718. this._uniformBuffer.updateFloat("visibility", mesh.visibility);
  68719. // Diffuse
  68720. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha);
  68721. }
  68722. // Textures
  68723. if (scene.texturesEnabled) {
  68724. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  68725. effect.setTexture("diffuseSampler", this._diffuseTexture);
  68726. }
  68727. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  68728. effect.setTexture("ambientSampler", this._ambientTexture);
  68729. }
  68730. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  68731. effect.setTexture("opacitySampler", this._opacityTexture);
  68732. }
  68733. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  68734. if (this._reflectionTexture.isCube) {
  68735. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  68736. }
  68737. else {
  68738. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  68739. }
  68740. }
  68741. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  68742. effect.setTexture("emissiveSampler", this._emissiveTexture);
  68743. }
  68744. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  68745. effect.setTexture("lightmapSampler", this._lightmapTexture);
  68746. }
  68747. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  68748. effect.setTexture("specularSampler", this._specularTexture);
  68749. }
  68750. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  68751. effect.setTexture("bumpSampler", this._bumpTexture);
  68752. }
  68753. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  68754. var depth = 1.0;
  68755. if (this._refractionTexture.isCube) {
  68756. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  68757. }
  68758. else {
  68759. effect.setTexture("refraction2DSampler", this._refractionTexture);
  68760. }
  68761. }
  68762. }
  68763. // Clip plane
  68764. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  68765. // Colors
  68766. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  68767. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  68768. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  68769. }
  68770. if (mustRebind || !this.isFrozen) {
  68771. // Lights
  68772. if (scene.lightsEnabled && !this._disableLighting) {
  68773. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  68774. }
  68775. // View
  68776. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  68777. this.bindView(effect);
  68778. }
  68779. // Fog
  68780. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  68781. // Morph targets
  68782. if (defines.NUM_MORPH_INFLUENCERS) {
  68783. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  68784. }
  68785. // Log. depth
  68786. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  68787. // image processing
  68788. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  68789. this._imageProcessingConfiguration.bind(this._activeEffect);
  68790. }
  68791. }
  68792. this._uniformBuffer.update();
  68793. this._afterBind(mesh, this._activeEffect);
  68794. };
  68795. /**
  68796. * Get the list of animatables in the material.
  68797. * @returns the list of animatables object used in the material
  68798. */
  68799. StandardMaterial.prototype.getAnimatables = function () {
  68800. var results = [];
  68801. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  68802. results.push(this._diffuseTexture);
  68803. }
  68804. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  68805. results.push(this._ambientTexture);
  68806. }
  68807. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  68808. results.push(this._opacityTexture);
  68809. }
  68810. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  68811. results.push(this._reflectionTexture);
  68812. }
  68813. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  68814. results.push(this._emissiveTexture);
  68815. }
  68816. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  68817. results.push(this._specularTexture);
  68818. }
  68819. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  68820. results.push(this._bumpTexture);
  68821. }
  68822. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  68823. results.push(this._lightmapTexture);
  68824. }
  68825. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  68826. results.push(this._refractionTexture);
  68827. }
  68828. return results;
  68829. };
  68830. /**
  68831. * Gets the active textures from the material
  68832. * @returns an array of textures
  68833. */
  68834. StandardMaterial.prototype.getActiveTextures = function () {
  68835. var activeTextures = _super.prototype.getActiveTextures.call(this);
  68836. if (this._diffuseTexture) {
  68837. activeTextures.push(this._diffuseTexture);
  68838. }
  68839. if (this._ambientTexture) {
  68840. activeTextures.push(this._ambientTexture);
  68841. }
  68842. if (this._opacityTexture) {
  68843. activeTextures.push(this._opacityTexture);
  68844. }
  68845. if (this._reflectionTexture) {
  68846. activeTextures.push(this._reflectionTexture);
  68847. }
  68848. if (this._emissiveTexture) {
  68849. activeTextures.push(this._emissiveTexture);
  68850. }
  68851. if (this._specularTexture) {
  68852. activeTextures.push(this._specularTexture);
  68853. }
  68854. if (this._bumpTexture) {
  68855. activeTextures.push(this._bumpTexture);
  68856. }
  68857. if (this._lightmapTexture) {
  68858. activeTextures.push(this._lightmapTexture);
  68859. }
  68860. if (this._refractionTexture) {
  68861. activeTextures.push(this._refractionTexture);
  68862. }
  68863. return activeTextures;
  68864. };
  68865. /**
  68866. * Specifies if the material uses a texture
  68867. * @param texture defines the texture to check against the material
  68868. * @returns a boolean specifying if the material uses the texture
  68869. */
  68870. StandardMaterial.prototype.hasTexture = function (texture) {
  68871. if (_super.prototype.hasTexture.call(this, texture)) {
  68872. return true;
  68873. }
  68874. if (this._diffuseTexture === texture) {
  68875. return true;
  68876. }
  68877. if (this._ambientTexture === texture) {
  68878. return true;
  68879. }
  68880. if (this._opacityTexture === texture) {
  68881. return true;
  68882. }
  68883. if (this._reflectionTexture === texture) {
  68884. return true;
  68885. }
  68886. if (this._emissiveTexture === texture) {
  68887. return true;
  68888. }
  68889. if (this._specularTexture === texture) {
  68890. return true;
  68891. }
  68892. if (this._bumpTexture === texture) {
  68893. return true;
  68894. }
  68895. if (this._lightmapTexture === texture) {
  68896. return true;
  68897. }
  68898. if (this._refractionTexture === texture) {
  68899. return true;
  68900. }
  68901. return false;
  68902. };
  68903. /**
  68904. * Disposes the material
  68905. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68906. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  68907. */
  68908. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  68909. if (forceDisposeTextures) {
  68910. if (this._diffuseTexture) {
  68911. this._diffuseTexture.dispose();
  68912. }
  68913. if (this._ambientTexture) {
  68914. this._ambientTexture.dispose();
  68915. }
  68916. if (this._opacityTexture) {
  68917. this._opacityTexture.dispose();
  68918. }
  68919. if (this._reflectionTexture) {
  68920. this._reflectionTexture.dispose();
  68921. }
  68922. if (this._emissiveTexture) {
  68923. this._emissiveTexture.dispose();
  68924. }
  68925. if (this._specularTexture) {
  68926. this._specularTexture.dispose();
  68927. }
  68928. if (this._bumpTexture) {
  68929. this._bumpTexture.dispose();
  68930. }
  68931. if (this._lightmapTexture) {
  68932. this._lightmapTexture.dispose();
  68933. }
  68934. if (this._refractionTexture) {
  68935. this._refractionTexture.dispose();
  68936. }
  68937. }
  68938. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  68939. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  68940. }
  68941. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  68942. };
  68943. /**
  68944. * Makes a duplicate of the material, and gives it a new name
  68945. * @param name defines the new name for the duplicated material
  68946. * @returns the cloned material
  68947. */
  68948. StandardMaterial.prototype.clone = function (name) {
  68949. var _this = this;
  68950. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  68951. result.name = name;
  68952. result.id = name;
  68953. return result;
  68954. };
  68955. /**
  68956. * Serializes this material in a JSON representation
  68957. * @returns the serialized material object
  68958. */
  68959. StandardMaterial.prototype.serialize = function () {
  68960. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  68961. };
  68962. /**
  68963. * Creates a standard material from parsed material data
  68964. * @param source defines the JSON representation of the material
  68965. * @param scene defines the hosting scene
  68966. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68967. * @returns a new standard material
  68968. */
  68969. StandardMaterial.Parse = function (source, scene, rootUrl) {
  68970. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  68971. };
  68972. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  68973. // Flags used to enable or disable a type of texture for all Standard Materials
  68974. /**
  68975. * Are diffuse textures enabled in the application.
  68976. */
  68977. get: function () {
  68978. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  68979. },
  68980. set: function (value) {
  68981. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  68982. },
  68983. enumerable: true,
  68984. configurable: true
  68985. });
  68986. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  68987. /**
  68988. * Are ambient textures enabled in the application.
  68989. */
  68990. get: function () {
  68991. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  68992. },
  68993. set: function (value) {
  68994. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  68995. },
  68996. enumerable: true,
  68997. configurable: true
  68998. });
  68999. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  69000. /**
  69001. * Are opacity textures enabled in the application.
  69002. */
  69003. get: function () {
  69004. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  69005. },
  69006. set: function (value) {
  69007. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  69008. },
  69009. enumerable: true,
  69010. configurable: true
  69011. });
  69012. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  69013. /**
  69014. * Are reflection textures enabled in the application.
  69015. */
  69016. get: function () {
  69017. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  69018. },
  69019. set: function (value) {
  69020. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  69021. },
  69022. enumerable: true,
  69023. configurable: true
  69024. });
  69025. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  69026. /**
  69027. * Are emissive textures enabled in the application.
  69028. */
  69029. get: function () {
  69030. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  69031. },
  69032. set: function (value) {
  69033. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  69034. },
  69035. enumerable: true,
  69036. configurable: true
  69037. });
  69038. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  69039. /**
  69040. * Are specular textures enabled in the application.
  69041. */
  69042. get: function () {
  69043. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  69044. },
  69045. set: function (value) {
  69046. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  69047. },
  69048. enumerable: true,
  69049. configurable: true
  69050. });
  69051. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  69052. /**
  69053. * Are bump textures enabled in the application.
  69054. */
  69055. get: function () {
  69056. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  69057. },
  69058. set: function (value) {
  69059. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  69060. },
  69061. enumerable: true,
  69062. configurable: true
  69063. });
  69064. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  69065. /**
  69066. * Are lightmap textures enabled in the application.
  69067. */
  69068. get: function () {
  69069. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  69070. },
  69071. set: function (value) {
  69072. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  69073. },
  69074. enumerable: true,
  69075. configurable: true
  69076. });
  69077. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  69078. /**
  69079. * Are refraction textures enabled in the application.
  69080. */
  69081. get: function () {
  69082. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  69083. },
  69084. set: function (value) {
  69085. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  69086. },
  69087. enumerable: true,
  69088. configurable: true
  69089. });
  69090. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  69091. /**
  69092. * Are color grading textures enabled in the application.
  69093. */
  69094. get: function () {
  69095. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  69096. },
  69097. set: function (value) {
  69098. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  69099. },
  69100. enumerable: true,
  69101. configurable: true
  69102. });
  69103. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  69104. /**
  69105. * Are fresnels enabled in the application.
  69106. */
  69107. get: function () {
  69108. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  69109. },
  69110. set: function (value) {
  69111. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  69112. },
  69113. enumerable: true,
  69114. configurable: true
  69115. });
  69116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  69118. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  69119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  69121. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  69122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  69124. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  69125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69127. ], StandardMaterial.prototype, "ambientTexture", void 0);
  69128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  69130. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  69131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  69133. ], StandardMaterial.prototype, "opacityTexture", void 0);
  69134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  69136. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  69137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69139. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  69140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  69142. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  69143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69145. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  69146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  69148. ], StandardMaterial.prototype, "_specularTexture", void 0);
  69149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69151. ], StandardMaterial.prototype, "specularTexture", void 0);
  69152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  69154. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  69155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69157. ], StandardMaterial.prototype, "bumpTexture", void 0);
  69158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  69160. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  69161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69163. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  69164. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69165. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  69166. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  69167. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69169. ], StandardMaterial.prototype, "refractionTexture", void 0);
  69170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  69172. ], StandardMaterial.prototype, "ambientColor", void 0);
  69173. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69174. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  69175. ], StandardMaterial.prototype, "diffuseColor", void 0);
  69176. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69177. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  69178. ], StandardMaterial.prototype, "specularColor", void 0);
  69179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  69181. ], StandardMaterial.prototype, "emissiveColor", void 0);
  69182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69184. ], StandardMaterial.prototype, "specularPower", void 0);
  69185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  69187. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  69188. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69189. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69190. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  69191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  69193. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  69194. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69196. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  69197. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69198. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  69199. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  69200. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69202. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  69203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  69205. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  69206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69208. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  69209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  69211. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  69212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69214. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  69215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  69217. ], StandardMaterial.prototype, "_disableLighting", void 0);
  69218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  69220. ], StandardMaterial.prototype, "disableLighting", void 0);
  69221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  69223. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  69224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69226. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  69227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  69229. ], StandardMaterial.prototype, "_useParallax", void 0);
  69230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69232. ], StandardMaterial.prototype, "useParallax", void 0);
  69233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  69235. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  69236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69238. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  69239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69241. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  69242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  69244. ], StandardMaterial.prototype, "_roughness", void 0);
  69245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69247. ], StandardMaterial.prototype, "roughness", void 0);
  69248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69250. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  69251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69253. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  69254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69256. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  69257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  69259. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  69260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69262. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  69263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  69265. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  69266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69268. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  69269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  69271. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  69272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  69274. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  69275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  69277. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  69278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69280. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  69281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  69283. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  69284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69286. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  69287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  69289. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  69290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69292. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  69293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  69295. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  69296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69298. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  69299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  69301. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  69302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69304. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  69305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  69307. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  69308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  69310. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  69311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  69313. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  69314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69316. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  69317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  69319. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  69320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69322. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  69323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  69325. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  69326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69328. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  69329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69331. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  69332. return StandardMaterial;
  69333. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  69334. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  69335. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  69336. return new StandardMaterial("default material", scene);
  69337. };
  69338. /***/ }),
  69339. /***/ "./Materials/uniformBuffer.ts":
  69340. /*!************************************!*\
  69341. !*** ./Materials/uniformBuffer.ts ***!
  69342. \************************************/
  69343. /*! exports provided: UniformBuffer */
  69344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69345. "use strict";
  69346. __webpack_require__.r(__webpack_exports__);
  69347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  69348. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  69349. /**
  69350. * Uniform buffer objects.
  69351. *
  69352. * Handles blocks of uniform on the GPU.
  69353. *
  69354. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  69355. *
  69356. * For more information, please refer to :
  69357. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  69358. */
  69359. var UniformBuffer = /** @class */ (function () {
  69360. /**
  69361. * Instantiates a new Uniform buffer objects.
  69362. *
  69363. * Handles blocks of uniform on the GPU.
  69364. *
  69365. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  69366. *
  69367. * For more information, please refer to :
  69368. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  69369. * @param engine Define the engine the buffer is associated with
  69370. * @param data Define the data contained in the buffer
  69371. * @param dynamic Define if the buffer is updatable
  69372. */
  69373. function UniformBuffer(engine, data, dynamic) {
  69374. this._engine = engine;
  69375. this._noUBO = !engine.supportsUniformBuffers;
  69376. this._dynamic = dynamic;
  69377. this._data = data || [];
  69378. this._uniformLocations = {};
  69379. this._uniformSizes = {};
  69380. this._uniformLocationPointer = 0;
  69381. this._needSync = false;
  69382. if (this._noUBO) {
  69383. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  69384. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  69385. this.updateFloat = this._updateFloatForEffect;
  69386. this.updateFloat2 = this._updateFloat2ForEffect;
  69387. this.updateFloat3 = this._updateFloat3ForEffect;
  69388. this.updateFloat4 = this._updateFloat4ForEffect;
  69389. this.updateMatrix = this._updateMatrixForEffect;
  69390. this.updateVector3 = this._updateVector3ForEffect;
  69391. this.updateVector4 = this._updateVector4ForEffect;
  69392. this.updateColor3 = this._updateColor3ForEffect;
  69393. this.updateColor4 = this._updateColor4ForEffect;
  69394. }
  69395. else {
  69396. this._engine._uniformBuffers.push(this);
  69397. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  69398. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  69399. this.updateFloat = this._updateFloatForUniform;
  69400. this.updateFloat2 = this._updateFloat2ForUniform;
  69401. this.updateFloat3 = this._updateFloat3ForUniform;
  69402. this.updateFloat4 = this._updateFloat4ForUniform;
  69403. this.updateMatrix = this._updateMatrixForUniform;
  69404. this.updateVector3 = this._updateVector3ForUniform;
  69405. this.updateVector4 = this._updateVector4ForUniform;
  69406. this.updateColor3 = this._updateColor3ForUniform;
  69407. this.updateColor4 = this._updateColor4ForUniform;
  69408. }
  69409. }
  69410. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  69411. /**
  69412. * Indicates if the buffer is using the WebGL2 UBO implementation,
  69413. * or just falling back on setUniformXXX calls.
  69414. */
  69415. get: function () {
  69416. return !this._noUBO;
  69417. },
  69418. enumerable: true,
  69419. configurable: true
  69420. });
  69421. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  69422. /**
  69423. * Indicates if the WebGL underlying uniform buffer is in sync
  69424. * with the javascript cache data.
  69425. */
  69426. get: function () {
  69427. return !this._needSync;
  69428. },
  69429. enumerable: true,
  69430. configurable: true
  69431. });
  69432. /**
  69433. * Indicates if the WebGL underlying uniform buffer is dynamic.
  69434. * Also, a dynamic UniformBuffer will disable cache verification and always
  69435. * update the underlying WebGL uniform buffer to the GPU.
  69436. * @returns if Dynamic, otherwise false
  69437. */
  69438. UniformBuffer.prototype.isDynamic = function () {
  69439. return this._dynamic !== undefined;
  69440. };
  69441. /**
  69442. * The data cache on JS side.
  69443. * @returns the underlying data as a float array
  69444. */
  69445. UniformBuffer.prototype.getData = function () {
  69446. return this._bufferData;
  69447. };
  69448. /**
  69449. * The underlying WebGL Uniform buffer.
  69450. * @returns the webgl buffer
  69451. */
  69452. UniformBuffer.prototype.getBuffer = function () {
  69453. return this._buffer;
  69454. };
  69455. /**
  69456. * std140 layout specifies how to align data within an UBO structure.
  69457. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  69458. * for specs.
  69459. */
  69460. UniformBuffer.prototype._fillAlignment = function (size) {
  69461. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  69462. // and 4x4 matrices
  69463. // TODO : change if other types are used
  69464. var alignment;
  69465. if (size <= 2) {
  69466. alignment = size;
  69467. }
  69468. else {
  69469. alignment = 4;
  69470. }
  69471. if ((this._uniformLocationPointer % alignment) !== 0) {
  69472. var oldPointer = this._uniformLocationPointer;
  69473. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  69474. var diff = this._uniformLocationPointer - oldPointer;
  69475. for (var i = 0; i < diff; i++) {
  69476. this._data.push(0);
  69477. }
  69478. }
  69479. };
  69480. /**
  69481. * Adds an uniform in the buffer.
  69482. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  69483. * for the layout to be correct !
  69484. * @param name Name of the uniform, as used in the uniform block in the shader.
  69485. * @param size Data size, or data directly.
  69486. */
  69487. UniformBuffer.prototype.addUniform = function (name, size) {
  69488. if (this._noUBO) {
  69489. return;
  69490. }
  69491. if (this._uniformLocations[name] !== undefined) {
  69492. // Already existing uniform
  69493. return;
  69494. }
  69495. // This function must be called in the order of the shader layout !
  69496. // size can be the size of the uniform, or data directly
  69497. var data;
  69498. if (size instanceof Array) {
  69499. data = size;
  69500. size = data.length;
  69501. }
  69502. else {
  69503. size = size;
  69504. data = [];
  69505. // Fill with zeros
  69506. for (var i = 0; i < size; i++) {
  69507. data.push(0);
  69508. }
  69509. }
  69510. this._fillAlignment(size);
  69511. this._uniformSizes[name] = size;
  69512. this._uniformLocations[name] = this._uniformLocationPointer;
  69513. this._uniformLocationPointer += size;
  69514. for (var i = 0; i < size; i++) {
  69515. this._data.push(data[i]);
  69516. }
  69517. this._needSync = true;
  69518. };
  69519. /**
  69520. * Adds a Matrix 4x4 to the uniform buffer.
  69521. * @param name Name of the uniform, as used in the uniform block in the shader.
  69522. * @param mat A 4x4 matrix.
  69523. */
  69524. UniformBuffer.prototype.addMatrix = function (name, mat) {
  69525. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  69526. };
  69527. /**
  69528. * Adds a vec2 to the uniform buffer.
  69529. * @param name Name of the uniform, as used in the uniform block in the shader.
  69530. * @param x Define the x component value of the vec2
  69531. * @param y Define the y component value of the vec2
  69532. */
  69533. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  69534. var temp = [x, y];
  69535. this.addUniform(name, temp);
  69536. };
  69537. /**
  69538. * Adds a vec3 to the uniform buffer.
  69539. * @param name Name of the uniform, as used in the uniform block in the shader.
  69540. * @param x Define the x component value of the vec3
  69541. * @param y Define the y component value of the vec3
  69542. * @param z Define the z component value of the vec3
  69543. */
  69544. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  69545. var temp = [x, y, z];
  69546. this.addUniform(name, temp);
  69547. };
  69548. /**
  69549. * Adds a vec3 to the uniform buffer.
  69550. * @param name Name of the uniform, as used in the uniform block in the shader.
  69551. * @param color Define the vec3 from a Color
  69552. */
  69553. UniformBuffer.prototype.addColor3 = function (name, color) {
  69554. var temp = new Array();
  69555. color.toArray(temp);
  69556. this.addUniform(name, temp);
  69557. };
  69558. /**
  69559. * Adds a vec4 to the uniform buffer.
  69560. * @param name Name of the uniform, as used in the uniform block in the shader.
  69561. * @param color Define the rgb components from a Color
  69562. * @param alpha Define the a component of the vec4
  69563. */
  69564. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  69565. var temp = new Array();
  69566. color.toArray(temp);
  69567. temp.push(alpha);
  69568. this.addUniform(name, temp);
  69569. };
  69570. /**
  69571. * Adds a vec3 to the uniform buffer.
  69572. * @param name Name of the uniform, as used in the uniform block in the shader.
  69573. * @param vector Define the vec3 components from a Vector
  69574. */
  69575. UniformBuffer.prototype.addVector3 = function (name, vector) {
  69576. var temp = new Array();
  69577. vector.toArray(temp);
  69578. this.addUniform(name, temp);
  69579. };
  69580. /**
  69581. * Adds a Matrix 3x3 to the uniform buffer.
  69582. * @param name Name of the uniform, as used in the uniform block in the shader.
  69583. */
  69584. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  69585. this.addUniform(name, 12);
  69586. };
  69587. /**
  69588. * Adds a Matrix 2x2 to the uniform buffer.
  69589. * @param name Name of the uniform, as used in the uniform block in the shader.
  69590. */
  69591. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  69592. this.addUniform(name, 8);
  69593. };
  69594. /**
  69595. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  69596. */
  69597. UniformBuffer.prototype.create = function () {
  69598. if (this._noUBO) {
  69599. return;
  69600. }
  69601. if (this._buffer) {
  69602. return; // nothing to do
  69603. }
  69604. // See spec, alignment must be filled as a vec4
  69605. this._fillAlignment(4);
  69606. this._bufferData = new Float32Array(this._data);
  69607. this._rebuild();
  69608. this._needSync = true;
  69609. };
  69610. /** @hidden */
  69611. UniformBuffer.prototype._rebuild = function () {
  69612. if (this._noUBO) {
  69613. return;
  69614. }
  69615. if (this._dynamic) {
  69616. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  69617. }
  69618. else {
  69619. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  69620. }
  69621. };
  69622. /**
  69623. * Updates the WebGL Uniform Buffer on the GPU.
  69624. * If the `dynamic` flag is set to true, no cache comparison is done.
  69625. * Otherwise, the buffer will be updated only if the cache differs.
  69626. */
  69627. UniformBuffer.prototype.update = function () {
  69628. if (!this._buffer) {
  69629. this.create();
  69630. return;
  69631. }
  69632. if (!this._dynamic && !this._needSync) {
  69633. return;
  69634. }
  69635. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  69636. this._needSync = false;
  69637. };
  69638. /**
  69639. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  69640. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  69641. * @param data Define the flattened data
  69642. * @param size Define the size of the data.
  69643. */
  69644. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  69645. var location = this._uniformLocations[uniformName];
  69646. if (location === undefined) {
  69647. if (this._buffer) {
  69648. // Cannot add an uniform if the buffer is already created
  69649. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  69650. return;
  69651. }
  69652. this.addUniform(uniformName, size);
  69653. location = this._uniformLocations[uniformName];
  69654. }
  69655. if (!this._buffer) {
  69656. this.create();
  69657. }
  69658. if (!this._dynamic) {
  69659. // Cache for static uniform buffers
  69660. var changed = false;
  69661. for (var i = 0; i < size; i++) {
  69662. if (this._bufferData[location + i] !== data[i]) {
  69663. changed = true;
  69664. this._bufferData[location + i] = data[i];
  69665. }
  69666. }
  69667. this._needSync = this._needSync || changed;
  69668. }
  69669. else {
  69670. // No cache for dynamic
  69671. for (var i = 0; i < size; i++) {
  69672. this._bufferData[location + i] = data[i];
  69673. }
  69674. }
  69675. };
  69676. // Update methods
  69677. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  69678. // To match std140, matrix must be realigned
  69679. for (var i = 0; i < 3; i++) {
  69680. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  69681. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  69682. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  69683. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  69684. }
  69685. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  69686. };
  69687. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  69688. this._currentEffect.setMatrix3x3(name, matrix);
  69689. };
  69690. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  69691. this._currentEffect.setMatrix2x2(name, matrix);
  69692. };
  69693. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  69694. // To match std140, matrix must be realigned
  69695. for (var i = 0; i < 2; i++) {
  69696. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  69697. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  69698. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  69699. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  69700. }
  69701. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  69702. };
  69703. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  69704. this._currentEffect.setFloat(name, x);
  69705. };
  69706. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  69707. UniformBuffer._tempBuffer[0] = x;
  69708. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  69709. };
  69710. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  69711. if (suffix === void 0) { suffix = ""; }
  69712. this._currentEffect.setFloat2(name + suffix, x, y);
  69713. };
  69714. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  69715. UniformBuffer._tempBuffer[0] = x;
  69716. UniformBuffer._tempBuffer[1] = y;
  69717. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  69718. };
  69719. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  69720. if (suffix === void 0) { suffix = ""; }
  69721. this._currentEffect.setFloat3(name + suffix, x, y, z);
  69722. };
  69723. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  69724. UniformBuffer._tempBuffer[0] = x;
  69725. UniformBuffer._tempBuffer[1] = y;
  69726. UniformBuffer._tempBuffer[2] = z;
  69727. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  69728. };
  69729. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  69730. if (suffix === void 0) { suffix = ""; }
  69731. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  69732. };
  69733. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  69734. UniformBuffer._tempBuffer[0] = x;
  69735. UniformBuffer._tempBuffer[1] = y;
  69736. UniformBuffer._tempBuffer[2] = z;
  69737. UniformBuffer._tempBuffer[3] = w;
  69738. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  69739. };
  69740. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  69741. this._currentEffect.setMatrix(name, mat);
  69742. };
  69743. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  69744. this.updateUniform(name, mat.toArray(), 16);
  69745. };
  69746. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  69747. this._currentEffect.setVector3(name, vector);
  69748. };
  69749. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  69750. vector.toArray(UniformBuffer._tempBuffer);
  69751. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  69752. };
  69753. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  69754. this._currentEffect.setVector4(name, vector);
  69755. };
  69756. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  69757. vector.toArray(UniformBuffer._tempBuffer);
  69758. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  69759. };
  69760. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  69761. if (suffix === void 0) { suffix = ""; }
  69762. this._currentEffect.setColor3(name + suffix, color);
  69763. };
  69764. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  69765. color.toArray(UniformBuffer._tempBuffer);
  69766. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  69767. };
  69768. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  69769. if (suffix === void 0) { suffix = ""; }
  69770. this._currentEffect.setColor4(name + suffix, color, alpha);
  69771. };
  69772. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  69773. color.toArray(UniformBuffer._tempBuffer);
  69774. UniformBuffer._tempBuffer[3] = alpha;
  69775. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  69776. };
  69777. /**
  69778. * Sets a sampler uniform on the effect.
  69779. * @param name Define the name of the sampler.
  69780. * @param texture Define the texture to set in the sampler
  69781. */
  69782. UniformBuffer.prototype.setTexture = function (name, texture) {
  69783. this._currentEffect.setTexture(name, texture);
  69784. };
  69785. /**
  69786. * Directly updates the value of the uniform in the cache AND on the GPU.
  69787. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  69788. * @param data Define the flattened data
  69789. */
  69790. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  69791. this.updateUniform(uniformName, data, data.length);
  69792. this.update();
  69793. };
  69794. /**
  69795. * Binds this uniform buffer to an effect.
  69796. * @param effect Define the effect to bind the buffer to
  69797. * @param name Name of the uniform block in the shader.
  69798. */
  69799. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  69800. this._currentEffect = effect;
  69801. if (this._noUBO || !this._buffer) {
  69802. return;
  69803. }
  69804. effect.bindUniformBuffer(this._buffer, name);
  69805. };
  69806. /**
  69807. * Disposes the uniform buffer.
  69808. */
  69809. UniformBuffer.prototype.dispose = function () {
  69810. if (this._noUBO) {
  69811. return;
  69812. }
  69813. var uniformBuffers = this._engine._uniformBuffers;
  69814. var index = uniformBuffers.indexOf(this);
  69815. if (index !== -1) {
  69816. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  69817. uniformBuffers.pop();
  69818. }
  69819. if (!this._buffer) {
  69820. return;
  69821. }
  69822. if (this._engine._releaseBuffer(this._buffer)) {
  69823. this._buffer = null;
  69824. }
  69825. };
  69826. // Pool for avoiding memory leaks
  69827. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  69828. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  69829. return UniformBuffer;
  69830. }());
  69831. /***/ }),
  69832. /***/ "./Maths/index.ts":
  69833. /*!************************!*\
  69834. !*** ./Maths/index.ts ***!
  69835. \************************/
  69836. /*! 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 */
  69837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69838. "use strict";
  69839. __webpack_require__.r(__webpack_exports__);
  69840. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  69841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  69842. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  69843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  69844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  69845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  69846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  69847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  69848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  69849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  69850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  69851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  69852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  69853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  69854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  69855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  69856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  69857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  69858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  69859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  69860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  69861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  69862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  69863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  69864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  69865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  69866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  69867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  69868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  69869. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  69870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  69871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  69872. /***/ }),
  69873. /***/ "./Maths/math.scalar.ts":
  69874. /*!******************************!*\
  69875. !*** ./Maths/math.scalar.ts ***!
  69876. \******************************/
  69877. /*! exports provided: Scalar */
  69878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69879. "use strict";
  69880. __webpack_require__.r(__webpack_exports__);
  69881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  69882. /**
  69883. * Scalar computation library
  69884. */
  69885. var Scalar = /** @class */ (function () {
  69886. function Scalar() {
  69887. }
  69888. /**
  69889. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69890. * @param a number
  69891. * @param b number
  69892. * @param epsilon (default = 1.401298E-45)
  69893. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69894. */
  69895. Scalar.WithinEpsilon = function (a, b, epsilon) {
  69896. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  69897. var num = a - b;
  69898. return -epsilon <= num && num <= epsilon;
  69899. };
  69900. /**
  69901. * Returns a string : the upper case translation of the number i to hexadecimal.
  69902. * @param i number
  69903. * @returns the upper case translation of the number i to hexadecimal.
  69904. */
  69905. Scalar.ToHex = function (i) {
  69906. var str = i.toString(16);
  69907. if (i <= 15) {
  69908. return ("0" + str).toUpperCase();
  69909. }
  69910. return str.toUpperCase();
  69911. };
  69912. /**
  69913. * Returns -1 if value is negative and +1 is value is positive.
  69914. * @param value the value
  69915. * @returns the value itself if it's equal to zero.
  69916. */
  69917. Scalar.Sign = function (value) {
  69918. value = +value; // convert to a number
  69919. if (value === 0 || isNaN(value)) {
  69920. return value;
  69921. }
  69922. return value > 0 ? 1 : -1;
  69923. };
  69924. /**
  69925. * Returns the value itself if it's between min and max.
  69926. * Returns min if the value is lower than min.
  69927. * Returns max if the value is greater than max.
  69928. * @param value the value to clmap
  69929. * @param min the min value to clamp to (default: 0)
  69930. * @param max the max value to clamp to (default: 1)
  69931. * @returns the clamped value
  69932. */
  69933. Scalar.Clamp = function (value, min, max) {
  69934. if (min === void 0) { min = 0; }
  69935. if (max === void 0) { max = 1; }
  69936. return Math.min(max, Math.max(min, value));
  69937. };
  69938. /**
  69939. * the log2 of value.
  69940. * @param value the value to compute log2 of
  69941. * @returns the log2 of value.
  69942. */
  69943. Scalar.Log2 = function (value) {
  69944. return Math.log(value) * Math.LOG2E;
  69945. };
  69946. /**
  69947. * Loops the value, so that it is never larger than length and never smaller than 0.
  69948. *
  69949. * This is similar to the modulo operator but it works with floating point numbers.
  69950. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69951. * With t = 5 and length = 2.5, the result would be 0.0.
  69952. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69953. * @param value the value
  69954. * @param length the length
  69955. * @returns the looped value
  69956. */
  69957. Scalar.Repeat = function (value, length) {
  69958. return value - Math.floor(value / length) * length;
  69959. };
  69960. /**
  69961. * Normalize the value between 0.0 and 1.0 using min and max values
  69962. * @param value value to normalize
  69963. * @param min max to normalize between
  69964. * @param max min to normalize between
  69965. * @returns the normalized value
  69966. */
  69967. Scalar.Normalize = function (value, min, max) {
  69968. return (value - min) / (max - min);
  69969. };
  69970. /**
  69971. * Denormalize the value from 0.0 and 1.0 using min and max values
  69972. * @param normalized value to denormalize
  69973. * @param min max to denormalize between
  69974. * @param max min to denormalize between
  69975. * @returns the denormalized value
  69976. */
  69977. Scalar.Denormalize = function (normalized, min, max) {
  69978. return (normalized * (max - min) + min);
  69979. };
  69980. /**
  69981. * Calculates the shortest difference between two given angles given in degrees.
  69982. * @param current current angle in degrees
  69983. * @param target target angle in degrees
  69984. * @returns the delta
  69985. */
  69986. Scalar.DeltaAngle = function (current, target) {
  69987. var num = Scalar.Repeat(target - current, 360.0);
  69988. if (num > 180.0) {
  69989. num -= 360.0;
  69990. }
  69991. return num;
  69992. };
  69993. /**
  69994. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69995. * @param tx value
  69996. * @param length length
  69997. * @returns The returned value will move back and forth between 0 and length
  69998. */
  69999. Scalar.PingPong = function (tx, length) {
  70000. var t = Scalar.Repeat(tx, length * 2.0);
  70001. return length - Math.abs(t - length);
  70002. };
  70003. /**
  70004. * Interpolates between min and max with smoothing at the limits.
  70005. *
  70006. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70007. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70008. * @param from from
  70009. * @param to to
  70010. * @param tx value
  70011. * @returns the smooth stepped value
  70012. */
  70013. Scalar.SmoothStep = function (from, to, tx) {
  70014. var t = Scalar.Clamp(tx);
  70015. t = -2.0 * t * t * t + 3.0 * t * t;
  70016. return to * t + from * (1.0 - t);
  70017. };
  70018. /**
  70019. * Moves a value current towards target.
  70020. *
  70021. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70022. * Negative values of maxDelta pushes the value away from target.
  70023. * @param current current value
  70024. * @param target target value
  70025. * @param maxDelta max distance to move
  70026. * @returns resulting value
  70027. */
  70028. Scalar.MoveTowards = function (current, target, maxDelta) {
  70029. var result = 0;
  70030. if (Math.abs(target - current) <= maxDelta) {
  70031. result = target;
  70032. }
  70033. else {
  70034. result = current + Scalar.Sign(target - current) * maxDelta;
  70035. }
  70036. return result;
  70037. };
  70038. /**
  70039. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70040. *
  70041. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70042. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70043. * @param current current value
  70044. * @param target target value
  70045. * @param maxDelta max distance to move
  70046. * @returns resulting angle
  70047. */
  70048. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  70049. var num = Scalar.DeltaAngle(current, target);
  70050. var result = 0;
  70051. if (-maxDelta < num && num < maxDelta) {
  70052. result = target;
  70053. }
  70054. else {
  70055. target = current + num;
  70056. result = Scalar.MoveTowards(current, target, maxDelta);
  70057. }
  70058. return result;
  70059. };
  70060. /**
  70061. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70062. * @param start start value
  70063. * @param end target value
  70064. * @param amount amount to lerp between
  70065. * @returns the lerped value
  70066. */
  70067. Scalar.Lerp = function (start, end, amount) {
  70068. return start + ((end - start) * amount);
  70069. };
  70070. /**
  70071. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70072. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70073. * @param start start value
  70074. * @param end target value
  70075. * @param amount amount to lerp between
  70076. * @returns the lerped value
  70077. */
  70078. Scalar.LerpAngle = function (start, end, amount) {
  70079. var num = Scalar.Repeat(end - start, 360.0);
  70080. if (num > 180.0) {
  70081. num -= 360.0;
  70082. }
  70083. return start + num * Scalar.Clamp(amount);
  70084. };
  70085. /**
  70086. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70087. * @param a start value
  70088. * @param b target value
  70089. * @param value value between a and b
  70090. * @returns the inverseLerp value
  70091. */
  70092. Scalar.InverseLerp = function (a, b, value) {
  70093. var result = 0;
  70094. if (a != b) {
  70095. result = Scalar.Clamp((value - a) / (b - a));
  70096. }
  70097. else {
  70098. result = 0.0;
  70099. }
  70100. return result;
  70101. };
  70102. /**
  70103. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70104. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70105. * @param value1 spline value
  70106. * @param tangent1 spline value
  70107. * @param value2 spline value
  70108. * @param tangent2 spline value
  70109. * @param amount input value
  70110. * @returns hermite result
  70111. */
  70112. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70113. var squared = amount * amount;
  70114. var cubed = amount * squared;
  70115. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70116. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70117. var part3 = (cubed - (2.0 * squared)) + amount;
  70118. var part4 = cubed - squared;
  70119. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  70120. };
  70121. /**
  70122. * Returns a random float number between and min and max values
  70123. * @param min min value of random
  70124. * @param max max value of random
  70125. * @returns random value
  70126. */
  70127. Scalar.RandomRange = function (min, max) {
  70128. if (min === max) {
  70129. return min;
  70130. }
  70131. return ((Math.random() * (max - min)) + min);
  70132. };
  70133. /**
  70134. * This function returns percentage of a number in a given range.
  70135. *
  70136. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70137. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70138. * @param number to convert to percentage
  70139. * @param min min range
  70140. * @param max max range
  70141. * @returns the percentage
  70142. */
  70143. Scalar.RangeToPercent = function (number, min, max) {
  70144. return ((number - min) / (max - min));
  70145. };
  70146. /**
  70147. * This function returns number that corresponds to the percentage in a given range.
  70148. *
  70149. * PercentToRange(0.34,0,100) will return 34.
  70150. * @param percent to convert to number
  70151. * @param min min range
  70152. * @param max max range
  70153. * @returns the number
  70154. */
  70155. Scalar.PercentToRange = function (percent, min, max) {
  70156. return ((max - min) * percent + min);
  70157. };
  70158. /**
  70159. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70160. * @param angle The angle to normalize in radian.
  70161. * @return The converted angle.
  70162. */
  70163. Scalar.NormalizeRadians = function (angle) {
  70164. // More precise but slower version kept for reference.
  70165. // angle = angle % Tools.TwoPi;
  70166. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  70167. //if (angle > Math.PI) {
  70168. // angle -= Tools.TwoPi;
  70169. //}
  70170. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  70171. return angle;
  70172. };
  70173. /**
  70174. * Two pi constants convenient for computation.
  70175. */
  70176. Scalar.TwoPi = Math.PI * 2;
  70177. return Scalar;
  70178. }());
  70179. /***/ }),
  70180. /***/ "./Maths/math.ts":
  70181. /*!***********************!*\
  70182. !*** ./Maths/math.ts ***!
  70183. \***********************/
  70184. /*! 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 */
  70185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70186. "use strict";
  70187. __webpack_require__.r(__webpack_exports__);
  70188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  70189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  70190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  70191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  70192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  70193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  70194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  70195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  70196. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  70197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  70198. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  70199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  70200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  70201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  70202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  70203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  70204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  70205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  70206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  70207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  70208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  70209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  70210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  70211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  70212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  70213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  70214. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  70215. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  70216. /**
  70217. * Constant used to convert a value to gamma space
  70218. * @ignorenaming
  70219. */
  70220. var ToGammaSpace = 1 / 2.2;
  70221. /**
  70222. * Constant used to convert a value to linear space
  70223. * @ignorenaming
  70224. */
  70225. var ToLinearSpace = 2.2;
  70226. /**
  70227. * Constant used to define the minimal number value in Babylon.js
  70228. * @ignorenaming
  70229. */
  70230. var Epsilon = 0.001;
  70231. /**
  70232. * Class used to hold a RBG color
  70233. */
  70234. var Color3 = /** @class */ (function () {
  70235. /**
  70236. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70237. * @param r defines the red component (between 0 and 1, default is 0)
  70238. * @param g defines the green component (between 0 and 1, default is 0)
  70239. * @param b defines the blue component (between 0 and 1, default is 0)
  70240. */
  70241. function Color3(
  70242. /**
  70243. * Defines the red component (between 0 and 1, default is 0)
  70244. */
  70245. r,
  70246. /**
  70247. * Defines the green component (between 0 and 1, default is 0)
  70248. */
  70249. g,
  70250. /**
  70251. * Defines the blue component (between 0 and 1, default is 0)
  70252. */
  70253. b) {
  70254. if (r === void 0) { r = 0; }
  70255. if (g === void 0) { g = 0; }
  70256. if (b === void 0) { b = 0; }
  70257. this.r = r;
  70258. this.g = g;
  70259. this.b = b;
  70260. }
  70261. /**
  70262. * Creates a string with the Color3 current values
  70263. * @returns the string representation of the Color3 object
  70264. */
  70265. Color3.prototype.toString = function () {
  70266. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  70267. };
  70268. /**
  70269. * Returns the string "Color3"
  70270. * @returns "Color3"
  70271. */
  70272. Color3.prototype.getClassName = function () {
  70273. return "Color3";
  70274. };
  70275. /**
  70276. * Compute the Color3 hash code
  70277. * @returns an unique number that can be used to hash Color3 objects
  70278. */
  70279. Color3.prototype.getHashCode = function () {
  70280. var hash = this.r || 0;
  70281. hash = (hash * 397) ^ (this.g || 0);
  70282. hash = (hash * 397) ^ (this.b || 0);
  70283. return hash;
  70284. };
  70285. // Operators
  70286. /**
  70287. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70288. * @param array defines the array where to store the r,g,b components
  70289. * @param index defines an optional index in the target array to define where to start storing values
  70290. * @returns the current Color3 object
  70291. */
  70292. Color3.prototype.toArray = function (array, index) {
  70293. if (index === void 0) { index = 0; }
  70294. array[index] = this.r;
  70295. array[index + 1] = this.g;
  70296. array[index + 2] = this.b;
  70297. return this;
  70298. };
  70299. /**
  70300. * Returns a new Color4 object from the current Color3 and the given alpha
  70301. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70302. * @returns a new Color4 object
  70303. */
  70304. Color3.prototype.toColor4 = function (alpha) {
  70305. if (alpha === void 0) { alpha = 1; }
  70306. return new Color4(this.r, this.g, this.b, alpha);
  70307. };
  70308. /**
  70309. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70310. * @returns the new array
  70311. */
  70312. Color3.prototype.asArray = function () {
  70313. var result = new Array();
  70314. this.toArray(result, 0);
  70315. return result;
  70316. };
  70317. /**
  70318. * Returns the luminance value
  70319. * @returns a float value
  70320. */
  70321. Color3.prototype.toLuminance = function () {
  70322. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  70323. };
  70324. /**
  70325. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70326. * @param otherColor defines the second operand
  70327. * @returns the new Color3 object
  70328. */
  70329. Color3.prototype.multiply = function (otherColor) {
  70330. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  70331. };
  70332. /**
  70333. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70334. * @param otherColor defines the second operand
  70335. * @param result defines the Color3 object where to store the result
  70336. * @returns the current Color3
  70337. */
  70338. Color3.prototype.multiplyToRef = function (otherColor, result) {
  70339. result.r = this.r * otherColor.r;
  70340. result.g = this.g * otherColor.g;
  70341. result.b = this.b * otherColor.b;
  70342. return this;
  70343. };
  70344. /**
  70345. * Determines equality between Color3 objects
  70346. * @param otherColor defines the second operand
  70347. * @returns true if the rgb values are equal to the given ones
  70348. */
  70349. Color3.prototype.equals = function (otherColor) {
  70350. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  70351. };
  70352. /**
  70353. * Determines equality between the current Color3 object and a set of r,b,g values
  70354. * @param r defines the red component to check
  70355. * @param g defines the green component to check
  70356. * @param b defines the blue component to check
  70357. * @returns true if the rgb values are equal to the given ones
  70358. */
  70359. Color3.prototype.equalsFloats = function (r, g, b) {
  70360. return this.r === r && this.g === g && this.b === b;
  70361. };
  70362. /**
  70363. * Multiplies in place each rgb value by scale
  70364. * @param scale defines the scaling factor
  70365. * @returns the updated Color3
  70366. */
  70367. Color3.prototype.scale = function (scale) {
  70368. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  70369. };
  70370. /**
  70371. * Multiplies the rgb values by scale and stores the result into "result"
  70372. * @param scale defines the scaling factor
  70373. * @param result defines the Color3 object where to store the result
  70374. * @returns the unmodified current Color3
  70375. */
  70376. Color3.prototype.scaleToRef = function (scale, result) {
  70377. result.r = this.r * scale;
  70378. result.g = this.g * scale;
  70379. result.b = this.b * scale;
  70380. return this;
  70381. };
  70382. /**
  70383. * Scale the current Color3 values by a factor and add the result to a given Color3
  70384. * @param scale defines the scale factor
  70385. * @param result defines color to store the result into
  70386. * @returns the unmodified current Color3
  70387. */
  70388. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  70389. result.r += this.r * scale;
  70390. result.g += this.g * scale;
  70391. result.b += this.b * scale;
  70392. return this;
  70393. };
  70394. /**
  70395. * Clamps the rgb values by the min and max values and stores the result into "result"
  70396. * @param min defines minimum clamping value (default is 0)
  70397. * @param max defines maximum clamping value (default is 1)
  70398. * @param result defines color to store the result into
  70399. * @returns the original Color3
  70400. */
  70401. Color3.prototype.clampToRef = function (min, max, result) {
  70402. if (min === void 0) { min = 0; }
  70403. if (max === void 0) { max = 1; }
  70404. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  70405. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  70406. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  70407. return this;
  70408. };
  70409. /**
  70410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70411. * @param otherColor defines the second operand
  70412. * @returns the new Color3
  70413. */
  70414. Color3.prototype.add = function (otherColor) {
  70415. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  70416. };
  70417. /**
  70418. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70419. * @param otherColor defines the second operand
  70420. * @param result defines Color3 object to store the result into
  70421. * @returns the unmodified current Color3
  70422. */
  70423. Color3.prototype.addToRef = function (otherColor, result) {
  70424. result.r = this.r + otherColor.r;
  70425. result.g = this.g + otherColor.g;
  70426. result.b = this.b + otherColor.b;
  70427. return this;
  70428. };
  70429. /**
  70430. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70431. * @param otherColor defines the second operand
  70432. * @returns the new Color3
  70433. */
  70434. Color3.prototype.subtract = function (otherColor) {
  70435. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  70436. };
  70437. /**
  70438. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70439. * @param otherColor defines the second operand
  70440. * @param result defines Color3 object to store the result into
  70441. * @returns the unmodified current Color3
  70442. */
  70443. Color3.prototype.subtractToRef = function (otherColor, result) {
  70444. result.r = this.r - otherColor.r;
  70445. result.g = this.g - otherColor.g;
  70446. result.b = this.b - otherColor.b;
  70447. return this;
  70448. };
  70449. /**
  70450. * Copy the current object
  70451. * @returns a new Color3 copied the current one
  70452. */
  70453. Color3.prototype.clone = function () {
  70454. return new Color3(this.r, this.g, this.b);
  70455. };
  70456. /**
  70457. * Copies the rgb values from the source in the current Color3
  70458. * @param source defines the source Color3 object
  70459. * @returns the updated Color3 object
  70460. */
  70461. Color3.prototype.copyFrom = function (source) {
  70462. this.r = source.r;
  70463. this.g = source.g;
  70464. this.b = source.b;
  70465. return this;
  70466. };
  70467. /**
  70468. * Updates the Color3 rgb values from the given floats
  70469. * @param r defines the red component to read from
  70470. * @param g defines the green component to read from
  70471. * @param b defines the blue component to read from
  70472. * @returns the current Color3 object
  70473. */
  70474. Color3.prototype.copyFromFloats = function (r, g, b) {
  70475. this.r = r;
  70476. this.g = g;
  70477. this.b = b;
  70478. return this;
  70479. };
  70480. /**
  70481. * Updates the Color3 rgb values from the given floats
  70482. * @param r defines the red component to read from
  70483. * @param g defines the green component to read from
  70484. * @param b defines the blue component to read from
  70485. * @returns the current Color3 object
  70486. */
  70487. Color3.prototype.set = function (r, g, b) {
  70488. return this.copyFromFloats(r, g, b);
  70489. };
  70490. /**
  70491. * Compute the Color3 hexadecimal code as a string
  70492. * @returns a string containing the hexadecimal representation of the Color3 object
  70493. */
  70494. Color3.prototype.toHexString = function () {
  70495. var intR = (this.r * 255) | 0;
  70496. var intG = (this.g * 255) | 0;
  70497. var intB = (this.b * 255) | 0;
  70498. 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);
  70499. };
  70500. /**
  70501. * Computes a new Color3 converted from the current one to linear space
  70502. * @returns a new Color3 object
  70503. */
  70504. Color3.prototype.toLinearSpace = function () {
  70505. var convertedColor = new Color3();
  70506. this.toLinearSpaceToRef(convertedColor);
  70507. return convertedColor;
  70508. };
  70509. /**
  70510. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70511. * @param convertedColor defines the Color3 object where to store the linear space version
  70512. * @returns the unmodified Color3
  70513. */
  70514. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  70515. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  70516. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  70517. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  70518. return this;
  70519. };
  70520. /**
  70521. * Computes a new Color3 converted from the current one to gamma space
  70522. * @returns a new Color3 object
  70523. */
  70524. Color3.prototype.toGammaSpace = function () {
  70525. var convertedColor = new Color3();
  70526. this.toGammaSpaceToRef(convertedColor);
  70527. return convertedColor;
  70528. };
  70529. /**
  70530. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70531. * @param convertedColor defines the Color3 object where to store the gamma space version
  70532. * @returns the unmodified Color3
  70533. */
  70534. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  70535. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  70536. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  70537. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  70538. return this;
  70539. };
  70540. /**
  70541. * Creates a new Color3 from the string containing valid hexadecimal values
  70542. * @param hex defines a string containing valid hexadecimal values
  70543. * @returns a new Color3 object
  70544. */
  70545. Color3.FromHexString = function (hex) {
  70546. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  70547. return new Color3(0, 0, 0);
  70548. }
  70549. var r = parseInt(hex.substring(1, 3), 16);
  70550. var g = parseInt(hex.substring(3, 5), 16);
  70551. var b = parseInt(hex.substring(5, 7), 16);
  70552. return Color3.FromInts(r, g, b);
  70553. };
  70554. /**
  70555. * Creates a new Vector3 from the starting index of the given array
  70556. * @param array defines the source array
  70557. * @param offset defines an offset in the source array
  70558. * @returns a new Color3 object
  70559. */
  70560. Color3.FromArray = function (array, offset) {
  70561. if (offset === void 0) { offset = 0; }
  70562. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  70563. };
  70564. /**
  70565. * Creates a new Color3 from integer values (< 256)
  70566. * @param r defines the red component to read from (value between 0 and 255)
  70567. * @param g defines the green component to read from (value between 0 and 255)
  70568. * @param b defines the blue component to read from (value between 0 and 255)
  70569. * @returns a new Color3 object
  70570. */
  70571. Color3.FromInts = function (r, g, b) {
  70572. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  70573. };
  70574. /**
  70575. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70576. * @param start defines the start Color3 value
  70577. * @param end defines the end Color3 value
  70578. * @param amount defines the gradient value between start and end
  70579. * @returns a new Color3 object
  70580. */
  70581. Color3.Lerp = function (start, end, amount) {
  70582. var result = new Color3(0.0, 0.0, 0.0);
  70583. Color3.LerpToRef(start, end, amount, result);
  70584. return result;
  70585. };
  70586. /**
  70587. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70588. * @param left defines the start value
  70589. * @param right defines the end value
  70590. * @param amount defines the gradient factor
  70591. * @param result defines the Color3 object where to store the result
  70592. */
  70593. Color3.LerpToRef = function (left, right, amount, result) {
  70594. result.r = left.r + ((right.r - left.r) * amount);
  70595. result.g = left.g + ((right.g - left.g) * amount);
  70596. result.b = left.b + ((right.b - left.b) * amount);
  70597. };
  70598. /**
  70599. * Returns a Color3 value containing a red color
  70600. * @returns a new Color3 object
  70601. */
  70602. Color3.Red = function () { return new Color3(1, 0, 0); };
  70603. /**
  70604. * Returns a Color3 value containing a green color
  70605. * @returns a new Color3 object
  70606. */
  70607. Color3.Green = function () { return new Color3(0, 1, 0); };
  70608. /**
  70609. * Returns a Color3 value containing a blue color
  70610. * @returns a new Color3 object
  70611. */
  70612. Color3.Blue = function () { return new Color3(0, 0, 1); };
  70613. /**
  70614. * Returns a Color3 value containing a black color
  70615. * @returns a new Color3 object
  70616. */
  70617. Color3.Black = function () { return new Color3(0, 0, 0); };
  70618. Object.defineProperty(Color3, "BlackReadOnly", {
  70619. /**
  70620. * Gets a Color3 value containing a black color that must not be updated
  70621. */
  70622. get: function () {
  70623. return Color3._BlackReadOnly;
  70624. },
  70625. enumerable: true,
  70626. configurable: true
  70627. });
  70628. /**
  70629. * Returns a Color3 value containing a white color
  70630. * @returns a new Color3 object
  70631. */
  70632. Color3.White = function () { return new Color3(1, 1, 1); };
  70633. /**
  70634. * Returns a Color3 value containing a purple color
  70635. * @returns a new Color3 object
  70636. */
  70637. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  70638. /**
  70639. * Returns a Color3 value containing a magenta color
  70640. * @returns a new Color3 object
  70641. */
  70642. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  70643. /**
  70644. * Returns a Color3 value containing a yellow color
  70645. * @returns a new Color3 object
  70646. */
  70647. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  70648. /**
  70649. * Returns a Color3 value containing a gray color
  70650. * @returns a new Color3 object
  70651. */
  70652. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  70653. /**
  70654. * Returns a Color3 value containing a teal color
  70655. * @returns a new Color3 object
  70656. */
  70657. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  70658. /**
  70659. * Returns a Color3 value containing a random color
  70660. * @returns a new Color3 object
  70661. */
  70662. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  70663. // Statics
  70664. Color3._BlackReadOnly = Color3.Black();
  70665. return Color3;
  70666. }());
  70667. /**
  70668. * Class used to hold a RBGA color
  70669. */
  70670. var Color4 = /** @class */ (function () {
  70671. /**
  70672. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70673. * @param r defines the red component (between 0 and 1, default is 0)
  70674. * @param g defines the green component (between 0 and 1, default is 0)
  70675. * @param b defines the blue component (between 0 and 1, default is 0)
  70676. * @param a defines the alpha component (between 0 and 1, default is 1)
  70677. */
  70678. function Color4(
  70679. /**
  70680. * Defines the red component (between 0 and 1, default is 0)
  70681. */
  70682. r,
  70683. /**
  70684. * Defines the green component (between 0 and 1, default is 0)
  70685. */
  70686. g,
  70687. /**
  70688. * Defines the blue component (between 0 and 1, default is 0)
  70689. */
  70690. b,
  70691. /**
  70692. * Defines the alpha component (between 0 and 1, default is 1)
  70693. */
  70694. a) {
  70695. if (r === void 0) { r = 0; }
  70696. if (g === void 0) { g = 0; }
  70697. if (b === void 0) { b = 0; }
  70698. if (a === void 0) { a = 1; }
  70699. this.r = r;
  70700. this.g = g;
  70701. this.b = b;
  70702. this.a = a;
  70703. }
  70704. // Operators
  70705. /**
  70706. * Adds in place the given Color4 values to the current Color4 object
  70707. * @param right defines the second operand
  70708. * @returns the current updated Color4 object
  70709. */
  70710. Color4.prototype.addInPlace = function (right) {
  70711. this.r += right.r;
  70712. this.g += right.g;
  70713. this.b += right.b;
  70714. this.a += right.a;
  70715. return this;
  70716. };
  70717. /**
  70718. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70719. * @returns the new array
  70720. */
  70721. Color4.prototype.asArray = function () {
  70722. var result = new Array();
  70723. this.toArray(result, 0);
  70724. return result;
  70725. };
  70726. /**
  70727. * Stores from the starting index in the given array the Color4 successive values
  70728. * @param array defines the array where to store the r,g,b components
  70729. * @param index defines an optional index in the target array to define where to start storing values
  70730. * @returns the current Color4 object
  70731. */
  70732. Color4.prototype.toArray = function (array, index) {
  70733. if (index === void 0) { index = 0; }
  70734. array[index] = this.r;
  70735. array[index + 1] = this.g;
  70736. array[index + 2] = this.b;
  70737. array[index + 3] = this.a;
  70738. return this;
  70739. };
  70740. /**
  70741. * Determines equality between Color4 objects
  70742. * @param otherColor defines the second operand
  70743. * @returns true if the rgba values are equal to the given ones
  70744. */
  70745. Color4.prototype.equals = function (otherColor) {
  70746. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  70747. };
  70748. /**
  70749. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70750. * @param right defines the second operand
  70751. * @returns a new Color4 object
  70752. */
  70753. Color4.prototype.add = function (right) {
  70754. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  70755. };
  70756. /**
  70757. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70758. * @param right defines the second operand
  70759. * @returns a new Color4 object
  70760. */
  70761. Color4.prototype.subtract = function (right) {
  70762. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  70763. };
  70764. /**
  70765. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70766. * @param right defines the second operand
  70767. * @param result defines the Color4 object where to store the result
  70768. * @returns the current Color4 object
  70769. */
  70770. Color4.prototype.subtractToRef = function (right, result) {
  70771. result.r = this.r - right.r;
  70772. result.g = this.g - right.g;
  70773. result.b = this.b - right.b;
  70774. result.a = this.a - right.a;
  70775. return this;
  70776. };
  70777. /**
  70778. * Creates a new Color4 with the current Color4 values multiplied by scale
  70779. * @param scale defines the scaling factor to apply
  70780. * @returns a new Color4 object
  70781. */
  70782. Color4.prototype.scale = function (scale) {
  70783. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  70784. };
  70785. /**
  70786. * Multiplies the current Color4 values by scale and stores the result in "result"
  70787. * @param scale defines the scaling factor to apply
  70788. * @param result defines the Color4 object where to store the result
  70789. * @returns the current unmodified Color4
  70790. */
  70791. Color4.prototype.scaleToRef = function (scale, result) {
  70792. result.r = this.r * scale;
  70793. result.g = this.g * scale;
  70794. result.b = this.b * scale;
  70795. result.a = this.a * scale;
  70796. return this;
  70797. };
  70798. /**
  70799. * Scale the current Color4 values by a factor and add the result to a given Color4
  70800. * @param scale defines the scale factor
  70801. * @param result defines the Color4 object where to store the result
  70802. * @returns the unmodified current Color4
  70803. */
  70804. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  70805. result.r += this.r * scale;
  70806. result.g += this.g * scale;
  70807. result.b += this.b * scale;
  70808. result.a += this.a * scale;
  70809. return this;
  70810. };
  70811. /**
  70812. * Clamps the rgb values by the min and max values and stores the result into "result"
  70813. * @param min defines minimum clamping value (default is 0)
  70814. * @param max defines maximum clamping value (default is 1)
  70815. * @param result defines color to store the result into.
  70816. * @returns the cuurent Color4
  70817. */
  70818. Color4.prototype.clampToRef = function (min, max, result) {
  70819. if (min === void 0) { min = 0; }
  70820. if (max === void 0) { max = 1; }
  70821. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  70822. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  70823. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  70824. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  70825. return this;
  70826. };
  70827. /**
  70828. * Multipy an Color4 value by another and return a new Color4 object
  70829. * @param color defines the Color4 value to multiply by
  70830. * @returns a new Color4 object
  70831. */
  70832. Color4.prototype.multiply = function (color) {
  70833. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  70834. };
  70835. /**
  70836. * Multipy a Color4 value by another and push the result in a reference value
  70837. * @param color defines the Color4 value to multiply by
  70838. * @param result defines the Color4 to fill the result in
  70839. * @returns the result Color4
  70840. */
  70841. Color4.prototype.multiplyToRef = function (color, result) {
  70842. result.r = this.r * color.r;
  70843. result.g = this.g * color.g;
  70844. result.b = this.b * color.b;
  70845. result.a = this.a * color.a;
  70846. return result;
  70847. };
  70848. /**
  70849. * Creates a string with the Color4 current values
  70850. * @returns the string representation of the Color4 object
  70851. */
  70852. Color4.prototype.toString = function () {
  70853. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  70854. };
  70855. /**
  70856. * Returns the string "Color4"
  70857. * @returns "Color4"
  70858. */
  70859. Color4.prototype.getClassName = function () {
  70860. return "Color4";
  70861. };
  70862. /**
  70863. * Compute the Color4 hash code
  70864. * @returns an unique number that can be used to hash Color4 objects
  70865. */
  70866. Color4.prototype.getHashCode = function () {
  70867. var hash = this.r || 0;
  70868. hash = (hash * 397) ^ (this.g || 0);
  70869. hash = (hash * 397) ^ (this.b || 0);
  70870. hash = (hash * 397) ^ (this.a || 0);
  70871. return hash;
  70872. };
  70873. /**
  70874. * Creates a new Color4 copied from the current one
  70875. * @returns a new Color4 object
  70876. */
  70877. Color4.prototype.clone = function () {
  70878. return new Color4(this.r, this.g, this.b, this.a);
  70879. };
  70880. /**
  70881. * Copies the given Color4 values into the current one
  70882. * @param source defines the source Color4 object
  70883. * @returns the current updated Color4 object
  70884. */
  70885. Color4.prototype.copyFrom = function (source) {
  70886. this.r = source.r;
  70887. this.g = source.g;
  70888. this.b = source.b;
  70889. this.a = source.a;
  70890. return this;
  70891. };
  70892. /**
  70893. * Copies the given float values into the current one
  70894. * @param r defines the red component to read from
  70895. * @param g defines the green component to read from
  70896. * @param b defines the blue component to read from
  70897. * @param a defines the alpha component to read from
  70898. * @returns the current updated Color4 object
  70899. */
  70900. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  70901. this.r = r;
  70902. this.g = g;
  70903. this.b = b;
  70904. this.a = a;
  70905. return this;
  70906. };
  70907. /**
  70908. * Copies the given float values into the current one
  70909. * @param r defines the red component to read from
  70910. * @param g defines the green component to read from
  70911. * @param b defines the blue component to read from
  70912. * @param a defines the alpha component to read from
  70913. * @returns the current updated Color4 object
  70914. */
  70915. Color4.prototype.set = function (r, g, b, a) {
  70916. return this.copyFromFloats(r, g, b, a);
  70917. };
  70918. /**
  70919. * Compute the Color4 hexadecimal code as a string
  70920. * @returns a string containing the hexadecimal representation of the Color4 object
  70921. */
  70922. Color4.prototype.toHexString = function () {
  70923. var intR = (this.r * 255) | 0;
  70924. var intG = (this.g * 255) | 0;
  70925. var intB = (this.b * 255) | 0;
  70926. var intA = (this.a * 255) | 0;
  70927. 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);
  70928. };
  70929. /**
  70930. * Computes a new Color4 converted from the current one to linear space
  70931. * @returns a new Color4 object
  70932. */
  70933. Color4.prototype.toLinearSpace = function () {
  70934. var convertedColor = new Color4();
  70935. this.toLinearSpaceToRef(convertedColor);
  70936. return convertedColor;
  70937. };
  70938. /**
  70939. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70940. * @param convertedColor defines the Color4 object where to store the linear space version
  70941. * @returns the unmodified Color4
  70942. */
  70943. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  70944. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  70945. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  70946. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  70947. convertedColor.a = this.a;
  70948. return this;
  70949. };
  70950. /**
  70951. * Computes a new Color4 converted from the current one to gamma space
  70952. * @returns a new Color4 object
  70953. */
  70954. Color4.prototype.toGammaSpace = function () {
  70955. var convertedColor = new Color4();
  70956. this.toGammaSpaceToRef(convertedColor);
  70957. return convertedColor;
  70958. };
  70959. /**
  70960. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70961. * @param convertedColor defines the Color4 object where to store the gamma space version
  70962. * @returns the unmodified Color4
  70963. */
  70964. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  70965. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  70966. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  70967. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  70968. convertedColor.a = this.a;
  70969. return this;
  70970. };
  70971. // Statics
  70972. /**
  70973. * Creates a new Color4 from the string containing valid hexadecimal values
  70974. * @param hex defines a string containing valid hexadecimal values
  70975. * @returns a new Color4 object
  70976. */
  70977. Color4.FromHexString = function (hex) {
  70978. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  70979. return new Color4(0.0, 0.0, 0.0, 0.0);
  70980. }
  70981. var r = parseInt(hex.substring(1, 3), 16);
  70982. var g = parseInt(hex.substring(3, 5), 16);
  70983. var b = parseInt(hex.substring(5, 7), 16);
  70984. var a = parseInt(hex.substring(7, 9), 16);
  70985. return Color4.FromInts(r, g, b, a);
  70986. };
  70987. /**
  70988. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70989. * @param left defines the start value
  70990. * @param right defines the end value
  70991. * @param amount defines the gradient factor
  70992. * @returns a new Color4 object
  70993. */
  70994. Color4.Lerp = function (left, right, amount) {
  70995. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  70996. Color4.LerpToRef(left, right, amount, result);
  70997. return result;
  70998. };
  70999. /**
  71000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71001. * @param left defines the start value
  71002. * @param right defines the end value
  71003. * @param amount defines the gradient factor
  71004. * @param result defines the Color4 object where to store data
  71005. */
  71006. Color4.LerpToRef = function (left, right, amount, result) {
  71007. result.r = left.r + (right.r - left.r) * amount;
  71008. result.g = left.g + (right.g - left.g) * amount;
  71009. result.b = left.b + (right.b - left.b) * amount;
  71010. result.a = left.a + (right.a - left.a) * amount;
  71011. };
  71012. /**
  71013. * Creates a new Color4 from a Color3 and an alpha value
  71014. * @param color3 defines the source Color3 to read from
  71015. * @param alpha defines the alpha component (1.0 by default)
  71016. * @returns a new Color4 object
  71017. */
  71018. Color4.FromColor3 = function (color3, alpha) {
  71019. if (alpha === void 0) { alpha = 1.0; }
  71020. return new Color4(color3.r, color3.g, color3.b, alpha);
  71021. };
  71022. /**
  71023. * Creates a new Color4 from the starting index element of the given array
  71024. * @param array defines the source array to read from
  71025. * @param offset defines the offset in the source array
  71026. * @returns a new Color4 object
  71027. */
  71028. Color4.FromArray = function (array, offset) {
  71029. if (offset === void 0) { offset = 0; }
  71030. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71031. };
  71032. /**
  71033. * Creates a new Color3 from integer values (< 256)
  71034. * @param r defines the red component to read from (value between 0 and 255)
  71035. * @param g defines the green component to read from (value between 0 and 255)
  71036. * @param b defines the blue component to read from (value between 0 and 255)
  71037. * @param a defines the alpha component to read from (value between 0 and 255)
  71038. * @returns a new Color3 object
  71039. */
  71040. Color4.FromInts = function (r, g, b, a) {
  71041. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  71042. };
  71043. /**
  71044. * Check the content of a given array and convert it to an array containing RGBA data
  71045. * If the original array was already containing count * 4 values then it is returned directly
  71046. * @param colors defines the array to check
  71047. * @param count defines the number of RGBA data to expect
  71048. * @returns an array containing count * 4 values (RGBA)
  71049. */
  71050. Color4.CheckColors4 = function (colors, count) {
  71051. // Check if color3 was used
  71052. if (colors.length === count * 3) {
  71053. var colors4 = [];
  71054. for (var index = 0; index < colors.length; index += 3) {
  71055. var newIndex = (index / 3) * 4;
  71056. colors4[newIndex] = colors[index];
  71057. colors4[newIndex + 1] = colors[index + 1];
  71058. colors4[newIndex + 2] = colors[index + 2];
  71059. colors4[newIndex + 3] = 1.0;
  71060. }
  71061. return colors4;
  71062. }
  71063. return colors;
  71064. };
  71065. return Color4;
  71066. }());
  71067. /**
  71068. * Class representing a vector containing 2 coordinates
  71069. */
  71070. var Vector2 = /** @class */ (function () {
  71071. /**
  71072. * Creates a new Vector2 from the given x and y coordinates
  71073. * @param x defines the first coordinate
  71074. * @param y defines the second coordinate
  71075. */
  71076. function Vector2(
  71077. /** defines the first coordinate */
  71078. x,
  71079. /** defines the second coordinate */
  71080. y) {
  71081. if (x === void 0) { x = 0; }
  71082. if (y === void 0) { y = 0; }
  71083. this.x = x;
  71084. this.y = y;
  71085. }
  71086. /**
  71087. * Gets a string with the Vector2 coordinates
  71088. * @returns a string with the Vector2 coordinates
  71089. */
  71090. Vector2.prototype.toString = function () {
  71091. return "{X: " + this.x + " Y:" + this.y + "}";
  71092. };
  71093. /**
  71094. * Gets class name
  71095. * @returns the string "Vector2"
  71096. */
  71097. Vector2.prototype.getClassName = function () {
  71098. return "Vector2";
  71099. };
  71100. /**
  71101. * Gets current vector hash code
  71102. * @returns the Vector2 hash code as a number
  71103. */
  71104. Vector2.prototype.getHashCode = function () {
  71105. var hash = this.x || 0;
  71106. hash = (hash * 397) ^ (this.y || 0);
  71107. return hash;
  71108. };
  71109. // Operators
  71110. /**
  71111. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  71112. * @param array defines the source array
  71113. * @param index defines the offset in source array
  71114. * @returns the current Vector2
  71115. */
  71116. Vector2.prototype.toArray = function (array, index) {
  71117. if (index === void 0) { index = 0; }
  71118. array[index] = this.x;
  71119. array[index + 1] = this.y;
  71120. return this;
  71121. };
  71122. /**
  71123. * Copy the current vector to an array
  71124. * @returns a new array with 2 elements: the Vector2 coordinates.
  71125. */
  71126. Vector2.prototype.asArray = function () {
  71127. var result = new Array();
  71128. this.toArray(result, 0);
  71129. return result;
  71130. };
  71131. /**
  71132. * Sets the Vector2 coordinates with the given Vector2 coordinates
  71133. * @param source defines the source Vector2
  71134. * @returns the current updated Vector2
  71135. */
  71136. Vector2.prototype.copyFrom = function (source) {
  71137. this.x = source.x;
  71138. this.y = source.y;
  71139. return this;
  71140. };
  71141. /**
  71142. * Sets the Vector2 coordinates with the given floats
  71143. * @param x defines the first coordinate
  71144. * @param y defines the second coordinate
  71145. * @returns the current updated Vector2
  71146. */
  71147. Vector2.prototype.copyFromFloats = function (x, y) {
  71148. this.x = x;
  71149. this.y = y;
  71150. return this;
  71151. };
  71152. /**
  71153. * Sets the Vector2 coordinates with the given floats
  71154. * @param x defines the first coordinate
  71155. * @param y defines the second coordinate
  71156. * @returns the current updated Vector2
  71157. */
  71158. Vector2.prototype.set = function (x, y) {
  71159. return this.copyFromFloats(x, y);
  71160. };
  71161. /**
  71162. * Add another vector with the current one
  71163. * @param otherVector defines the other vector
  71164. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  71165. */
  71166. Vector2.prototype.add = function (otherVector) {
  71167. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  71168. };
  71169. /**
  71170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  71171. * @param otherVector defines the other vector
  71172. * @param result defines the target vector
  71173. * @returns the unmodified current Vector2
  71174. */
  71175. Vector2.prototype.addToRef = function (otherVector, result) {
  71176. result.x = this.x + otherVector.x;
  71177. result.y = this.y + otherVector.y;
  71178. return this;
  71179. };
  71180. /**
  71181. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  71182. * @param otherVector defines the other vector
  71183. * @returns the current updated Vector2
  71184. */
  71185. Vector2.prototype.addInPlace = function (otherVector) {
  71186. this.x += otherVector.x;
  71187. this.y += otherVector.y;
  71188. return this;
  71189. };
  71190. /**
  71191. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  71192. * @param otherVector defines the other vector
  71193. * @returns a new Vector2
  71194. */
  71195. Vector2.prototype.addVector3 = function (otherVector) {
  71196. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  71197. };
  71198. /**
  71199. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  71200. * @param otherVector defines the other vector
  71201. * @returns a new Vector2
  71202. */
  71203. Vector2.prototype.subtract = function (otherVector) {
  71204. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  71205. };
  71206. /**
  71207. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  71208. * @param otherVector defines the other vector
  71209. * @param result defines the target vector
  71210. * @returns the unmodified current Vector2
  71211. */
  71212. Vector2.prototype.subtractToRef = function (otherVector, result) {
  71213. result.x = this.x - otherVector.x;
  71214. result.y = this.y - otherVector.y;
  71215. return this;
  71216. };
  71217. /**
  71218. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  71219. * @param otherVector defines the other vector
  71220. * @returns the current updated Vector2
  71221. */
  71222. Vector2.prototype.subtractInPlace = function (otherVector) {
  71223. this.x -= otherVector.x;
  71224. this.y -= otherVector.y;
  71225. return this;
  71226. };
  71227. /**
  71228. * Multiplies in place the current Vector2 coordinates by the given ones
  71229. * @param otherVector defines the other vector
  71230. * @returns the current updated Vector2
  71231. */
  71232. Vector2.prototype.multiplyInPlace = function (otherVector) {
  71233. this.x *= otherVector.x;
  71234. this.y *= otherVector.y;
  71235. return this;
  71236. };
  71237. /**
  71238. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  71239. * @param otherVector defines the other vector
  71240. * @returns a new Vector2
  71241. */
  71242. Vector2.prototype.multiply = function (otherVector) {
  71243. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  71244. };
  71245. /**
  71246. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  71247. * @param otherVector defines the other vector
  71248. * @param result defines the target vector
  71249. * @returns the unmodified current Vector2
  71250. */
  71251. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  71252. result.x = this.x * otherVector.x;
  71253. result.y = this.y * otherVector.y;
  71254. return this;
  71255. };
  71256. /**
  71257. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  71258. * @param x defines the first coordinate
  71259. * @param y defines the second coordinate
  71260. * @returns a new Vector2
  71261. */
  71262. Vector2.prototype.multiplyByFloats = function (x, y) {
  71263. return new Vector2(this.x * x, this.y * y);
  71264. };
  71265. /**
  71266. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  71267. * @param otherVector defines the other vector
  71268. * @returns a new Vector2
  71269. */
  71270. Vector2.prototype.divide = function (otherVector) {
  71271. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  71272. };
  71273. /**
  71274. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  71275. * @param otherVector defines the other vector
  71276. * @param result defines the target vector
  71277. * @returns the unmodified current Vector2
  71278. */
  71279. Vector2.prototype.divideToRef = function (otherVector, result) {
  71280. result.x = this.x / otherVector.x;
  71281. result.y = this.y / otherVector.y;
  71282. return this;
  71283. };
  71284. /**
  71285. * Divides the current Vector2 coordinates by the given ones
  71286. * @param otherVector defines the other vector
  71287. * @returns the current updated Vector2
  71288. */
  71289. Vector2.prototype.divideInPlace = function (otherVector) {
  71290. return this.divideToRef(otherVector, this);
  71291. };
  71292. /**
  71293. * Gets a new Vector2 with current Vector2 negated coordinates
  71294. * @returns a new Vector2
  71295. */
  71296. Vector2.prototype.negate = function () {
  71297. return new Vector2(-this.x, -this.y);
  71298. };
  71299. /**
  71300. * Multiply the Vector2 coordinates by scale
  71301. * @param scale defines the scaling factor
  71302. * @returns the current updated Vector2
  71303. */
  71304. Vector2.prototype.scaleInPlace = function (scale) {
  71305. this.x *= scale;
  71306. this.y *= scale;
  71307. return this;
  71308. };
  71309. /**
  71310. * Returns a new Vector2 scaled by "scale" from the current Vector2
  71311. * @param scale defines the scaling factor
  71312. * @returns a new Vector2
  71313. */
  71314. Vector2.prototype.scale = function (scale) {
  71315. var result = new Vector2(0, 0);
  71316. this.scaleToRef(scale, result);
  71317. return result;
  71318. };
  71319. /**
  71320. * Scale the current Vector2 values by a factor to a given Vector2
  71321. * @param scale defines the scale factor
  71322. * @param result defines the Vector2 object where to store the result
  71323. * @returns the unmodified current Vector2
  71324. */
  71325. Vector2.prototype.scaleToRef = function (scale, result) {
  71326. result.x = this.x * scale;
  71327. result.y = this.y * scale;
  71328. return this;
  71329. };
  71330. /**
  71331. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  71332. * @param scale defines the scale factor
  71333. * @param result defines the Vector2 object where to store the result
  71334. * @returns the unmodified current Vector2
  71335. */
  71336. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  71337. result.x += this.x * scale;
  71338. result.y += this.y * scale;
  71339. return this;
  71340. };
  71341. /**
  71342. * Gets a boolean if two vectors are equals
  71343. * @param otherVector defines the other vector
  71344. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  71345. */
  71346. Vector2.prototype.equals = function (otherVector) {
  71347. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  71348. };
  71349. /**
  71350. * Gets a boolean if two vectors are equals (using an epsilon value)
  71351. * @param otherVector defines the other vector
  71352. * @param epsilon defines the minimal distance to consider equality
  71353. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71354. */
  71355. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  71356. if (epsilon === void 0) { epsilon = Epsilon; }
  71357. 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);
  71358. };
  71359. /**
  71360. * Gets a new Vector2 from current Vector2 floored values
  71361. * @returns a new Vector2
  71362. */
  71363. Vector2.prototype.floor = function () {
  71364. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  71365. };
  71366. /**
  71367. * Gets a new Vector2 from current Vector2 floored values
  71368. * @returns a new Vector2
  71369. */
  71370. Vector2.prototype.fract = function () {
  71371. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  71372. };
  71373. // Properties
  71374. /**
  71375. * Gets the length of the vector
  71376. * @returns the vector length (float)
  71377. */
  71378. Vector2.prototype.length = function () {
  71379. return Math.sqrt(this.x * this.x + this.y * this.y);
  71380. };
  71381. /**
  71382. * Gets the vector squared length
  71383. * @returns the vector squared length (float)
  71384. */
  71385. Vector2.prototype.lengthSquared = function () {
  71386. return (this.x * this.x + this.y * this.y);
  71387. };
  71388. // Methods
  71389. /**
  71390. * Normalize the vector
  71391. * @returns the current updated Vector2
  71392. */
  71393. Vector2.prototype.normalize = function () {
  71394. var len = this.length();
  71395. if (len === 0) {
  71396. return this;
  71397. }
  71398. var num = 1.0 / len;
  71399. this.x *= num;
  71400. this.y *= num;
  71401. return this;
  71402. };
  71403. /**
  71404. * Gets a new Vector2 copied from the Vector2
  71405. * @returns a new Vector2
  71406. */
  71407. Vector2.prototype.clone = function () {
  71408. return new Vector2(this.x, this.y);
  71409. };
  71410. // Statics
  71411. /**
  71412. * Gets a new Vector2(0, 0)
  71413. * @returns a new Vector2
  71414. */
  71415. Vector2.Zero = function () {
  71416. return new Vector2(0, 0);
  71417. };
  71418. /**
  71419. * Gets a new Vector2(1, 1)
  71420. * @returns a new Vector2
  71421. */
  71422. Vector2.One = function () {
  71423. return new Vector2(1, 1);
  71424. };
  71425. /**
  71426. * Gets a new Vector2 set from the given index element of the given array
  71427. * @param array defines the data source
  71428. * @param offset defines the offset in the data source
  71429. * @returns a new Vector2
  71430. */
  71431. Vector2.FromArray = function (array, offset) {
  71432. if (offset === void 0) { offset = 0; }
  71433. return new Vector2(array[offset], array[offset + 1]);
  71434. };
  71435. /**
  71436. * Sets "result" from the given index element of the given array
  71437. * @param array defines the data source
  71438. * @param offset defines the offset in the data source
  71439. * @param result defines the target vector
  71440. */
  71441. Vector2.FromArrayToRef = function (array, offset, result) {
  71442. result.x = array[offset];
  71443. result.y = array[offset + 1];
  71444. };
  71445. /**
  71446. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71447. * @param value1 defines 1st point of control
  71448. * @param value2 defines 2nd point of control
  71449. * @param value3 defines 3rd point of control
  71450. * @param value4 defines 4th point of control
  71451. * @param amount defines the interpolation factor
  71452. * @returns a new Vector2
  71453. */
  71454. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  71455. var squared = amount * amount;
  71456. var cubed = amount * squared;
  71457. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  71458. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  71459. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  71460. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  71461. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  71462. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  71463. return new Vector2(x, y);
  71464. };
  71465. /**
  71466. * 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".
  71467. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71468. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71469. * @param value defines the value to clamp
  71470. * @param min defines the lower limit
  71471. * @param max defines the upper limit
  71472. * @returns a new Vector2
  71473. */
  71474. Vector2.Clamp = function (value, min, max) {
  71475. var x = value.x;
  71476. x = (x > max.x) ? max.x : x;
  71477. x = (x < min.x) ? min.x : x;
  71478. var y = value.y;
  71479. y = (y > max.y) ? max.y : y;
  71480. y = (y < min.y) ? min.y : y;
  71481. return new Vector2(x, y);
  71482. };
  71483. /**
  71484. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71485. * @param value1 defines the 1st control point
  71486. * @param tangent1 defines the outgoing tangent
  71487. * @param value2 defines the 2nd control point
  71488. * @param tangent2 defines the incoming tangent
  71489. * @param amount defines the interpolation factor
  71490. * @returns a new Vector2
  71491. */
  71492. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71493. var squared = amount * amount;
  71494. var cubed = amount * squared;
  71495. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71496. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71497. var part3 = (cubed - (2.0 * squared)) + amount;
  71498. var part4 = cubed - squared;
  71499. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71500. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71501. return new Vector2(x, y);
  71502. };
  71503. /**
  71504. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71505. * @param start defines the start vector
  71506. * @param end defines the end vector
  71507. * @param amount defines the interpolation factor
  71508. * @returns a new Vector2
  71509. */
  71510. Vector2.Lerp = function (start, end, amount) {
  71511. var x = start.x + ((end.x - start.x) * amount);
  71512. var y = start.y + ((end.y - start.y) * amount);
  71513. return new Vector2(x, y);
  71514. };
  71515. /**
  71516. * Gets the dot product of the vector "left" and the vector "right"
  71517. * @param left defines first vector
  71518. * @param right defines second vector
  71519. * @returns the dot product (float)
  71520. */
  71521. Vector2.Dot = function (left, right) {
  71522. return left.x * right.x + left.y * right.y;
  71523. };
  71524. /**
  71525. * Returns a new Vector2 equal to the normalized given vector
  71526. * @param vector defines the vector to normalize
  71527. * @returns a new Vector2
  71528. */
  71529. Vector2.Normalize = function (vector) {
  71530. var newVector = vector.clone();
  71531. newVector.normalize();
  71532. return newVector;
  71533. };
  71534. /**
  71535. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71536. * @param left defines 1st vector
  71537. * @param right defines 2nd vector
  71538. * @returns a new Vector2
  71539. */
  71540. Vector2.Minimize = function (left, right) {
  71541. var x = (left.x < right.x) ? left.x : right.x;
  71542. var y = (left.y < right.y) ? left.y : right.y;
  71543. return new Vector2(x, y);
  71544. };
  71545. /**
  71546. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71547. * @param left defines 1st vector
  71548. * @param right defines 2nd vector
  71549. * @returns a new Vector2
  71550. */
  71551. Vector2.Maximize = function (left, right) {
  71552. var x = (left.x > right.x) ? left.x : right.x;
  71553. var y = (left.y > right.y) ? left.y : right.y;
  71554. return new Vector2(x, y);
  71555. };
  71556. /**
  71557. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71558. * @param vector defines the vector to transform
  71559. * @param transformation defines the matrix to apply
  71560. * @returns a new Vector2
  71561. */
  71562. Vector2.Transform = function (vector, transformation) {
  71563. var r = Vector2.Zero();
  71564. Vector2.TransformToRef(vector, transformation, r);
  71565. return r;
  71566. };
  71567. /**
  71568. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71569. * @param vector defines the vector to transform
  71570. * @param transformation defines the matrix to apply
  71571. * @param result defines the target vector
  71572. */
  71573. Vector2.TransformToRef = function (vector, transformation, result) {
  71574. var m = transformation.m;
  71575. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  71576. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  71577. result.x = x;
  71578. result.y = y;
  71579. };
  71580. /**
  71581. * Determines if a given vector is included in a triangle
  71582. * @param p defines the vector to test
  71583. * @param p0 defines 1st triangle point
  71584. * @param p1 defines 2nd triangle point
  71585. * @param p2 defines 3rd triangle point
  71586. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71587. */
  71588. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  71589. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  71590. var sign = a < 0 ? -1 : 1;
  71591. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  71592. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  71593. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  71594. };
  71595. /**
  71596. * Gets the distance between the vectors "value1" and "value2"
  71597. * @param value1 defines first vector
  71598. * @param value2 defines second vector
  71599. * @returns the distance between vectors
  71600. */
  71601. Vector2.Distance = function (value1, value2) {
  71602. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  71603. };
  71604. /**
  71605. * Returns the squared distance between the vectors "value1" and "value2"
  71606. * @param value1 defines first vector
  71607. * @param value2 defines second vector
  71608. * @returns the squared distance between vectors
  71609. */
  71610. Vector2.DistanceSquared = function (value1, value2) {
  71611. var x = value1.x - value2.x;
  71612. var y = value1.y - value2.y;
  71613. return (x * x) + (y * y);
  71614. };
  71615. /**
  71616. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71617. * @param value1 defines first vector
  71618. * @param value2 defines second vector
  71619. * @returns a new Vector2
  71620. */
  71621. Vector2.Center = function (value1, value2) {
  71622. var center = value1.add(value2);
  71623. center.scaleInPlace(0.5);
  71624. return center;
  71625. };
  71626. /**
  71627. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71628. * @param p defines the middle point
  71629. * @param segA defines one point of the segment
  71630. * @param segB defines the other point of the segment
  71631. * @returns the shortest distance
  71632. */
  71633. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  71634. var l2 = Vector2.DistanceSquared(segA, segB);
  71635. if (l2 === 0.0) {
  71636. return Vector2.Distance(p, segA);
  71637. }
  71638. var v = segB.subtract(segA);
  71639. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  71640. var proj = segA.add(v.multiplyByFloats(t, t));
  71641. return Vector2.Distance(p, proj);
  71642. };
  71643. return Vector2;
  71644. }());
  71645. /**
  71646. * Classed used to store (x,y,z) vector representation
  71647. * A Vector3 is the main object used in 3D geometry
  71648. * It can represent etiher the coordinates of a point the space, either a direction
  71649. * Reminder: js uses a left handed forward facing system
  71650. */
  71651. var Vector3 = /** @class */ (function () {
  71652. /**
  71653. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71654. * @param x defines the first coordinates (on X axis)
  71655. * @param y defines the second coordinates (on Y axis)
  71656. * @param z defines the third coordinates (on Z axis)
  71657. */
  71658. function Vector3(
  71659. /**
  71660. * Defines the first coordinates (on X axis)
  71661. */
  71662. x,
  71663. /**
  71664. * Defines the second coordinates (on Y axis)
  71665. */
  71666. y,
  71667. /**
  71668. * Defines the third coordinates (on Z axis)
  71669. */
  71670. z) {
  71671. if (x === void 0) { x = 0; }
  71672. if (y === void 0) { y = 0; }
  71673. if (z === void 0) { z = 0; }
  71674. this.x = x;
  71675. this.y = y;
  71676. this.z = z;
  71677. }
  71678. /**
  71679. * Creates a string representation of the Vector3
  71680. * @returns a string with the Vector3 coordinates.
  71681. */
  71682. Vector3.prototype.toString = function () {
  71683. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  71684. };
  71685. /**
  71686. * Gets the class name
  71687. * @returns the string "Vector3"
  71688. */
  71689. Vector3.prototype.getClassName = function () {
  71690. return "Vector3";
  71691. };
  71692. /**
  71693. * Creates the Vector3 hash code
  71694. * @returns a number which tends to be unique between Vector3 instances
  71695. */
  71696. Vector3.prototype.getHashCode = function () {
  71697. var hash = this.x || 0;
  71698. hash = (hash * 397) ^ (this.y || 0);
  71699. hash = (hash * 397) ^ (this.z || 0);
  71700. return hash;
  71701. };
  71702. // Operators
  71703. /**
  71704. * Creates an array containing three elements : the coordinates of the Vector3
  71705. * @returns a new array of numbers
  71706. */
  71707. Vector3.prototype.asArray = function () {
  71708. var result = [];
  71709. this.toArray(result, 0);
  71710. return result;
  71711. };
  71712. /**
  71713. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71714. * @param array defines the destination array
  71715. * @param index defines the offset in the destination array
  71716. * @returns the current Vector3
  71717. */
  71718. Vector3.prototype.toArray = function (array, index) {
  71719. if (index === void 0) { index = 0; }
  71720. array[index] = this.x;
  71721. array[index + 1] = this.y;
  71722. array[index + 2] = this.z;
  71723. return this;
  71724. };
  71725. /**
  71726. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71727. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71728. */
  71729. Vector3.prototype.toQuaternion = function () {
  71730. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  71731. };
  71732. /**
  71733. * Adds the given vector to the current Vector3
  71734. * @param otherVector defines the second operand
  71735. * @returns the current updated Vector3
  71736. */
  71737. Vector3.prototype.addInPlace = function (otherVector) {
  71738. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  71739. };
  71740. /**
  71741. * Adds the given coordinates to the current Vector3
  71742. * @param x defines the x coordinate of the operand
  71743. * @param y defines the y coordinate of the operand
  71744. * @param z defines the z coordinate of the operand
  71745. * @returns the current updated Vector3
  71746. */
  71747. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  71748. this.x += x;
  71749. this.y += y;
  71750. this.z += z;
  71751. return this;
  71752. };
  71753. /**
  71754. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71755. * @param otherVector defines the second operand
  71756. * @returns the resulting Vector3
  71757. */
  71758. Vector3.prototype.add = function (otherVector) {
  71759. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  71760. };
  71761. /**
  71762. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71763. * @param otherVector defines the second operand
  71764. * @param result defines the Vector3 object where to store the result
  71765. * @returns the current Vector3
  71766. */
  71767. Vector3.prototype.addToRef = function (otherVector, result) {
  71768. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  71769. };
  71770. /**
  71771. * Subtract the given vector from the current Vector3
  71772. * @param otherVector defines the second operand
  71773. * @returns the current updated Vector3
  71774. */
  71775. Vector3.prototype.subtractInPlace = function (otherVector) {
  71776. this.x -= otherVector.x;
  71777. this.y -= otherVector.y;
  71778. this.z -= otherVector.z;
  71779. return this;
  71780. };
  71781. /**
  71782. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71783. * @param otherVector defines the second operand
  71784. * @returns the resulting Vector3
  71785. */
  71786. Vector3.prototype.subtract = function (otherVector) {
  71787. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  71788. };
  71789. /**
  71790. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71791. * @param otherVector defines the second operand
  71792. * @param result defines the Vector3 object where to store the result
  71793. * @returns the current Vector3
  71794. */
  71795. Vector3.prototype.subtractToRef = function (otherVector, result) {
  71796. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  71797. };
  71798. /**
  71799. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71800. * @param x defines the x coordinate of the operand
  71801. * @param y defines the y coordinate of the operand
  71802. * @param z defines the z coordinate of the operand
  71803. * @returns the resulting Vector3
  71804. */
  71805. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  71806. return new Vector3(this.x - x, this.y - y, this.z - z);
  71807. };
  71808. /**
  71809. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71810. * @param x defines the x coordinate of the operand
  71811. * @param y defines the y coordinate of the operand
  71812. * @param z defines the z coordinate of the operand
  71813. * @param result defines the Vector3 object where to store the result
  71814. * @returns the current Vector3
  71815. */
  71816. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  71817. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  71818. };
  71819. /**
  71820. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71821. * @returns a new Vector3
  71822. */
  71823. Vector3.prototype.negate = function () {
  71824. return new Vector3(-this.x, -this.y, -this.z);
  71825. };
  71826. /**
  71827. * Multiplies the Vector3 coordinates by the float "scale"
  71828. * @param scale defines the multiplier factor
  71829. * @returns the current updated Vector3
  71830. */
  71831. Vector3.prototype.scaleInPlace = function (scale) {
  71832. this.x *= scale;
  71833. this.y *= scale;
  71834. this.z *= scale;
  71835. return this;
  71836. };
  71837. /**
  71838. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71839. * @param scale defines the multiplier factor
  71840. * @returns a new Vector3
  71841. */
  71842. Vector3.prototype.scale = function (scale) {
  71843. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  71844. };
  71845. /**
  71846. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71847. * @param scale defines the multiplier factor
  71848. * @param result defines the Vector3 object where to store the result
  71849. * @returns the current Vector3
  71850. */
  71851. Vector3.prototype.scaleToRef = function (scale, result) {
  71852. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  71853. };
  71854. /**
  71855. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71856. * @param scale defines the scale factor
  71857. * @param result defines the Vector3 object where to store the result
  71858. * @returns the unmodified current Vector3
  71859. */
  71860. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  71861. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  71862. };
  71863. /**
  71864. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71865. * @param otherVector defines the second operand
  71866. * @returns true if both vectors are equals
  71867. */
  71868. Vector3.prototype.equals = function (otherVector) {
  71869. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  71870. };
  71871. /**
  71872. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71873. * @param otherVector defines the second operand
  71874. * @param epsilon defines the minimal distance to define values as equals
  71875. * @returns true if both vectors are distant less than epsilon
  71876. */
  71877. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  71878. if (epsilon === void 0) { epsilon = Epsilon; }
  71879. 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);
  71880. };
  71881. /**
  71882. * Returns true if the current Vector3 coordinates equals the given floats
  71883. * @param x defines the x coordinate of the operand
  71884. * @param y defines the y coordinate of the operand
  71885. * @param z defines the z coordinate of the operand
  71886. * @returns true if both vectors are equals
  71887. */
  71888. Vector3.prototype.equalsToFloats = function (x, y, z) {
  71889. return this.x === x && this.y === y && this.z === z;
  71890. };
  71891. /**
  71892. * Multiplies the current Vector3 coordinates by the given ones
  71893. * @param otherVector defines the second operand
  71894. * @returns the current updated Vector3
  71895. */
  71896. Vector3.prototype.multiplyInPlace = function (otherVector) {
  71897. this.x *= otherVector.x;
  71898. this.y *= otherVector.y;
  71899. this.z *= otherVector.z;
  71900. return this;
  71901. };
  71902. /**
  71903. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71904. * @param otherVector defines the second operand
  71905. * @returns the new Vector3
  71906. */
  71907. Vector3.prototype.multiply = function (otherVector) {
  71908. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  71909. };
  71910. /**
  71911. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71912. * @param otherVector defines the second operand
  71913. * @param result defines the Vector3 object where to store the result
  71914. * @returns the current Vector3
  71915. */
  71916. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  71917. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  71918. };
  71919. /**
  71920. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71921. * @param x defines the x coordinate of the operand
  71922. * @param y defines the y coordinate of the operand
  71923. * @param z defines the z coordinate of the operand
  71924. * @returns the new Vector3
  71925. */
  71926. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  71927. return new Vector3(this.x * x, this.y * y, this.z * z);
  71928. };
  71929. /**
  71930. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71931. * @param otherVector defines the second operand
  71932. * @returns the new Vector3
  71933. */
  71934. Vector3.prototype.divide = function (otherVector) {
  71935. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  71936. };
  71937. /**
  71938. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71939. * @param otherVector defines the second operand
  71940. * @param result defines the Vector3 object where to store the result
  71941. * @returns the current Vector3
  71942. */
  71943. Vector3.prototype.divideToRef = function (otherVector, result) {
  71944. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  71945. };
  71946. /**
  71947. * Divides the current Vector3 coordinates by the given ones.
  71948. * @param otherVector defines the second operand
  71949. * @returns the current updated Vector3
  71950. */
  71951. Vector3.prototype.divideInPlace = function (otherVector) {
  71952. return this.divideToRef(otherVector, this);
  71953. };
  71954. /**
  71955. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71956. * @param other defines the second operand
  71957. * @returns the current updated Vector3
  71958. */
  71959. Vector3.prototype.minimizeInPlace = function (other) {
  71960. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  71961. };
  71962. /**
  71963. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71964. * @param other defines the second operand
  71965. * @returns the current updated Vector3
  71966. */
  71967. Vector3.prototype.maximizeInPlace = function (other) {
  71968. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  71969. };
  71970. /**
  71971. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71972. * @param x defines the x coordinate of the operand
  71973. * @param y defines the y coordinate of the operand
  71974. * @param z defines the z coordinate of the operand
  71975. * @returns the current updated Vector3
  71976. */
  71977. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  71978. if (x < this.x) {
  71979. this.x = x;
  71980. }
  71981. if (y < this.y) {
  71982. this.y = y;
  71983. }
  71984. if (z < this.z) {
  71985. this.z = z;
  71986. }
  71987. return this;
  71988. };
  71989. /**
  71990. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71991. * @param x defines the x coordinate of the operand
  71992. * @param y defines the y coordinate of the operand
  71993. * @param z defines the z coordinate of the operand
  71994. * @returns the current updated Vector3
  71995. */
  71996. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  71997. if (x > this.x) {
  71998. this.x = x;
  71999. }
  72000. if (y > this.y) {
  72001. this.y = y;
  72002. }
  72003. if (z > this.z) {
  72004. this.z = z;
  72005. }
  72006. return this;
  72007. };
  72008. /**
  72009. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  72010. * Check if is non uniform within a certain amount of decimal places to account for this
  72011. * @param epsilon the amount the values can differ
  72012. * @returns if the the vector is non uniform to a certain number of decimal places
  72013. */
  72014. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  72015. var absX = Math.abs(this.x);
  72016. var absY = Math.abs(this.y);
  72017. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  72018. return true;
  72019. }
  72020. var absZ = Math.abs(this.z);
  72021. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  72022. return true;
  72023. }
  72024. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  72025. return true;
  72026. }
  72027. return false;
  72028. };
  72029. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  72030. /**
  72031. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  72032. */
  72033. get: function () {
  72034. var absX = Math.abs(this.x);
  72035. var absY = Math.abs(this.y);
  72036. if (absX !== absY) {
  72037. return true;
  72038. }
  72039. var absZ = Math.abs(this.z);
  72040. if (absX !== absZ) {
  72041. return true;
  72042. }
  72043. if (absY !== absZ) {
  72044. return true;
  72045. }
  72046. return false;
  72047. },
  72048. enumerable: true,
  72049. configurable: true
  72050. });
  72051. /**
  72052. * Gets a new Vector3 from current Vector3 floored values
  72053. * @returns a new Vector3
  72054. */
  72055. Vector3.prototype.floor = function () {
  72056. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  72057. };
  72058. /**
  72059. * Gets a new Vector3 from current Vector3 floored values
  72060. * @returns a new Vector3
  72061. */
  72062. Vector3.prototype.fract = function () {
  72063. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  72064. };
  72065. // Properties
  72066. /**
  72067. * Gets the length of the Vector3
  72068. * @returns the length of the Vecto3
  72069. */
  72070. Vector3.prototype.length = function () {
  72071. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  72072. };
  72073. /**
  72074. * Gets the squared length of the Vector3
  72075. * @returns squared length of the Vector3
  72076. */
  72077. Vector3.prototype.lengthSquared = function () {
  72078. return (this.x * this.x + this.y * this.y + this.z * this.z);
  72079. };
  72080. /**
  72081. * Normalize the current Vector3.
  72082. * Please note that this is an in place operation.
  72083. * @returns the current updated Vector3
  72084. */
  72085. Vector3.prototype.normalize = function () {
  72086. return this.normalizeFromLength(this.length());
  72087. };
  72088. /**
  72089. * Reorders the x y z properties of the vector in place
  72090. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  72091. * @returns the current updated vector
  72092. */
  72093. Vector3.prototype.reorderInPlace = function (order) {
  72094. var _this = this;
  72095. order = order.toLowerCase();
  72096. if (order === "xyz") {
  72097. return this;
  72098. }
  72099. MathTmp.Vector3[0].copyFrom(this);
  72100. ["x", "y", "z"].forEach(function (val, i) {
  72101. _this[val] = MathTmp.Vector3[0][order[i]];
  72102. });
  72103. return this;
  72104. };
  72105. /**
  72106. * Rotates the vector around 0,0,0 by a quaternion
  72107. * @param quaternion the rotation quaternion
  72108. * @param result vector to store the result
  72109. * @returns the resulting vector
  72110. */
  72111. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  72112. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  72113. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  72114. return result;
  72115. };
  72116. /**
  72117. * Rotates a vector around a given point
  72118. * @param quaternion the rotation quaternion
  72119. * @param point the point to rotate around
  72120. * @param result vector to store the result
  72121. * @returns the resulting vector
  72122. */
  72123. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  72124. this.subtractToRef(point, MathTmp.Vector3[0]);
  72125. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  72126. point.addToRef(MathTmp.Vector3[0], result);
  72127. return result;
  72128. };
  72129. /**
  72130. * Normalize the current Vector3 with the given input length.
  72131. * Please note that this is an in place operation.
  72132. * @param len the length of the vector
  72133. * @returns the current updated Vector3
  72134. */
  72135. Vector3.prototype.normalizeFromLength = function (len) {
  72136. if (len === 0 || len === 1.0) {
  72137. return this;
  72138. }
  72139. return this.scaleInPlace(1.0 / len);
  72140. };
  72141. /**
  72142. * Normalize the current Vector3 to a new vector
  72143. * @returns the new Vector3
  72144. */
  72145. Vector3.prototype.normalizeToNew = function () {
  72146. var normalized = new Vector3(0, 0, 0);
  72147. this.normalizeToRef(normalized);
  72148. return normalized;
  72149. };
  72150. /**
  72151. * Normalize the current Vector3 to the reference
  72152. * @param reference define the Vector3 to update
  72153. * @returns the updated Vector3
  72154. */
  72155. Vector3.prototype.normalizeToRef = function (reference) {
  72156. var len = this.length();
  72157. if (len === 0 || len === 1.0) {
  72158. return reference.copyFromFloats(this.x, this.y, this.z);
  72159. }
  72160. return this.scaleToRef(1.0 / len, reference);
  72161. };
  72162. /**
  72163. * Creates a new Vector3 copied from the current Vector3
  72164. * @returns the new Vector3
  72165. */
  72166. Vector3.prototype.clone = function () {
  72167. return new Vector3(this.x, this.y, this.z);
  72168. };
  72169. /**
  72170. * Copies the given vector coordinates to the current Vector3 ones
  72171. * @param source defines the source Vector3
  72172. * @returns the current updated Vector3
  72173. */
  72174. Vector3.prototype.copyFrom = function (source) {
  72175. return this.copyFromFloats(source.x, source.y, source.z);
  72176. };
  72177. /**
  72178. * Copies the given floats to the current Vector3 coordinates
  72179. * @param x defines the x coordinate of the operand
  72180. * @param y defines the y coordinate of the operand
  72181. * @param z defines the z coordinate of the operand
  72182. * @returns the current updated Vector3
  72183. */
  72184. Vector3.prototype.copyFromFloats = function (x, y, z) {
  72185. this.x = x;
  72186. this.y = y;
  72187. this.z = z;
  72188. return this;
  72189. };
  72190. /**
  72191. * Copies the given floats to the current Vector3 coordinates
  72192. * @param x defines the x coordinate of the operand
  72193. * @param y defines the y coordinate of the operand
  72194. * @param z defines the z coordinate of the operand
  72195. * @returns the current updated Vector3
  72196. */
  72197. Vector3.prototype.set = function (x, y, z) {
  72198. return this.copyFromFloats(x, y, z);
  72199. };
  72200. /**
  72201. * Copies the given float to the current Vector3 coordinates
  72202. * @param v defines the x, y and z coordinates of the operand
  72203. * @returns the current updated Vector3
  72204. */
  72205. Vector3.prototype.setAll = function (v) {
  72206. this.x = this.y = this.z = v;
  72207. return this;
  72208. };
  72209. // Statics
  72210. /**
  72211. * Get the clip factor between two vectors
  72212. * @param vector0 defines the first operand
  72213. * @param vector1 defines the second operand
  72214. * @param axis defines the axis to use
  72215. * @param size defines the size along the axis
  72216. * @returns the clip factor
  72217. */
  72218. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  72219. var d0 = Vector3.Dot(vector0, axis) - size;
  72220. var d1 = Vector3.Dot(vector1, axis) - size;
  72221. var s = d0 / (d0 - d1);
  72222. return s;
  72223. };
  72224. /**
  72225. * Get angle between two vectors
  72226. * @param vector0 angle between vector0 and vector1
  72227. * @param vector1 angle between vector0 and vector1
  72228. * @param normal direction of the normal
  72229. * @return the angle between vector0 and vector1
  72230. */
  72231. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  72232. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  72233. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  72234. var dot = Vector3.Dot(v0, v1);
  72235. var n = MathTmp.Vector3[3];
  72236. Vector3.CrossToRef(v0, v1, n);
  72237. if (Vector3.Dot(n, normal) > 0) {
  72238. return Math.acos(dot);
  72239. }
  72240. return -Math.acos(dot);
  72241. };
  72242. /**
  72243. * Returns a new Vector3 set from the index "offset" of the given array
  72244. * @param array defines the source array
  72245. * @param offset defines the offset in the source array
  72246. * @returns the new Vector3
  72247. */
  72248. Vector3.FromArray = function (array, offset) {
  72249. if (offset === void 0) { offset = 0; }
  72250. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  72251. };
  72252. /**
  72253. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  72254. * This function is deprecated. Use FromArray instead
  72255. * @param array defines the source array
  72256. * @param offset defines the offset in the source array
  72257. * @returns the new Vector3
  72258. */
  72259. Vector3.FromFloatArray = function (array, offset) {
  72260. return Vector3.FromArray(array, offset);
  72261. };
  72262. /**
  72263. * Sets the given vector "result" with the element values from the index "offset" of the given array
  72264. * @param array defines the source array
  72265. * @param offset defines the offset in the source array
  72266. * @param result defines the Vector3 where to store the result
  72267. */
  72268. Vector3.FromArrayToRef = function (array, offset, result) {
  72269. result.x = array[offset];
  72270. result.y = array[offset + 1];
  72271. result.z = array[offset + 2];
  72272. };
  72273. /**
  72274. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  72275. * This function is deprecated. Use FromArrayToRef instead.
  72276. * @param array defines the source array
  72277. * @param offset defines the offset in the source array
  72278. * @param result defines the Vector3 where to store the result
  72279. */
  72280. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  72281. return Vector3.FromArrayToRef(array, offset, result);
  72282. };
  72283. /**
  72284. * Sets the given vector "result" with the given floats.
  72285. * @param x defines the x coordinate of the source
  72286. * @param y defines the y coordinate of the source
  72287. * @param z defines the z coordinate of the source
  72288. * @param result defines the Vector3 where to store the result
  72289. */
  72290. Vector3.FromFloatsToRef = function (x, y, z, result) {
  72291. result.copyFromFloats(x, y, z);
  72292. };
  72293. /**
  72294. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  72295. * @returns a new empty Vector3
  72296. */
  72297. Vector3.Zero = function () {
  72298. return new Vector3(0.0, 0.0, 0.0);
  72299. };
  72300. /**
  72301. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  72302. * @returns a new unit Vector3
  72303. */
  72304. Vector3.One = function () {
  72305. return new Vector3(1.0, 1.0, 1.0);
  72306. };
  72307. /**
  72308. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  72309. * @returns a new up Vector3
  72310. */
  72311. Vector3.Up = function () {
  72312. return new Vector3(0.0, 1.0, 0.0);
  72313. };
  72314. Object.defineProperty(Vector3, "UpReadOnly", {
  72315. /**
  72316. * Gets a up Vector3 that must not be updated
  72317. */
  72318. get: function () {
  72319. return Vector3._UpReadOnly;
  72320. },
  72321. enumerable: true,
  72322. configurable: true
  72323. });
  72324. /**
  72325. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  72326. * @returns a new down Vector3
  72327. */
  72328. Vector3.Down = function () {
  72329. return new Vector3(0.0, -1.0, 0.0);
  72330. };
  72331. /**
  72332. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  72333. * @returns a new forward Vector3
  72334. */
  72335. Vector3.Forward = function () {
  72336. return new Vector3(0.0, 0.0, 1.0);
  72337. };
  72338. /**
  72339. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  72340. * @returns a new forward Vector3
  72341. */
  72342. Vector3.Backward = function () {
  72343. return new Vector3(0.0, 0.0, -1.0);
  72344. };
  72345. /**
  72346. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  72347. * @returns a new right Vector3
  72348. */
  72349. Vector3.Right = function () {
  72350. return new Vector3(1.0, 0.0, 0.0);
  72351. };
  72352. /**
  72353. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  72354. * @returns a new left Vector3
  72355. */
  72356. Vector3.Left = function () {
  72357. return new Vector3(-1.0, 0.0, 0.0);
  72358. };
  72359. /**
  72360. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  72361. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72362. * @param vector defines the Vector3 to transform
  72363. * @param transformation defines the transformation matrix
  72364. * @returns the transformed Vector3
  72365. */
  72366. Vector3.TransformCoordinates = function (vector, transformation) {
  72367. var result = Vector3.Zero();
  72368. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  72369. return result;
  72370. };
  72371. /**
  72372. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  72373. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72374. * @param vector defines the Vector3 to transform
  72375. * @param transformation defines the transformation matrix
  72376. * @param result defines the Vector3 where to store the result
  72377. */
  72378. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  72379. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  72380. };
  72381. /**
  72382. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  72383. * This method computes tranformed coordinates only, not transformed direction vectors
  72384. * @param x define the x coordinate of the source vector
  72385. * @param y define the y coordinate of the source vector
  72386. * @param z define the z coordinate of the source vector
  72387. * @param transformation defines the transformation matrix
  72388. * @param result defines the Vector3 where to store the result
  72389. */
  72390. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  72391. var m = transformation.m;
  72392. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  72393. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  72394. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  72395. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  72396. result.x = rx * rw;
  72397. result.y = ry * rw;
  72398. result.z = rz * rw;
  72399. };
  72400. /**
  72401. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  72402. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72403. * @param vector defines the Vector3 to transform
  72404. * @param transformation defines the transformation matrix
  72405. * @returns the new Vector3
  72406. */
  72407. Vector3.TransformNormal = function (vector, transformation) {
  72408. var result = Vector3.Zero();
  72409. Vector3.TransformNormalToRef(vector, transformation, result);
  72410. return result;
  72411. };
  72412. /**
  72413. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  72414. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72415. * @param vector defines the Vector3 to transform
  72416. * @param transformation defines the transformation matrix
  72417. * @param result defines the Vector3 where to store the result
  72418. */
  72419. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  72420. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  72421. };
  72422. /**
  72423. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  72424. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72425. * @param x define the x coordinate of the source vector
  72426. * @param y define the y coordinate of the source vector
  72427. * @param z define the z coordinate of the source vector
  72428. * @param transformation defines the transformation matrix
  72429. * @param result defines the Vector3 where to store the result
  72430. */
  72431. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  72432. var m = transformation.m;
  72433. result.x = x * m[0] + y * m[4] + z * m[8];
  72434. result.y = x * m[1] + y * m[5] + z * m[9];
  72435. result.z = x * m[2] + y * m[6] + z * m[10];
  72436. };
  72437. /**
  72438. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  72439. * @param value1 defines the first control point
  72440. * @param value2 defines the second control point
  72441. * @param value3 defines the third control point
  72442. * @param value4 defines the fourth control point
  72443. * @param amount defines the amount on the spline to use
  72444. * @returns the new Vector3
  72445. */
  72446. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  72447. var squared = amount * amount;
  72448. var cubed = amount * squared;
  72449. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  72450. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  72451. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  72452. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  72453. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  72454. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  72455. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  72456. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  72457. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  72458. return new Vector3(x, y, z);
  72459. };
  72460. /**
  72461. * 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"
  72462. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72463. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72464. * @param value defines the current value
  72465. * @param min defines the lower range value
  72466. * @param max defines the upper range value
  72467. * @returns the new Vector3
  72468. */
  72469. Vector3.Clamp = function (value, min, max) {
  72470. var v = new Vector3();
  72471. Vector3.ClampToRef(value, min, max, v);
  72472. return v;
  72473. };
  72474. /**
  72475. * 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"
  72476. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72477. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72478. * @param value defines the current value
  72479. * @param min defines the lower range value
  72480. * @param max defines the upper range value
  72481. * @param result defines the Vector3 where to store the result
  72482. */
  72483. Vector3.ClampToRef = function (value, min, max, result) {
  72484. var x = value.x;
  72485. x = (x > max.x) ? max.x : x;
  72486. x = (x < min.x) ? min.x : x;
  72487. var y = value.y;
  72488. y = (y > max.y) ? max.y : y;
  72489. y = (y < min.y) ? min.y : y;
  72490. var z = value.z;
  72491. z = (z > max.z) ? max.z : z;
  72492. z = (z < min.z) ? min.z : z;
  72493. result.copyFromFloats(x, y, z);
  72494. };
  72495. /**
  72496. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  72497. * @param value1 defines the first control point
  72498. * @param tangent1 defines the first tangent vector
  72499. * @param value2 defines the second control point
  72500. * @param tangent2 defines the second tangent vector
  72501. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  72502. * @returns the new Vector3
  72503. */
  72504. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  72505. var squared = amount * amount;
  72506. var cubed = amount * squared;
  72507. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  72508. var part2 = (-2.0 * cubed) + (3.0 * squared);
  72509. var part3 = (cubed - (2.0 * squared)) + amount;
  72510. var part4 = cubed - squared;
  72511. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  72512. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  72513. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  72514. return new Vector3(x, y, z);
  72515. };
  72516. /**
  72517. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  72518. * @param start defines the start value
  72519. * @param end defines the end value
  72520. * @param amount max defines amount between both (between 0 and 1)
  72521. * @returns the new Vector3
  72522. */
  72523. Vector3.Lerp = function (start, end, amount) {
  72524. var result = new Vector3(0, 0, 0);
  72525. Vector3.LerpToRef(start, end, amount, result);
  72526. return result;
  72527. };
  72528. /**
  72529. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  72530. * @param start defines the start value
  72531. * @param end defines the end value
  72532. * @param amount max defines amount between both (between 0 and 1)
  72533. * @param result defines the Vector3 where to store the result
  72534. */
  72535. Vector3.LerpToRef = function (start, end, amount, result) {
  72536. result.x = start.x + ((end.x - start.x) * amount);
  72537. result.y = start.y + ((end.y - start.y) * amount);
  72538. result.z = start.z + ((end.z - start.z) * amount);
  72539. };
  72540. /**
  72541. * Returns the dot product (float) between the vectors "left" and "right"
  72542. * @param left defines the left operand
  72543. * @param right defines the right operand
  72544. * @returns the dot product
  72545. */
  72546. Vector3.Dot = function (left, right) {
  72547. return (left.x * right.x + left.y * right.y + left.z * right.z);
  72548. };
  72549. /**
  72550. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  72551. * The cross product is then orthogonal to both "left" and "right"
  72552. * @param left defines the left operand
  72553. * @param right defines the right operand
  72554. * @returns the cross product
  72555. */
  72556. Vector3.Cross = function (left, right) {
  72557. var result = Vector3.Zero();
  72558. Vector3.CrossToRef(left, right, result);
  72559. return result;
  72560. };
  72561. /**
  72562. * Sets the given vector "result" with the cross product of "left" and "right"
  72563. * The cross product is then orthogonal to both "left" and "right"
  72564. * @param left defines the left operand
  72565. * @param right defines the right operand
  72566. * @param result defines the Vector3 where to store the result
  72567. */
  72568. Vector3.CrossToRef = function (left, right, result) {
  72569. var x = left.y * right.z - left.z * right.y;
  72570. var y = left.z * right.x - left.x * right.z;
  72571. var z = left.x * right.y - left.y * right.x;
  72572. result.copyFromFloats(x, y, z);
  72573. };
  72574. /**
  72575. * Returns a new Vector3 as the normalization of the given vector
  72576. * @param vector defines the Vector3 to normalize
  72577. * @returns the new Vector3
  72578. */
  72579. Vector3.Normalize = function (vector) {
  72580. var result = Vector3.Zero();
  72581. Vector3.NormalizeToRef(vector, result);
  72582. return result;
  72583. };
  72584. /**
  72585. * Sets the given vector "result" with the normalization of the given first vector
  72586. * @param vector defines the Vector3 to normalize
  72587. * @param result defines the Vector3 where to store the result
  72588. */
  72589. Vector3.NormalizeToRef = function (vector, result) {
  72590. vector.normalizeToRef(result);
  72591. };
  72592. /**
  72593. * Project a Vector3 onto screen space
  72594. * @param vector defines the Vector3 to project
  72595. * @param world defines the world matrix to use
  72596. * @param transform defines the transform (view x projection) matrix to use
  72597. * @param viewport defines the screen viewport to use
  72598. * @returns the new Vector3
  72599. */
  72600. Vector3.Project = function (vector, world, transform, viewport) {
  72601. var cw = viewport.width;
  72602. var ch = viewport.height;
  72603. var cx = viewport.x;
  72604. var cy = viewport.y;
  72605. var viewportMatrix = MathTmp.Matrix[1];
  72606. 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);
  72607. var matrix = MathTmp.Matrix[0];
  72608. world.multiplyToRef(transform, matrix);
  72609. matrix.multiplyToRef(viewportMatrix, matrix);
  72610. return Vector3.TransformCoordinates(vector, matrix);
  72611. };
  72612. /** @hidden */
  72613. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  72614. Vector3.TransformCoordinatesToRef(source, matrix, result);
  72615. var m = matrix.m;
  72616. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  72617. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  72618. result.scaleInPlace(1.0 / num);
  72619. }
  72620. };
  72621. /**
  72622. * Unproject from screen space to object space
  72623. * @param source defines the screen space Vector3 to use
  72624. * @param viewportWidth defines the current width of the viewport
  72625. * @param viewportHeight defines the current height of the viewport
  72626. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72627. * @param transform defines the transform (view x projection) matrix to use
  72628. * @returns the new Vector3
  72629. */
  72630. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  72631. var matrix = MathTmp.Matrix[0];
  72632. world.multiplyToRef(transform, matrix);
  72633. matrix.invert();
  72634. source.x = source.x / viewportWidth * 2 - 1;
  72635. source.y = -(source.y / viewportHeight * 2 - 1);
  72636. var vector = new Vector3();
  72637. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  72638. return vector;
  72639. };
  72640. /**
  72641. * Unproject from screen space to object space
  72642. * @param source defines the screen space Vector3 to use
  72643. * @param viewportWidth defines the current width of the viewport
  72644. * @param viewportHeight defines the current height of the viewport
  72645. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72646. * @param view defines the view matrix to use
  72647. * @param projection defines the projection matrix to use
  72648. * @returns the new Vector3
  72649. */
  72650. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  72651. var result = Vector3.Zero();
  72652. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  72653. return result;
  72654. };
  72655. /**
  72656. * Unproject from screen space to object space
  72657. * @param source defines the screen space Vector3 to use
  72658. * @param viewportWidth defines the current width of the viewport
  72659. * @param viewportHeight defines the current height of the viewport
  72660. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72661. * @param view defines the view matrix to use
  72662. * @param projection defines the projection matrix to use
  72663. * @param result defines the Vector3 where to store the result
  72664. */
  72665. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  72666. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  72667. };
  72668. /**
  72669. * Unproject from screen space to object space
  72670. * @param sourceX defines the screen space x coordinate to use
  72671. * @param sourceY defines the screen space y coordinate to use
  72672. * @param sourceZ defines the screen space z coordinate to use
  72673. * @param viewportWidth defines the current width of the viewport
  72674. * @param viewportHeight defines the current height of the viewport
  72675. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72676. * @param view defines the view matrix to use
  72677. * @param projection defines the projection matrix to use
  72678. * @param result defines the Vector3 where to store the result
  72679. */
  72680. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  72681. var matrix = MathTmp.Matrix[0];
  72682. world.multiplyToRef(view, matrix);
  72683. matrix.multiplyToRef(projection, matrix);
  72684. matrix.invert();
  72685. var screenSource = MathTmp.Vector3[0];
  72686. screenSource.x = sourceX / viewportWidth * 2 - 1;
  72687. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  72688. screenSource.z = 2 * sourceZ - 1.0;
  72689. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  72690. };
  72691. /**
  72692. * Gets the minimal coordinate values between two Vector3
  72693. * @param left defines the first operand
  72694. * @param right defines the second operand
  72695. * @returns the new Vector3
  72696. */
  72697. Vector3.Minimize = function (left, right) {
  72698. var min = left.clone();
  72699. min.minimizeInPlace(right);
  72700. return min;
  72701. };
  72702. /**
  72703. * Gets the maximal coordinate values between two Vector3
  72704. * @param left defines the first operand
  72705. * @param right defines the second operand
  72706. * @returns the new Vector3
  72707. */
  72708. Vector3.Maximize = function (left, right) {
  72709. var max = left.clone();
  72710. max.maximizeInPlace(right);
  72711. return max;
  72712. };
  72713. /**
  72714. * Returns the distance between the vectors "value1" and "value2"
  72715. * @param value1 defines the first operand
  72716. * @param value2 defines the second operand
  72717. * @returns the distance
  72718. */
  72719. Vector3.Distance = function (value1, value2) {
  72720. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  72721. };
  72722. /**
  72723. * Returns the squared distance between the vectors "value1" and "value2"
  72724. * @param value1 defines the first operand
  72725. * @param value2 defines the second operand
  72726. * @returns the squared distance
  72727. */
  72728. Vector3.DistanceSquared = function (value1, value2) {
  72729. var x = value1.x - value2.x;
  72730. var y = value1.y - value2.y;
  72731. var z = value1.z - value2.z;
  72732. return (x * x) + (y * y) + (z * z);
  72733. };
  72734. /**
  72735. * Returns a new Vector3 located at the center between "value1" and "value2"
  72736. * @param value1 defines the first operand
  72737. * @param value2 defines the second operand
  72738. * @returns the new Vector3
  72739. */
  72740. Vector3.Center = function (value1, value2) {
  72741. var center = value1.add(value2);
  72742. center.scaleInPlace(0.5);
  72743. return center;
  72744. };
  72745. /**
  72746. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  72747. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  72748. * to something in order to rotate it from its local system to the given target system
  72749. * Note: axis1, axis2 and axis3 are normalized during this operation
  72750. * @param axis1 defines the first axis
  72751. * @param axis2 defines the second axis
  72752. * @param axis3 defines the third axis
  72753. * @returns a new Vector3
  72754. */
  72755. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  72756. var rotation = Vector3.Zero();
  72757. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  72758. return rotation;
  72759. };
  72760. /**
  72761. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  72762. * @param axis1 defines the first axis
  72763. * @param axis2 defines the second axis
  72764. * @param axis3 defines the third axis
  72765. * @param ref defines the Vector3 where to store the result
  72766. */
  72767. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  72768. var quat = MathTmp.Quaternion[0];
  72769. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  72770. quat.toEulerAnglesToRef(ref);
  72771. };
  72772. Vector3._UpReadOnly = Vector3.Up();
  72773. return Vector3;
  72774. }());
  72775. /**
  72776. * Vector4 class created for EulerAngle class conversion to Quaternion
  72777. */
  72778. var Vector4 = /** @class */ (function () {
  72779. /**
  72780. * Creates a Vector4 object from the given floats.
  72781. * @param x x value of the vector
  72782. * @param y y value of the vector
  72783. * @param z z value of the vector
  72784. * @param w w value of the vector
  72785. */
  72786. function Vector4(
  72787. /** x value of the vector */
  72788. x,
  72789. /** y value of the vector */
  72790. y,
  72791. /** z value of the vector */
  72792. z,
  72793. /** w value of the vector */
  72794. w) {
  72795. this.x = x;
  72796. this.y = y;
  72797. this.z = z;
  72798. this.w = w;
  72799. }
  72800. /**
  72801. * Returns the string with the Vector4 coordinates.
  72802. * @returns a string containing all the vector values
  72803. */
  72804. Vector4.prototype.toString = function () {
  72805. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  72806. };
  72807. /**
  72808. * Returns the string "Vector4".
  72809. * @returns "Vector4"
  72810. */
  72811. Vector4.prototype.getClassName = function () {
  72812. return "Vector4";
  72813. };
  72814. /**
  72815. * Returns the Vector4 hash code.
  72816. * @returns a unique hash code
  72817. */
  72818. Vector4.prototype.getHashCode = function () {
  72819. var hash = this.x || 0;
  72820. hash = (hash * 397) ^ (this.y || 0);
  72821. hash = (hash * 397) ^ (this.z || 0);
  72822. hash = (hash * 397) ^ (this.w || 0);
  72823. return hash;
  72824. };
  72825. // Operators
  72826. /**
  72827. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  72828. * @returns the resulting array
  72829. */
  72830. Vector4.prototype.asArray = function () {
  72831. var result = new Array();
  72832. this.toArray(result, 0);
  72833. return result;
  72834. };
  72835. /**
  72836. * Populates the given array from the given index with the Vector4 coordinates.
  72837. * @param array array to populate
  72838. * @param index index of the array to start at (default: 0)
  72839. * @returns the Vector4.
  72840. */
  72841. Vector4.prototype.toArray = function (array, index) {
  72842. if (index === undefined) {
  72843. index = 0;
  72844. }
  72845. array[index] = this.x;
  72846. array[index + 1] = this.y;
  72847. array[index + 2] = this.z;
  72848. array[index + 3] = this.w;
  72849. return this;
  72850. };
  72851. /**
  72852. * Adds the given vector to the current Vector4.
  72853. * @param otherVector the vector to add
  72854. * @returns the updated Vector4.
  72855. */
  72856. Vector4.prototype.addInPlace = function (otherVector) {
  72857. this.x += otherVector.x;
  72858. this.y += otherVector.y;
  72859. this.z += otherVector.z;
  72860. this.w += otherVector.w;
  72861. return this;
  72862. };
  72863. /**
  72864. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  72865. * @param otherVector the vector to add
  72866. * @returns the resulting vector
  72867. */
  72868. Vector4.prototype.add = function (otherVector) {
  72869. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  72870. };
  72871. /**
  72872. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  72873. * @param otherVector the vector to add
  72874. * @param result the vector to store the result
  72875. * @returns the current Vector4.
  72876. */
  72877. Vector4.prototype.addToRef = function (otherVector, result) {
  72878. result.x = this.x + otherVector.x;
  72879. result.y = this.y + otherVector.y;
  72880. result.z = this.z + otherVector.z;
  72881. result.w = this.w + otherVector.w;
  72882. return this;
  72883. };
  72884. /**
  72885. * Subtract in place the given vector from the current Vector4.
  72886. * @param otherVector the vector to subtract
  72887. * @returns the updated Vector4.
  72888. */
  72889. Vector4.prototype.subtractInPlace = function (otherVector) {
  72890. this.x -= otherVector.x;
  72891. this.y -= otherVector.y;
  72892. this.z -= otherVector.z;
  72893. this.w -= otherVector.w;
  72894. return this;
  72895. };
  72896. /**
  72897. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  72898. * @param otherVector the vector to add
  72899. * @returns the new vector with the result
  72900. */
  72901. Vector4.prototype.subtract = function (otherVector) {
  72902. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  72903. };
  72904. /**
  72905. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72906. * @param otherVector the vector to subtract
  72907. * @param result the vector to store the result
  72908. * @returns the current Vector4.
  72909. */
  72910. Vector4.prototype.subtractToRef = function (otherVector, result) {
  72911. result.x = this.x - otherVector.x;
  72912. result.y = this.y - otherVector.y;
  72913. result.z = this.z - otherVector.z;
  72914. result.w = this.w - otherVector.w;
  72915. return this;
  72916. };
  72917. /**
  72918. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72919. */
  72920. /**
  72921. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72922. * @param x value to subtract
  72923. * @param y value to subtract
  72924. * @param z value to subtract
  72925. * @param w value to subtract
  72926. * @returns new vector containing the result
  72927. */
  72928. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  72929. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  72930. };
  72931. /**
  72932. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72933. * @param x value to subtract
  72934. * @param y value to subtract
  72935. * @param z value to subtract
  72936. * @param w value to subtract
  72937. * @param result the vector to store the result in
  72938. * @returns the current Vector4.
  72939. */
  72940. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  72941. result.x = this.x - x;
  72942. result.y = this.y - y;
  72943. result.z = this.z - z;
  72944. result.w = this.w - w;
  72945. return this;
  72946. };
  72947. /**
  72948. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72949. * @returns a new vector with the negated values
  72950. */
  72951. Vector4.prototype.negate = function () {
  72952. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  72953. };
  72954. /**
  72955. * Multiplies the current Vector4 coordinates by scale (float).
  72956. * @param scale the number to scale with
  72957. * @returns the updated Vector4.
  72958. */
  72959. Vector4.prototype.scaleInPlace = function (scale) {
  72960. this.x *= scale;
  72961. this.y *= scale;
  72962. this.z *= scale;
  72963. this.w *= scale;
  72964. return this;
  72965. };
  72966. /**
  72967. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72968. * @param scale the number to scale with
  72969. * @returns a new vector with the result
  72970. */
  72971. Vector4.prototype.scale = function (scale) {
  72972. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  72973. };
  72974. /**
  72975. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72976. * @param scale the number to scale with
  72977. * @param result a vector to store the result in
  72978. * @returns the current Vector4.
  72979. */
  72980. Vector4.prototype.scaleToRef = function (scale, result) {
  72981. result.x = this.x * scale;
  72982. result.y = this.y * scale;
  72983. result.z = this.z * scale;
  72984. result.w = this.w * scale;
  72985. return this;
  72986. };
  72987. /**
  72988. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72989. * @param scale defines the scale factor
  72990. * @param result defines the Vector4 object where to store the result
  72991. * @returns the unmodified current Vector4
  72992. */
  72993. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  72994. result.x += this.x * scale;
  72995. result.y += this.y * scale;
  72996. result.z += this.z * scale;
  72997. result.w += this.w * scale;
  72998. return this;
  72999. };
  73000. /**
  73001. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73002. * @param otherVector the vector to compare against
  73003. * @returns true if they are equal
  73004. */
  73005. Vector4.prototype.equals = function (otherVector) {
  73006. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  73007. };
  73008. /**
  73009. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73010. * @param otherVector vector to compare against
  73011. * @param epsilon (Default: very small number)
  73012. * @returns true if they are equal
  73013. */
  73014. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  73015. if (epsilon === void 0) { epsilon = Epsilon; }
  73016. return otherVector
  73017. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  73018. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  73019. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  73020. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  73021. };
  73022. /**
  73023. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73024. * @param x x value to compare against
  73025. * @param y y value to compare against
  73026. * @param z z value to compare against
  73027. * @param w w value to compare against
  73028. * @returns true if equal
  73029. */
  73030. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  73031. return this.x === x && this.y === y && this.z === z && this.w === w;
  73032. };
  73033. /**
  73034. * Multiplies in place the current Vector4 by the given one.
  73035. * @param otherVector vector to multiple with
  73036. * @returns the updated Vector4.
  73037. */
  73038. Vector4.prototype.multiplyInPlace = function (otherVector) {
  73039. this.x *= otherVector.x;
  73040. this.y *= otherVector.y;
  73041. this.z *= otherVector.z;
  73042. this.w *= otherVector.w;
  73043. return this;
  73044. };
  73045. /**
  73046. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73047. * @param otherVector vector to multiple with
  73048. * @returns resulting new vector
  73049. */
  73050. Vector4.prototype.multiply = function (otherVector) {
  73051. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  73052. };
  73053. /**
  73054. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73055. * @param otherVector vector to multiple with
  73056. * @param result vector to store the result
  73057. * @returns the current Vector4.
  73058. */
  73059. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  73060. result.x = this.x * otherVector.x;
  73061. result.y = this.y * otherVector.y;
  73062. result.z = this.z * otherVector.z;
  73063. result.w = this.w * otherVector.w;
  73064. return this;
  73065. };
  73066. /**
  73067. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73068. * @param x x value multiply with
  73069. * @param y y value multiply with
  73070. * @param z z value multiply with
  73071. * @param w w value multiply with
  73072. * @returns resulting new vector
  73073. */
  73074. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  73075. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  73076. };
  73077. /**
  73078. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73079. * @param otherVector vector to devide with
  73080. * @returns resulting new vector
  73081. */
  73082. Vector4.prototype.divide = function (otherVector) {
  73083. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  73084. };
  73085. /**
  73086. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73087. * @param otherVector vector to devide with
  73088. * @param result vector to store the result
  73089. * @returns the current Vector4.
  73090. */
  73091. Vector4.prototype.divideToRef = function (otherVector, result) {
  73092. result.x = this.x / otherVector.x;
  73093. result.y = this.y / otherVector.y;
  73094. result.z = this.z / otherVector.z;
  73095. result.w = this.w / otherVector.w;
  73096. return this;
  73097. };
  73098. /**
  73099. * Divides the current Vector3 coordinates by the given ones.
  73100. * @param otherVector vector to devide with
  73101. * @returns the updated Vector3.
  73102. */
  73103. Vector4.prototype.divideInPlace = function (otherVector) {
  73104. return this.divideToRef(otherVector, this);
  73105. };
  73106. /**
  73107. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73108. * @param other defines the second operand
  73109. * @returns the current updated Vector4
  73110. */
  73111. Vector4.prototype.minimizeInPlace = function (other) {
  73112. if (other.x < this.x) {
  73113. this.x = other.x;
  73114. }
  73115. if (other.y < this.y) {
  73116. this.y = other.y;
  73117. }
  73118. if (other.z < this.z) {
  73119. this.z = other.z;
  73120. }
  73121. if (other.w < this.w) {
  73122. this.w = other.w;
  73123. }
  73124. return this;
  73125. };
  73126. /**
  73127. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73128. * @param other defines the second operand
  73129. * @returns the current updated Vector4
  73130. */
  73131. Vector4.prototype.maximizeInPlace = function (other) {
  73132. if (other.x > this.x) {
  73133. this.x = other.x;
  73134. }
  73135. if (other.y > this.y) {
  73136. this.y = other.y;
  73137. }
  73138. if (other.z > this.z) {
  73139. this.z = other.z;
  73140. }
  73141. if (other.w > this.w) {
  73142. this.w = other.w;
  73143. }
  73144. return this;
  73145. };
  73146. /**
  73147. * Gets a new Vector4 from current Vector4 floored values
  73148. * @returns a new Vector4
  73149. */
  73150. Vector4.prototype.floor = function () {
  73151. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  73152. };
  73153. /**
  73154. * Gets a new Vector4 from current Vector3 floored values
  73155. * @returns a new Vector4
  73156. */
  73157. Vector4.prototype.fract = function () {
  73158. 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));
  73159. };
  73160. // Properties
  73161. /**
  73162. * Returns the Vector4 length (float).
  73163. * @returns the length
  73164. */
  73165. Vector4.prototype.length = function () {
  73166. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  73167. };
  73168. /**
  73169. * Returns the Vector4 squared length (float).
  73170. * @returns the length squared
  73171. */
  73172. Vector4.prototype.lengthSquared = function () {
  73173. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  73174. };
  73175. // Methods
  73176. /**
  73177. * Normalizes in place the Vector4.
  73178. * @returns the updated Vector4.
  73179. */
  73180. Vector4.prototype.normalize = function () {
  73181. var len = this.length();
  73182. if (len === 0) {
  73183. return this;
  73184. }
  73185. return this.scaleInPlace(1.0 / len);
  73186. };
  73187. /**
  73188. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73189. * @returns this converted to a new vector3
  73190. */
  73191. Vector4.prototype.toVector3 = function () {
  73192. return new Vector3(this.x, this.y, this.z);
  73193. };
  73194. /**
  73195. * Returns a new Vector4 copied from the current one.
  73196. * @returns the new cloned vector
  73197. */
  73198. Vector4.prototype.clone = function () {
  73199. return new Vector4(this.x, this.y, this.z, this.w);
  73200. };
  73201. /**
  73202. * Updates the current Vector4 with the given one coordinates.
  73203. * @param source the source vector to copy from
  73204. * @returns the updated Vector4.
  73205. */
  73206. Vector4.prototype.copyFrom = function (source) {
  73207. this.x = source.x;
  73208. this.y = source.y;
  73209. this.z = source.z;
  73210. this.w = source.w;
  73211. return this;
  73212. };
  73213. /**
  73214. * Updates the current Vector4 coordinates with the given floats.
  73215. * @param x float to copy from
  73216. * @param y float to copy from
  73217. * @param z float to copy from
  73218. * @param w float to copy from
  73219. * @returns the updated Vector4.
  73220. */
  73221. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  73222. this.x = x;
  73223. this.y = y;
  73224. this.z = z;
  73225. this.w = w;
  73226. return this;
  73227. };
  73228. /**
  73229. * Updates the current Vector4 coordinates with the given floats.
  73230. * @param x float to set from
  73231. * @param y float to set from
  73232. * @param z float to set from
  73233. * @param w float to set from
  73234. * @returns the updated Vector4.
  73235. */
  73236. Vector4.prototype.set = function (x, y, z, w) {
  73237. return this.copyFromFloats(x, y, z, w);
  73238. };
  73239. /**
  73240. * Copies the given float to the current Vector3 coordinates
  73241. * @param v defines the x, y, z and w coordinates of the operand
  73242. * @returns the current updated Vector3
  73243. */
  73244. Vector4.prototype.setAll = function (v) {
  73245. this.x = this.y = this.z = this.w = v;
  73246. return this;
  73247. };
  73248. // Statics
  73249. /**
  73250. * Returns a new Vector4 set from the starting index of the given array.
  73251. * @param array the array to pull values from
  73252. * @param offset the offset into the array to start at
  73253. * @returns the new vector
  73254. */
  73255. Vector4.FromArray = function (array, offset) {
  73256. if (!offset) {
  73257. offset = 0;
  73258. }
  73259. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  73260. };
  73261. /**
  73262. * Updates the given vector "result" from the starting index of the given array.
  73263. * @param array the array to pull values from
  73264. * @param offset the offset into the array to start at
  73265. * @param result the vector to store the result in
  73266. */
  73267. Vector4.FromArrayToRef = function (array, offset, result) {
  73268. result.x = array[offset];
  73269. result.y = array[offset + 1];
  73270. result.z = array[offset + 2];
  73271. result.w = array[offset + 3];
  73272. };
  73273. /**
  73274. * Updates the given vector "result" from the starting index of the given Float32Array.
  73275. * @param array the array to pull values from
  73276. * @param offset the offset into the array to start at
  73277. * @param result the vector to store the result in
  73278. */
  73279. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  73280. Vector4.FromArrayToRef(array, offset, result);
  73281. };
  73282. /**
  73283. * Updates the given vector "result" coordinates from the given floats.
  73284. * @param x float to set from
  73285. * @param y float to set from
  73286. * @param z float to set from
  73287. * @param w float to set from
  73288. * @param result the vector to the floats in
  73289. */
  73290. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  73291. result.x = x;
  73292. result.y = y;
  73293. result.z = z;
  73294. result.w = w;
  73295. };
  73296. /**
  73297. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  73298. * @returns the new vector
  73299. */
  73300. Vector4.Zero = function () {
  73301. return new Vector4(0.0, 0.0, 0.0, 0.0);
  73302. };
  73303. /**
  73304. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  73305. * @returns the new vector
  73306. */
  73307. Vector4.One = function () {
  73308. return new Vector4(1.0, 1.0, 1.0, 1.0);
  73309. };
  73310. /**
  73311. * Returns a new normalized Vector4 from the given one.
  73312. * @param vector the vector to normalize
  73313. * @returns the vector
  73314. */
  73315. Vector4.Normalize = function (vector) {
  73316. var result = Vector4.Zero();
  73317. Vector4.NormalizeToRef(vector, result);
  73318. return result;
  73319. };
  73320. /**
  73321. * Updates the given vector "result" from the normalization of the given one.
  73322. * @param vector the vector to normalize
  73323. * @param result the vector to store the result in
  73324. */
  73325. Vector4.NormalizeToRef = function (vector, result) {
  73326. result.copyFrom(vector);
  73327. result.normalize();
  73328. };
  73329. /**
  73330. * Returns a vector with the minimum values from the left and right vectors
  73331. * @param left left vector to minimize
  73332. * @param right right vector to minimize
  73333. * @returns a new vector with the minimum of the left and right vector values
  73334. */
  73335. Vector4.Minimize = function (left, right) {
  73336. var min = left.clone();
  73337. min.minimizeInPlace(right);
  73338. return min;
  73339. };
  73340. /**
  73341. * Returns a vector with the maximum values from the left and right vectors
  73342. * @param left left vector to maximize
  73343. * @param right right vector to maximize
  73344. * @returns a new vector with the maximum of the left and right vector values
  73345. */
  73346. Vector4.Maximize = function (left, right) {
  73347. var max = left.clone();
  73348. max.maximizeInPlace(right);
  73349. return max;
  73350. };
  73351. /**
  73352. * Returns the distance (float) between the vectors "value1" and "value2".
  73353. * @param value1 value to calulate the distance between
  73354. * @param value2 value to calulate the distance between
  73355. * @return the distance between the two vectors
  73356. */
  73357. Vector4.Distance = function (value1, value2) {
  73358. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  73359. };
  73360. /**
  73361. * Returns the squared distance (float) between the vectors "value1" and "value2".
  73362. * @param value1 value to calulate the distance between
  73363. * @param value2 value to calulate the distance between
  73364. * @return the distance between the two vectors squared
  73365. */
  73366. Vector4.DistanceSquared = function (value1, value2) {
  73367. var x = value1.x - value2.x;
  73368. var y = value1.y - value2.y;
  73369. var z = value1.z - value2.z;
  73370. var w = value1.w - value2.w;
  73371. return (x * x) + (y * y) + (z * z) + (w * w);
  73372. };
  73373. /**
  73374. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  73375. * @param value1 value to calulate the center between
  73376. * @param value2 value to calulate the center between
  73377. * @return the center between the two vectors
  73378. */
  73379. Vector4.Center = function (value1, value2) {
  73380. var center = value1.add(value2);
  73381. center.scaleInPlace(0.5);
  73382. return center;
  73383. };
  73384. /**
  73385. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  73386. * This methods computes transformed normalized direction vectors only.
  73387. * @param vector the vector to transform
  73388. * @param transformation the transformation matrix to apply
  73389. * @returns the new vector
  73390. */
  73391. Vector4.TransformNormal = function (vector, transformation) {
  73392. var result = Vector4.Zero();
  73393. Vector4.TransformNormalToRef(vector, transformation, result);
  73394. return result;
  73395. };
  73396. /**
  73397. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  73398. * This methods computes transformed normalized direction vectors only.
  73399. * @param vector the vector to transform
  73400. * @param transformation the transformation matrix to apply
  73401. * @param result the vector to store the result in
  73402. */
  73403. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  73404. var m = transformation.m;
  73405. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  73406. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  73407. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  73408. result.x = x;
  73409. result.y = y;
  73410. result.z = z;
  73411. result.w = vector.w;
  73412. };
  73413. /**
  73414. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  73415. * This methods computes transformed normalized direction vectors only.
  73416. * @param x value to transform
  73417. * @param y value to transform
  73418. * @param z value to transform
  73419. * @param w value to transform
  73420. * @param transformation the transformation matrix to apply
  73421. * @param result the vector to store the results in
  73422. */
  73423. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  73424. var m = transformation.m;
  73425. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  73426. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  73427. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  73428. result.w = w;
  73429. };
  73430. /**
  73431. * Creates a new Vector4 from a Vector3
  73432. * @param source defines the source data
  73433. * @param w defines the 4th component (default is 0)
  73434. * @returns a new Vector4
  73435. */
  73436. Vector4.FromVector3 = function (source, w) {
  73437. if (w === void 0) { w = 0; }
  73438. return new Vector4(source.x, source.y, source.z, w);
  73439. };
  73440. return Vector4;
  73441. }());
  73442. /**
  73443. * Size containing widht and height
  73444. */
  73445. var Size = /** @class */ (function () {
  73446. /**
  73447. * Creates a Size object from the given width and height (floats).
  73448. * @param width width of the new size
  73449. * @param height height of the new size
  73450. */
  73451. function Size(width, height) {
  73452. this.width = width;
  73453. this.height = height;
  73454. }
  73455. /**
  73456. * Returns a string with the Size width and height
  73457. * @returns a string with the Size width and height
  73458. */
  73459. Size.prototype.toString = function () {
  73460. return "{W: " + this.width + ", H: " + this.height + "}";
  73461. };
  73462. /**
  73463. * "Size"
  73464. * @returns the string "Size"
  73465. */
  73466. Size.prototype.getClassName = function () {
  73467. return "Size";
  73468. };
  73469. /**
  73470. * Returns the Size hash code.
  73471. * @returns a hash code for a unique width and height
  73472. */
  73473. Size.prototype.getHashCode = function () {
  73474. var hash = this.width || 0;
  73475. hash = (hash * 397) ^ (this.height || 0);
  73476. return hash;
  73477. };
  73478. /**
  73479. * Updates the current size from the given one.
  73480. * @param src the given size
  73481. */
  73482. Size.prototype.copyFrom = function (src) {
  73483. this.width = src.width;
  73484. this.height = src.height;
  73485. };
  73486. /**
  73487. * Updates in place the current Size from the given floats.
  73488. * @param width width of the new size
  73489. * @param height height of the new size
  73490. * @returns the updated Size.
  73491. */
  73492. Size.prototype.copyFromFloats = function (width, height) {
  73493. this.width = width;
  73494. this.height = height;
  73495. return this;
  73496. };
  73497. /**
  73498. * Updates in place the current Size from the given floats.
  73499. * @param width width to set
  73500. * @param height height to set
  73501. * @returns the updated Size.
  73502. */
  73503. Size.prototype.set = function (width, height) {
  73504. return this.copyFromFloats(width, height);
  73505. };
  73506. /**
  73507. * Multiplies the width and height by numbers
  73508. * @param w factor to multiple the width by
  73509. * @param h factor to multiple the height by
  73510. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  73511. */
  73512. Size.prototype.multiplyByFloats = function (w, h) {
  73513. return new Size(this.width * w, this.height * h);
  73514. };
  73515. /**
  73516. * Clones the size
  73517. * @returns a new Size copied from the given one.
  73518. */
  73519. Size.prototype.clone = function () {
  73520. return new Size(this.width, this.height);
  73521. };
  73522. /**
  73523. * True if the current Size and the given one width and height are strictly equal.
  73524. * @param other the other size to compare against
  73525. * @returns True if the current Size and the given one width and height are strictly equal.
  73526. */
  73527. Size.prototype.equals = function (other) {
  73528. if (!other) {
  73529. return false;
  73530. }
  73531. return (this.width === other.width) && (this.height === other.height);
  73532. };
  73533. Object.defineProperty(Size.prototype, "surface", {
  73534. /**
  73535. * The surface of the Size : width * height (float).
  73536. */
  73537. get: function () {
  73538. return this.width * this.height;
  73539. },
  73540. enumerable: true,
  73541. configurable: true
  73542. });
  73543. /**
  73544. * Create a new size of zero
  73545. * @returns a new Size set to (0.0, 0.0)
  73546. */
  73547. Size.Zero = function () {
  73548. return new Size(0.0, 0.0);
  73549. };
  73550. /**
  73551. * Sums the width and height of two sizes
  73552. * @param otherSize size to add to this size
  73553. * @returns a new Size set as the addition result of the current Size and the given one.
  73554. */
  73555. Size.prototype.add = function (otherSize) {
  73556. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  73557. return r;
  73558. };
  73559. /**
  73560. * Subtracts the width and height of two
  73561. * @param otherSize size to subtract to this size
  73562. * @returns a new Size set as the subtraction result of the given one from the current Size.
  73563. */
  73564. Size.prototype.subtract = function (otherSize) {
  73565. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  73566. return r;
  73567. };
  73568. /**
  73569. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  73570. * @param start starting size to lerp between
  73571. * @param end end size to lerp between
  73572. * @param amount amount to lerp between the start and end values
  73573. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  73574. */
  73575. Size.Lerp = function (start, end, amount) {
  73576. var w = start.width + ((end.width - start.width) * amount);
  73577. var h = start.height + ((end.height - start.height) * amount);
  73578. return new Size(w, h);
  73579. };
  73580. return Size;
  73581. }());
  73582. /**
  73583. * Class used to store quaternion data
  73584. * @see https://en.wikipedia.org/wiki/Quaternion
  73585. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  73586. */
  73587. var Quaternion = /** @class */ (function () {
  73588. /**
  73589. * Creates a new Quaternion from the given floats
  73590. * @param x defines the first component (0 by default)
  73591. * @param y defines the second component (0 by default)
  73592. * @param z defines the third component (0 by default)
  73593. * @param w defines the fourth component (1.0 by default)
  73594. */
  73595. function Quaternion(
  73596. /** defines the first component (0 by default) */
  73597. x,
  73598. /** defines the second component (0 by default) */
  73599. y,
  73600. /** defines the third component (0 by default) */
  73601. z,
  73602. /** defines the fourth component (1.0 by default) */
  73603. w) {
  73604. if (x === void 0) { x = 0.0; }
  73605. if (y === void 0) { y = 0.0; }
  73606. if (z === void 0) { z = 0.0; }
  73607. if (w === void 0) { w = 1.0; }
  73608. this.x = x;
  73609. this.y = y;
  73610. this.z = z;
  73611. this.w = w;
  73612. }
  73613. /**
  73614. * Gets a string representation for the current quaternion
  73615. * @returns a string with the Quaternion coordinates
  73616. */
  73617. Quaternion.prototype.toString = function () {
  73618. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  73619. };
  73620. /**
  73621. * Gets the class name of the quaternion
  73622. * @returns the string "Quaternion"
  73623. */
  73624. Quaternion.prototype.getClassName = function () {
  73625. return "Quaternion";
  73626. };
  73627. /**
  73628. * Gets a hash code for this quaternion
  73629. * @returns the quaternion hash code
  73630. */
  73631. Quaternion.prototype.getHashCode = function () {
  73632. var hash = this.x || 0;
  73633. hash = (hash * 397) ^ (this.y || 0);
  73634. hash = (hash * 397) ^ (this.z || 0);
  73635. hash = (hash * 397) ^ (this.w || 0);
  73636. return hash;
  73637. };
  73638. /**
  73639. * Copy the quaternion to an array
  73640. * @returns a new array populated with 4 elements from the quaternion coordinates
  73641. */
  73642. Quaternion.prototype.asArray = function () {
  73643. return [this.x, this.y, this.z, this.w];
  73644. };
  73645. /**
  73646. * Check if two quaternions are equals
  73647. * @param otherQuaternion defines the second operand
  73648. * @return true if the current quaternion and the given one coordinates are strictly equals
  73649. */
  73650. Quaternion.prototype.equals = function (otherQuaternion) {
  73651. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  73652. };
  73653. /**
  73654. * Clone the current quaternion
  73655. * @returns a new quaternion copied from the current one
  73656. */
  73657. Quaternion.prototype.clone = function () {
  73658. return new Quaternion(this.x, this.y, this.z, this.w);
  73659. };
  73660. /**
  73661. * Copy a quaternion to the current one
  73662. * @param other defines the other quaternion
  73663. * @returns the updated current quaternion
  73664. */
  73665. Quaternion.prototype.copyFrom = function (other) {
  73666. this.x = other.x;
  73667. this.y = other.y;
  73668. this.z = other.z;
  73669. this.w = other.w;
  73670. return this;
  73671. };
  73672. /**
  73673. * Updates the current quaternion with the given float coordinates
  73674. * @param x defines the x coordinate
  73675. * @param y defines the y coordinate
  73676. * @param z defines the z coordinate
  73677. * @param w defines the w coordinate
  73678. * @returns the updated current quaternion
  73679. */
  73680. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  73681. this.x = x;
  73682. this.y = y;
  73683. this.z = z;
  73684. this.w = w;
  73685. return this;
  73686. };
  73687. /**
  73688. * Updates the current quaternion from the given float coordinates
  73689. * @param x defines the x coordinate
  73690. * @param y defines the y coordinate
  73691. * @param z defines the z coordinate
  73692. * @param w defines the w coordinate
  73693. * @returns the updated current quaternion
  73694. */
  73695. Quaternion.prototype.set = function (x, y, z, w) {
  73696. return this.copyFromFloats(x, y, z, w);
  73697. };
  73698. /**
  73699. * Adds two quaternions
  73700. * @param other defines the second operand
  73701. * @returns a new quaternion as the addition result of the given one and the current quaternion
  73702. */
  73703. Quaternion.prototype.add = function (other) {
  73704. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  73705. };
  73706. /**
  73707. * Add a quaternion to the current one
  73708. * @param other defines the quaternion to add
  73709. * @returns the current quaternion
  73710. */
  73711. Quaternion.prototype.addInPlace = function (other) {
  73712. this.x += other.x;
  73713. this.y += other.y;
  73714. this.z += other.z;
  73715. this.w += other.w;
  73716. return this;
  73717. };
  73718. /**
  73719. * Subtract two quaternions
  73720. * @param other defines the second operand
  73721. * @returns a new quaternion as the subtraction result of the given one from the current one
  73722. */
  73723. Quaternion.prototype.subtract = function (other) {
  73724. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  73725. };
  73726. /**
  73727. * Multiplies the current quaternion by a scale factor
  73728. * @param value defines the scale factor
  73729. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  73730. */
  73731. Quaternion.prototype.scale = function (value) {
  73732. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  73733. };
  73734. /**
  73735. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  73736. * @param scale defines the scale factor
  73737. * @param result defines the Quaternion object where to store the result
  73738. * @returns the unmodified current quaternion
  73739. */
  73740. Quaternion.prototype.scaleToRef = function (scale, result) {
  73741. result.x = this.x * scale;
  73742. result.y = this.y * scale;
  73743. result.z = this.z * scale;
  73744. result.w = this.w * scale;
  73745. return this;
  73746. };
  73747. /**
  73748. * Multiplies in place the current quaternion by a scale factor
  73749. * @param value defines the scale factor
  73750. * @returns the current modified quaternion
  73751. */
  73752. Quaternion.prototype.scaleInPlace = function (value) {
  73753. this.x *= value;
  73754. this.y *= value;
  73755. this.z *= value;
  73756. this.w *= value;
  73757. return this;
  73758. };
  73759. /**
  73760. * Scale the current quaternion values by a factor and add the result to a given quaternion
  73761. * @param scale defines the scale factor
  73762. * @param result defines the Quaternion object where to store the result
  73763. * @returns the unmodified current quaternion
  73764. */
  73765. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  73766. result.x += this.x * scale;
  73767. result.y += this.y * scale;
  73768. result.z += this.z * scale;
  73769. result.w += this.w * scale;
  73770. return this;
  73771. };
  73772. /**
  73773. * Multiplies two quaternions
  73774. * @param q1 defines the second operand
  73775. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  73776. */
  73777. Quaternion.prototype.multiply = function (q1) {
  73778. var result = new Quaternion(0, 0, 0, 1.0);
  73779. this.multiplyToRef(q1, result);
  73780. return result;
  73781. };
  73782. /**
  73783. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  73784. * @param q1 defines the second operand
  73785. * @param result defines the target quaternion
  73786. * @returns the current quaternion
  73787. */
  73788. Quaternion.prototype.multiplyToRef = function (q1, result) {
  73789. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  73790. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  73791. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  73792. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  73793. result.copyFromFloats(x, y, z, w);
  73794. return this;
  73795. };
  73796. /**
  73797. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  73798. * @param q1 defines the second operand
  73799. * @returns the currentupdated quaternion
  73800. */
  73801. Quaternion.prototype.multiplyInPlace = function (q1) {
  73802. this.multiplyToRef(q1, this);
  73803. return this;
  73804. };
  73805. /**
  73806. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  73807. * @param ref defines the target quaternion
  73808. * @returns the current quaternion
  73809. */
  73810. Quaternion.prototype.conjugateToRef = function (ref) {
  73811. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  73812. return this;
  73813. };
  73814. /**
  73815. * Conjugates in place (1-q) the current quaternion
  73816. * @returns the current updated quaternion
  73817. */
  73818. Quaternion.prototype.conjugateInPlace = function () {
  73819. this.x *= -1;
  73820. this.y *= -1;
  73821. this.z *= -1;
  73822. return this;
  73823. };
  73824. /**
  73825. * Conjugates in place (1-q) the current quaternion
  73826. * @returns a new quaternion
  73827. */
  73828. Quaternion.prototype.conjugate = function () {
  73829. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  73830. return result;
  73831. };
  73832. /**
  73833. * Gets length of current quaternion
  73834. * @returns the quaternion length (float)
  73835. */
  73836. Quaternion.prototype.length = function () {
  73837. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  73838. };
  73839. /**
  73840. * Normalize in place the current quaternion
  73841. * @returns the current updated quaternion
  73842. */
  73843. Quaternion.prototype.normalize = function () {
  73844. var len = this.length();
  73845. if (len === 0) {
  73846. return this;
  73847. }
  73848. var inv = 1.0 / len;
  73849. this.x *= inv;
  73850. this.y *= inv;
  73851. this.z *= inv;
  73852. this.w *= inv;
  73853. return this;
  73854. };
  73855. /**
  73856. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  73857. * @param order is a reserved parameter and is ignore for now
  73858. * @returns a new Vector3 containing the Euler angles
  73859. */
  73860. Quaternion.prototype.toEulerAngles = function (order) {
  73861. if (order === void 0) { order = "YZX"; }
  73862. var result = Vector3.Zero();
  73863. this.toEulerAnglesToRef(result);
  73864. return result;
  73865. };
  73866. /**
  73867. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  73868. * @param result defines the vector which will be filled with the Euler angles
  73869. * @param order is a reserved parameter and is ignore for now
  73870. * @returns the current unchanged quaternion
  73871. */
  73872. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  73873. var qz = this.z;
  73874. var qx = this.x;
  73875. var qy = this.y;
  73876. var qw = this.w;
  73877. var sqw = qw * qw;
  73878. var sqz = qz * qz;
  73879. var sqx = qx * qx;
  73880. var sqy = qy * qy;
  73881. var zAxisY = qy * qz - qx * qw;
  73882. var limit = .4999999;
  73883. if (zAxisY < -limit) {
  73884. result.y = 2 * Math.atan2(qy, qw);
  73885. result.x = Math.PI / 2;
  73886. result.z = 0;
  73887. }
  73888. else if (zAxisY > limit) {
  73889. result.y = 2 * Math.atan2(qy, qw);
  73890. result.x = -Math.PI / 2;
  73891. result.z = 0;
  73892. }
  73893. else {
  73894. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  73895. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  73896. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  73897. }
  73898. return this;
  73899. };
  73900. /**
  73901. * Updates the given rotation matrix with the current quaternion values
  73902. * @param result defines the target matrix
  73903. * @returns the current unchanged quaternion
  73904. */
  73905. Quaternion.prototype.toRotationMatrix = function (result) {
  73906. Matrix.FromQuaternionToRef(this, result);
  73907. return this;
  73908. };
  73909. /**
  73910. * Updates the current quaternion from the given rotation matrix values
  73911. * @param matrix defines the source matrix
  73912. * @returns the current updated quaternion
  73913. */
  73914. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  73915. Quaternion.FromRotationMatrixToRef(matrix, this);
  73916. return this;
  73917. };
  73918. // Statics
  73919. /**
  73920. * Creates a new quaternion from a rotation matrix
  73921. * @param matrix defines the source matrix
  73922. * @returns a new quaternion created from the given rotation matrix values
  73923. */
  73924. Quaternion.FromRotationMatrix = function (matrix) {
  73925. var result = new Quaternion();
  73926. Quaternion.FromRotationMatrixToRef(matrix, result);
  73927. return result;
  73928. };
  73929. /**
  73930. * Updates the given quaternion with the given rotation matrix values
  73931. * @param matrix defines the source matrix
  73932. * @param result defines the target quaternion
  73933. */
  73934. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  73935. var data = matrix.m;
  73936. var m11 = data[0], m12 = data[4], m13 = data[8];
  73937. var m21 = data[1], m22 = data[5], m23 = data[9];
  73938. var m31 = data[2], m32 = data[6], m33 = data[10];
  73939. var trace = m11 + m22 + m33;
  73940. var s;
  73941. if (trace > 0) {
  73942. s = 0.5 / Math.sqrt(trace + 1.0);
  73943. result.w = 0.25 / s;
  73944. result.x = (m32 - m23) * s;
  73945. result.y = (m13 - m31) * s;
  73946. result.z = (m21 - m12) * s;
  73947. }
  73948. else if (m11 > m22 && m11 > m33) {
  73949. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  73950. result.w = (m32 - m23) / s;
  73951. result.x = 0.25 * s;
  73952. result.y = (m12 + m21) / s;
  73953. result.z = (m13 + m31) / s;
  73954. }
  73955. else if (m22 > m33) {
  73956. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  73957. result.w = (m13 - m31) / s;
  73958. result.x = (m12 + m21) / s;
  73959. result.y = 0.25 * s;
  73960. result.z = (m23 + m32) / s;
  73961. }
  73962. else {
  73963. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  73964. result.w = (m21 - m12) / s;
  73965. result.x = (m13 + m31) / s;
  73966. result.y = (m23 + m32) / s;
  73967. result.z = 0.25 * s;
  73968. }
  73969. };
  73970. /**
  73971. * Returns the dot product (float) between the quaternions "left" and "right"
  73972. * @param left defines the left operand
  73973. * @param right defines the right operand
  73974. * @returns the dot product
  73975. */
  73976. Quaternion.Dot = function (left, right) {
  73977. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  73978. };
  73979. /**
  73980. * Checks if the two quaternions are close to each other
  73981. * @param quat0 defines the first quaternion to check
  73982. * @param quat1 defines the second quaternion to check
  73983. * @returns true if the two quaternions are close to each other
  73984. */
  73985. Quaternion.AreClose = function (quat0, quat1) {
  73986. var dot = Quaternion.Dot(quat0, quat1);
  73987. return dot >= 0;
  73988. };
  73989. /**
  73990. * Creates an empty quaternion
  73991. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  73992. */
  73993. Quaternion.Zero = function () {
  73994. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  73995. };
  73996. /**
  73997. * Inverse a given quaternion
  73998. * @param q defines the source quaternion
  73999. * @returns a new quaternion as the inverted current quaternion
  74000. */
  74001. Quaternion.Inverse = function (q) {
  74002. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  74003. };
  74004. /**
  74005. * Inverse a given quaternion
  74006. * @param q defines the source quaternion
  74007. * @param result the quaternion the result will be stored in
  74008. * @returns the result quaternion
  74009. */
  74010. Quaternion.InverseToRef = function (q, result) {
  74011. result.set(-q.x, -q.y, -q.z, q.w);
  74012. return result;
  74013. };
  74014. /**
  74015. * Creates an identity quaternion
  74016. * @returns the identity quaternion
  74017. */
  74018. Quaternion.Identity = function () {
  74019. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  74020. };
  74021. /**
  74022. * Gets a boolean indicating if the given quaternion is identity
  74023. * @param quaternion defines the quaternion to check
  74024. * @returns true if the quaternion is identity
  74025. */
  74026. Quaternion.IsIdentity = function (quaternion) {
  74027. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  74028. };
  74029. /**
  74030. * Creates a quaternion from a rotation around an axis
  74031. * @param axis defines the axis to use
  74032. * @param angle defines the angle to use
  74033. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74034. */
  74035. Quaternion.RotationAxis = function (axis, angle) {
  74036. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  74037. };
  74038. /**
  74039. * Creates a rotation around an axis and stores it into the given quaternion
  74040. * @param axis defines the axis to use
  74041. * @param angle defines the angle to use
  74042. * @param result defines the target quaternion
  74043. * @returns the target quaternion
  74044. */
  74045. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  74046. var sin = Math.sin(angle / 2);
  74047. axis.normalize();
  74048. result.w = Math.cos(angle / 2);
  74049. result.x = axis.x * sin;
  74050. result.y = axis.y * sin;
  74051. result.z = axis.z * sin;
  74052. return result;
  74053. };
  74054. /**
  74055. * Creates a new quaternion from data stored into an array
  74056. * @param array defines the data source
  74057. * @param offset defines the offset in the source array where the data starts
  74058. * @returns a new quaternion
  74059. */
  74060. Quaternion.FromArray = function (array, offset) {
  74061. if (!offset) {
  74062. offset = 0;
  74063. }
  74064. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  74065. };
  74066. /**
  74067. * Create a quaternion from Euler rotation angles
  74068. * @param x Pitch
  74069. * @param y Yaw
  74070. * @param z Roll
  74071. * @returns the new Quaternion
  74072. */
  74073. Quaternion.FromEulerAngles = function (x, y, z) {
  74074. var q = new Quaternion();
  74075. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  74076. return q;
  74077. };
  74078. /**
  74079. * Updates a quaternion from Euler rotation angles
  74080. * @param x Pitch
  74081. * @param y Yaw
  74082. * @param z Roll
  74083. * @param result the quaternion to store the result
  74084. * @returns the updated quaternion
  74085. */
  74086. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  74087. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  74088. return result;
  74089. };
  74090. /**
  74091. * Create a quaternion from Euler rotation vector
  74092. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74093. * @returns the new Quaternion
  74094. */
  74095. Quaternion.FromEulerVector = function (vec) {
  74096. var q = new Quaternion();
  74097. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  74098. return q;
  74099. };
  74100. /**
  74101. * Updates a quaternion from Euler rotation vector
  74102. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74103. * @param result the quaternion to store the result
  74104. * @returns the updated quaternion
  74105. */
  74106. Quaternion.FromEulerVectorToRef = function (vec, result) {
  74107. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  74108. return result;
  74109. };
  74110. /**
  74111. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74112. * @param yaw defines the rotation around Y axis
  74113. * @param pitch defines the rotation around X axis
  74114. * @param roll defines the rotation around Z axis
  74115. * @returns the new quaternion
  74116. */
  74117. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  74118. var q = new Quaternion();
  74119. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  74120. return q;
  74121. };
  74122. /**
  74123. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74124. * @param yaw defines the rotation around Y axis
  74125. * @param pitch defines the rotation around X axis
  74126. * @param roll defines the rotation around Z axis
  74127. * @param result defines the target quaternion
  74128. */
  74129. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  74130. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  74131. var halfRoll = roll * 0.5;
  74132. var halfPitch = pitch * 0.5;
  74133. var halfYaw = yaw * 0.5;
  74134. var sinRoll = Math.sin(halfRoll);
  74135. var cosRoll = Math.cos(halfRoll);
  74136. var sinPitch = Math.sin(halfPitch);
  74137. var cosPitch = Math.cos(halfPitch);
  74138. var sinYaw = Math.sin(halfYaw);
  74139. var cosYaw = Math.cos(halfYaw);
  74140. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  74141. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  74142. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  74143. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  74144. };
  74145. /**
  74146. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74147. * @param alpha defines the rotation around first axis
  74148. * @param beta defines the rotation around second axis
  74149. * @param gamma defines the rotation around third axis
  74150. * @returns the new quaternion
  74151. */
  74152. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  74153. var result = new Quaternion();
  74154. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  74155. return result;
  74156. };
  74157. /**
  74158. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74159. * @param alpha defines the rotation around first axis
  74160. * @param beta defines the rotation around second axis
  74161. * @param gamma defines the rotation around third axis
  74162. * @param result defines the target quaternion
  74163. */
  74164. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  74165. // Produces a quaternion from Euler angles in the z-x-z orientation
  74166. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  74167. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  74168. var halfBeta = beta * 0.5;
  74169. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  74170. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  74171. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  74172. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  74173. };
  74174. /**
  74175. * 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)
  74176. * @param axis1 defines the first axis
  74177. * @param axis2 defines the second axis
  74178. * @param axis3 defines the third axis
  74179. * @returns the new quaternion
  74180. */
  74181. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  74182. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  74183. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  74184. return quat;
  74185. };
  74186. /**
  74187. * 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
  74188. * @param axis1 defines the first axis
  74189. * @param axis2 defines the second axis
  74190. * @param axis3 defines the third axis
  74191. * @param ref defines the target quaternion
  74192. */
  74193. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  74194. var rotMat = MathTmp.Matrix[0];
  74195. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  74196. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  74197. };
  74198. /**
  74199. * Interpolates between two quaternions
  74200. * @param left defines first quaternion
  74201. * @param right defines second quaternion
  74202. * @param amount defines the gradient to use
  74203. * @returns the new interpolated quaternion
  74204. */
  74205. Quaternion.Slerp = function (left, right, amount) {
  74206. var result = Quaternion.Identity();
  74207. Quaternion.SlerpToRef(left, right, amount, result);
  74208. return result;
  74209. };
  74210. /**
  74211. * Interpolates between two quaternions and stores it into a target quaternion
  74212. * @param left defines first quaternion
  74213. * @param right defines second quaternion
  74214. * @param amount defines the gradient to use
  74215. * @param result defines the target quaternion
  74216. */
  74217. Quaternion.SlerpToRef = function (left, right, amount, result) {
  74218. var num2;
  74219. var num3;
  74220. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  74221. var flag = false;
  74222. if (num4 < 0) {
  74223. flag = true;
  74224. num4 = -num4;
  74225. }
  74226. if (num4 > 0.999999) {
  74227. num3 = 1 - amount;
  74228. num2 = flag ? -amount : amount;
  74229. }
  74230. else {
  74231. var num5 = Math.acos(num4);
  74232. var num6 = (1.0 / Math.sin(num5));
  74233. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  74234. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  74235. }
  74236. result.x = (num3 * left.x) + (num2 * right.x);
  74237. result.y = (num3 * left.y) + (num2 * right.y);
  74238. result.z = (num3 * left.z) + (num2 * right.z);
  74239. result.w = (num3 * left.w) + (num2 * right.w);
  74240. };
  74241. /**
  74242. * Interpolate between two quaternions using Hermite interpolation
  74243. * @param value1 defines first quaternion
  74244. * @param tangent1 defines the incoming tangent
  74245. * @param value2 defines second quaternion
  74246. * @param tangent2 defines the outgoing tangent
  74247. * @param amount defines the target quaternion
  74248. * @returns the new interpolated quaternion
  74249. */
  74250. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  74251. var squared = amount * amount;
  74252. var cubed = amount * squared;
  74253. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  74254. var part2 = (-2.0 * cubed) + (3.0 * squared);
  74255. var part3 = (cubed - (2.0 * squared)) + amount;
  74256. var part4 = cubed - squared;
  74257. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  74258. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  74259. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  74260. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  74261. return new Quaternion(x, y, z, w);
  74262. };
  74263. return Quaternion;
  74264. }());
  74265. /**
  74266. * Class used to store matrix data (4x4)
  74267. */
  74268. var Matrix = /** @class */ (function () {
  74269. /**
  74270. * Creates an empty matrix (filled with zeros)
  74271. */
  74272. function Matrix() {
  74273. this._isIdentity = false;
  74274. this._isIdentityDirty = true;
  74275. this._isIdentity3x2 = true;
  74276. this._isIdentity3x2Dirty = true;
  74277. this._m = new Float32Array(16);
  74278. this._updateIdentityStatus(false);
  74279. }
  74280. Object.defineProperty(Matrix.prototype, "m", {
  74281. /**
  74282. * Gets the internal data of the matrix
  74283. */
  74284. get: function () { return this._m; },
  74285. enumerable: true,
  74286. configurable: true
  74287. });
  74288. /** @hidden */
  74289. Matrix.prototype._markAsUpdated = function () {
  74290. this.updateFlag = Matrix._updateFlagSeed++;
  74291. this._isIdentity = false;
  74292. this._isIdentity3x2 = false;
  74293. this._isIdentityDirty = true;
  74294. this._isIdentity3x2Dirty = true;
  74295. };
  74296. /** @hidden */
  74297. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  74298. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  74299. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  74300. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  74301. this.updateFlag = Matrix._updateFlagSeed++;
  74302. this._isIdentity = isIdentity;
  74303. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  74304. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  74305. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  74306. };
  74307. // Properties
  74308. /**
  74309. * Check if the current matrix is identity
  74310. * @returns true is the matrix is the identity matrix
  74311. */
  74312. Matrix.prototype.isIdentity = function () {
  74313. if (this._isIdentityDirty) {
  74314. this._isIdentityDirty = false;
  74315. var m = this._m;
  74316. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  74317. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  74318. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  74319. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  74320. }
  74321. return this._isIdentity;
  74322. };
  74323. /**
  74324. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74325. * @returns true is the matrix is the identity matrix
  74326. */
  74327. Matrix.prototype.isIdentityAs3x2 = function () {
  74328. if (this._isIdentity3x2Dirty) {
  74329. this._isIdentity3x2Dirty = false;
  74330. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  74331. this._isIdentity3x2 = false;
  74332. }
  74333. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  74334. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  74335. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  74336. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  74337. this._isIdentity3x2 = false;
  74338. }
  74339. else {
  74340. this._isIdentity3x2 = true;
  74341. }
  74342. }
  74343. return this._isIdentity3x2;
  74344. };
  74345. /**
  74346. * Gets the determinant of the matrix
  74347. * @returns the matrix determinant
  74348. */
  74349. Matrix.prototype.determinant = function () {
  74350. if (this._isIdentity === true) {
  74351. return 1;
  74352. }
  74353. var m = this._m;
  74354. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  74355. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  74356. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  74357. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  74358. // https://en.wikipedia.org/wiki/Laplace_expansion
  74359. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  74360. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  74361. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  74362. // where
  74363. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  74364. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  74365. //
  74366. // Here we do that for the 1st row.
  74367. var det_22_33 = m22 * m33 - m32 * m23;
  74368. var det_21_33 = m21 * m33 - m31 * m23;
  74369. var det_21_32 = m21 * m32 - m31 * m22;
  74370. var det_20_33 = m20 * m33 - m30 * m23;
  74371. var det_20_32 = m20 * m32 - m22 * m30;
  74372. var det_20_31 = m20 * m31 - m30 * m21;
  74373. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  74374. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  74375. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  74376. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  74377. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  74378. };
  74379. // Methods
  74380. /**
  74381. * Returns the matrix as a Float32Array
  74382. * @returns the matrix underlying array
  74383. */
  74384. Matrix.prototype.toArray = function () {
  74385. return this._m;
  74386. };
  74387. /**
  74388. * Returns the matrix as a Float32Array
  74389. * @returns the matrix underlying array.
  74390. */
  74391. Matrix.prototype.asArray = function () {
  74392. return this._m;
  74393. };
  74394. /**
  74395. * Inverts the current matrix in place
  74396. * @returns the current inverted matrix
  74397. */
  74398. Matrix.prototype.invert = function () {
  74399. this.invertToRef(this);
  74400. return this;
  74401. };
  74402. /**
  74403. * Sets all the matrix elements to zero
  74404. * @returns the current matrix
  74405. */
  74406. Matrix.prototype.reset = function () {
  74407. 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);
  74408. this._updateIdentityStatus(false);
  74409. return this;
  74410. };
  74411. /**
  74412. * Adds the current matrix with a second one
  74413. * @param other defines the matrix to add
  74414. * @returns a new matrix as the addition of the current matrix and the given one
  74415. */
  74416. Matrix.prototype.add = function (other) {
  74417. var result = new Matrix();
  74418. this.addToRef(other, result);
  74419. return result;
  74420. };
  74421. /**
  74422. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74423. * @param other defines the matrix to add
  74424. * @param result defines the target matrix
  74425. * @returns the current matrix
  74426. */
  74427. Matrix.prototype.addToRef = function (other, result) {
  74428. var m = this._m;
  74429. var resultM = result._m;
  74430. var otherM = other.m;
  74431. for (var index = 0; index < 16; index++) {
  74432. resultM[index] = m[index] + otherM[index];
  74433. }
  74434. result._markAsUpdated();
  74435. return this;
  74436. };
  74437. /**
  74438. * Adds in place the given matrix to the current matrix
  74439. * @param other defines the second operand
  74440. * @returns the current updated matrix
  74441. */
  74442. Matrix.prototype.addToSelf = function (other) {
  74443. var m = this._m;
  74444. var otherM = other.m;
  74445. for (var index = 0; index < 16; index++) {
  74446. m[index] += otherM[index];
  74447. }
  74448. this._markAsUpdated();
  74449. return this;
  74450. };
  74451. /**
  74452. * Sets the given matrix to the current inverted Matrix
  74453. * @param other defines the target matrix
  74454. * @returns the unmodified current matrix
  74455. */
  74456. Matrix.prototype.invertToRef = function (other) {
  74457. if (this._isIdentity === true) {
  74458. Matrix.IdentityToRef(other);
  74459. return this;
  74460. }
  74461. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  74462. var m = this._m;
  74463. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  74464. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  74465. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  74466. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  74467. var det_22_33 = m22 * m33 - m32 * m23;
  74468. var det_21_33 = m21 * m33 - m31 * m23;
  74469. var det_21_32 = m21 * m32 - m31 * m22;
  74470. var det_20_33 = m20 * m33 - m30 * m23;
  74471. var det_20_32 = m20 * m32 - m22 * m30;
  74472. var det_20_31 = m20 * m31 - m30 * m21;
  74473. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  74474. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  74475. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  74476. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  74477. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  74478. if (det === 0) {
  74479. // not invertible
  74480. other.copyFrom(this);
  74481. return this;
  74482. }
  74483. var detInv = 1 / det;
  74484. var det_12_33 = m12 * m33 - m32 * m13;
  74485. var det_11_33 = m11 * m33 - m31 * m13;
  74486. var det_11_32 = m11 * m32 - m31 * m12;
  74487. var det_10_33 = m10 * m33 - m30 * m13;
  74488. var det_10_32 = m10 * m32 - m30 * m12;
  74489. var det_10_31 = m10 * m31 - m30 * m11;
  74490. var det_12_23 = m12 * m23 - m22 * m13;
  74491. var det_11_23 = m11 * m23 - m21 * m13;
  74492. var det_11_22 = m11 * m22 - m21 * m12;
  74493. var det_10_23 = m10 * m23 - m20 * m13;
  74494. var det_10_22 = m10 * m22 - m20 * m12;
  74495. var det_10_21 = m10 * m21 - m20 * m11;
  74496. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  74497. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  74498. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  74499. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  74500. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  74501. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  74502. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  74503. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  74504. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  74505. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  74506. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  74507. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  74508. 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);
  74509. return this;
  74510. };
  74511. /**
  74512. * add a value at the specified position in the current Matrix
  74513. * @param index the index of the value within the matrix. between 0 and 15.
  74514. * @param value the value to be added
  74515. * @returns the current updated matrix
  74516. */
  74517. Matrix.prototype.addAtIndex = function (index, value) {
  74518. this._m[index] += value;
  74519. this._markAsUpdated();
  74520. return this;
  74521. };
  74522. /**
  74523. * mutiply the specified position in the current Matrix by a value
  74524. * @param index the index of the value within the matrix. between 0 and 15.
  74525. * @param value the value to be added
  74526. * @returns the current updated matrix
  74527. */
  74528. Matrix.prototype.multiplyAtIndex = function (index, value) {
  74529. this._m[index] *= value;
  74530. this._markAsUpdated();
  74531. return this;
  74532. };
  74533. /**
  74534. * Inserts the translation vector (using 3 floats) in the current matrix
  74535. * @param x defines the 1st component of the translation
  74536. * @param y defines the 2nd component of the translation
  74537. * @param z defines the 3rd component of the translation
  74538. * @returns the current updated matrix
  74539. */
  74540. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  74541. this._m[12] = x;
  74542. this._m[13] = y;
  74543. this._m[14] = z;
  74544. this._markAsUpdated();
  74545. return this;
  74546. };
  74547. /**
  74548. * Inserts the translation vector in the current matrix
  74549. * @param vector3 defines the translation to insert
  74550. * @returns the current updated matrix
  74551. */
  74552. Matrix.prototype.setTranslation = function (vector3) {
  74553. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  74554. };
  74555. /**
  74556. * Gets the translation value of the current matrix
  74557. * @returns a new Vector3 as the extracted translation from the matrix
  74558. */
  74559. Matrix.prototype.getTranslation = function () {
  74560. return new Vector3(this._m[12], this._m[13], this._m[14]);
  74561. };
  74562. /**
  74563. * Fill a Vector3 with the extracted translation from the matrix
  74564. * @param result defines the Vector3 where to store the translation
  74565. * @returns the current matrix
  74566. */
  74567. Matrix.prototype.getTranslationToRef = function (result) {
  74568. result.x = this._m[12];
  74569. result.y = this._m[13];
  74570. result.z = this._m[14];
  74571. return this;
  74572. };
  74573. /**
  74574. * Remove rotation and scaling part from the matrix
  74575. * @returns the updated matrix
  74576. */
  74577. Matrix.prototype.removeRotationAndScaling = function () {
  74578. var m = this.m;
  74579. 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);
  74580. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  74581. return this;
  74582. };
  74583. /**
  74584. * Multiply two matrices
  74585. * @param other defines the second operand
  74586. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74587. */
  74588. Matrix.prototype.multiply = function (other) {
  74589. var result = new Matrix();
  74590. this.multiplyToRef(other, result);
  74591. return result;
  74592. };
  74593. /**
  74594. * Copy the current matrix from the given one
  74595. * @param other defines the source matrix
  74596. * @returns the current updated matrix
  74597. */
  74598. Matrix.prototype.copyFrom = function (other) {
  74599. other.copyToArray(this._m);
  74600. var o = other;
  74601. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  74602. return this;
  74603. };
  74604. /**
  74605. * Populates the given array from the starting index with the current matrix values
  74606. * @param array defines the target array
  74607. * @param offset defines the offset in the target array where to start storing values
  74608. * @returns the current matrix
  74609. */
  74610. Matrix.prototype.copyToArray = function (array, offset) {
  74611. if (offset === void 0) { offset = 0; }
  74612. for (var index = 0; index < 16; index++) {
  74613. array[offset + index] = this._m[index];
  74614. }
  74615. return this;
  74616. };
  74617. /**
  74618. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74619. * @param other defines the second operand
  74620. * @param result defines the matrix where to store the multiplication
  74621. * @returns the current matrix
  74622. */
  74623. Matrix.prototype.multiplyToRef = function (other, result) {
  74624. if (this._isIdentity) {
  74625. result.copyFrom(other);
  74626. return this;
  74627. }
  74628. if (other._isIdentity) {
  74629. result.copyFrom(this);
  74630. return this;
  74631. }
  74632. this.multiplyToArray(other, result._m, 0);
  74633. result._markAsUpdated();
  74634. return this;
  74635. };
  74636. /**
  74637. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74638. * @param other defines the second operand
  74639. * @param result defines the array where to store the multiplication
  74640. * @param offset defines the offset in the target array where to start storing values
  74641. * @returns the current matrix
  74642. */
  74643. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  74644. var m = this._m;
  74645. var otherM = other.m;
  74646. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  74647. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  74648. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  74649. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  74650. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  74651. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  74652. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  74653. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  74654. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  74655. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  74656. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  74657. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  74658. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  74659. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  74660. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  74661. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  74662. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  74663. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  74664. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  74665. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  74666. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  74667. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  74668. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  74669. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  74670. return this;
  74671. };
  74672. /**
  74673. * Check equality between this matrix and a second one
  74674. * @param value defines the second matrix to compare
  74675. * @returns true is the current matrix and the given one values are strictly equal
  74676. */
  74677. Matrix.prototype.equals = function (value) {
  74678. var other = value;
  74679. if (!other) {
  74680. return false;
  74681. }
  74682. if (this._isIdentity || other._isIdentity) {
  74683. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  74684. return this._isIdentity && other._isIdentity;
  74685. }
  74686. }
  74687. var m = this.m;
  74688. var om = other.m;
  74689. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  74690. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  74691. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  74692. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  74693. };
  74694. /**
  74695. * Clone the current matrix
  74696. * @returns a new matrix from the current matrix
  74697. */
  74698. Matrix.prototype.clone = function () {
  74699. var matrix = new Matrix();
  74700. matrix.copyFrom(this);
  74701. return matrix;
  74702. };
  74703. /**
  74704. * Returns the name of the current matrix class
  74705. * @returns the string "Matrix"
  74706. */
  74707. Matrix.prototype.getClassName = function () {
  74708. return "Matrix";
  74709. };
  74710. /**
  74711. * Gets the hash code of the current matrix
  74712. * @returns the hash code
  74713. */
  74714. Matrix.prototype.getHashCode = function () {
  74715. var hash = this._m[0] || 0;
  74716. for (var i = 1; i < 16; i++) {
  74717. hash = (hash * 397) ^ (this._m[i] || 0);
  74718. }
  74719. return hash;
  74720. };
  74721. /**
  74722. * Decomposes the current Matrix into a translation, rotation and scaling components
  74723. * @param scale defines the scale vector3 given as a reference to update
  74724. * @param rotation defines the rotation quaternion given as a reference to update
  74725. * @param translation defines the translation vector3 given as a reference to update
  74726. * @returns true if operation was successful
  74727. */
  74728. Matrix.prototype.decompose = function (scale, rotation, translation) {
  74729. if (this._isIdentity) {
  74730. if (translation) {
  74731. translation.setAll(0);
  74732. }
  74733. if (scale) {
  74734. scale.setAll(1);
  74735. }
  74736. if (rotation) {
  74737. rotation.copyFromFloats(0, 0, 0, 1);
  74738. }
  74739. return true;
  74740. }
  74741. var m = this._m;
  74742. if (translation) {
  74743. translation.copyFromFloats(m[12], m[13], m[14]);
  74744. }
  74745. scale = scale || MathTmp.Vector3[0];
  74746. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  74747. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  74748. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  74749. if (this.determinant() <= 0) {
  74750. scale.y *= -1;
  74751. }
  74752. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  74753. if (rotation) {
  74754. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  74755. }
  74756. return false;
  74757. }
  74758. if (rotation) {
  74759. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  74760. 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]);
  74761. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  74762. }
  74763. return true;
  74764. };
  74765. /**
  74766. * Gets specific row of the matrix
  74767. * @param index defines the number of the row to get
  74768. * @returns the index-th row of the current matrix as a new Vector4
  74769. */
  74770. Matrix.prototype.getRow = function (index) {
  74771. if (index < 0 || index > 3) {
  74772. return null;
  74773. }
  74774. var i = index * 4;
  74775. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  74776. };
  74777. /**
  74778. * Sets the index-th row of the current matrix to the vector4 values
  74779. * @param index defines the number of the row to set
  74780. * @param row defines the target vector4
  74781. * @returns the updated current matrix
  74782. */
  74783. Matrix.prototype.setRow = function (index, row) {
  74784. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  74785. };
  74786. /**
  74787. * Compute the transpose of the matrix
  74788. * @returns the new transposed matrix
  74789. */
  74790. Matrix.prototype.transpose = function () {
  74791. return Matrix.Transpose(this);
  74792. };
  74793. /**
  74794. * Compute the transpose of the matrix and store it in a given matrix
  74795. * @param result defines the target matrix
  74796. * @returns the current matrix
  74797. */
  74798. Matrix.prototype.transposeToRef = function (result) {
  74799. Matrix.TransposeToRef(this, result);
  74800. return this;
  74801. };
  74802. /**
  74803. * Sets the index-th row of the current matrix with the given 4 x float values
  74804. * @param index defines the row index
  74805. * @param x defines the x component to set
  74806. * @param y defines the y component to set
  74807. * @param z defines the z component to set
  74808. * @param w defines the w component to set
  74809. * @returns the updated current matrix
  74810. */
  74811. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  74812. if (index < 0 || index > 3) {
  74813. return this;
  74814. }
  74815. var i = index * 4;
  74816. this._m[i + 0] = x;
  74817. this._m[i + 1] = y;
  74818. this._m[i + 2] = z;
  74819. this._m[i + 3] = w;
  74820. this._markAsUpdated();
  74821. return this;
  74822. };
  74823. /**
  74824. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74825. * @param scale defines the scale factor
  74826. * @returns a new matrix
  74827. */
  74828. Matrix.prototype.scale = function (scale) {
  74829. var result = new Matrix();
  74830. this.scaleToRef(scale, result);
  74831. return result;
  74832. };
  74833. /**
  74834. * Scale the current matrix values by a factor to a given result matrix
  74835. * @param scale defines the scale factor
  74836. * @param result defines the matrix to store the result
  74837. * @returns the current matrix
  74838. */
  74839. Matrix.prototype.scaleToRef = function (scale, result) {
  74840. for (var index = 0; index < 16; index++) {
  74841. result._m[index] = this._m[index] * scale;
  74842. }
  74843. result._markAsUpdated();
  74844. return this;
  74845. };
  74846. /**
  74847. * Scale the current matrix values by a factor and add the result to a given matrix
  74848. * @param scale defines the scale factor
  74849. * @param result defines the Matrix to store the result
  74850. * @returns the current matrix
  74851. */
  74852. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  74853. for (var index = 0; index < 16; index++) {
  74854. result._m[index] += this._m[index] * scale;
  74855. }
  74856. result._markAsUpdated();
  74857. return this;
  74858. };
  74859. /**
  74860. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74861. * @param ref matrix to store the result
  74862. */
  74863. Matrix.prototype.toNormalMatrix = function (ref) {
  74864. var tmp = MathTmp.Matrix[0];
  74865. this.invertToRef(tmp);
  74866. tmp.transposeToRef(ref);
  74867. var m = ref._m;
  74868. 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);
  74869. };
  74870. /**
  74871. * Gets only rotation part of the current matrix
  74872. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74873. */
  74874. Matrix.prototype.getRotationMatrix = function () {
  74875. var result = new Matrix();
  74876. this.getRotationMatrixToRef(result);
  74877. return result;
  74878. };
  74879. /**
  74880. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74881. * @param result defines the target matrix to store data to
  74882. * @returns the current matrix
  74883. */
  74884. Matrix.prototype.getRotationMatrixToRef = function (result) {
  74885. var scale = MathTmp.Vector3[0];
  74886. if (!this.decompose(scale)) {
  74887. Matrix.IdentityToRef(result);
  74888. return this;
  74889. }
  74890. var m = this._m;
  74891. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  74892. 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);
  74893. return this;
  74894. };
  74895. /**
  74896. * Toggles model matrix from being right handed to left handed in place and vice versa
  74897. */
  74898. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  74899. var m = this._m;
  74900. m[2] *= -1;
  74901. m[6] *= -1;
  74902. m[8] *= -1;
  74903. m[9] *= -1;
  74904. m[14] *= -1;
  74905. this._markAsUpdated();
  74906. };
  74907. /**
  74908. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74909. */
  74910. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  74911. var m = this._m;
  74912. m[8] *= -1;
  74913. m[9] *= -1;
  74914. m[10] *= -1;
  74915. m[11] *= -1;
  74916. this._markAsUpdated();
  74917. };
  74918. // Statics
  74919. /**
  74920. * Creates a matrix from an array
  74921. * @param array defines the source array
  74922. * @param offset defines an offset in the source array
  74923. * @returns a new Matrix set from the starting index of the given array
  74924. */
  74925. Matrix.FromArray = function (array, offset) {
  74926. if (offset === void 0) { offset = 0; }
  74927. var result = new Matrix();
  74928. Matrix.FromArrayToRef(array, offset, result);
  74929. return result;
  74930. };
  74931. /**
  74932. * Copy the content of an array into a given matrix
  74933. * @param array defines the source array
  74934. * @param offset defines an offset in the source array
  74935. * @param result defines the target matrix
  74936. */
  74937. Matrix.FromArrayToRef = function (array, offset, result) {
  74938. for (var index = 0; index < 16; index++) {
  74939. result._m[index] = array[index + offset];
  74940. }
  74941. result._markAsUpdated();
  74942. };
  74943. /**
  74944. * Stores an array into a matrix after having multiplied each component by a given factor
  74945. * @param array defines the source array
  74946. * @param offset defines the offset in the source array
  74947. * @param scale defines the scaling factor
  74948. * @param result defines the target matrix
  74949. */
  74950. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  74951. for (var index = 0; index < 16; index++) {
  74952. result._m[index] = array[index + offset] * scale;
  74953. }
  74954. result._markAsUpdated();
  74955. };
  74956. Object.defineProperty(Matrix, "IdentityReadOnly", {
  74957. /**
  74958. * Gets an identity matrix that must not be updated
  74959. */
  74960. get: function () {
  74961. return Matrix._identityReadOnly;
  74962. },
  74963. enumerable: true,
  74964. configurable: true
  74965. });
  74966. /**
  74967. * Stores a list of values (16) inside a given matrix
  74968. * @param initialM11 defines 1st value of 1st row
  74969. * @param initialM12 defines 2nd value of 1st row
  74970. * @param initialM13 defines 3rd value of 1st row
  74971. * @param initialM14 defines 4th value of 1st row
  74972. * @param initialM21 defines 1st value of 2nd row
  74973. * @param initialM22 defines 2nd value of 2nd row
  74974. * @param initialM23 defines 3rd value of 2nd row
  74975. * @param initialM24 defines 4th value of 2nd row
  74976. * @param initialM31 defines 1st value of 3rd row
  74977. * @param initialM32 defines 2nd value of 3rd row
  74978. * @param initialM33 defines 3rd value of 3rd row
  74979. * @param initialM34 defines 4th value of 3rd row
  74980. * @param initialM41 defines 1st value of 4th row
  74981. * @param initialM42 defines 2nd value of 4th row
  74982. * @param initialM43 defines 3rd value of 4th row
  74983. * @param initialM44 defines 4th value of 4th row
  74984. * @param result defines the target matrix
  74985. */
  74986. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  74987. var m = result._m;
  74988. m[0] = initialM11;
  74989. m[1] = initialM12;
  74990. m[2] = initialM13;
  74991. m[3] = initialM14;
  74992. m[4] = initialM21;
  74993. m[5] = initialM22;
  74994. m[6] = initialM23;
  74995. m[7] = initialM24;
  74996. m[8] = initialM31;
  74997. m[9] = initialM32;
  74998. m[10] = initialM33;
  74999. m[11] = initialM34;
  75000. m[12] = initialM41;
  75001. m[13] = initialM42;
  75002. m[14] = initialM43;
  75003. m[15] = initialM44;
  75004. result._markAsUpdated();
  75005. };
  75006. /**
  75007. * Creates new matrix from a list of values (16)
  75008. * @param initialM11 defines 1st value of 1st row
  75009. * @param initialM12 defines 2nd value of 1st row
  75010. * @param initialM13 defines 3rd value of 1st row
  75011. * @param initialM14 defines 4th value of 1st row
  75012. * @param initialM21 defines 1st value of 2nd row
  75013. * @param initialM22 defines 2nd value of 2nd row
  75014. * @param initialM23 defines 3rd value of 2nd row
  75015. * @param initialM24 defines 4th value of 2nd row
  75016. * @param initialM31 defines 1st value of 3rd row
  75017. * @param initialM32 defines 2nd value of 3rd row
  75018. * @param initialM33 defines 3rd value of 3rd row
  75019. * @param initialM34 defines 4th value of 3rd row
  75020. * @param initialM41 defines 1st value of 4th row
  75021. * @param initialM42 defines 2nd value of 4th row
  75022. * @param initialM43 defines 3rd value of 4th row
  75023. * @param initialM44 defines 4th value of 4th row
  75024. * @returns the new matrix
  75025. */
  75026. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  75027. var result = new Matrix();
  75028. var m = result._m;
  75029. m[0] = initialM11;
  75030. m[1] = initialM12;
  75031. m[2] = initialM13;
  75032. m[3] = initialM14;
  75033. m[4] = initialM21;
  75034. m[5] = initialM22;
  75035. m[6] = initialM23;
  75036. m[7] = initialM24;
  75037. m[8] = initialM31;
  75038. m[9] = initialM32;
  75039. m[10] = initialM33;
  75040. m[11] = initialM34;
  75041. m[12] = initialM41;
  75042. m[13] = initialM42;
  75043. m[14] = initialM43;
  75044. m[15] = initialM44;
  75045. result._markAsUpdated();
  75046. return result;
  75047. };
  75048. /**
  75049. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75050. * @param scale defines the scale vector3
  75051. * @param rotation defines the rotation quaternion
  75052. * @param translation defines the translation vector3
  75053. * @returns a new matrix
  75054. */
  75055. Matrix.Compose = function (scale, rotation, translation) {
  75056. var result = new Matrix();
  75057. Matrix.ComposeToRef(scale, rotation, translation, result);
  75058. return result;
  75059. };
  75060. /**
  75061. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75062. * @param scale defines the scale vector3
  75063. * @param rotation defines the rotation quaternion
  75064. * @param translation defines the translation vector3
  75065. * @param result defines the target matrix
  75066. */
  75067. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  75068. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  75069. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  75070. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  75071. result.setTranslation(translation);
  75072. };
  75073. /**
  75074. * Creates a new identity matrix
  75075. * @returns a new identity matrix
  75076. */
  75077. Matrix.Identity = function () {
  75078. 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);
  75079. identity._updateIdentityStatus(true);
  75080. return identity;
  75081. };
  75082. /**
  75083. * Creates a new identity matrix and stores the result in a given matrix
  75084. * @param result defines the target matrix
  75085. */
  75086. Matrix.IdentityToRef = function (result) {
  75087. 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);
  75088. result._updateIdentityStatus(true);
  75089. };
  75090. /**
  75091. * Creates a new zero matrix
  75092. * @returns a new zero matrix
  75093. */
  75094. Matrix.Zero = function () {
  75095. 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);
  75096. zero._updateIdentityStatus(false);
  75097. return zero;
  75098. };
  75099. /**
  75100. * Creates a new rotation matrix for "angle" radians around the X axis
  75101. * @param angle defines the angle (in radians) to use
  75102. * @return the new matrix
  75103. */
  75104. Matrix.RotationX = function (angle) {
  75105. var result = new Matrix();
  75106. Matrix.RotationXToRef(angle, result);
  75107. return result;
  75108. };
  75109. /**
  75110. * Creates a new matrix as the invert of a given matrix
  75111. * @param source defines the source matrix
  75112. * @returns the new matrix
  75113. */
  75114. Matrix.Invert = function (source) {
  75115. var result = new Matrix();
  75116. source.invertToRef(result);
  75117. return result;
  75118. };
  75119. /**
  75120. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  75121. * @param angle defines the angle (in radians) to use
  75122. * @param result defines the target matrix
  75123. */
  75124. Matrix.RotationXToRef = function (angle, result) {
  75125. var s = Math.sin(angle);
  75126. var c = Math.cos(angle);
  75127. 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);
  75128. result._updateIdentityStatus(c === 1 && s === 0);
  75129. };
  75130. /**
  75131. * Creates a new rotation matrix for "angle" radians around the Y axis
  75132. * @param angle defines the angle (in radians) to use
  75133. * @return the new matrix
  75134. */
  75135. Matrix.RotationY = function (angle) {
  75136. var result = new Matrix();
  75137. Matrix.RotationYToRef(angle, result);
  75138. return result;
  75139. };
  75140. /**
  75141. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  75142. * @param angle defines the angle (in radians) to use
  75143. * @param result defines the target matrix
  75144. */
  75145. Matrix.RotationYToRef = function (angle, result) {
  75146. var s = Math.sin(angle);
  75147. var c = Math.cos(angle);
  75148. 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);
  75149. result._updateIdentityStatus(c === 1 && s === 0);
  75150. };
  75151. /**
  75152. * Creates a new rotation matrix for "angle" radians around the Z axis
  75153. * @param angle defines the angle (in radians) to use
  75154. * @return the new matrix
  75155. */
  75156. Matrix.RotationZ = function (angle) {
  75157. var result = new Matrix();
  75158. Matrix.RotationZToRef(angle, result);
  75159. return result;
  75160. };
  75161. /**
  75162. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  75163. * @param angle defines the angle (in radians) to use
  75164. * @param result defines the target matrix
  75165. */
  75166. Matrix.RotationZToRef = function (angle, result) {
  75167. var s = Math.sin(angle);
  75168. var c = Math.cos(angle);
  75169. 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);
  75170. result._updateIdentityStatus(c === 1 && s === 0);
  75171. };
  75172. /**
  75173. * Creates a new rotation matrix for "angle" radians around the given axis
  75174. * @param axis defines the axis to use
  75175. * @param angle defines the angle (in radians) to use
  75176. * @return the new matrix
  75177. */
  75178. Matrix.RotationAxis = function (axis, angle) {
  75179. var result = new Matrix();
  75180. Matrix.RotationAxisToRef(axis, angle, result);
  75181. return result;
  75182. };
  75183. /**
  75184. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  75185. * @param axis defines the axis to use
  75186. * @param angle defines the angle (in radians) to use
  75187. * @param result defines the target matrix
  75188. */
  75189. Matrix.RotationAxisToRef = function (axis, angle, result) {
  75190. var s = Math.sin(-angle);
  75191. var c = Math.cos(-angle);
  75192. var c1 = 1 - c;
  75193. axis.normalize();
  75194. var m = result._m;
  75195. m[0] = (axis.x * axis.x) * c1 + c;
  75196. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  75197. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  75198. m[3] = 0.0;
  75199. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  75200. m[5] = (axis.y * axis.y) * c1 + c;
  75201. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  75202. m[7] = 0.0;
  75203. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  75204. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  75205. m[10] = (axis.z * axis.z) * c1 + c;
  75206. m[11] = 0.0;
  75207. m[12] = 0.0;
  75208. m[13] = 0.0;
  75209. m[14] = 0.0;
  75210. m[15] = 1.0;
  75211. result._markAsUpdated();
  75212. };
  75213. /**
  75214. * Creates a rotation matrix
  75215. * @param yaw defines the yaw angle in radians (Y axis)
  75216. * @param pitch defines the pitch angle in radians (X axis)
  75217. * @param roll defines the roll angle in radians (X axis)
  75218. * @returns the new rotation matrix
  75219. */
  75220. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  75221. var result = new Matrix();
  75222. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  75223. return result;
  75224. };
  75225. /**
  75226. * Creates a rotation matrix and stores it in a given matrix
  75227. * @param yaw defines the yaw angle in radians (Y axis)
  75228. * @param pitch defines the pitch angle in radians (X axis)
  75229. * @param roll defines the roll angle in radians (X axis)
  75230. * @param result defines the target matrix
  75231. */
  75232. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  75233. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  75234. MathTmp.Quaternion[0].toRotationMatrix(result);
  75235. };
  75236. /**
  75237. * Creates a scaling matrix
  75238. * @param x defines the scale factor on X axis
  75239. * @param y defines the scale factor on Y axis
  75240. * @param z defines the scale factor on Z axis
  75241. * @returns the new matrix
  75242. */
  75243. Matrix.Scaling = function (x, y, z) {
  75244. var result = new Matrix();
  75245. Matrix.ScalingToRef(x, y, z, result);
  75246. return result;
  75247. };
  75248. /**
  75249. * Creates a scaling matrix and stores it in a given matrix
  75250. * @param x defines the scale factor on X axis
  75251. * @param y defines the scale factor on Y axis
  75252. * @param z defines the scale factor on Z axis
  75253. * @param result defines the target matrix
  75254. */
  75255. Matrix.ScalingToRef = function (x, y, z, result) {
  75256. 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);
  75257. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  75258. };
  75259. /**
  75260. * Creates a translation matrix
  75261. * @param x defines the translation on X axis
  75262. * @param y defines the translation on Y axis
  75263. * @param z defines the translationon Z axis
  75264. * @returns the new matrix
  75265. */
  75266. Matrix.Translation = function (x, y, z) {
  75267. var result = new Matrix();
  75268. Matrix.TranslationToRef(x, y, z, result);
  75269. return result;
  75270. };
  75271. /**
  75272. * Creates a translation matrix and stores it in a given matrix
  75273. * @param x defines the translation on X axis
  75274. * @param y defines the translation on Y axis
  75275. * @param z defines the translationon Z axis
  75276. * @param result defines the target matrix
  75277. */
  75278. Matrix.TranslationToRef = function (x, y, z, result) {
  75279. 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);
  75280. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  75281. };
  75282. /**
  75283. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75284. * @param startValue defines the start value
  75285. * @param endValue defines the end value
  75286. * @param gradient defines the gradient factor
  75287. * @returns the new matrix
  75288. */
  75289. Matrix.Lerp = function (startValue, endValue, gradient) {
  75290. var result = new Matrix();
  75291. Matrix.LerpToRef(startValue, endValue, gradient, result);
  75292. return result;
  75293. };
  75294. /**
  75295. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75296. * @param startValue defines the start value
  75297. * @param endValue defines the end value
  75298. * @param gradient defines the gradient factor
  75299. * @param result defines the Matrix object where to store data
  75300. */
  75301. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  75302. var resultM = result._m;
  75303. var startM = startValue.m;
  75304. var endM = endValue.m;
  75305. for (var index = 0; index < 16; index++) {
  75306. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  75307. }
  75308. result._markAsUpdated();
  75309. };
  75310. /**
  75311. * Builds a new matrix whose values are computed by:
  75312. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75313. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75314. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75315. * @param startValue defines the first matrix
  75316. * @param endValue defines the second matrix
  75317. * @param gradient defines the gradient between the two matrices
  75318. * @returns the new matrix
  75319. */
  75320. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  75321. var result = new Matrix();
  75322. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  75323. return result;
  75324. };
  75325. /**
  75326. * Update a matrix to values which are computed by:
  75327. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75328. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75329. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75330. * @param startValue defines the first matrix
  75331. * @param endValue defines the second matrix
  75332. * @param gradient defines the gradient between the two matrices
  75333. * @param result defines the target matrix
  75334. */
  75335. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  75336. var startScale = MathTmp.Vector3[0];
  75337. var startRotation = MathTmp.Quaternion[0];
  75338. var startTranslation = MathTmp.Vector3[1];
  75339. startValue.decompose(startScale, startRotation, startTranslation);
  75340. var endScale = MathTmp.Vector3[2];
  75341. var endRotation = MathTmp.Quaternion[1];
  75342. var endTranslation = MathTmp.Vector3[3];
  75343. endValue.decompose(endScale, endRotation, endTranslation);
  75344. var resultScale = MathTmp.Vector3[4];
  75345. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  75346. var resultRotation = MathTmp.Quaternion[2];
  75347. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  75348. var resultTranslation = MathTmp.Vector3[5];
  75349. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  75350. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  75351. };
  75352. /**
  75353. * 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"
  75354. * This function works in left handed mode
  75355. * @param eye defines the final position of the entity
  75356. * @param target defines where the entity should look at
  75357. * @param up defines the up vector for the entity
  75358. * @returns the new matrix
  75359. */
  75360. Matrix.LookAtLH = function (eye, target, up) {
  75361. var result = new Matrix();
  75362. Matrix.LookAtLHToRef(eye, target, up, result);
  75363. return result;
  75364. };
  75365. /**
  75366. * 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".
  75367. * This function works in left handed mode
  75368. * @param eye defines the final position of the entity
  75369. * @param target defines where the entity should look at
  75370. * @param up defines the up vector for the entity
  75371. * @param result defines the target matrix
  75372. */
  75373. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  75374. var xAxis = MathTmp.Vector3[0];
  75375. var yAxis = MathTmp.Vector3[1];
  75376. var zAxis = MathTmp.Vector3[2];
  75377. // Z axis
  75378. target.subtractToRef(eye, zAxis);
  75379. zAxis.normalize();
  75380. // X axis
  75381. Vector3.CrossToRef(up, zAxis, xAxis);
  75382. var xSquareLength = xAxis.lengthSquared();
  75383. if (xSquareLength === 0) {
  75384. xAxis.x = 1.0;
  75385. }
  75386. else {
  75387. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  75388. }
  75389. // Y axis
  75390. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  75391. yAxis.normalize();
  75392. // Eye angles
  75393. var ex = -Vector3.Dot(xAxis, eye);
  75394. var ey = -Vector3.Dot(yAxis, eye);
  75395. var ez = -Vector3.Dot(zAxis, eye);
  75396. 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);
  75397. };
  75398. /**
  75399. * 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"
  75400. * This function works in right handed mode
  75401. * @param eye defines the final position of the entity
  75402. * @param target defines where the entity should look at
  75403. * @param up defines the up vector for the entity
  75404. * @returns the new matrix
  75405. */
  75406. Matrix.LookAtRH = function (eye, target, up) {
  75407. var result = new Matrix();
  75408. Matrix.LookAtRHToRef(eye, target, up, result);
  75409. return result;
  75410. };
  75411. /**
  75412. * 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".
  75413. * This function works in right handed mode
  75414. * @param eye defines the final position of the entity
  75415. * @param target defines where the entity should look at
  75416. * @param up defines the up vector for the entity
  75417. * @param result defines the target matrix
  75418. */
  75419. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  75420. var xAxis = MathTmp.Vector3[0];
  75421. var yAxis = MathTmp.Vector3[1];
  75422. var zAxis = MathTmp.Vector3[2];
  75423. // Z axis
  75424. eye.subtractToRef(target, zAxis);
  75425. zAxis.normalize();
  75426. // X axis
  75427. Vector3.CrossToRef(up, zAxis, xAxis);
  75428. var xSquareLength = xAxis.lengthSquared();
  75429. if (xSquareLength === 0) {
  75430. xAxis.x = 1.0;
  75431. }
  75432. else {
  75433. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  75434. }
  75435. // Y axis
  75436. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  75437. yAxis.normalize();
  75438. // Eye angles
  75439. var ex = -Vector3.Dot(xAxis, eye);
  75440. var ey = -Vector3.Dot(yAxis, eye);
  75441. var ez = -Vector3.Dot(zAxis, eye);
  75442. 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);
  75443. };
  75444. /**
  75445. * Create a left-handed orthographic projection matrix
  75446. * @param width defines the viewport width
  75447. * @param height defines the viewport height
  75448. * @param znear defines the near clip plane
  75449. * @param zfar defines the far clip plane
  75450. * @returns a new matrix as a left-handed orthographic projection matrix
  75451. */
  75452. Matrix.OrthoLH = function (width, height, znear, zfar) {
  75453. var matrix = new Matrix();
  75454. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  75455. return matrix;
  75456. };
  75457. /**
  75458. * Store a left-handed orthographic projection to a given matrix
  75459. * @param width defines the viewport width
  75460. * @param height defines the viewport height
  75461. * @param znear defines the near clip plane
  75462. * @param zfar defines the far clip plane
  75463. * @param result defines the target matrix
  75464. */
  75465. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  75466. var n = znear;
  75467. var f = zfar;
  75468. var a = 2.0 / width;
  75469. var b = 2.0 / height;
  75470. var c = 2.0 / (f - n);
  75471. var d = -(f + n) / (f - n);
  75472. 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);
  75473. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  75474. };
  75475. /**
  75476. * Create a left-handed orthographic projection matrix
  75477. * @param left defines the viewport left coordinate
  75478. * @param right defines the viewport right coordinate
  75479. * @param bottom defines the viewport bottom coordinate
  75480. * @param top defines the viewport top coordinate
  75481. * @param znear defines the near clip plane
  75482. * @param zfar defines the far clip plane
  75483. * @returns a new matrix as a left-handed orthographic projection matrix
  75484. */
  75485. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  75486. var matrix = new Matrix();
  75487. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  75488. return matrix;
  75489. };
  75490. /**
  75491. * Stores a left-handed orthographic projection into a given matrix
  75492. * @param left defines the viewport left coordinate
  75493. * @param right defines the viewport right coordinate
  75494. * @param bottom defines the viewport bottom coordinate
  75495. * @param top defines the viewport top coordinate
  75496. * @param znear defines the near clip plane
  75497. * @param zfar defines the far clip plane
  75498. * @param result defines the target matrix
  75499. */
  75500. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  75501. var n = znear;
  75502. var f = zfar;
  75503. var a = 2.0 / (right - left);
  75504. var b = 2.0 / (top - bottom);
  75505. var c = 2.0 / (f - n);
  75506. var d = -(f + n) / (f - n);
  75507. var i0 = (left + right) / (left - right);
  75508. var i1 = (top + bottom) / (bottom - top);
  75509. 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);
  75510. result._markAsUpdated();
  75511. };
  75512. /**
  75513. * Creates a right-handed orthographic projection matrix
  75514. * @param left defines the viewport left coordinate
  75515. * @param right defines the viewport right coordinate
  75516. * @param bottom defines the viewport bottom coordinate
  75517. * @param top defines the viewport top coordinate
  75518. * @param znear defines the near clip plane
  75519. * @param zfar defines the far clip plane
  75520. * @returns a new matrix as a right-handed orthographic projection matrix
  75521. */
  75522. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  75523. var matrix = new Matrix();
  75524. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  75525. return matrix;
  75526. };
  75527. /**
  75528. * Stores a right-handed orthographic projection into a given matrix
  75529. * @param left defines the viewport left coordinate
  75530. * @param right defines the viewport right coordinate
  75531. * @param bottom defines the viewport bottom coordinate
  75532. * @param top defines the viewport top coordinate
  75533. * @param znear defines the near clip plane
  75534. * @param zfar defines the far clip plane
  75535. * @param result defines the target matrix
  75536. */
  75537. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  75538. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  75539. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  75540. };
  75541. /**
  75542. * Creates a left-handed perspective projection matrix
  75543. * @param width defines the viewport width
  75544. * @param height defines the viewport height
  75545. * @param znear defines the near clip plane
  75546. * @param zfar defines the far clip plane
  75547. * @returns a new matrix as a left-handed perspective projection matrix
  75548. */
  75549. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  75550. var matrix = new Matrix();
  75551. var n = znear;
  75552. var f = zfar;
  75553. var a = 2.0 * n / width;
  75554. var b = 2.0 * n / height;
  75555. var c = (f + n) / (f - n);
  75556. var d = -2.0 * f * n / (f - n);
  75557. 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);
  75558. matrix._updateIdentityStatus(false);
  75559. return matrix;
  75560. };
  75561. /**
  75562. * Creates a left-handed perspective projection matrix
  75563. * @param fov defines the horizontal field of view
  75564. * @param aspect defines the aspect ratio
  75565. * @param znear defines the near clip plane
  75566. * @param zfar defines the far clip plane
  75567. * @returns a new matrix as a left-handed perspective projection matrix
  75568. */
  75569. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  75570. var matrix = new Matrix();
  75571. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  75572. return matrix;
  75573. };
  75574. /**
  75575. * Stores a left-handed perspective projection into a given matrix
  75576. * @param fov defines the horizontal field of view
  75577. * @param aspect defines the aspect ratio
  75578. * @param znear defines the near clip plane
  75579. * @param zfar defines the far clip plane
  75580. * @param result defines the target matrix
  75581. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75582. */
  75583. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  75584. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  75585. var n = znear;
  75586. var f = zfar;
  75587. var t = 1.0 / (Math.tan(fov * 0.5));
  75588. var a = isVerticalFovFixed ? (t / aspect) : t;
  75589. var b = isVerticalFovFixed ? t : (t * aspect);
  75590. var c = (f + n) / (f - n);
  75591. var d = -2.0 * f * n / (f - n);
  75592. 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);
  75593. result._updateIdentityStatus(false);
  75594. };
  75595. /**
  75596. * Creates a right-handed perspective projection matrix
  75597. * @param fov defines the horizontal field of view
  75598. * @param aspect defines the aspect ratio
  75599. * @param znear defines the near clip plane
  75600. * @param zfar defines the far clip plane
  75601. * @returns a new matrix as a right-handed perspective projection matrix
  75602. */
  75603. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  75604. var matrix = new Matrix();
  75605. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  75606. return matrix;
  75607. };
  75608. /**
  75609. * Stores a right-handed perspective projection into a given matrix
  75610. * @param fov defines the horizontal field of view
  75611. * @param aspect defines the aspect ratio
  75612. * @param znear defines the near clip plane
  75613. * @param zfar defines the far clip plane
  75614. * @param result defines the target matrix
  75615. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75616. */
  75617. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  75618. //alternatively this could be expressed as:
  75619. // m = PerspectiveFovLHToRef
  75620. // m[10] *= -1.0;
  75621. // m[11] *= -1.0;
  75622. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  75623. var n = znear;
  75624. var f = zfar;
  75625. var t = 1.0 / (Math.tan(fov * 0.5));
  75626. var a = isVerticalFovFixed ? (t / aspect) : t;
  75627. var b = isVerticalFovFixed ? t : (t * aspect);
  75628. var c = -(f + n) / (f - n);
  75629. var d = -2 * f * n / (f - n);
  75630. 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);
  75631. result._updateIdentityStatus(false);
  75632. };
  75633. /**
  75634. * Stores a perspective projection for WebVR info a given matrix
  75635. * @param fov defines the field of view
  75636. * @param znear defines the near clip plane
  75637. * @param zfar defines the far clip plane
  75638. * @param result defines the target matrix
  75639. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75640. */
  75641. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  75642. if (rightHanded === void 0) { rightHanded = false; }
  75643. var rightHandedFactor = rightHanded ? -1 : 1;
  75644. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  75645. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  75646. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  75647. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  75648. var xScale = 2.0 / (leftTan + rightTan);
  75649. var yScale = 2.0 / (upTan + downTan);
  75650. var m = result._m;
  75651. m[0] = xScale;
  75652. m[1] = m[2] = m[3] = m[4] = 0.0;
  75653. m[5] = yScale;
  75654. m[6] = m[7] = 0.0;
  75655. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  75656. m[9] = -((upTan - downTan) * yScale * 0.5);
  75657. m[10] = -zfar / (znear - zfar);
  75658. m[11] = 1.0 * rightHandedFactor;
  75659. m[12] = m[13] = m[15] = 0.0;
  75660. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  75661. result._markAsUpdated();
  75662. };
  75663. /**
  75664. * Computes a complete transformation matrix
  75665. * @param viewport defines the viewport to use
  75666. * @param world defines the world matrix
  75667. * @param view defines the view matrix
  75668. * @param projection defines the projection matrix
  75669. * @param zmin defines the near clip plane
  75670. * @param zmax defines the far clip plane
  75671. * @returns the transformation matrix
  75672. */
  75673. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  75674. var cw = viewport.width;
  75675. var ch = viewport.height;
  75676. var cx = viewport.x;
  75677. var cy = viewport.y;
  75678. 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);
  75679. var matrix = MathTmp.Matrix[0];
  75680. world.multiplyToRef(view, matrix);
  75681. matrix.multiplyToRef(projection, matrix);
  75682. return matrix.multiply(viewportMatrix);
  75683. };
  75684. /**
  75685. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75686. * @param matrix defines the matrix to use
  75687. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75688. */
  75689. Matrix.GetAsMatrix2x2 = function (matrix) {
  75690. var m = matrix.m;
  75691. return new Float32Array([m[0], m[1], m[4], m[5]]);
  75692. };
  75693. /**
  75694. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75695. * @param matrix defines the matrix to use
  75696. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75697. */
  75698. Matrix.GetAsMatrix3x3 = function (matrix) {
  75699. var m = matrix.m;
  75700. return new Float32Array([
  75701. m[0], m[1], m[2],
  75702. m[4], m[5], m[6],
  75703. m[8], m[9], m[10]
  75704. ]);
  75705. };
  75706. /**
  75707. * Compute the transpose of a given matrix
  75708. * @param matrix defines the matrix to transpose
  75709. * @returns the new matrix
  75710. */
  75711. Matrix.Transpose = function (matrix) {
  75712. var result = new Matrix();
  75713. Matrix.TransposeToRef(matrix, result);
  75714. return result;
  75715. };
  75716. /**
  75717. * Compute the transpose of a matrix and store it in a target matrix
  75718. * @param matrix defines the matrix to transpose
  75719. * @param result defines the target matrix
  75720. */
  75721. Matrix.TransposeToRef = function (matrix, result) {
  75722. var rm = result._m;
  75723. var mm = matrix.m;
  75724. rm[0] = mm[0];
  75725. rm[1] = mm[4];
  75726. rm[2] = mm[8];
  75727. rm[3] = mm[12];
  75728. rm[4] = mm[1];
  75729. rm[5] = mm[5];
  75730. rm[6] = mm[9];
  75731. rm[7] = mm[13];
  75732. rm[8] = mm[2];
  75733. rm[9] = mm[6];
  75734. rm[10] = mm[10];
  75735. rm[11] = mm[14];
  75736. rm[12] = mm[3];
  75737. rm[13] = mm[7];
  75738. rm[14] = mm[11];
  75739. rm[15] = mm[15];
  75740. // identity-ness does not change when transposing
  75741. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  75742. };
  75743. /**
  75744. * Computes a reflection matrix from a plane
  75745. * @param plane defines the reflection plane
  75746. * @returns a new matrix
  75747. */
  75748. Matrix.Reflection = function (plane) {
  75749. var matrix = new Matrix();
  75750. Matrix.ReflectionToRef(plane, matrix);
  75751. return matrix;
  75752. };
  75753. /**
  75754. * Computes a reflection matrix from a plane
  75755. * @param plane defines the reflection plane
  75756. * @param result defines the target matrix
  75757. */
  75758. Matrix.ReflectionToRef = function (plane, result) {
  75759. plane.normalize();
  75760. var x = plane.normal.x;
  75761. var y = plane.normal.y;
  75762. var z = plane.normal.z;
  75763. var temp = -2 * x;
  75764. var temp2 = -2 * y;
  75765. var temp3 = -2 * z;
  75766. 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);
  75767. };
  75768. /**
  75769. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75770. * @param xaxis defines the value of the 1st axis
  75771. * @param yaxis defines the value of the 2nd axis
  75772. * @param zaxis defines the value of the 3rd axis
  75773. * @param result defines the target matrix
  75774. */
  75775. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  75776. 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);
  75777. };
  75778. /**
  75779. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75780. * @param quat defines the quaternion to use
  75781. * @param result defines the target matrix
  75782. */
  75783. Matrix.FromQuaternionToRef = function (quat, result) {
  75784. var xx = quat.x * quat.x;
  75785. var yy = quat.y * quat.y;
  75786. var zz = quat.z * quat.z;
  75787. var xy = quat.x * quat.y;
  75788. var zw = quat.z * quat.w;
  75789. var zx = quat.z * quat.x;
  75790. var yw = quat.y * quat.w;
  75791. var yz = quat.y * quat.z;
  75792. var xw = quat.x * quat.w;
  75793. result._m[0] = 1.0 - (2.0 * (yy + zz));
  75794. result._m[1] = 2.0 * (xy + zw);
  75795. result._m[2] = 2.0 * (zx - yw);
  75796. result._m[3] = 0.0;
  75797. result._m[4] = 2.0 * (xy - zw);
  75798. result._m[5] = 1.0 - (2.0 * (zz + xx));
  75799. result._m[6] = 2.0 * (yz + xw);
  75800. result._m[7] = 0.0;
  75801. result._m[8] = 2.0 * (zx + yw);
  75802. result._m[9] = 2.0 * (yz - xw);
  75803. result._m[10] = 1.0 - (2.0 * (yy + xx));
  75804. result._m[11] = 0.0;
  75805. result._m[12] = 0.0;
  75806. result._m[13] = 0.0;
  75807. result._m[14] = 0.0;
  75808. result._m[15] = 1.0;
  75809. result._markAsUpdated();
  75810. };
  75811. Matrix._updateFlagSeed = 0;
  75812. Matrix._identityReadOnly = Matrix.Identity();
  75813. return Matrix;
  75814. }());
  75815. /**
  75816. * Represens a plane by the equation ax + by + cz + d = 0
  75817. */
  75818. var Plane = /** @class */ (function () {
  75819. /**
  75820. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75821. * @param a a component of the plane
  75822. * @param b b component of the plane
  75823. * @param c c component of the plane
  75824. * @param d d component of the plane
  75825. */
  75826. function Plane(a, b, c, d) {
  75827. this.normal = new Vector3(a, b, c);
  75828. this.d = d;
  75829. }
  75830. /**
  75831. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75832. */
  75833. Plane.prototype.asArray = function () {
  75834. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  75835. };
  75836. // Methods
  75837. /**
  75838. * @returns a new plane copied from the current Plane.
  75839. */
  75840. Plane.prototype.clone = function () {
  75841. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  75842. };
  75843. /**
  75844. * @returns the string "Plane".
  75845. */
  75846. Plane.prototype.getClassName = function () {
  75847. return "Plane";
  75848. };
  75849. /**
  75850. * @returns the Plane hash code.
  75851. */
  75852. Plane.prototype.getHashCode = function () {
  75853. var hash = this.normal.getHashCode();
  75854. hash = (hash * 397) ^ (this.d || 0);
  75855. return hash;
  75856. };
  75857. /**
  75858. * Normalize the current Plane in place.
  75859. * @returns the updated Plane.
  75860. */
  75861. Plane.prototype.normalize = function () {
  75862. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  75863. var magnitude = 0.0;
  75864. if (norm !== 0) {
  75865. magnitude = 1.0 / norm;
  75866. }
  75867. this.normal.x *= magnitude;
  75868. this.normal.y *= magnitude;
  75869. this.normal.z *= magnitude;
  75870. this.d *= magnitude;
  75871. return this;
  75872. };
  75873. /**
  75874. * Applies a transformation the plane and returns the result
  75875. * @param transformation the transformation matrix to be applied to the plane
  75876. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75877. */
  75878. Plane.prototype.transform = function (transformation) {
  75879. var transposedMatrix = MathTmp.Matrix[0];
  75880. Matrix.TransposeToRef(transformation, transposedMatrix);
  75881. var m = transposedMatrix.m;
  75882. var x = this.normal.x;
  75883. var y = this.normal.y;
  75884. var z = this.normal.z;
  75885. var d = this.d;
  75886. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  75887. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  75888. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  75889. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  75890. return new Plane(normalX, normalY, normalZ, finalD);
  75891. };
  75892. /**
  75893. * Calcualtte the dot product between the point and the plane normal
  75894. * @param point point to calculate the dot product with
  75895. * @returns the dot product (float) of the point coordinates and the plane normal.
  75896. */
  75897. Plane.prototype.dotCoordinate = function (point) {
  75898. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  75899. };
  75900. /**
  75901. * Updates the current Plane from the plane defined by the three given points.
  75902. * @param point1 one of the points used to contruct the plane
  75903. * @param point2 one of the points used to contruct the plane
  75904. * @param point3 one of the points used to contruct the plane
  75905. * @returns the updated Plane.
  75906. */
  75907. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  75908. var x1 = point2.x - point1.x;
  75909. var y1 = point2.y - point1.y;
  75910. var z1 = point2.z - point1.z;
  75911. var x2 = point3.x - point1.x;
  75912. var y2 = point3.y - point1.y;
  75913. var z2 = point3.z - point1.z;
  75914. var yz = (y1 * z2) - (z1 * y2);
  75915. var xz = (z1 * x2) - (x1 * z2);
  75916. var xy = (x1 * y2) - (y1 * x2);
  75917. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  75918. var invPyth;
  75919. if (pyth !== 0) {
  75920. invPyth = 1.0 / pyth;
  75921. }
  75922. else {
  75923. invPyth = 0.0;
  75924. }
  75925. this.normal.x = yz * invPyth;
  75926. this.normal.y = xz * invPyth;
  75927. this.normal.z = xy * invPyth;
  75928. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  75929. return this;
  75930. };
  75931. /**
  75932. * Checks if the plane is facing a given direction
  75933. * @param direction the direction to check if the plane is facing
  75934. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75935. * @returns True is the vector "direction" is the same side than the plane normal.
  75936. */
  75937. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  75938. var dot = Vector3.Dot(this.normal, direction);
  75939. return (dot <= epsilon);
  75940. };
  75941. /**
  75942. * Calculates the distance to a point
  75943. * @param point point to calculate distance to
  75944. * @returns the signed distance (float) from the given point to the Plane.
  75945. */
  75946. Plane.prototype.signedDistanceTo = function (point) {
  75947. return Vector3.Dot(point, this.normal) + this.d;
  75948. };
  75949. // Statics
  75950. /**
  75951. * Creates a plane from an array
  75952. * @param array the array to create a plane from
  75953. * @returns a new Plane from the given array.
  75954. */
  75955. Plane.FromArray = function (array) {
  75956. return new Plane(array[0], array[1], array[2], array[3]);
  75957. };
  75958. /**
  75959. * Creates a plane from three points
  75960. * @param point1 point used to create the plane
  75961. * @param point2 point used to create the plane
  75962. * @param point3 point used to create the plane
  75963. * @returns a new Plane defined by the three given points.
  75964. */
  75965. Plane.FromPoints = function (point1, point2, point3) {
  75966. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  75967. result.copyFromPoints(point1, point2, point3);
  75968. return result;
  75969. };
  75970. /**
  75971. * Creates a plane from an origin point and a normal
  75972. * @param origin origin of the plane to be constructed
  75973. * @param normal normal of the plane to be constructed
  75974. * @returns a new Plane the normal vector to this plane at the given origin point.
  75975. * Note : the vector "normal" is updated because normalized.
  75976. */
  75977. Plane.FromPositionAndNormal = function (origin, normal) {
  75978. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  75979. normal.normalize();
  75980. result.normal = normal;
  75981. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  75982. return result;
  75983. };
  75984. /**
  75985. * Calculates the distance from a plane and a point
  75986. * @param origin origin of the plane to be constructed
  75987. * @param normal normal of the plane to be constructed
  75988. * @param point point to calculate distance to
  75989. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75990. */
  75991. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  75992. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  75993. return Vector3.Dot(point, normal) + d;
  75994. };
  75995. return Plane;
  75996. }());
  75997. /**
  75998. * Class used to represent a viewport on screen
  75999. */
  76000. var Viewport = /** @class */ (function () {
  76001. /**
  76002. * Creates a Viewport object located at (x, y) and sized (width, height)
  76003. * @param x defines viewport left coordinate
  76004. * @param y defines viewport top coordinate
  76005. * @param width defines the viewport width
  76006. * @param height defines the viewport height
  76007. */
  76008. function Viewport(
  76009. /** viewport left coordinate */
  76010. x,
  76011. /** viewport top coordinate */
  76012. y,
  76013. /**viewport width */
  76014. width,
  76015. /** viewport height */
  76016. height) {
  76017. this.x = x;
  76018. this.y = y;
  76019. this.width = width;
  76020. this.height = height;
  76021. }
  76022. /**
  76023. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76024. * @param renderWidth defines the rendering width
  76025. * @param renderHeight defines the rendering height
  76026. * @returns a new Viewport
  76027. */
  76028. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  76029. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  76030. };
  76031. /**
  76032. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76033. * @param renderWidth defines the rendering width
  76034. * @param renderHeight defines the rendering height
  76035. * @param ref defines the target viewport
  76036. * @returns the current viewport
  76037. */
  76038. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  76039. ref.x = this.x * renderWidth;
  76040. ref.y = this.y * renderHeight;
  76041. ref.width = this.width * renderWidth;
  76042. ref.height = this.height * renderHeight;
  76043. return this;
  76044. };
  76045. /**
  76046. * Returns a new Viewport copied from the current one
  76047. * @returns a new Viewport
  76048. */
  76049. Viewport.prototype.clone = function () {
  76050. return new Viewport(this.x, this.y, this.width, this.height);
  76051. };
  76052. return Viewport;
  76053. }());
  76054. /**
  76055. * Reprasents a camera frustum
  76056. */
  76057. var Frustum = /** @class */ (function () {
  76058. function Frustum() {
  76059. }
  76060. /**
  76061. * Gets the planes representing the frustum
  76062. * @param transform matrix to be applied to the returned planes
  76063. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  76064. */
  76065. Frustum.GetPlanes = function (transform) {
  76066. var frustumPlanes = [];
  76067. for (var index = 0; index < 6; index++) {
  76068. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  76069. }
  76070. Frustum.GetPlanesToRef(transform, frustumPlanes);
  76071. return frustumPlanes;
  76072. };
  76073. /**
  76074. * Gets the near frustum plane transformed by the transform matrix
  76075. * @param transform transformation matrix to be applied to the resulting frustum plane
  76076. * @param frustumPlane the resuling frustum plane
  76077. */
  76078. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  76079. var m = transform.m;
  76080. frustumPlane.normal.x = m[3] + m[2];
  76081. frustumPlane.normal.y = m[7] + m[6];
  76082. frustumPlane.normal.z = m[11] + m[10];
  76083. frustumPlane.d = m[15] + m[14];
  76084. frustumPlane.normalize();
  76085. };
  76086. /**
  76087. * Gets the far frustum plane transformed by the transform matrix
  76088. * @param transform transformation matrix to be applied to the resulting frustum plane
  76089. * @param frustumPlane the resuling frustum plane
  76090. */
  76091. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  76092. var m = transform.m;
  76093. frustumPlane.normal.x = m[3] - m[2];
  76094. frustumPlane.normal.y = m[7] - m[6];
  76095. frustumPlane.normal.z = m[11] - m[10];
  76096. frustumPlane.d = m[15] - m[14];
  76097. frustumPlane.normalize();
  76098. };
  76099. /**
  76100. * Gets the left frustum plane transformed by the transform matrix
  76101. * @param transform transformation matrix to be applied to the resulting frustum plane
  76102. * @param frustumPlane the resuling frustum plane
  76103. */
  76104. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  76105. var m = transform.m;
  76106. frustumPlane.normal.x = m[3] + m[0];
  76107. frustumPlane.normal.y = m[7] + m[4];
  76108. frustumPlane.normal.z = m[11] + m[8];
  76109. frustumPlane.d = m[15] + m[12];
  76110. frustumPlane.normalize();
  76111. };
  76112. /**
  76113. * Gets the right frustum plane transformed by the transform matrix
  76114. * @param transform transformation matrix to be applied to the resulting frustum plane
  76115. * @param frustumPlane the resuling frustum plane
  76116. */
  76117. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  76118. var m = transform.m;
  76119. frustumPlane.normal.x = m[3] - m[0];
  76120. frustumPlane.normal.y = m[7] - m[4];
  76121. frustumPlane.normal.z = m[11] - m[8];
  76122. frustumPlane.d = m[15] - m[12];
  76123. frustumPlane.normalize();
  76124. };
  76125. /**
  76126. * Gets the top frustum plane transformed by the transform matrix
  76127. * @param transform transformation matrix to be applied to the resulting frustum plane
  76128. * @param frustumPlane the resuling frustum plane
  76129. */
  76130. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  76131. var m = transform.m;
  76132. frustumPlane.normal.x = m[3] - m[1];
  76133. frustumPlane.normal.y = m[7] - m[5];
  76134. frustumPlane.normal.z = m[11] - m[9];
  76135. frustumPlane.d = m[15] - m[13];
  76136. frustumPlane.normalize();
  76137. };
  76138. /**
  76139. * Gets the bottom frustum plane transformed by the transform matrix
  76140. * @param transform transformation matrix to be applied to the resulting frustum plane
  76141. * @param frustumPlane the resuling frustum plane
  76142. */
  76143. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  76144. var m = transform.m;
  76145. frustumPlane.normal.x = m[3] + m[1];
  76146. frustumPlane.normal.y = m[7] + m[5];
  76147. frustumPlane.normal.z = m[11] + m[9];
  76148. frustumPlane.d = m[15] + m[13];
  76149. frustumPlane.normalize();
  76150. };
  76151. /**
  76152. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  76153. * @param transform transformation matrix to be applied to the resulting frustum planes
  76154. * @param frustumPlanes the resuling frustum planes
  76155. */
  76156. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  76157. // Near
  76158. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  76159. // Far
  76160. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  76161. // Left
  76162. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  76163. // Right
  76164. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  76165. // Top
  76166. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  76167. // Bottom
  76168. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  76169. };
  76170. return Frustum;
  76171. }());
  76172. /** Defines supported spaces */
  76173. var Space;
  76174. (function (Space) {
  76175. /** Local (object) space */
  76176. Space[Space["LOCAL"] = 0] = "LOCAL";
  76177. /** World space */
  76178. Space[Space["WORLD"] = 1] = "WORLD";
  76179. /** Bone space */
  76180. Space[Space["BONE"] = 2] = "BONE";
  76181. })(Space || (Space = {}));
  76182. /** Defines the 3 main axes */
  76183. var Axis = /** @class */ (function () {
  76184. function Axis() {
  76185. }
  76186. /** X axis */
  76187. Axis.X = new Vector3(1.0, 0.0, 0.0);
  76188. /** Y axis */
  76189. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  76190. /** Z axis */
  76191. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  76192. return Axis;
  76193. }());
  76194. /** Class used to represent a Bezier curve */
  76195. var BezierCurve = /** @class */ (function () {
  76196. function BezierCurve() {
  76197. }
  76198. /**
  76199. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  76200. * @param t defines the time
  76201. * @param x1 defines the left coordinate on X axis
  76202. * @param y1 defines the left coordinate on Y axis
  76203. * @param x2 defines the right coordinate on X axis
  76204. * @param y2 defines the right coordinate on Y axis
  76205. * @returns the interpolated value
  76206. */
  76207. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  76208. // Extract X (which is equal to time here)
  76209. var f0 = 1 - 3 * x2 + 3 * x1;
  76210. var f1 = 3 * x2 - 6 * x1;
  76211. var f2 = 3 * x1;
  76212. var refinedT = t;
  76213. for (var i = 0; i < 5; i++) {
  76214. var refinedT2 = refinedT * refinedT;
  76215. var refinedT3 = refinedT2 * refinedT;
  76216. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  76217. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  76218. refinedT -= (x - t) * slope;
  76219. refinedT = Math.min(1, Math.max(0, refinedT));
  76220. }
  76221. // Resolve cubic bezier for the given x
  76222. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  76223. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  76224. Math.pow(refinedT, 3);
  76225. };
  76226. return BezierCurve;
  76227. }());
  76228. /**
  76229. * Defines potential orientation for back face culling
  76230. */
  76231. var Orientation;
  76232. (function (Orientation) {
  76233. /**
  76234. * Clockwise
  76235. */
  76236. Orientation[Orientation["CW"] = 0] = "CW";
  76237. /** Counter clockwise */
  76238. Orientation[Orientation["CCW"] = 1] = "CCW";
  76239. })(Orientation || (Orientation = {}));
  76240. /**
  76241. * Defines angle representation
  76242. */
  76243. var Angle = /** @class */ (function () {
  76244. /**
  76245. * Creates an Angle object of "radians" radians (float).
  76246. * @param radians the angle in radians
  76247. */
  76248. function Angle(radians) {
  76249. this._radians = radians;
  76250. if (this._radians < 0.0) {
  76251. this._radians += (2.0 * Math.PI);
  76252. }
  76253. }
  76254. /**
  76255. * Get value in degrees
  76256. * @returns the Angle value in degrees (float)
  76257. */
  76258. Angle.prototype.degrees = function () {
  76259. return this._radians * 180.0 / Math.PI;
  76260. };
  76261. /**
  76262. * Get value in radians
  76263. * @returns the Angle value in radians (float)
  76264. */
  76265. Angle.prototype.radians = function () {
  76266. return this._radians;
  76267. };
  76268. /**
  76269. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  76270. * @param a defines first vector
  76271. * @param b defines second vector
  76272. * @returns a new Angle
  76273. */
  76274. Angle.BetweenTwoPoints = function (a, b) {
  76275. var delta = b.subtract(a);
  76276. var theta = Math.atan2(delta.y, delta.x);
  76277. return new Angle(theta);
  76278. };
  76279. /**
  76280. * Gets a new Angle object from the given float in radians
  76281. * @param radians defines the angle value in radians
  76282. * @returns a new Angle
  76283. */
  76284. Angle.FromRadians = function (radians) {
  76285. return new Angle(radians);
  76286. };
  76287. /**
  76288. * Gets a new Angle object from the given float in degrees
  76289. * @param degrees defines the angle value in degrees
  76290. * @returns a new Angle
  76291. */
  76292. Angle.FromDegrees = function (degrees) {
  76293. return new Angle(degrees * Math.PI / 180.0);
  76294. };
  76295. return Angle;
  76296. }());
  76297. /**
  76298. * This represents an arc in a 2d space.
  76299. */
  76300. var Arc2 = /** @class */ (function () {
  76301. /**
  76302. * Creates an Arc object from the three given points : start, middle and end.
  76303. * @param startPoint Defines the start point of the arc
  76304. * @param midPoint Defines the midlle point of the arc
  76305. * @param endPoint Defines the end point of the arc
  76306. */
  76307. function Arc2(
  76308. /** Defines the start point of the arc */
  76309. startPoint,
  76310. /** Defines the mid point of the arc */
  76311. midPoint,
  76312. /** Defines the end point of the arc */
  76313. endPoint) {
  76314. this.startPoint = startPoint;
  76315. this.midPoint = midPoint;
  76316. this.endPoint = endPoint;
  76317. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  76318. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  76319. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  76320. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  76321. 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);
  76322. this.radius = this.centerPoint.subtract(this.startPoint).length();
  76323. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  76324. var a1 = this.startAngle.degrees();
  76325. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  76326. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  76327. // angles correction
  76328. if (a2 - a1 > +180.0) {
  76329. a2 -= 360.0;
  76330. }
  76331. if (a2 - a1 < -180.0) {
  76332. a2 += 360.0;
  76333. }
  76334. if (a3 - a2 > +180.0) {
  76335. a3 -= 360.0;
  76336. }
  76337. if (a3 - a2 < -180.0) {
  76338. a3 += 360.0;
  76339. }
  76340. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  76341. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  76342. }
  76343. return Arc2;
  76344. }());
  76345. /**
  76346. * Represents a 2D path made up of multiple 2D points
  76347. */
  76348. var Path2 = /** @class */ (function () {
  76349. /**
  76350. * Creates a Path2 object from the starting 2D coordinates x and y.
  76351. * @param x the starting points x value
  76352. * @param y the starting points y value
  76353. */
  76354. function Path2(x, y) {
  76355. this._points = new Array();
  76356. this._length = 0.0;
  76357. /**
  76358. * If the path start and end point are the same
  76359. */
  76360. this.closed = false;
  76361. this._points.push(new Vector2(x, y));
  76362. }
  76363. /**
  76364. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  76365. * @param x the added points x value
  76366. * @param y the added points y value
  76367. * @returns the updated Path2.
  76368. */
  76369. Path2.prototype.addLineTo = function (x, y) {
  76370. if (this.closed) {
  76371. return this;
  76372. }
  76373. var newPoint = new Vector2(x, y);
  76374. var previousPoint = this._points[this._points.length - 1];
  76375. this._points.push(newPoint);
  76376. this._length += newPoint.subtract(previousPoint).length();
  76377. return this;
  76378. };
  76379. /**
  76380. * 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.
  76381. * @param midX middle point x value
  76382. * @param midY middle point y value
  76383. * @param endX end point x value
  76384. * @param endY end point y value
  76385. * @param numberOfSegments (default: 36)
  76386. * @returns the updated Path2.
  76387. */
  76388. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  76389. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  76390. if (this.closed) {
  76391. return this;
  76392. }
  76393. var startPoint = this._points[this._points.length - 1];
  76394. var midPoint = new Vector2(midX, midY);
  76395. var endPoint = new Vector2(endX, endY);
  76396. var arc = new Arc2(startPoint, midPoint, endPoint);
  76397. var increment = arc.angle.radians() / numberOfSegments;
  76398. if (arc.orientation === Orientation.CW) {
  76399. increment *= -1;
  76400. }
  76401. var currentAngle = arc.startAngle.radians() + increment;
  76402. for (var i = 0; i < numberOfSegments; i++) {
  76403. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  76404. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  76405. this.addLineTo(x, y);
  76406. currentAngle += increment;
  76407. }
  76408. return this;
  76409. };
  76410. /**
  76411. * Closes the Path2.
  76412. * @returns the Path2.
  76413. */
  76414. Path2.prototype.close = function () {
  76415. this.closed = true;
  76416. return this;
  76417. };
  76418. /**
  76419. * Gets the sum of the distance between each sequential point in the path
  76420. * @returns the Path2 total length (float).
  76421. */
  76422. Path2.prototype.length = function () {
  76423. var result = this._length;
  76424. if (!this.closed) {
  76425. var lastPoint = this._points[this._points.length - 1];
  76426. var firstPoint = this._points[0];
  76427. result += (firstPoint.subtract(lastPoint).length());
  76428. }
  76429. return result;
  76430. };
  76431. /**
  76432. * Gets the points which construct the path
  76433. * @returns the Path2 internal array of points.
  76434. */
  76435. Path2.prototype.getPoints = function () {
  76436. return this._points;
  76437. };
  76438. /**
  76439. * Retreives the point at the distance aways from the starting point
  76440. * @param normalizedLengthPosition the length along the path to retreive the point from
  76441. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  76442. */
  76443. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  76444. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  76445. return Vector2.Zero();
  76446. }
  76447. var lengthPosition = normalizedLengthPosition * this.length();
  76448. var previousOffset = 0;
  76449. for (var i = 0; i < this._points.length; i++) {
  76450. var j = (i + 1) % this._points.length;
  76451. var a = this._points[i];
  76452. var b = this._points[j];
  76453. var bToA = b.subtract(a);
  76454. var nextOffset = (bToA.length() + previousOffset);
  76455. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  76456. var dir = bToA.normalize();
  76457. var localOffset = lengthPosition - previousOffset;
  76458. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  76459. }
  76460. previousOffset = nextOffset;
  76461. }
  76462. return Vector2.Zero();
  76463. };
  76464. /**
  76465. * Creates a new path starting from an x and y position
  76466. * @param x starting x value
  76467. * @param y starting y value
  76468. * @returns a new Path2 starting at the coordinates (x, y).
  76469. */
  76470. Path2.StartingAt = function (x, y) {
  76471. return new Path2(x, y);
  76472. };
  76473. return Path2;
  76474. }());
  76475. /**
  76476. * Represents a 3D path made up of multiple 3D points
  76477. */
  76478. var Path3D = /** @class */ (function () {
  76479. /**
  76480. * new Path3D(path, normal, raw)
  76481. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  76482. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  76483. * @param path an array of Vector3, the curve axis of the Path3D
  76484. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  76485. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  76486. */
  76487. function Path3D(
  76488. /**
  76489. * an array of Vector3, the curve axis of the Path3D
  76490. */
  76491. path, firstNormal, raw) {
  76492. if (firstNormal === void 0) { firstNormal = null; }
  76493. this.path = path;
  76494. this._curve = new Array();
  76495. this._distances = new Array();
  76496. this._tangents = new Array();
  76497. this._normals = new Array();
  76498. this._binormals = new Array();
  76499. for (var p = 0; p < path.length; p++) {
  76500. this._curve[p] = path[p].clone(); // hard copy
  76501. }
  76502. this._raw = raw || false;
  76503. this._compute(firstNormal);
  76504. }
  76505. /**
  76506. * Returns the Path3D array of successive Vector3 designing its curve.
  76507. * @returns the Path3D array of successive Vector3 designing its curve.
  76508. */
  76509. Path3D.prototype.getCurve = function () {
  76510. return this._curve;
  76511. };
  76512. /**
  76513. * Returns an array populated with tangent vectors on each Path3D curve point.
  76514. * @returns an array populated with tangent vectors on each Path3D curve point.
  76515. */
  76516. Path3D.prototype.getTangents = function () {
  76517. return this._tangents;
  76518. };
  76519. /**
  76520. * Returns an array populated with normal vectors on each Path3D curve point.
  76521. * @returns an array populated with normal vectors on each Path3D curve point.
  76522. */
  76523. Path3D.prototype.getNormals = function () {
  76524. return this._normals;
  76525. };
  76526. /**
  76527. * Returns an array populated with binormal vectors on each Path3D curve point.
  76528. * @returns an array populated with binormal vectors on each Path3D curve point.
  76529. */
  76530. Path3D.prototype.getBinormals = function () {
  76531. return this._binormals;
  76532. };
  76533. /**
  76534. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  76535. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  76536. */
  76537. Path3D.prototype.getDistances = function () {
  76538. return this._distances;
  76539. };
  76540. /**
  76541. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  76542. * @param path path which all values are copied into the curves points
  76543. * @param firstNormal which should be projected onto the curve
  76544. * @returns the same object updated.
  76545. */
  76546. Path3D.prototype.update = function (path, firstNormal) {
  76547. if (firstNormal === void 0) { firstNormal = null; }
  76548. for (var p = 0; p < path.length; p++) {
  76549. this._curve[p].x = path[p].x;
  76550. this._curve[p].y = path[p].y;
  76551. this._curve[p].z = path[p].z;
  76552. }
  76553. this._compute(firstNormal);
  76554. return this;
  76555. };
  76556. // private function compute() : computes tangents, normals and binormals
  76557. Path3D.prototype._compute = function (firstNormal) {
  76558. var l = this._curve.length;
  76559. // first and last tangents
  76560. this._tangents[0] = this._getFirstNonNullVector(0);
  76561. if (!this._raw) {
  76562. this._tangents[0].normalize();
  76563. }
  76564. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  76565. if (!this._raw) {
  76566. this._tangents[l - 1].normalize();
  76567. }
  76568. // normals and binormals at first point : arbitrary vector with _normalVector()
  76569. var tg0 = this._tangents[0];
  76570. var pp0 = this._normalVector(tg0, firstNormal);
  76571. this._normals[0] = pp0;
  76572. if (!this._raw) {
  76573. this._normals[0].normalize();
  76574. }
  76575. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  76576. if (!this._raw) {
  76577. this._binormals[0].normalize();
  76578. }
  76579. this._distances[0] = 0.0;
  76580. // normals and binormals : next points
  76581. var prev; // previous vector (segment)
  76582. var cur; // current vector (segment)
  76583. var curTang; // current tangent
  76584. // previous normal
  76585. var prevBinor; // previous binormal
  76586. for (var i = 1; i < l; i++) {
  76587. // tangents
  76588. prev = this._getLastNonNullVector(i);
  76589. if (i < l - 1) {
  76590. cur = this._getFirstNonNullVector(i);
  76591. this._tangents[i] = prev.add(cur);
  76592. this._tangents[i].normalize();
  76593. }
  76594. this._distances[i] = this._distances[i - 1] + prev.length();
  76595. // normals and binormals
  76596. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  76597. curTang = this._tangents[i];
  76598. prevBinor = this._binormals[i - 1];
  76599. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  76600. if (!this._raw) {
  76601. this._normals[i].normalize();
  76602. }
  76603. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  76604. if (!this._raw) {
  76605. this._binormals[i].normalize();
  76606. }
  76607. }
  76608. };
  76609. // private function getFirstNonNullVector(index)
  76610. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  76611. Path3D.prototype._getFirstNonNullVector = function (index) {
  76612. var i = 1;
  76613. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  76614. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  76615. i++;
  76616. nNVector = this._curve[index + i].subtract(this._curve[index]);
  76617. }
  76618. return nNVector;
  76619. };
  76620. // private function getLastNonNullVector(index)
  76621. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  76622. Path3D.prototype._getLastNonNullVector = function (index) {
  76623. var i = 1;
  76624. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  76625. while (nLVector.length() === 0 && index > i + 1) {
  76626. i++;
  76627. nLVector = this._curve[index].subtract(this._curve[index - i]);
  76628. }
  76629. return nLVector;
  76630. };
  76631. // private function normalVector(v0, vt, va) :
  76632. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  76633. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  76634. Path3D.prototype._normalVector = function (vt, va) {
  76635. var normal0;
  76636. var tgl = vt.length();
  76637. if (tgl === 0.0) {
  76638. tgl = 1.0;
  76639. }
  76640. if (va === undefined || va === null) {
  76641. var point;
  76642. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  76643. point = new Vector3(0.0, -1.0, 0.0);
  76644. }
  76645. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  76646. point = new Vector3(1.0, 0.0, 0.0);
  76647. }
  76648. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  76649. point = new Vector3(0.0, 0.0, 1.0);
  76650. }
  76651. else {
  76652. point = Vector3.Zero();
  76653. }
  76654. normal0 = Vector3.Cross(vt, point);
  76655. }
  76656. else {
  76657. normal0 = Vector3.Cross(vt, va);
  76658. Vector3.CrossToRef(normal0, vt, normal0);
  76659. }
  76660. normal0.normalize();
  76661. return normal0;
  76662. };
  76663. return Path3D;
  76664. }());
  76665. /**
  76666. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76667. * A Curve3 is designed from a series of successive Vector3.
  76668. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  76669. */
  76670. var Curve3 = /** @class */ (function () {
  76671. /**
  76672. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76673. * A Curve3 is designed from a series of successive Vector3.
  76674. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  76675. * @param points points which make up the curve
  76676. */
  76677. function Curve3(points) {
  76678. this._length = 0.0;
  76679. this._points = points;
  76680. this._length = this._computeLength(points);
  76681. }
  76682. /**
  76683. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  76684. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  76685. * @param v1 (Vector3) the control point
  76686. * @param v2 (Vector3) the end point of the Quadratic Bezier
  76687. * @param nbPoints (integer) the wanted number of points in the curve
  76688. * @returns the created Curve3
  76689. */
  76690. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  76691. nbPoints = nbPoints > 2 ? nbPoints : 3;
  76692. var bez = new Array();
  76693. var equation = function (t, val0, val1, val2) {
  76694. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  76695. return res;
  76696. };
  76697. for (var i = 0; i <= nbPoints; i++) {
  76698. 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)));
  76699. }
  76700. return new Curve3(bez);
  76701. };
  76702. /**
  76703. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  76704. * @param v0 (Vector3) the origin point of the Cubic Bezier
  76705. * @param v1 (Vector3) the first control point
  76706. * @param v2 (Vector3) the second control point
  76707. * @param v3 (Vector3) the end point of the Cubic Bezier
  76708. * @param nbPoints (integer) the wanted number of points in the curve
  76709. * @returns the created Curve3
  76710. */
  76711. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  76712. nbPoints = nbPoints > 3 ? nbPoints : 4;
  76713. var bez = new Array();
  76714. var equation = function (t, val0, val1, val2, val3) {
  76715. 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;
  76716. return res;
  76717. };
  76718. for (var i = 0; i <= nbPoints; i++) {
  76719. 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)));
  76720. }
  76721. return new Curve3(bez);
  76722. };
  76723. /**
  76724. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  76725. * @param p1 (Vector3) the origin point of the Hermite Spline
  76726. * @param t1 (Vector3) the tangent vector at the origin point
  76727. * @param p2 (Vector3) the end point of the Hermite Spline
  76728. * @param t2 (Vector3) the tangent vector at the end point
  76729. * @param nbPoints (integer) the wanted number of points in the curve
  76730. * @returns the created Curve3
  76731. */
  76732. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  76733. var hermite = new Array();
  76734. var step = 1.0 / nbPoints;
  76735. for (var i = 0; i <= nbPoints; i++) {
  76736. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  76737. }
  76738. return new Curve3(hermite);
  76739. };
  76740. /**
  76741. * Returns a Curve3 object along a CatmullRom Spline curve :
  76742. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  76743. * @param nbPoints (integer) the wanted number of points between each curve control points
  76744. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  76745. * @returns the created Curve3
  76746. */
  76747. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  76748. var catmullRom = new Array();
  76749. var step = 1.0 / nbPoints;
  76750. var amount = 0.0;
  76751. if (closed) {
  76752. var pointsCount = points.length;
  76753. for (var i = 0; i < pointsCount; i++) {
  76754. amount = 0;
  76755. for (var c = 0; c < nbPoints; c++) {
  76756. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  76757. amount += step;
  76758. }
  76759. }
  76760. catmullRom.push(catmullRom[0]);
  76761. }
  76762. else {
  76763. var totalPoints = new Array();
  76764. totalPoints.push(points[0].clone());
  76765. Array.prototype.push.apply(totalPoints, points);
  76766. totalPoints.push(points[points.length - 1].clone());
  76767. for (var i = 0; i < totalPoints.length - 3; i++) {
  76768. amount = 0;
  76769. for (var c = 0; c < nbPoints; c++) {
  76770. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  76771. amount += step;
  76772. }
  76773. }
  76774. i--;
  76775. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  76776. }
  76777. return new Curve3(catmullRom);
  76778. };
  76779. /**
  76780. * @returns the Curve3 stored array of successive Vector3
  76781. */
  76782. Curve3.prototype.getPoints = function () {
  76783. return this._points;
  76784. };
  76785. /**
  76786. * @returns the computed length (float) of the curve.
  76787. */
  76788. Curve3.prototype.length = function () {
  76789. return this._length;
  76790. };
  76791. /**
  76792. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  76793. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  76794. * curveA and curveB keep unchanged.
  76795. * @param curve the curve to continue from this curve
  76796. * @returns the newly constructed curve
  76797. */
  76798. Curve3.prototype.continue = function (curve) {
  76799. var lastPoint = this._points[this._points.length - 1];
  76800. var continuedPoints = this._points.slice();
  76801. var curvePoints = curve.getPoints();
  76802. for (var i = 1; i < curvePoints.length; i++) {
  76803. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  76804. }
  76805. var continuedCurve = new Curve3(continuedPoints);
  76806. return continuedCurve;
  76807. };
  76808. Curve3.prototype._computeLength = function (path) {
  76809. var l = 0;
  76810. for (var i = 1; i < path.length; i++) {
  76811. l += (path[i].subtract(path[i - 1])).length();
  76812. }
  76813. return l;
  76814. };
  76815. return Curve3;
  76816. }());
  76817. // Vertex formats
  76818. /**
  76819. * Contains position and normal vectors for a vertex
  76820. */
  76821. var PositionNormalVertex = /** @class */ (function () {
  76822. /**
  76823. * Creates a PositionNormalVertex
  76824. * @param position the position of the vertex (defaut: 0,0,0)
  76825. * @param normal the normal of the vertex (defaut: 0,1,0)
  76826. */
  76827. function PositionNormalVertex(
  76828. /** the position of the vertex (defaut: 0,0,0) */
  76829. position,
  76830. /** the normal of the vertex (defaut: 0,1,0) */
  76831. normal) {
  76832. if (position === void 0) { position = Vector3.Zero(); }
  76833. if (normal === void 0) { normal = Vector3.Up(); }
  76834. this.position = position;
  76835. this.normal = normal;
  76836. }
  76837. /**
  76838. * Clones the PositionNormalVertex
  76839. * @returns the cloned PositionNormalVertex
  76840. */
  76841. PositionNormalVertex.prototype.clone = function () {
  76842. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  76843. };
  76844. return PositionNormalVertex;
  76845. }());
  76846. /**
  76847. * Contains position, normal and uv vectors for a vertex
  76848. */
  76849. var PositionNormalTextureVertex = /** @class */ (function () {
  76850. /**
  76851. * Creates a PositionNormalTextureVertex
  76852. * @param position the position of the vertex (defaut: 0,0,0)
  76853. * @param normal the normal of the vertex (defaut: 0,1,0)
  76854. * @param uv the uv of the vertex (default: 0,0)
  76855. */
  76856. function PositionNormalTextureVertex(
  76857. /** the position of the vertex (defaut: 0,0,0) */
  76858. position,
  76859. /** the normal of the vertex (defaut: 0,1,0) */
  76860. normal,
  76861. /** the uv of the vertex (default: 0,0) */
  76862. uv) {
  76863. if (position === void 0) { position = Vector3.Zero(); }
  76864. if (normal === void 0) { normal = Vector3.Up(); }
  76865. if (uv === void 0) { uv = Vector2.Zero(); }
  76866. this.position = position;
  76867. this.normal = normal;
  76868. this.uv = uv;
  76869. }
  76870. /**
  76871. * Clones the PositionNormalTextureVertex
  76872. * @returns the cloned PositionNormalTextureVertex
  76873. */
  76874. PositionNormalTextureVertex.prototype.clone = function () {
  76875. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  76876. };
  76877. return PositionNormalTextureVertex;
  76878. }());
  76879. // Temporary pre-allocated objects for engine internal use
  76880. // usage in any internal function :
  76881. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  76882. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  76883. /**
  76884. * @hidden
  76885. */
  76886. var Tmp = /** @class */ (function () {
  76887. function Tmp() {
  76888. }
  76889. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  76890. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  76891. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  76892. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  76893. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  76894. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  76895. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  76896. return Tmp;
  76897. }());
  76898. /**
  76899. * @hidden
  76900. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  76901. */
  76902. var MathTmp = /** @class */ (function () {
  76903. function MathTmp() {
  76904. }
  76905. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  76906. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  76907. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  76908. return MathTmp;
  76909. }());
  76910. /***/ }),
  76911. /***/ "./Maths/sphericalPolynomial.ts":
  76912. /*!**************************************!*\
  76913. !*** ./Maths/sphericalPolynomial.ts ***!
  76914. \**************************************/
  76915. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  76916. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76917. "use strict";
  76918. __webpack_require__.r(__webpack_exports__);
  76919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  76920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  76921. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  76922. /**
  76923. * Class representing spherical polynomial coefficients to the 3rd degree
  76924. */
  76925. var SphericalPolynomial = /** @class */ (function () {
  76926. function SphericalPolynomial() {
  76927. /**
  76928. * The x coefficients of the spherical polynomial
  76929. */
  76930. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76931. /**
  76932. * The y coefficients of the spherical polynomial
  76933. */
  76934. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76935. /**
  76936. * The z coefficients of the spherical polynomial
  76937. */
  76938. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76939. /**
  76940. * The xx coefficients of the spherical polynomial
  76941. */
  76942. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76943. /**
  76944. * The yy coefficients of the spherical polynomial
  76945. */
  76946. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76947. /**
  76948. * The zz coefficients of the spherical polynomial
  76949. */
  76950. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76951. /**
  76952. * The xy coefficients of the spherical polynomial
  76953. */
  76954. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76955. /**
  76956. * The yz coefficients of the spherical polynomial
  76957. */
  76958. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76959. /**
  76960. * The zx coefficients of the spherical polynomial
  76961. */
  76962. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76963. }
  76964. /**
  76965. * Adds an ambient color to the spherical polynomial
  76966. * @param color the color to add
  76967. */
  76968. SphericalPolynomial.prototype.addAmbient = function (color) {
  76969. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  76970. this.xx = this.xx.add(colorVector);
  76971. this.yy = this.yy.add(colorVector);
  76972. this.zz = this.zz.add(colorVector);
  76973. };
  76974. /**
  76975. * Scales the spherical polynomial by the given amount
  76976. * @param scale the amount to scale
  76977. */
  76978. SphericalPolynomial.prototype.scale = function (scale) {
  76979. this.x = this.x.scale(scale);
  76980. this.y = this.y.scale(scale);
  76981. this.z = this.z.scale(scale);
  76982. this.xx = this.xx.scale(scale);
  76983. this.yy = this.yy.scale(scale);
  76984. this.zz = this.zz.scale(scale);
  76985. this.yz = this.yz.scale(scale);
  76986. this.zx = this.zx.scale(scale);
  76987. this.xy = this.xy.scale(scale);
  76988. };
  76989. /**
  76990. * Gets the spherical polynomial from harmonics
  76991. * @param harmonics the spherical harmonics
  76992. * @returns the spherical polynomial
  76993. */
  76994. SphericalPolynomial.FromHarmonics = function (harmonics) {
  76995. var result = new SphericalPolynomial();
  76996. result.x = harmonics.l11.scale(1.02333);
  76997. result.y = harmonics.l1_1.scale(1.02333);
  76998. result.z = harmonics.l10.scale(1.02333);
  76999. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  77000. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  77001. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  77002. result.yz = harmonics.l2_1.scale(0.858086);
  77003. result.zx = harmonics.l21.scale(0.858086);
  77004. result.xy = harmonics.l2_2.scale(0.858086);
  77005. result.scale(1.0 / Math.PI);
  77006. return result;
  77007. };
  77008. /**
  77009. * Constructs a spherical polynomial from an array.
  77010. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  77011. * @returns the spherical polynomial
  77012. */
  77013. SphericalPolynomial.FromArray = function (data) {
  77014. var sp = new SphericalPolynomial();
  77015. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  77016. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  77017. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  77018. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  77019. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  77020. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  77021. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  77022. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  77023. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  77024. return sp;
  77025. };
  77026. return SphericalPolynomial;
  77027. }());
  77028. /**
  77029. * Class representing spherical harmonics coefficients to the 3rd degree
  77030. */
  77031. var SphericalHarmonics = /** @class */ (function () {
  77032. function SphericalHarmonics() {
  77033. /**
  77034. * The l0,0 coefficients of the spherical harmonics
  77035. */
  77036. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77037. /**
  77038. * The l1,-1 coefficients of the spherical harmonics
  77039. */
  77040. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77041. /**
  77042. * The l1,0 coefficients of the spherical harmonics
  77043. */
  77044. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77045. /**
  77046. * The l1,1 coefficients of the spherical harmonics
  77047. */
  77048. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77049. /**
  77050. * The l2,-2 coefficients of the spherical harmonics
  77051. */
  77052. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77053. /**
  77054. * The l2,-1 coefficients of the spherical harmonics
  77055. */
  77056. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77057. /**
  77058. * The l2,0 coefficients of the spherical harmonics
  77059. */
  77060. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77061. /**
  77062. * The l2,1 coefficients of the spherical harmonics
  77063. */
  77064. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77065. /**
  77066. * The l2,2 coefficients of the spherical harmonics
  77067. */
  77068. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77069. }
  77070. /**
  77071. * Adds a light to the spherical harmonics
  77072. * @param direction the direction of the light
  77073. * @param color the color of the light
  77074. * @param deltaSolidAngle the delta solid angle of the light
  77075. */
  77076. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  77077. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  77078. var c = colorVector.scale(deltaSolidAngle);
  77079. this.l00 = this.l00.add(c.scale(0.282095));
  77080. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  77081. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  77082. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  77083. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  77084. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  77085. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  77086. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  77087. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  77088. };
  77089. /**
  77090. * Scales the spherical harmonics by the given amount
  77091. * @param scale the amount to scale
  77092. */
  77093. SphericalHarmonics.prototype.scale = function (scale) {
  77094. this.l00 = this.l00.scale(scale);
  77095. this.l1_1 = this.l1_1.scale(scale);
  77096. this.l10 = this.l10.scale(scale);
  77097. this.l11 = this.l11.scale(scale);
  77098. this.l2_2 = this.l2_2.scale(scale);
  77099. this.l2_1 = this.l2_1.scale(scale);
  77100. this.l20 = this.l20.scale(scale);
  77101. this.l21 = this.l21.scale(scale);
  77102. this.lL22 = this.lL22.scale(scale);
  77103. };
  77104. /**
  77105. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  77106. *
  77107. * ```
  77108. * E_lm = A_l * L_lm
  77109. * ```
  77110. *
  77111. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  77112. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  77113. * the scaling factors are given in equation 9.
  77114. */
  77115. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  77116. // Constant (Band 0)
  77117. this.l00 = this.l00.scale(3.141593);
  77118. // Linear (Band 1)
  77119. this.l1_1 = this.l1_1.scale(2.094395);
  77120. this.l10 = this.l10.scale(2.094395);
  77121. this.l11 = this.l11.scale(2.094395);
  77122. // Quadratic (Band 2)
  77123. this.l2_2 = this.l2_2.scale(0.785398);
  77124. this.l2_1 = this.l2_1.scale(0.785398);
  77125. this.l20 = this.l20.scale(0.785398);
  77126. this.l21 = this.l21.scale(0.785398);
  77127. this.lL22 = this.lL22.scale(0.785398);
  77128. };
  77129. /**
  77130. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  77131. *
  77132. * ```
  77133. * L = (1/pi) * E * rho
  77134. * ```
  77135. *
  77136. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  77137. */
  77138. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  77139. this.scale(1.0 / Math.PI);
  77140. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  77141. // (The pixel shader must apply albedo after texture fetches, etc).
  77142. };
  77143. /**
  77144. * Gets the spherical harmonics from polynomial
  77145. * @param polynomial the spherical polynomial
  77146. * @returns the spherical harmonics
  77147. */
  77148. SphericalHarmonics.FromPolynomial = function (polynomial) {
  77149. var result = new SphericalHarmonics();
  77150. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  77151. result.l1_1 = polynomial.y.scale(0.977204);
  77152. result.l10 = polynomial.z.scale(0.977204);
  77153. result.l11 = polynomial.x.scale(0.977204);
  77154. result.l2_2 = polynomial.xy.scale(1.16538);
  77155. result.l2_1 = polynomial.yz.scale(1.16538);
  77156. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  77157. result.l21 = polynomial.zx.scale(1.16538);
  77158. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  77159. result.scale(Math.PI);
  77160. return result;
  77161. };
  77162. /**
  77163. * Constructs a spherical harmonics from an array.
  77164. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  77165. * @returns the spherical harmonics
  77166. */
  77167. SphericalHarmonics.FromArray = function (data) {
  77168. var sh = new SphericalHarmonics();
  77169. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  77170. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  77171. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  77172. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  77173. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  77174. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  77175. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  77176. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  77177. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  77178. return sh;
  77179. };
  77180. return SphericalHarmonics;
  77181. }());
  77182. /***/ }),
  77183. /***/ "./Meshes/Builders/boxBuilder.ts":
  77184. /*!***************************************!*\
  77185. !*** ./Meshes/Builders/boxBuilder.ts ***!
  77186. \***************************************/
  77187. /*! exports provided: BoxBuilder */
  77188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77189. "use strict";
  77190. __webpack_require__.r(__webpack_exports__);
  77191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  77192. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77193. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77194. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77195. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  77196. var normalsSource = [
  77197. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  77198. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  77199. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  77200. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  77201. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  77202. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  77203. ];
  77204. var indices = [];
  77205. var positions = [];
  77206. var normals = [];
  77207. var uvs = [];
  77208. var width = options.width || options.size || 1;
  77209. var height = options.height || options.size || 1;
  77210. var depth = options.depth || options.size || 1;
  77211. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77212. var faceUV = options.faceUV || new Array(6);
  77213. var faceColors = options.faceColors;
  77214. var colors = [];
  77215. // default face colors and UV if undefined
  77216. for (var f = 0; f < 6; f++) {
  77217. if (faceUV[f] === undefined) {
  77218. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  77219. }
  77220. if (faceColors && faceColors[f] === undefined) {
  77221. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  77222. }
  77223. }
  77224. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  77225. // Create each face in turn.
  77226. for (var index = 0; index < normalsSource.length; index++) {
  77227. var normal = normalsSource[index];
  77228. // Get two vectors perpendicular to the face normal and to each other.
  77229. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  77230. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  77231. // Six indices (two triangles) per face.
  77232. var verticesLength = positions.length / 3;
  77233. indices.push(verticesLength);
  77234. indices.push(verticesLength + 1);
  77235. indices.push(verticesLength + 2);
  77236. indices.push(verticesLength);
  77237. indices.push(verticesLength + 2);
  77238. indices.push(verticesLength + 3);
  77239. // Four vertices per face.
  77240. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  77241. positions.push(vertex.x, vertex.y, vertex.z);
  77242. normals.push(normal.x, normal.y, normal.z);
  77243. uvs.push(faceUV[index].z, faceUV[index].w);
  77244. if (faceColors) {
  77245. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  77246. }
  77247. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  77248. positions.push(vertex.x, vertex.y, vertex.z);
  77249. normals.push(normal.x, normal.y, normal.z);
  77250. uvs.push(faceUV[index].x, faceUV[index].w);
  77251. if (faceColors) {
  77252. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  77253. }
  77254. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  77255. positions.push(vertex.x, vertex.y, vertex.z);
  77256. normals.push(normal.x, normal.y, normal.z);
  77257. uvs.push(faceUV[index].x, faceUV[index].y);
  77258. if (faceColors) {
  77259. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  77260. }
  77261. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  77262. positions.push(vertex.x, vertex.y, vertex.z);
  77263. normals.push(normal.x, normal.y, normal.z);
  77264. uvs.push(faceUV[index].z, faceUV[index].y);
  77265. if (faceColors) {
  77266. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  77267. }
  77268. }
  77269. // sides
  77270. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77271. // Result
  77272. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77273. vertexData.indices = indices;
  77274. vertexData.positions = positions;
  77275. vertexData.normals = normals;
  77276. vertexData.uvs = uvs;
  77277. if (faceColors) {
  77278. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  77279. vertexData.colors = totalColors;
  77280. }
  77281. return vertexData;
  77282. };
  77283. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  77284. if (scene === void 0) { scene = null; }
  77285. var options = {
  77286. size: size,
  77287. sideOrientation: sideOrientation,
  77288. updatable: updatable
  77289. };
  77290. return BoxBuilder.CreateBox(name, options, scene);
  77291. };
  77292. /**
  77293. * Class containing static functions to help procedurally build meshes
  77294. */
  77295. var BoxBuilder = /** @class */ (function () {
  77296. function BoxBuilder() {
  77297. }
  77298. /**
  77299. * Creates a box mesh
  77300. * * The parameter `size` sets the size (float) of each box side (default 1)
  77301. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  77302. * * 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)
  77303. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  77304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77305. * * 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
  77306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77307. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  77308. * @param name defines the name of the mesh
  77309. * @param options defines the options used to create the mesh
  77310. * @param scene defines the hosting scene
  77311. * @returns the box mesh
  77312. */
  77313. BoxBuilder.CreateBox = function (name, options, scene) {
  77314. if (scene === void 0) { scene = null; }
  77315. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77316. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77317. box._originalBuilderSideOrientation = options.sideOrientation;
  77318. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  77319. vertexData.applyToMesh(box, options.updatable);
  77320. return box;
  77321. };
  77322. return BoxBuilder;
  77323. }());
  77324. /***/ }),
  77325. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  77326. /*!********************************************!*\
  77327. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  77328. \********************************************/
  77329. /*! exports provided: CylinderBuilder */
  77330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77331. "use strict";
  77332. __webpack_require__.r(__webpack_exports__);
  77333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  77334. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77335. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77336. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77337. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  77338. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  77339. var height = options.height || 2;
  77340. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  77341. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  77342. var tessellation = options.tessellation || 24;
  77343. var subdivisions = options.subdivisions || 1;
  77344. var hasRings = options.hasRings ? true : false;
  77345. var enclose = options.enclose ? true : false;
  77346. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77347. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77348. var faceUV = options.faceUV || new Array(3);
  77349. var faceColors = options.faceColors;
  77350. // default face colors and UV if undefined
  77351. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  77352. var ringNb = (hasRings) ? subdivisions : 1;
  77353. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  77354. var f;
  77355. for (f = 0; f < surfaceNb; f++) {
  77356. if (faceColors && faceColors[f] === undefined) {
  77357. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  77358. }
  77359. }
  77360. for (f = 0; f < surfaceNb; f++) {
  77361. if (faceUV && faceUV[f] === undefined) {
  77362. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  77363. }
  77364. }
  77365. var indices = new Array();
  77366. var positions = new Array();
  77367. var normals = new Array();
  77368. var uvs = new Array();
  77369. var colors = new Array();
  77370. var angle_step = Math.PI * 2 * arc / tessellation;
  77371. var angle;
  77372. var h;
  77373. var radius;
  77374. var tan = (diameterBottom - diameterTop) / 2 / height;
  77375. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77376. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77377. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77378. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77379. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77380. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  77381. // positions, normals, uvs
  77382. var i;
  77383. var j;
  77384. var r;
  77385. var ringIdx = 1;
  77386. var s = 1; // surface index
  77387. var cs = 0;
  77388. var v = 0;
  77389. for (i = 0; i <= subdivisions; i++) {
  77390. h = i / subdivisions;
  77391. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  77392. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  77393. for (r = 0; r < ringIdx; r++) {
  77394. if (hasRings) {
  77395. s += r;
  77396. }
  77397. if (enclose) {
  77398. s += 2 * r;
  77399. }
  77400. for (j = 0; j <= tessellation; j++) {
  77401. angle = j * angle_step;
  77402. // position
  77403. ringVertex.x = Math.cos(-angle) * radius;
  77404. ringVertex.y = -height / 2 + h * height;
  77405. ringVertex.z = Math.sin(-angle) * radius;
  77406. // normal
  77407. if (diameterTop === 0 && i === subdivisions) {
  77408. // if no top cap, reuse former normals
  77409. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  77410. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  77411. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  77412. }
  77413. else {
  77414. ringNormal.x = ringVertex.x;
  77415. ringNormal.z = ringVertex.z;
  77416. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  77417. ringNormal.normalize();
  77418. }
  77419. // keep first ring vertex values for enclose
  77420. if (j === 0) {
  77421. ringFirstVertex.copyFrom(ringVertex);
  77422. ringFirstNormal.copyFrom(ringNormal);
  77423. }
  77424. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  77425. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  77426. if (hasRings) {
  77427. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  77428. }
  77429. else {
  77430. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  77431. }
  77432. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  77433. if (faceColors) {
  77434. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  77435. }
  77436. }
  77437. // if enclose, add four vertices and their dedicated normals
  77438. if (arc !== 1 && enclose) {
  77439. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  77440. positions.push(0, ringVertex.y, 0);
  77441. positions.push(0, ringVertex.y, 0);
  77442. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  77443. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  77444. quadNormal.normalize();
  77445. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  77446. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  77447. quadNormal.normalize();
  77448. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  77449. if (hasRings) {
  77450. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  77451. }
  77452. else {
  77453. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  77454. }
  77455. uvs.push(faceUV[s + 1].x, v);
  77456. uvs.push(faceUV[s + 1].z, v);
  77457. if (hasRings) {
  77458. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  77459. }
  77460. else {
  77461. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  77462. }
  77463. uvs.push(faceUV[s + 2].x, v);
  77464. uvs.push(faceUV[s + 2].z, v);
  77465. if (faceColors) {
  77466. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  77467. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  77468. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  77469. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  77470. }
  77471. }
  77472. if (cs !== s) {
  77473. cs = s;
  77474. }
  77475. }
  77476. }
  77477. // indices
  77478. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  77479. var s;
  77480. i = 0;
  77481. for (s = 0; s < subdivisions; s++) {
  77482. var i0 = 0;
  77483. var i1 = 0;
  77484. var i2 = 0;
  77485. var i3 = 0;
  77486. for (j = 0; j < tessellation; j++) {
  77487. i0 = i * (e + 1) + j;
  77488. i1 = (i + 1) * (e + 1) + j;
  77489. i2 = i * (e + 1) + (j + 1);
  77490. i3 = (i + 1) * (e + 1) + (j + 1);
  77491. indices.push(i0, i1, i2);
  77492. indices.push(i3, i2, i1);
  77493. }
  77494. if (arc !== 1 && enclose) { // if enclose, add two quads
  77495. indices.push(i0 + 2, i1 + 2, i2 + 2);
  77496. indices.push(i3 + 2, i2 + 2, i1 + 2);
  77497. indices.push(i0 + 4, i1 + 4, i2 + 4);
  77498. indices.push(i3 + 4, i2 + 4, i1 + 4);
  77499. }
  77500. i = (hasRings) ? (i + 2) : (i + 1);
  77501. }
  77502. // Caps
  77503. var createCylinderCap = function (isTop) {
  77504. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  77505. if (radius === 0) {
  77506. return;
  77507. }
  77508. // Cap positions, normals & uvs
  77509. var angle;
  77510. var circleVector;
  77511. var i;
  77512. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  77513. var c = null;
  77514. if (faceColors) {
  77515. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  77516. }
  77517. // cap center
  77518. var vbase = positions.length / 3;
  77519. var offset = isTop ? height / 2 : -height / 2;
  77520. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  77521. positions.push(center.x, center.y, center.z);
  77522. normals.push(0, isTop ? 1 : -1, 0);
  77523. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  77524. if (c) {
  77525. colors.push(c.r, c.g, c.b, c.a);
  77526. }
  77527. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  77528. for (i = 0; i <= tessellation; i++) {
  77529. angle = Math.PI * 2 * i * arc / tessellation;
  77530. var cos = Math.cos(-angle);
  77531. var sin = Math.sin(-angle);
  77532. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  77533. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  77534. positions.push(circleVector.x, circleVector.y, circleVector.z);
  77535. normals.push(0, isTop ? 1 : -1, 0);
  77536. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  77537. if (c) {
  77538. colors.push(c.r, c.g, c.b, c.a);
  77539. }
  77540. }
  77541. // Cap indices
  77542. for (i = 0; i < tessellation; i++) {
  77543. if (!isTop) {
  77544. indices.push(vbase);
  77545. indices.push(vbase + (i + 1));
  77546. indices.push(vbase + (i + 2));
  77547. }
  77548. else {
  77549. indices.push(vbase);
  77550. indices.push(vbase + (i + 2));
  77551. indices.push(vbase + (i + 1));
  77552. }
  77553. }
  77554. };
  77555. // add caps to geometry
  77556. createCylinderCap(false);
  77557. createCylinderCap(true);
  77558. // Sides
  77559. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77560. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77561. vertexData.indices = indices;
  77562. vertexData.positions = positions;
  77563. vertexData.normals = normals;
  77564. vertexData.uvs = uvs;
  77565. if (faceColors) {
  77566. vertexData.colors = colors;
  77567. }
  77568. return vertexData;
  77569. };
  77570. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  77571. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  77572. if (scene !== undefined) {
  77573. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  77574. updatable = scene;
  77575. }
  77576. scene = subdivisions;
  77577. subdivisions = 1;
  77578. }
  77579. var options = {
  77580. height: height,
  77581. diameterTop: diameterTop,
  77582. diameterBottom: diameterBottom,
  77583. tessellation: tessellation,
  77584. subdivisions: subdivisions,
  77585. sideOrientation: sideOrientation,
  77586. updatable: updatable
  77587. };
  77588. return CylinderBuilder.CreateCylinder(name, options, scene);
  77589. };
  77590. /**
  77591. * Class containing static functions to help procedurally build meshes
  77592. */
  77593. var CylinderBuilder = /** @class */ (function () {
  77594. function CylinderBuilder() {
  77595. }
  77596. /**
  77597. * Creates a cylinder or a cone mesh
  77598. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  77599. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  77600. * * 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.
  77601. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  77602. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  77603. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  77604. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  77605. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  77606. * * 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).
  77607. * * 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
  77608. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  77609. * * 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
  77610. * * 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.
  77611. * * If `enclose` is false, a ring surface is one element.
  77612. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  77613. * * 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
  77614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77615. * * 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
  77616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77617. * @param name defines the name of the mesh
  77618. * @param options defines the options used to create the mesh
  77619. * @param scene defines the hosting scene
  77620. * @returns the cylinder mesh
  77621. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  77622. */
  77623. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  77624. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77625. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77626. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  77627. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  77628. vertexData.applyToMesh(cylinder, options.updatable);
  77629. return cylinder;
  77630. };
  77631. return CylinderBuilder;
  77632. }());
  77633. /***/ }),
  77634. /***/ "./Meshes/Builders/decalBuilder.ts":
  77635. /*!*****************************************!*\
  77636. !*** ./Meshes/Builders/decalBuilder.ts ***!
  77637. \*****************************************/
  77638. /*! exports provided: DecalBuilder */
  77639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77640. "use strict";
  77641. __webpack_require__.r(__webpack_exports__);
  77642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  77643. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77644. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77645. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  77646. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77647. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  77648. var options = {
  77649. position: position,
  77650. normal: normal,
  77651. size: size,
  77652. angle: angle
  77653. };
  77654. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  77655. };
  77656. /**
  77657. * Class containing static functions to help procedurally build meshes
  77658. */
  77659. var DecalBuilder = /** @class */ (function () {
  77660. function DecalBuilder() {
  77661. }
  77662. /**
  77663. * Creates a decal mesh.
  77664. * 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
  77665. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  77666. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  77667. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  77668. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  77669. * @param name defines the name of the mesh
  77670. * @param sourceMesh defines the mesh where the decal must be applied
  77671. * @param options defines the options used to create the mesh
  77672. * @param scene defines the hosting scene
  77673. * @returns the decal mesh
  77674. * @see https://doc.babylonjs.com/how_to/decals
  77675. */
  77676. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  77677. var indices = sourceMesh.getIndices();
  77678. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  77679. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  77680. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77681. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  77682. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  77683. var angle = options.angle || 0;
  77684. // Getting correct rotation
  77685. if (!normal) {
  77686. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  77687. var camera = sourceMesh.getScene().activeCamera;
  77688. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  77689. normal = camera.globalPosition.subtract(cameraWorldTarget);
  77690. }
  77691. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  77692. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  77693. var pitch = Math.atan2(normal.y, len);
  77694. // Matrix
  77695. var decalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRoll(yaw, pitch, angle).multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(position.x, position.y, position.z));
  77696. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  77697. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  77698. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  77699. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  77700. vertexData.indices = [];
  77701. vertexData.positions = [];
  77702. vertexData.normals = [];
  77703. vertexData.uvs = [];
  77704. var currentVertexDataIndex = 0;
  77705. var extractDecalVector3 = function (indexId) {
  77706. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  77707. if (!indices || !positions || !normals) {
  77708. return result;
  77709. }
  77710. var vertexId = indices[indexId];
  77711. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  77712. // Send vector to decal local world
  77713. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  77714. // Get normal
  77715. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  77716. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  77717. return result;
  77718. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  77719. var clip = function (vertices, axis) {
  77720. if (vertices.length === 0) {
  77721. return vertices;
  77722. }
  77723. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  77724. var clipVertices = function (v0, v1) {
  77725. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  77726. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"](_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(v0.position, v1.position, clipFactor), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(v0.normal, v1.normal, clipFactor));
  77727. };
  77728. var result = new Array();
  77729. for (var index = 0; index < vertices.length; index += 3) {
  77730. var v1Out;
  77731. var v2Out;
  77732. var v3Out;
  77733. var total = 0;
  77734. var nV1 = null;
  77735. var nV2 = null;
  77736. var nV3 = null;
  77737. var nV4 = null;
  77738. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  77739. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  77740. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  77741. v1Out = d1 > 0;
  77742. v2Out = d2 > 0;
  77743. v3Out = d3 > 0;
  77744. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  77745. switch (total) {
  77746. case 0:
  77747. result.push(vertices[index]);
  77748. result.push(vertices[index + 1]);
  77749. result.push(vertices[index + 2]);
  77750. break;
  77751. case 1:
  77752. if (v1Out) {
  77753. nV1 = vertices[index + 1];
  77754. nV2 = vertices[index + 2];
  77755. nV3 = clipVertices(vertices[index], nV1);
  77756. nV4 = clipVertices(vertices[index], nV2);
  77757. }
  77758. if (v2Out) {
  77759. nV1 = vertices[index];
  77760. nV2 = vertices[index + 2];
  77761. nV3 = clipVertices(vertices[index + 1], nV1);
  77762. nV4 = clipVertices(vertices[index + 1], nV2);
  77763. result.push(nV3);
  77764. result.push(nV2.clone());
  77765. result.push(nV1.clone());
  77766. result.push(nV2.clone());
  77767. result.push(nV3.clone());
  77768. result.push(nV4);
  77769. break;
  77770. }
  77771. if (v3Out) {
  77772. nV1 = vertices[index];
  77773. nV2 = vertices[index + 1];
  77774. nV3 = clipVertices(vertices[index + 2], nV1);
  77775. nV4 = clipVertices(vertices[index + 2], nV2);
  77776. }
  77777. if (nV1 && nV2 && nV3 && nV4) {
  77778. result.push(nV1.clone());
  77779. result.push(nV2.clone());
  77780. result.push(nV3);
  77781. result.push(nV4);
  77782. result.push(nV3.clone());
  77783. result.push(nV2.clone());
  77784. }
  77785. break;
  77786. case 2:
  77787. if (!v1Out) {
  77788. nV1 = vertices[index].clone();
  77789. nV2 = clipVertices(nV1, vertices[index + 1]);
  77790. nV3 = clipVertices(nV1, vertices[index + 2]);
  77791. result.push(nV1);
  77792. result.push(nV2);
  77793. result.push(nV3);
  77794. }
  77795. if (!v2Out) {
  77796. nV1 = vertices[index + 1].clone();
  77797. nV2 = clipVertices(nV1, vertices[index + 2]);
  77798. nV3 = clipVertices(nV1, vertices[index]);
  77799. result.push(nV1);
  77800. result.push(nV2);
  77801. result.push(nV3);
  77802. }
  77803. if (!v3Out) {
  77804. nV1 = vertices[index + 2].clone();
  77805. nV2 = clipVertices(nV1, vertices[index]);
  77806. nV3 = clipVertices(nV1, vertices[index + 1]);
  77807. result.push(nV1);
  77808. result.push(nV2);
  77809. result.push(nV3);
  77810. }
  77811. break;
  77812. case 3:
  77813. break;
  77814. }
  77815. }
  77816. return result;
  77817. };
  77818. for (var index = 0; index < indices.length; index += 3) {
  77819. var faceVertices = new Array();
  77820. faceVertices.push(extractDecalVector3(index));
  77821. faceVertices.push(extractDecalVector3(index + 1));
  77822. faceVertices.push(extractDecalVector3(index + 2));
  77823. // Clip
  77824. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  77825. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  77826. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  77827. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  77828. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  77829. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  77830. if (faceVertices.length === 0) {
  77831. continue;
  77832. }
  77833. // Add UVs and get back to world
  77834. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  77835. var vertex = faceVertices[vIndex];
  77836. //TODO check for Int32Array | Uint32Array | Uint16Array
  77837. vertexData.indices.push(currentVertexDataIndex);
  77838. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  77839. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  77840. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  77841. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  77842. currentVertexDataIndex++;
  77843. }
  77844. }
  77845. // Return mesh
  77846. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  77847. vertexData.applyToMesh(decal);
  77848. decal.position = position.clone();
  77849. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  77850. return decal;
  77851. };
  77852. return DecalBuilder;
  77853. }());
  77854. /***/ }),
  77855. /***/ "./Meshes/Builders/discBuilder.ts":
  77856. /*!****************************************!*\
  77857. !*** ./Meshes/Builders/discBuilder.ts ***!
  77858. \****************************************/
  77859. /*! exports provided: DiscBuilder */
  77860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77861. "use strict";
  77862. __webpack_require__.r(__webpack_exports__);
  77863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  77864. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77865. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77866. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  77867. var positions = new Array();
  77868. var indices = new Array();
  77869. var normals = new Array();
  77870. var uvs = new Array();
  77871. var radius = options.radius || 0.5;
  77872. var tessellation = options.tessellation || 64;
  77873. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77874. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  77875. // positions and uvs
  77876. positions.push(0, 0, 0); // disc center first
  77877. uvs.push(0.5, 0.5);
  77878. var theta = Math.PI * 2 * arc;
  77879. var step = theta / tessellation;
  77880. for (var a = 0; a < theta; a += step) {
  77881. var x = Math.cos(a);
  77882. var y = Math.sin(a);
  77883. var u = (x + 1) / 2;
  77884. var v = (1 - y) / 2;
  77885. positions.push(radius * x, radius * y, 0);
  77886. uvs.push(u, v);
  77887. }
  77888. if (arc === 1) {
  77889. positions.push(positions[3], positions[4], positions[5]); // close the circle
  77890. uvs.push(uvs[2], uvs[3]);
  77891. }
  77892. //indices
  77893. var vertexNb = positions.length / 3;
  77894. for (var i = 1; i < vertexNb - 1; i++) {
  77895. indices.push(i + 1, 0, i);
  77896. }
  77897. // result
  77898. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  77899. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77900. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  77901. vertexData.indices = indices;
  77902. vertexData.positions = positions;
  77903. vertexData.normals = normals;
  77904. vertexData.uvs = uvs;
  77905. return vertexData;
  77906. };
  77907. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  77908. if (scene === void 0) { scene = null; }
  77909. var options = {
  77910. radius: radius,
  77911. tessellation: tessellation,
  77912. sideOrientation: sideOrientation,
  77913. updatable: updatable
  77914. };
  77915. return DiscBuilder.CreateDisc(name, options, scene);
  77916. };
  77917. /**
  77918. * Class containing static functions to help procedurally build meshes
  77919. */
  77920. var DiscBuilder = /** @class */ (function () {
  77921. function DiscBuilder() {
  77922. }
  77923. /**
  77924. * Creates a plane polygonal mesh. By default, this is a disc
  77925. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  77926. * * 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
  77927. * * 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
  77928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77929. * * 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
  77930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77931. * @param name defines the name of the mesh
  77932. * @param options defines the options used to create the mesh
  77933. * @param scene defines the hosting scene
  77934. * @returns the plane polygonal mesh
  77935. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  77936. */
  77937. DiscBuilder.CreateDisc = function (name, options, scene) {
  77938. if (scene === void 0) { scene = null; }
  77939. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  77940. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77941. disc._originalBuilderSideOrientation = options.sideOrientation;
  77942. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  77943. vertexData.applyToMesh(disc, options.updatable);
  77944. return disc;
  77945. };
  77946. return DiscBuilder;
  77947. }());
  77948. /***/ }),
  77949. /***/ "./Meshes/Builders/groundBuilder.ts":
  77950. /*!******************************************!*\
  77951. !*** ./Meshes/Builders/groundBuilder.ts ***!
  77952. \******************************************/
  77953. /*! exports provided: GroundBuilder */
  77954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77955. "use strict";
  77956. __webpack_require__.r(__webpack_exports__);
  77957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  77958. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77959. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77960. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77961. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  77962. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  77963. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  77964. var indices = [];
  77965. var positions = [];
  77966. var normals = [];
  77967. var uvs = [];
  77968. var row, col;
  77969. var width = options.width || 1;
  77970. var height = options.height || 1;
  77971. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  77972. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  77973. for (row = 0; row <= subdivisionsY; row++) {
  77974. for (col = 0; col <= subdivisionsX; col++) {
  77975. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  77976. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  77977. positions.push(position.x, position.y, position.z);
  77978. normals.push(normal.x, normal.y, normal.z);
  77979. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  77980. }
  77981. }
  77982. for (row = 0; row < subdivisionsY; row++) {
  77983. for (col = 0; col < subdivisionsX; col++) {
  77984. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  77985. indices.push(col + 1 + row * (subdivisionsX + 1));
  77986. indices.push(col + row * (subdivisionsX + 1));
  77987. indices.push(col + (row + 1) * (subdivisionsX + 1));
  77988. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  77989. indices.push(col + row * (subdivisionsX + 1));
  77990. }
  77991. }
  77992. // Result
  77993. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77994. vertexData.indices = indices;
  77995. vertexData.positions = positions;
  77996. vertexData.normals = normals;
  77997. vertexData.uvs = uvs;
  77998. return vertexData;
  77999. };
  78000. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  78001. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  78002. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  78003. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  78004. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  78005. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  78006. var precision = options.precision || { w: 1, h: 1 };
  78007. var indices = new Array();
  78008. var positions = new Array();
  78009. var normals = new Array();
  78010. var uvs = new Array();
  78011. var row, col, tileRow, tileCol;
  78012. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  78013. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  78014. precision.w = (precision.w < 1) ? 1 : precision.w;
  78015. precision.h = (precision.h < 1) ? 1 : precision.h;
  78016. var tileSize = {
  78017. 'w': (xmax - xmin) / subdivisions.w,
  78018. 'h': (zmax - zmin) / subdivisions.h
  78019. };
  78020. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  78021. // Indices
  78022. var base = positions.length / 3;
  78023. var rowLength = precision.w + 1;
  78024. for (row = 0; row < precision.h; row++) {
  78025. for (col = 0; col < precision.w; col++) {
  78026. var square = [
  78027. base + col + row * rowLength,
  78028. base + (col + 1) + row * rowLength,
  78029. base + (col + 1) + (row + 1) * rowLength,
  78030. base + col + (row + 1) * rowLength
  78031. ];
  78032. indices.push(square[1]);
  78033. indices.push(square[2]);
  78034. indices.push(square[3]);
  78035. indices.push(square[0]);
  78036. indices.push(square[1]);
  78037. indices.push(square[3]);
  78038. }
  78039. }
  78040. // Position, normals and uvs
  78041. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78042. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  78043. for (row = 0; row <= precision.h; row++) {
  78044. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  78045. for (col = 0; col <= precision.w; col++) {
  78046. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  78047. position.y = 0;
  78048. positions.push(position.x, position.y, position.z);
  78049. normals.push(normal.x, normal.y, normal.z);
  78050. uvs.push(col / precision.w, row / precision.h);
  78051. }
  78052. }
  78053. }
  78054. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  78055. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  78056. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  78057. }
  78058. }
  78059. // Result
  78060. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78061. vertexData.indices = indices;
  78062. vertexData.positions = positions;
  78063. vertexData.normals = normals;
  78064. vertexData.uvs = uvs;
  78065. return vertexData;
  78066. };
  78067. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  78068. var indices = [];
  78069. var positions = [];
  78070. var normals = [];
  78071. var uvs = [];
  78072. var row, col;
  78073. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  78074. var alphaFilter = options.alphaFilter || 0.0;
  78075. // Vertices
  78076. for (row = 0; row <= options.subdivisions; row++) {
  78077. for (col = 0; col <= options.subdivisions; col++) {
  78078. 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));
  78079. // Compute height
  78080. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  78081. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  78082. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  78083. var r = options.buffer[pos] / 255.0;
  78084. var g = options.buffer[pos + 1] / 255.0;
  78085. var b = options.buffer[pos + 2] / 255.0;
  78086. var a = options.buffer[pos + 3] / 255.0;
  78087. var gradient = r * filter.r + g * filter.g + b * filter.b;
  78088. // If our alpha channel is not within our filter then we will assign a 'special' height
  78089. // Then when building the indices, we will ignore any vertex that is using the special height
  78090. if (a >= alphaFilter) {
  78091. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  78092. }
  78093. else {
  78094. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  78095. }
  78096. // Add vertex
  78097. positions.push(position.x, position.y, position.z);
  78098. normals.push(0, 0, 0);
  78099. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  78100. }
  78101. }
  78102. // Indices
  78103. for (row = 0; row < options.subdivisions; row++) {
  78104. for (col = 0; col < options.subdivisions; col++) {
  78105. // Calculate Indices
  78106. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  78107. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  78108. var idx3 = (col + row * (options.subdivisions + 1));
  78109. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  78110. // Check that all indices are visible (based on our special height)
  78111. // Only display the vertex if all Indices are visible
  78112. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  78113. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  78114. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  78115. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  78116. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  78117. indices.push(idx1);
  78118. indices.push(idx2);
  78119. indices.push(idx3);
  78120. }
  78121. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  78122. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  78123. indices.push(idx4);
  78124. indices.push(idx1);
  78125. indices.push(idx3);
  78126. }
  78127. }
  78128. }
  78129. // Normals
  78130. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  78131. // Result
  78132. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78133. vertexData.indices = indices;
  78134. vertexData.positions = positions;
  78135. vertexData.normals = normals;
  78136. vertexData.uvs = uvs;
  78137. return vertexData;
  78138. };
  78139. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  78140. var options = {
  78141. width: width,
  78142. height: height,
  78143. subdivisions: subdivisions,
  78144. updatable: updatable
  78145. };
  78146. return GroundBuilder.CreateGround(name, options, scene);
  78147. };
  78148. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  78149. var options = {
  78150. xmin: xmin,
  78151. zmin: zmin,
  78152. xmax: xmax,
  78153. zmax: zmax,
  78154. subdivisions: subdivisions,
  78155. precision: precision,
  78156. updatable: updatable
  78157. };
  78158. return GroundBuilder.CreateTiledGround(name, options, scene);
  78159. };
  78160. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  78161. var options = {
  78162. width: width,
  78163. height: height,
  78164. subdivisions: subdivisions,
  78165. minHeight: minHeight,
  78166. maxHeight: maxHeight,
  78167. updatable: updatable,
  78168. onReady: onReady,
  78169. alphaFilter: alphaFilter
  78170. };
  78171. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  78172. };
  78173. /**
  78174. * Class containing static functions to help procedurally build meshes
  78175. */
  78176. var GroundBuilder = /** @class */ (function () {
  78177. function GroundBuilder() {
  78178. }
  78179. /**
  78180. * Creates a ground mesh
  78181. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  78182. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  78183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78184. * @param name defines the name of the mesh
  78185. * @param options defines the options used to create the mesh
  78186. * @param scene defines the hosting scene
  78187. * @returns the ground mesh
  78188. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  78189. */
  78190. GroundBuilder.CreateGround = function (name, options, scene) {
  78191. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  78192. ground._setReady(false);
  78193. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  78194. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  78195. ground._width = options.width || 1;
  78196. ground._height = options.height || 1;
  78197. ground._maxX = ground._width / 2;
  78198. ground._maxZ = ground._height / 2;
  78199. ground._minX = -ground._maxX;
  78200. ground._minZ = -ground._maxZ;
  78201. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  78202. vertexData.applyToMesh(ground, options.updatable);
  78203. ground._setReady(true);
  78204. return ground;
  78205. };
  78206. /**
  78207. * Creates a tiled ground mesh
  78208. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  78209. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  78210. * * 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
  78211. * * 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
  78212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78213. * @param name defines the name of the mesh
  78214. * @param options defines the options used to create the mesh
  78215. * @param scene defines the hosting scene
  78216. * @returns the tiled ground mesh
  78217. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  78218. */
  78219. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  78220. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78221. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  78222. vertexData.applyToMesh(tiledGround, options.updatable);
  78223. return tiledGround;
  78224. };
  78225. /**
  78226. * Creates a ground mesh from a height map
  78227. * * The parameter `url` sets the URL of the height map image resource.
  78228. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  78229. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  78230. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  78231. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  78232. * * 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.
  78233. * * 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).
  78234. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78236. * @param name defines the name of the mesh
  78237. * @param url defines the url to the height map
  78238. * @param options defines the options used to create the mesh
  78239. * @param scene defines the hosting scene
  78240. * @returns the ground mesh
  78241. * @see https://doc.babylonjs.com/babylon101/height_map
  78242. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  78243. */
  78244. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  78245. var width = options.width || 10.0;
  78246. var height = options.height || 10.0;
  78247. var subdivisions = options.subdivisions || 1 | 0;
  78248. var minHeight = options.minHeight || 0.0;
  78249. var maxHeight = options.maxHeight || 1.0;
  78250. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  78251. var alphaFilter = options.alphaFilter || 0.0;
  78252. var updatable = options.updatable;
  78253. var onReady = options.onReady;
  78254. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  78255. ground._subdivisionsX = subdivisions;
  78256. ground._subdivisionsY = subdivisions;
  78257. ground._width = width;
  78258. ground._height = height;
  78259. ground._maxX = ground._width / 2.0;
  78260. ground._maxZ = ground._height / 2.0;
  78261. ground._minX = -ground._maxX;
  78262. ground._minZ = -ground._maxZ;
  78263. ground._setReady(false);
  78264. var onload = function (img) {
  78265. // Getting height map data
  78266. var canvas = document.createElement("canvas");
  78267. var context = canvas.getContext("2d");
  78268. if (!context) {
  78269. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  78270. }
  78271. if (scene.isDisposed) {
  78272. return;
  78273. }
  78274. var bufferWidth = img.width;
  78275. var bufferHeight = img.height;
  78276. canvas.width = bufferWidth;
  78277. canvas.height = bufferHeight;
  78278. context.drawImage(img, 0, 0);
  78279. // Create VertexData from map data
  78280. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  78281. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  78282. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  78283. width: width, height: height,
  78284. subdivisions: subdivisions,
  78285. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  78286. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  78287. alphaFilter: alphaFilter
  78288. });
  78289. vertexData.applyToMesh(ground, updatable);
  78290. //execute ready callback, if set
  78291. if (onReady) {
  78292. onReady(ground);
  78293. }
  78294. ground._setReady(true);
  78295. };
  78296. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  78297. return ground;
  78298. };
  78299. return GroundBuilder;
  78300. }());
  78301. /***/ }),
  78302. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  78303. /*!*********************************************!*\
  78304. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  78305. \*********************************************/
  78306. /*! exports provided: IcoSphereBuilder */
  78307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78308. "use strict";
  78309. __webpack_require__.r(__webpack_exports__);
  78310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  78311. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78312. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78313. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78314. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  78315. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78316. var radius = options.radius || 1;
  78317. var flat = (options.flat === undefined) ? true : options.flat;
  78318. var subdivisions = options.subdivisions || 4;
  78319. var radiusX = options.radiusX || radius;
  78320. var radiusY = options.radiusY || radius;
  78321. var radiusZ = options.radiusZ || radius;
  78322. var t = (1 + Math.sqrt(5)) / 2;
  78323. // 12 vertex x,y,z
  78324. var ico_vertices = [
  78325. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  78326. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  78327. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  78328. ];
  78329. // index of 3 vertex makes a face of icopshere
  78330. var ico_indices = [
  78331. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  78332. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  78333. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  78334. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  78335. ];
  78336. // vertex for uv have aliased position, not for UV
  78337. var vertices_unalias_id = [
  78338. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  78339. // vertex alias
  78340. 0,
  78341. 2,
  78342. 3,
  78343. 3,
  78344. 3,
  78345. 4,
  78346. 7,
  78347. 8,
  78348. 9,
  78349. 9,
  78350. 10,
  78351. 11 // 23: B + 12
  78352. ];
  78353. // uv as integer step (not pixels !)
  78354. var ico_vertexuv = [
  78355. 5, 1, 3, 1, 6, 4, 0, 0,
  78356. 5, 3, 4, 2, 2, 2, 4, 0,
  78357. 2, 0, 1, 1, 6, 0, 6, 2,
  78358. // vertex alias (for same vertex on different faces)
  78359. 0, 4,
  78360. 3, 3,
  78361. 4, 4,
  78362. 3, 1,
  78363. 4, 2,
  78364. 4, 4,
  78365. 0, 2,
  78366. 1, 1,
  78367. 2, 2,
  78368. 3, 3,
  78369. 1, 3,
  78370. 2, 4 // 23: B + 12
  78371. ];
  78372. // Vertices[0, 1, ...9, A, B] : position on UV plane
  78373. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  78374. // First island of uv mapping
  78375. // v = 4h 3+ 2
  78376. // v = 3h 9+ 4
  78377. // v = 2h 9+ 5 B
  78378. // v = 1h 9 1 0
  78379. // v = 0h 3 8 7 A
  78380. // u = 0 1 2 3 4 5 6 *a
  78381. // Second island of uv mapping
  78382. // v = 4h 0+ B+ 4+
  78383. // v = 3h A+ 2+
  78384. // v = 2h 7+ 6 3+
  78385. // v = 1h 8+ 3+
  78386. // v = 0h
  78387. // u = 0 1 2 3 4 5 6 *a
  78388. // Face layout on texture UV mapping
  78389. // ============
  78390. // \ 4 /\ 16 / ======
  78391. // \ / \ / /\ 11 /
  78392. // \/ 7 \/ / \ /
  78393. // ======= / 10 \/
  78394. // /\ 17 /\ =======
  78395. // / \ / \ \ 15 /\
  78396. // / 8 \/ 12 \ \ / \
  78397. // ============ \/ 6 \
  78398. // \ 18 /\ ============
  78399. // \ / \ \ 5 /\ 0 /
  78400. // \/ 13 \ \ / \ /
  78401. // ======= \/ 1 \/
  78402. // =============
  78403. // /\ 19 /\ 2 /\
  78404. // / \ / \ / \
  78405. // / 14 \/ 9 \/ 3 \
  78406. // ===================
  78407. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  78408. var ustep = 138 / 1024;
  78409. var vstep = 239 / 1024;
  78410. var uoffset = 60 / 1024;
  78411. var voffset = 26 / 1024;
  78412. // Second island should have margin, not to touch the first island
  78413. // avoid any borderline artefact in pixel rounding
  78414. var island_u_offset = -40 / 1024;
  78415. var island_v_offset = +20 / 1024;
  78416. // face is either island 0 or 1 :
  78417. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  78418. var island = [
  78419. 0, 0, 0, 0, 1,
  78420. 0, 0, 1, 1, 0,
  78421. 0, 0, 1, 1, 0,
  78422. 0, 1, 1, 1, 0 // 15 - 19
  78423. ];
  78424. var indices = new Array();
  78425. var positions = new Array();
  78426. var normals = new Array();
  78427. var uvs = new Array();
  78428. var current_indice = 0;
  78429. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  78430. var face_vertex_pos = new Array(3);
  78431. var face_vertex_uv = new Array(3);
  78432. var v012;
  78433. for (v012 = 0; v012 < 3; v012++) {
  78434. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78435. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  78436. }
  78437. // create all with normals
  78438. for (var face = 0; face < 20; face++) {
  78439. // 3 vertex per face
  78440. for (v012 = 0; v012 < 3; v012++) {
  78441. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  78442. var v_id = ico_indices[3 * face + v012];
  78443. // vertex have 3D position (x,y,z)
  78444. 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]);
  78445. // Normalize to get normal, then scale to radius
  78446. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  78447. // uv Coordinates from vertex ID
  78448. 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);
  78449. }
  78450. // Subdivide the face (interpolate pos, norm, uv)
  78451. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  78452. // - norm is linear interpolation of vertex corner normal
  78453. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  78454. // - uv is linear interpolation
  78455. //
  78456. // Topology is as below for sub-divide by 2
  78457. // vertex shown as v0,v1,v2
  78458. // interp index is i1 to progress in range [v0,v1[
  78459. // interp index is i2 to progress in range [v0,v2[
  78460. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  78461. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  78462. //
  78463. //
  78464. // i2 v2
  78465. // ^ ^
  78466. // / / \
  78467. // / / \
  78468. // / / \
  78469. // / / (0,1) \
  78470. // / #---------\
  78471. // / / \ (0,0)'/ \
  78472. // / / \ / \
  78473. // / / \ / \
  78474. // / / (0,0) \ / (1,0) \
  78475. // / #---------#---------\
  78476. // v0 v1
  78477. //
  78478. // --------------------> i1
  78479. //
  78480. // interp of (i1,i2):
  78481. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  78482. // along i1 : lerp(x0,x1, i1/(S-i2))
  78483. //
  78484. // centroid of triangle is needed to get help normal computation
  78485. // (c1,c2) are used for centroid location
  78486. var interp_vertex = function (i1, i2, c1, c2) {
  78487. // vertex is interpolated from
  78488. // - face_vertex_pos[0..2]
  78489. // - face_vertex_uv[0..2]
  78490. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  78491. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  78492. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  78493. pos_interp.normalize();
  78494. var vertex_normal;
  78495. if (flat) {
  78496. // in flat mode, recalculate normal as face centroid normal
  78497. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  78498. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  78499. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  78500. }
  78501. else {
  78502. // in smooth mode, recalculate normal from each single vertex position
  78503. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  78504. }
  78505. // Vertex normal need correction due to X,Y,Z radius scaling
  78506. vertex_normal.x /= radiusX;
  78507. vertex_normal.y /= radiusY;
  78508. vertex_normal.z /= radiusZ;
  78509. vertex_normal.normalize();
  78510. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  78511. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  78512. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  78513. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  78514. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  78515. uvs.push(uv_interp.x, uv_interp.y);
  78516. // push each vertex has member of a face
  78517. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  78518. indices.push(current_indice);
  78519. current_indice++;
  78520. };
  78521. for (var i2 = 0; i2 < subdivisions; i2++) {
  78522. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  78523. // face : (i1,i2) for /\ :
  78524. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  78525. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  78526. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  78527. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  78528. if (i1 + i2 + 1 < subdivisions) {
  78529. // face : (i1,i2)' for \/ :
  78530. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  78531. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  78532. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  78533. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  78534. }
  78535. }
  78536. }
  78537. }
  78538. // Sides
  78539. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78540. // Result
  78541. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78542. vertexData.indices = indices;
  78543. vertexData.positions = positions;
  78544. vertexData.normals = normals;
  78545. vertexData.uvs = uvs;
  78546. return vertexData;
  78547. };
  78548. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  78549. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  78550. };
  78551. /**
  78552. * Class containing static functions to help procedurally build meshes
  78553. */
  78554. var IcoSphereBuilder = /** @class */ (function () {
  78555. function IcoSphereBuilder() {
  78556. }
  78557. /**
  78558. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78559. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78560. * * 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`)
  78561. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78562. * * 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
  78563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78564. * * 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
  78565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78566. * @param name defines the name of the mesh
  78567. * @param options defines the options used to create the mesh
  78568. * @param scene defines the hosting scene
  78569. * @returns the icosahedron mesh
  78570. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78571. */
  78572. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  78573. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78574. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78575. sphere._originalBuilderSideOrientation = options.sideOrientation;
  78576. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  78577. vertexData.applyToMesh(sphere, options.updatable);
  78578. return sphere;
  78579. };
  78580. return IcoSphereBuilder;
  78581. }());
  78582. /***/ }),
  78583. /***/ "./Meshes/Builders/index.ts":
  78584. /*!**********************************!*\
  78585. !*** ./Meshes/Builders/index.ts ***!
  78586. \**********************************/
  78587. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  78588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78589. "use strict";
  78590. __webpack_require__.r(__webpack_exports__);
  78591. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  78592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  78593. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  78594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  78595. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  78596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  78597. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  78598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  78599. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  78600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  78601. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  78602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  78603. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  78604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  78605. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  78606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  78607. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  78608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  78609. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  78610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  78611. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  78612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  78613. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  78614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  78615. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  78616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  78617. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  78618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  78619. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  78620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  78621. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  78622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  78623. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  78624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  78625. /***/ }),
  78626. /***/ "./Meshes/Builders/latheBuilder.ts":
  78627. /*!*****************************************!*\
  78628. !*** ./Meshes/Builders/latheBuilder.ts ***!
  78629. \*****************************************/
  78630. /*! exports provided: LatheBuilder */
  78631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78632. "use strict";
  78633. __webpack_require__.r(__webpack_exports__);
  78634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  78635. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78636. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78637. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  78638. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  78639. var options = {
  78640. shape: shape,
  78641. radius: radius,
  78642. tessellation: tessellation,
  78643. sideOrientation: sideOrientation,
  78644. updatable: updatable
  78645. };
  78646. return LatheBuilder.CreateLathe(name, options, scene);
  78647. };
  78648. /**
  78649. * Class containing static functions to help procedurally build meshes
  78650. */
  78651. var LatheBuilder = /** @class */ (function () {
  78652. function LatheBuilder() {
  78653. }
  78654. /**
  78655. * Creates lathe mesh.
  78656. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  78657. * * 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
  78658. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  78659. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  78660. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  78661. * * 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
  78662. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  78663. * * 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
  78664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78665. * * 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
  78666. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  78667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78668. * @param name defines the name of the mesh
  78669. * @param options defines the options used to create the mesh
  78670. * @param scene defines the hosting scene
  78671. * @returns the lathe mesh
  78672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  78673. */
  78674. LatheBuilder.CreateLathe = function (name, options, scene) {
  78675. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  78676. var closed = (options.closed === undefined) ? true : options.closed;
  78677. var shape = options.shape;
  78678. var radius = options.radius || 1;
  78679. var tessellation = options.tessellation || 64;
  78680. var clip = options.clip || 0;
  78681. var updatable = options.updatable;
  78682. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78683. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  78684. var pi2 = Math.PI * 2;
  78685. var paths = new Array();
  78686. var invertUV = options.invertUV || false;
  78687. var i = 0;
  78688. var p = 0;
  78689. var step = pi2 / tessellation * arc;
  78690. var rotated;
  78691. var path = new Array();
  78692. for (i = 0; i <= tessellation - clip; i++) {
  78693. var path = [];
  78694. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  78695. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  78696. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[0].x * radius, shape[0].y, Math.sin(i * step) * shape[0].x * radius));
  78697. }
  78698. for (p = 0; p < shape.length; p++) {
  78699. rotated = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[p].x * radius, shape[p].y, Math.sin(i * step) * shape[p].x * radius);
  78700. path.push(rotated);
  78701. }
  78702. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  78703. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[shape.length - 1].x * radius, shape[shape.length - 1].y, Math.sin(i * step) * shape[shape.length - 1].x * radius));
  78704. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  78705. }
  78706. paths.push(path);
  78707. }
  78708. // lathe ribbon
  78709. var lathe = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon(name, { pathArray: paths, closeArray: closed, sideOrientation: sideOrientation, updatable: updatable, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  78710. return lathe;
  78711. };
  78712. return LatheBuilder;
  78713. }());
  78714. /***/ }),
  78715. /***/ "./Meshes/Builders/linesBuilder.ts":
  78716. /*!*****************************************!*\
  78717. !*** ./Meshes/Builders/linesBuilder.ts ***!
  78718. \*****************************************/
  78719. /*! exports provided: LinesBuilder */
  78720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78721. "use strict";
  78722. __webpack_require__.r(__webpack_exports__);
  78723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  78724. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78725. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78726. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78727. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  78728. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  78729. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  78730. var indices = [];
  78731. var positions = [];
  78732. var lines = options.lines;
  78733. var colors = options.colors;
  78734. var vertexColors = [];
  78735. var idx = 0;
  78736. for (var l = 0; l < lines.length; l++) {
  78737. var points = lines[l];
  78738. for (var index = 0; index < points.length; index++) {
  78739. positions.push(points[index].x, points[index].y, points[index].z);
  78740. if (colors) {
  78741. var color = colors[l];
  78742. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  78743. }
  78744. if (index > 0) {
  78745. indices.push(idx - 1);
  78746. indices.push(idx);
  78747. }
  78748. idx++;
  78749. }
  78750. }
  78751. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78752. vertexData.indices = indices;
  78753. vertexData.positions = positions;
  78754. if (colors) {
  78755. vertexData.colors = vertexColors;
  78756. }
  78757. return vertexData;
  78758. };
  78759. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  78760. var dashSize = options.dashSize || 3;
  78761. var gapSize = options.gapSize || 1;
  78762. var dashNb = options.dashNb || 200;
  78763. var points = options.points;
  78764. var positions = new Array();
  78765. var indices = new Array();
  78766. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78767. var lg = 0;
  78768. var nb = 0;
  78769. var shft = 0;
  78770. var dashshft = 0;
  78771. var curshft = 0;
  78772. var idx = 0;
  78773. var i = 0;
  78774. for (i = 0; i < points.length - 1; i++) {
  78775. points[i + 1].subtractToRef(points[i], curvect);
  78776. lg += curvect.length();
  78777. }
  78778. shft = lg / dashNb;
  78779. dashshft = dashSize * shft / (dashSize + gapSize);
  78780. for (i = 0; i < points.length - 1; i++) {
  78781. points[i + 1].subtractToRef(points[i], curvect);
  78782. nb = Math.floor(curvect.length() / shft);
  78783. curvect.normalize();
  78784. for (var j = 0; j < nb; j++) {
  78785. curshft = shft * j;
  78786. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  78787. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  78788. indices.push(idx, idx + 1);
  78789. idx += 2;
  78790. }
  78791. }
  78792. // Result
  78793. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78794. vertexData.positions = positions;
  78795. vertexData.indices = indices;
  78796. return vertexData;
  78797. };
  78798. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  78799. if (scene === void 0) { scene = null; }
  78800. if (updatable === void 0) { updatable = false; }
  78801. if (instance === void 0) { instance = null; }
  78802. var options = {
  78803. points: points,
  78804. updatable: updatable,
  78805. instance: instance
  78806. };
  78807. return LinesBuilder.CreateLines(name, options, scene);
  78808. };
  78809. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  78810. if (scene === void 0) { scene = null; }
  78811. var options = {
  78812. points: points,
  78813. dashSize: dashSize,
  78814. gapSize: gapSize,
  78815. dashNb: dashNb,
  78816. updatable: updatable,
  78817. instance: instance
  78818. };
  78819. return LinesBuilder.CreateDashedLines(name, options, scene);
  78820. };
  78821. /**
  78822. * Class containing static functions to help procedurally build meshes
  78823. */
  78824. var LinesBuilder = /** @class */ (function () {
  78825. function LinesBuilder() {
  78826. }
  78827. /**
  78828. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  78829. * * 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
  78830. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  78831. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  78832. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  78833. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  78834. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  78835. * * 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
  78836. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  78837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78838. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  78839. * @param name defines the name of the new line system
  78840. * @param options defines the options used to create the line system
  78841. * @param scene defines the hosting scene
  78842. * @returns a new line system mesh
  78843. */
  78844. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  78845. var instance = options.instance;
  78846. var lines = options.lines;
  78847. var colors = options.colors;
  78848. if (instance) { // lines update
  78849. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  78850. var vertexColor;
  78851. var lineColors;
  78852. if (colors) {
  78853. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  78854. }
  78855. var i = 0;
  78856. var c = 0;
  78857. for (var l = 0; l < lines.length; l++) {
  78858. var points = lines[l];
  78859. for (var p = 0; p < points.length; p++) {
  78860. positions[i] = points[p].x;
  78861. positions[i + 1] = points[p].y;
  78862. positions[i + 2] = points[p].z;
  78863. if (colors && vertexColor) {
  78864. lineColors = colors[l];
  78865. vertexColor[c] = lineColors[p].r;
  78866. vertexColor[c + 1] = lineColors[p].g;
  78867. vertexColor[c + 2] = lineColors[p].b;
  78868. vertexColor[c + 3] = lineColors[p].a;
  78869. c += 4;
  78870. }
  78871. i += 3;
  78872. }
  78873. }
  78874. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  78875. if (colors && vertexColor) {
  78876. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  78877. }
  78878. return instance;
  78879. }
  78880. // line system creation
  78881. var useVertexColor = (colors) ? true : false;
  78882. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  78883. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  78884. vertexData.applyToMesh(lineSystem, options.updatable);
  78885. return lineSystem;
  78886. };
  78887. /**
  78888. * Creates a line mesh
  78889. * 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
  78890. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  78891. * * The parameter `points` is an array successive Vector3
  78892. * * 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
  78893. * * The optional parameter `colors` is an array of successive Color4, one per line point
  78894. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  78895. * * When updating an instance, remember that only point positions can change, not the number of points
  78896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  78898. * @param name defines the name of the new line system
  78899. * @param options defines the options used to create the line system
  78900. * @param scene defines the hosting scene
  78901. * @returns a new line mesh
  78902. */
  78903. LinesBuilder.CreateLines = function (name, options, scene) {
  78904. if (scene === void 0) { scene = null; }
  78905. var colors = (options.colors) ? [options.colors] : null;
  78906. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  78907. return lines;
  78908. };
  78909. /**
  78910. * Creates a dashed line mesh
  78911. * * 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
  78912. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  78913. * * The parameter `points` is an array successive Vector3
  78914. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  78915. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  78916. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78917. * * 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
  78918. * * When updating an instance, remember that only point positions can change, not the number of points
  78919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78920. * @param name defines the name of the mesh
  78921. * @param options defines the options used to create the mesh
  78922. * @param scene defines the hosting scene
  78923. * @returns the dashed line mesh
  78924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  78925. */
  78926. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  78927. if (scene === void 0) { scene = null; }
  78928. var points = options.points;
  78929. var instance = options.instance;
  78930. var gapSize = options.gapSize || 1;
  78931. var dashSize = options.dashSize || 3;
  78932. if (instance) { // dashed lines update
  78933. var positionFunction = function (positions) {
  78934. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78935. var nbSeg = positions.length / 6;
  78936. var lg = 0;
  78937. var nb = 0;
  78938. var shft = 0;
  78939. var dashshft = 0;
  78940. var curshft = 0;
  78941. var p = 0;
  78942. var i = 0;
  78943. var j = 0;
  78944. for (i = 0; i < points.length - 1; i++) {
  78945. points[i + 1].subtractToRef(points[i], curvect);
  78946. lg += curvect.length();
  78947. }
  78948. shft = lg / nbSeg;
  78949. var dashSize = instance._creationDataStorage.dashSize;
  78950. var gapSize = instance._creationDataStorage.gapSize;
  78951. dashshft = dashSize * shft / (dashSize + gapSize);
  78952. for (i = 0; i < points.length - 1; i++) {
  78953. points[i + 1].subtractToRef(points[i], curvect);
  78954. nb = Math.floor(curvect.length() / shft);
  78955. curvect.normalize();
  78956. j = 0;
  78957. while (j < nb && p < positions.length) {
  78958. curshft = shft * j;
  78959. positions[p] = points[i].x + curshft * curvect.x;
  78960. positions[p + 1] = points[i].y + curshft * curvect.y;
  78961. positions[p + 2] = points[i].z + curshft * curvect.z;
  78962. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  78963. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  78964. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  78965. p += 6;
  78966. j++;
  78967. }
  78968. }
  78969. while (p < positions.length) {
  78970. positions[p] = points[i].x;
  78971. positions[p + 1] = points[i].y;
  78972. positions[p + 2] = points[i].z;
  78973. p += 3;
  78974. }
  78975. };
  78976. instance.updateMeshPositions(positionFunction, false);
  78977. return instance;
  78978. }
  78979. // dashed lines creation
  78980. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  78981. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  78982. vertexData.applyToMesh(dashedLines, options.updatable);
  78983. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  78984. dashedLines._creationDataStorage.dashSize = dashSize;
  78985. dashedLines._creationDataStorage.gapSize = gapSize;
  78986. return dashedLines;
  78987. };
  78988. return LinesBuilder;
  78989. }());
  78990. /***/ }),
  78991. /***/ "./Meshes/Builders/planeBuilder.ts":
  78992. /*!*****************************************!*\
  78993. !*** ./Meshes/Builders/planeBuilder.ts ***!
  78994. \*****************************************/
  78995. /*! exports provided: PlaneBuilder */
  78996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78997. "use strict";
  78998. __webpack_require__.r(__webpack_exports__);
  78999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  79000. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79001. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79002. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  79003. var indices = [];
  79004. var positions = [];
  79005. var normals = [];
  79006. var uvs = [];
  79007. var width = options.width || options.size || 1;
  79008. var height = options.height || options.size || 1;
  79009. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  79010. // Vertices
  79011. var halfWidth = width / 2.0;
  79012. var halfHeight = height / 2.0;
  79013. positions.push(-halfWidth, -halfHeight, 0);
  79014. normals.push(0, 0, -1.0);
  79015. uvs.push(0.0, 0.0);
  79016. positions.push(halfWidth, -halfHeight, 0);
  79017. normals.push(0, 0, -1.0);
  79018. uvs.push(1.0, 0.0);
  79019. positions.push(halfWidth, halfHeight, 0);
  79020. normals.push(0, 0, -1.0);
  79021. uvs.push(1.0, 1.0);
  79022. positions.push(-halfWidth, halfHeight, 0);
  79023. normals.push(0, 0, -1.0);
  79024. uvs.push(0.0, 1.0);
  79025. // Indices
  79026. indices.push(0);
  79027. indices.push(1);
  79028. indices.push(2);
  79029. indices.push(0);
  79030. indices.push(2);
  79031. indices.push(3);
  79032. // Sides
  79033. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79034. // Result
  79035. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  79036. vertexData.indices = indices;
  79037. vertexData.positions = positions;
  79038. vertexData.normals = normals;
  79039. vertexData.uvs = uvs;
  79040. return vertexData;
  79041. };
  79042. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  79043. var options = {
  79044. size: size,
  79045. width: size,
  79046. height: size,
  79047. sideOrientation: sideOrientation,
  79048. updatable: updatable
  79049. };
  79050. return PlaneBuilder.CreatePlane(name, options, scene);
  79051. };
  79052. /**
  79053. * Class containing static functions to help procedurally build meshes
  79054. */
  79055. var PlaneBuilder = /** @class */ (function () {
  79056. function PlaneBuilder() {
  79057. }
  79058. /**
  79059. * Creates a plane mesh
  79060. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  79061. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  79062. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  79063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79064. * * 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
  79065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79066. * @param name defines the name of the mesh
  79067. * @param options defines the options used to create the mesh
  79068. * @param scene defines the hosting scene
  79069. * @returns the plane mesh
  79070. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  79071. */
  79072. PlaneBuilder.CreatePlane = function (name, options, scene) {
  79073. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  79074. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79075. plane._originalBuilderSideOrientation = options.sideOrientation;
  79076. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  79077. vertexData.applyToMesh(plane, options.updatable);
  79078. if (options.sourcePlane) {
  79079. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  79080. plane.setDirection(options.sourcePlane.normal.scale(-1));
  79081. }
  79082. return plane;
  79083. };
  79084. return PlaneBuilder;
  79085. }());
  79086. /***/ }),
  79087. /***/ "./Meshes/Builders/polygonBuilder.ts":
  79088. /*!*******************************************!*\
  79089. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  79090. \*******************************************/
  79091. /*! exports provided: PolygonBuilder */
  79092. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79093. "use strict";
  79094. __webpack_require__.r(__webpack_exports__);
  79095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  79096. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79097. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79098. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79099. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  79100. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  79101. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  79102. var faceUV = fUV || new Array(3);
  79103. var faceColors = fColors;
  79104. var colors = [];
  79105. // default face colors and UV if undefined
  79106. for (var f = 0; f < 3; f++) {
  79107. if (faceUV[f] === undefined) {
  79108. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  79109. }
  79110. if (faceColors && faceColors[f] === undefined) {
  79111. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  79112. }
  79113. }
  79114. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  79115. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  79116. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  79117. var indices = polygon.getIndices();
  79118. // set face colours and textures
  79119. var idx = 0;
  79120. var face = 0;
  79121. for (var index = 0; index < normals.length; index += 3) {
  79122. //Edge Face no. 1
  79123. if (Math.abs(normals[index + 1]) < 0.001) {
  79124. face = 1;
  79125. }
  79126. //Top Face no. 0
  79127. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  79128. face = 0;
  79129. }
  79130. //Bottom Face no. 2
  79131. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  79132. face = 2;
  79133. }
  79134. idx = index / 3;
  79135. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  79136. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  79137. if (faceColors) {
  79138. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  79139. }
  79140. }
  79141. // sides
  79142. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  79143. // Result
  79144. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79145. vertexData.indices = indices;
  79146. vertexData.positions = positions;
  79147. vertexData.normals = normals;
  79148. vertexData.uvs = uvs;
  79149. if (faceColors) {
  79150. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  79151. vertexData.colors = totalColors;
  79152. }
  79153. return vertexData;
  79154. };
  79155. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  79156. if (earcutInjection === void 0) { earcutInjection = earcut; }
  79157. var options = {
  79158. shape: shape,
  79159. holes: holes,
  79160. updatable: updatable,
  79161. sideOrientation: sideOrientation
  79162. };
  79163. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  79164. };
  79165. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  79166. if (earcutInjection === void 0) { earcutInjection = earcut; }
  79167. var options = {
  79168. shape: shape,
  79169. holes: holes,
  79170. depth: depth,
  79171. updatable: updatable,
  79172. sideOrientation: sideOrientation
  79173. };
  79174. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  79175. };
  79176. /**
  79177. * Class containing static functions to help procedurally build meshes
  79178. */
  79179. var PolygonBuilder = /** @class */ (function () {
  79180. function PolygonBuilder() {
  79181. }
  79182. /**
  79183. * Creates a polygon mesh
  79184. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  79185. * * 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
  79186. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79188. * * 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)
  79189. * * Remember you can only change the shape positions, not their number when updating a polygon
  79190. * @param name defines the name of the mesh
  79191. * @param options defines the options used to create the mesh
  79192. * @param scene defines the hosting scene
  79193. * @param earcutInjection can be used to inject your own earcut reference
  79194. * @returns the polygon mesh
  79195. */
  79196. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  79197. if (earcutInjection === void 0) { earcutInjection = earcut; }
  79198. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79199. var shape = options.shape;
  79200. var holes = options.holes || [];
  79201. var depth = options.depth || 0;
  79202. var contours = [];
  79203. var hole = [];
  79204. for (var i = 0; i < shape.length; i++) {
  79205. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  79206. }
  79207. var epsilon = 0.00000001;
  79208. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  79209. contours.pop();
  79210. }
  79211. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  79212. for (var hNb = 0; hNb < holes.length; hNb++) {
  79213. hole = [];
  79214. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  79215. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  79216. }
  79217. polygonTriangulation.addHole(hole);
  79218. }
  79219. var polygon = polygonTriangulation.build(options.updatable, depth);
  79220. polygon._originalBuilderSideOrientation = options.sideOrientation;
  79221. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  79222. vertexData.applyToMesh(polygon, options.updatable);
  79223. return polygon;
  79224. };
  79225. /**
  79226. * Creates an extruded polygon mesh, with depth in the Y direction.
  79227. * * 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)
  79228. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  79229. * @param name defines the name of the mesh
  79230. * @param options defines the options used to create the mesh
  79231. * @param scene defines the hosting scene
  79232. * @param earcutInjection can be used to inject your own earcut reference
  79233. * @returns the polygon mesh
  79234. */
  79235. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  79236. if (earcutInjection === void 0) { earcutInjection = earcut; }
  79237. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  79238. };
  79239. return PolygonBuilder;
  79240. }());
  79241. /***/ }),
  79242. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  79243. /*!**********************************************!*\
  79244. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  79245. \**********************************************/
  79246. /*! exports provided: PolyhedronBuilder */
  79247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79248. "use strict";
  79249. __webpack_require__.r(__webpack_exports__);
  79250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  79251. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79252. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79253. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79254. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  79255. // provided polyhedron types :
  79256. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79257. // 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)
  79258. var polyhedra = [];
  79259. 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]] };
  79260. 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]] };
  79261. polyhedra[2] = {
  79262. 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]],
  79263. 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]]
  79264. };
  79265. polyhedra[3] = {
  79266. 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]],
  79267. 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]]
  79268. };
  79269. polyhedra[4] = {
  79270. 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]],
  79271. 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]]
  79272. };
  79273. 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]] };
  79274. 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]] };
  79275. 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]] };
  79276. 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]] };
  79277. 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]] };
  79278. 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]] };
  79279. 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]] };
  79280. 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]] };
  79281. 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]] };
  79282. polyhedra[14] = {
  79283. 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]],
  79284. 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]]
  79285. };
  79286. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  79287. var size = options.size;
  79288. var sizeX = options.sizeX || size || 1;
  79289. var sizeY = options.sizeY || size || 1;
  79290. var sizeZ = options.sizeZ || size || 1;
  79291. var data = options.custom || polyhedra[type];
  79292. var nbfaces = data.face.length;
  79293. var faceUV = options.faceUV || new Array(nbfaces);
  79294. var faceColors = options.faceColors;
  79295. var flat = (options.flat === undefined) ? true : options.flat;
  79296. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79297. var positions = new Array();
  79298. var indices = new Array();
  79299. var normals = new Array();
  79300. var uvs = new Array();
  79301. var colors = new Array();
  79302. var index = 0;
  79303. var faceIdx = 0; // face cursor in the array "indexes"
  79304. var indexes = new Array();
  79305. var i = 0;
  79306. var f = 0;
  79307. var u, v, ang, x, y, tmp;
  79308. // default face colors and UV if undefined
  79309. if (flat) {
  79310. for (f = 0; f < nbfaces; f++) {
  79311. if (faceColors && faceColors[f] === undefined) {
  79312. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  79313. }
  79314. if (faceUV && faceUV[f] === undefined) {
  79315. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  79316. }
  79317. }
  79318. }
  79319. if (!flat) {
  79320. for (i = 0; i < data.vertex.length; i++) {
  79321. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  79322. uvs.push(0, 0);
  79323. }
  79324. for (f = 0; f < nbfaces; f++) {
  79325. for (i = 0; i < data.face[f].length - 2; i++) {
  79326. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  79327. }
  79328. }
  79329. }
  79330. else {
  79331. for (f = 0; f < nbfaces; f++) {
  79332. var fl = data.face[f].length; // number of vertices of the current face
  79333. ang = 2 * Math.PI / fl;
  79334. x = 0.5 * Math.tan(ang / 2);
  79335. y = 0.5;
  79336. // positions, uvs, colors
  79337. for (i = 0; i < fl; i++) {
  79338. // positions
  79339. 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);
  79340. indexes.push(index);
  79341. index++;
  79342. // uvs
  79343. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  79344. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  79345. uvs.push(u, v);
  79346. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  79347. y = x * Math.sin(ang) + y * Math.cos(ang);
  79348. x = tmp;
  79349. // colors
  79350. if (faceColors) {
  79351. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  79352. }
  79353. }
  79354. // indices from indexes
  79355. for (i = 0; i < fl - 2; i++) {
  79356. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  79357. }
  79358. faceIdx += fl;
  79359. }
  79360. }
  79361. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  79362. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79363. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79364. vertexData.positions = positions;
  79365. vertexData.indices = indices;
  79366. vertexData.normals = normals;
  79367. vertexData.uvs = uvs;
  79368. if (faceColors && flat) {
  79369. vertexData.colors = colors;
  79370. }
  79371. return vertexData;
  79372. };
  79373. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  79374. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  79375. };
  79376. /**
  79377. * Class containing static functions to help procedurally build meshes
  79378. */
  79379. var PolyhedronBuilder = /** @class */ (function () {
  79380. function PolyhedronBuilder() {
  79381. }
  79382. /**
  79383. * Creates a polyhedron mesh
  79384. * * 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
  79385. * * The parameter `size` (positive float, default 1) sets the polygon size
  79386. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79387. * * 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`
  79388. * * 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
  79389. * * 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)`)
  79390. * * 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
  79391. * * 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
  79392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79393. * * 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
  79394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79395. * @param name defines the name of the mesh
  79396. * @param options defines the options used to create the mesh
  79397. * @param scene defines the hosting scene
  79398. * @returns the polyhedron mesh
  79399. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  79400. */
  79401. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  79402. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79403. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79404. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  79405. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  79406. vertexData.applyToMesh(polyhedron, options.updatable);
  79407. return polyhedron;
  79408. };
  79409. return PolyhedronBuilder;
  79410. }());
  79411. /***/ }),
  79412. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  79413. /*!******************************************!*\
  79414. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  79415. \******************************************/
  79416. /*! exports provided: RibbonBuilder */
  79417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79418. "use strict";
  79419. __webpack_require__.r(__webpack_exports__);
  79420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  79421. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79422. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79423. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  79424. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79425. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  79426. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  79427. var pathArray = options.pathArray;
  79428. var closeArray = options.closeArray || false;
  79429. var closePath = options.closePath || false;
  79430. var invertUV = options.invertUV || false;
  79431. var defaultOffset = Math.floor(pathArray[0].length / 2);
  79432. var offset = options.offset || defaultOffset;
  79433. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  79434. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  79435. var customUV = options.uvs;
  79436. var customColors = options.colors;
  79437. var positions = [];
  79438. var indices = [];
  79439. var normals = [];
  79440. var uvs = [];
  79441. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  79442. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  79443. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  79444. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  79445. var minlg; // minimal length among all paths from pathArray
  79446. var lg = []; // array of path lengths : nb of vertex per path
  79447. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  79448. var p; // path iterator
  79449. var i; // point iterator
  79450. var j; // point iterator
  79451. // if single path in pathArray
  79452. if (pathArray.length < 2) {
  79453. var ar1 = [];
  79454. var ar2 = [];
  79455. for (i = 0; i < pathArray[0].length - offset; i++) {
  79456. ar1.push(pathArray[0][i]);
  79457. ar2.push(pathArray[0][i + offset]);
  79458. }
  79459. pathArray = [ar1, ar2];
  79460. }
  79461. // positions and horizontal distances (u)
  79462. var idc = 0;
  79463. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  79464. var path;
  79465. var l;
  79466. minlg = pathArray[0].length;
  79467. var vectlg;
  79468. var dist;
  79469. for (p = 0; p < pathArray.length; p++) {
  79470. uTotalDistance[p] = 0;
  79471. us[p] = [0];
  79472. path = pathArray[p];
  79473. l = path.length;
  79474. minlg = (minlg < l) ? minlg : l;
  79475. j = 0;
  79476. while (j < l) {
  79477. positions.push(path[j].x, path[j].y, path[j].z);
  79478. if (j > 0) {
  79479. vectlg = path[j].subtract(path[j - 1]).length();
  79480. dist = vectlg + uTotalDistance[p];
  79481. us[p].push(dist);
  79482. uTotalDistance[p] = dist;
  79483. }
  79484. j++;
  79485. }
  79486. if (closePath) { // an extra hidden vertex is added in the "positions" array
  79487. j--;
  79488. positions.push(path[0].x, path[0].y, path[0].z);
  79489. vectlg = path[j].subtract(path[0]).length();
  79490. dist = vectlg + uTotalDistance[p];
  79491. us[p].push(dist);
  79492. uTotalDistance[p] = dist;
  79493. }
  79494. lg[p] = l + closePathCorr;
  79495. idx[p] = idc;
  79496. idc += (l + closePathCorr);
  79497. }
  79498. // vertical distances (v)
  79499. var path1;
  79500. var path2;
  79501. var vertex1 = null;
  79502. var vertex2 = null;
  79503. for (i = 0; i < minlg + closePathCorr; i++) {
  79504. vTotalDistance[i] = 0;
  79505. vs[i] = [0];
  79506. for (p = 0; p < pathArray.length - 1; p++) {
  79507. path1 = pathArray[p];
  79508. path2 = pathArray[p + 1];
  79509. if (i === minlg) { // closePath
  79510. vertex1 = path1[0];
  79511. vertex2 = path2[0];
  79512. }
  79513. else {
  79514. vertex1 = path1[i];
  79515. vertex2 = path2[i];
  79516. }
  79517. vectlg = vertex2.subtract(vertex1).length();
  79518. dist = vectlg + vTotalDistance[i];
  79519. vs[i].push(dist);
  79520. vTotalDistance[i] = dist;
  79521. }
  79522. if (closeArray && vertex2 && vertex1) {
  79523. path1 = pathArray[p];
  79524. path2 = pathArray[0];
  79525. if (i === minlg) { // closePath
  79526. vertex2 = path2[0];
  79527. }
  79528. vectlg = vertex2.subtract(vertex1).length();
  79529. dist = vectlg + vTotalDistance[i];
  79530. vTotalDistance[i] = dist;
  79531. }
  79532. }
  79533. // uvs
  79534. var u;
  79535. var v;
  79536. if (customUV) {
  79537. for (p = 0; p < customUV.length; p++) {
  79538. uvs.push(customUV[p].x, customUV[p].y);
  79539. }
  79540. }
  79541. else {
  79542. for (p = 0; p < pathArray.length; p++) {
  79543. for (i = 0; i < minlg + closePathCorr; i++) {
  79544. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  79545. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  79546. if (invertUV) {
  79547. uvs.push(v, u);
  79548. }
  79549. else {
  79550. uvs.push(u, v);
  79551. }
  79552. }
  79553. }
  79554. }
  79555. // indices
  79556. p = 0; // path index
  79557. var pi = 0; // positions array index
  79558. var l1 = lg[p] - 1; // path1 length
  79559. var l2 = lg[p + 1] - 1; // path2 length
  79560. var min = (l1 < l2) ? l1 : l2; // current path stop index
  79561. var shft = idx[1] - idx[0]; // shift
  79562. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  79563. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  79564. // 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
  79565. indices.push(pi, pi + shft, pi + 1);
  79566. indices.push(pi + shft + 1, pi + 1, pi + shft);
  79567. pi += 1;
  79568. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  79569. p++;
  79570. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  79571. shft = idx[0] - idx[p];
  79572. l1 = lg[p] - 1;
  79573. l2 = lg[0] - 1;
  79574. }
  79575. else {
  79576. shft = idx[p + 1] - idx[p];
  79577. l1 = lg[p] - 1;
  79578. l2 = lg[p + 1] - 1;
  79579. }
  79580. pi = idx[p];
  79581. min = (l1 < l2) ? l1 + pi : l2 + pi;
  79582. }
  79583. }
  79584. // normals
  79585. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  79586. if (closePath) { // update both the first and last vertex normals to their average value
  79587. var indexFirst = 0;
  79588. var indexLast = 0;
  79589. for (p = 0; p < pathArray.length; p++) {
  79590. indexFirst = idx[p] * 3;
  79591. if (p + 1 < pathArray.length) {
  79592. indexLast = (idx[p + 1] - 1) * 3;
  79593. }
  79594. else {
  79595. indexLast = normals.length - 3;
  79596. }
  79597. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  79598. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  79599. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  79600. normals[indexLast] = normals[indexFirst];
  79601. normals[indexLast + 1] = normals[indexFirst + 1];
  79602. normals[indexLast + 2] = normals[indexFirst + 2];
  79603. }
  79604. }
  79605. // sides
  79606. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79607. // Colors
  79608. var colors = null;
  79609. if (customColors) {
  79610. colors = new Float32Array(customColors.length * 4);
  79611. for (var c = 0; c < customColors.length; c++) {
  79612. colors[c * 4] = customColors[c].r;
  79613. colors[c * 4 + 1] = customColors[c].g;
  79614. colors[c * 4 + 2] = customColors[c].b;
  79615. colors[c * 4 + 3] = customColors[c].a;
  79616. }
  79617. }
  79618. // Result
  79619. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  79620. var positions32 = new Float32Array(positions);
  79621. var normals32 = new Float32Array(normals);
  79622. var uvs32 = new Float32Array(uvs);
  79623. vertexData.indices = indices;
  79624. vertexData.positions = positions32;
  79625. vertexData.normals = normals32;
  79626. vertexData.uvs = uvs32;
  79627. if (colors) {
  79628. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  79629. }
  79630. if (closePath) {
  79631. vertexData._idx = idx;
  79632. }
  79633. return vertexData;
  79634. };
  79635. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  79636. if (closeArray === void 0) { closeArray = false; }
  79637. if (updatable === void 0) { updatable = false; }
  79638. return RibbonBuilder.CreateRibbon(name, {
  79639. pathArray: pathArray,
  79640. closeArray: closeArray,
  79641. closePath: closePath,
  79642. offset: offset,
  79643. updatable: updatable,
  79644. sideOrientation: sideOrientation,
  79645. instance: instance
  79646. }, scene);
  79647. };
  79648. /**
  79649. * Class containing static functions to help procedurally build meshes
  79650. */
  79651. var RibbonBuilder = /** @class */ (function () {
  79652. function RibbonBuilder() {
  79653. }
  79654. /**
  79655. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  79656. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  79657. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  79658. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  79659. * * 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
  79660. * * 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
  79661. * * 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
  79662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79663. * * 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
  79664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79665. * * 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
  79666. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  79667. * * 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
  79668. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  79669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79670. * @param name defines the name of the mesh
  79671. * @param options defines the options used to create the mesh
  79672. * @param scene defines the hosting scene
  79673. * @returns the ribbon mesh
  79674. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  79675. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79676. */
  79677. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  79678. if (scene === void 0) { scene = null; }
  79679. var pathArray = options.pathArray;
  79680. var closeArray = options.closeArray;
  79681. var closePath = options.closePath;
  79682. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79683. var instance = options.instance;
  79684. var updatable = options.updatable;
  79685. if (instance) { // existing ribbon instance update
  79686. // positionFunction : ribbon case
  79687. // only pathArray and sideOrientation parameters are taken into account for positions update
  79688. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  79689. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  79690. var positionFunction = function (positions) {
  79691. var minlg = pathArray[0].length;
  79692. var mesh = instance;
  79693. var i = 0;
  79694. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  79695. for (var si = 1; si <= ns; ++si) {
  79696. for (var p = 0; p < pathArray.length; ++p) {
  79697. var path = pathArray[p];
  79698. var l = path.length;
  79699. minlg = (minlg < l) ? minlg : l;
  79700. for (var j = 0; j < minlg; ++j) {
  79701. var pathPoint = path[j];
  79702. positions[i] = pathPoint.x;
  79703. positions[i + 1] = pathPoint.y;
  79704. positions[i + 2] = pathPoint.z;
  79705. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  79706. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  79707. i += 3;
  79708. }
  79709. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  79710. var pathPoint = path[0];
  79711. positions[i] = pathPoint.x;
  79712. positions[i + 1] = pathPoint.y;
  79713. positions[i + 2] = pathPoint.z;
  79714. i += 3;
  79715. }
  79716. }
  79717. }
  79718. };
  79719. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  79720. positionFunction(positions);
  79721. if (instance._boundingInfo) {
  79722. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  79723. }
  79724. else {
  79725. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  79726. }
  79727. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  79728. if (options.colors) {
  79729. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  79730. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  79731. var color = options.colors[c];
  79732. colors[colorIndex] = color.r;
  79733. colors[colorIndex + 1] = color.g;
  79734. colors[colorIndex + 2] = color.b;
  79735. colors[colorIndex + 3] = color.a;
  79736. }
  79737. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  79738. }
  79739. if (options.uvs) {
  79740. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  79741. for (var i = 0; i < options.uvs.length; i++) {
  79742. uvs[i * 2] = options.uvs[i].x;
  79743. uvs[i * 2 + 1] = options.uvs[i].y;
  79744. }
  79745. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  79746. }
  79747. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  79748. var indices = instance.getIndices();
  79749. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  79750. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  79751. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  79752. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  79753. var indexFirst = 0;
  79754. var indexLast = 0;
  79755. for (var p = 0; p < pathArray.length; p++) {
  79756. indexFirst = instance._creationDataStorage.idx[p] * 3;
  79757. if (p + 1 < pathArray.length) {
  79758. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  79759. }
  79760. else {
  79761. indexLast = normals.length - 3;
  79762. }
  79763. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  79764. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  79765. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  79766. normals[indexLast] = normals[indexFirst];
  79767. normals[indexLast + 1] = normals[indexFirst + 1];
  79768. normals[indexLast + 2] = normals[indexFirst + 2];
  79769. }
  79770. }
  79771. if (!(instance.areNormalsFrozen)) {
  79772. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  79773. }
  79774. }
  79775. return instance;
  79776. }
  79777. else { // new ribbon creation
  79778. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79779. ribbon._originalBuilderSideOrientation = sideOrientation;
  79780. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  79781. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  79782. if (closePath) {
  79783. ribbon._creationDataStorage.idx = vertexData._idx;
  79784. }
  79785. ribbon._creationDataStorage.closePath = closePath;
  79786. ribbon._creationDataStorage.closeArray = closeArray;
  79787. vertexData.applyToMesh(ribbon, updatable);
  79788. return ribbon;
  79789. }
  79790. };
  79791. return RibbonBuilder;
  79792. }());
  79793. /***/ }),
  79794. /***/ "./Meshes/Builders/shapeBuilder.ts":
  79795. /*!*****************************************!*\
  79796. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  79797. \*****************************************/
  79798. /*! exports provided: ShapeBuilder */
  79799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79800. "use strict";
  79801. __webpack_require__.r(__webpack_exports__);
  79802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  79803. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79804. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79805. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79806. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  79807. if (scene === void 0) { scene = null; }
  79808. var options = {
  79809. shape: shape,
  79810. path: path,
  79811. scale: scale,
  79812. rotation: rotation,
  79813. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  79814. sideOrientation: sideOrientation,
  79815. instance: instance,
  79816. updatable: updatable
  79817. };
  79818. return ShapeBuilder.ExtrudeShape(name, options, scene);
  79819. };
  79820. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  79821. var options = {
  79822. shape: shape,
  79823. path: path,
  79824. scaleFunction: scaleFunction,
  79825. rotationFunction: rotationFunction,
  79826. ribbonCloseArray: ribbonCloseArray,
  79827. ribbonClosePath: ribbonClosePath,
  79828. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  79829. sideOrientation: sideOrientation,
  79830. instance: instance,
  79831. updatable: updatable
  79832. };
  79833. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  79834. };
  79835. /**
  79836. * Class containing static functions to help procedurally build meshes
  79837. */
  79838. var ShapeBuilder = /** @class */ (function () {
  79839. function ShapeBuilder() {
  79840. }
  79841. /**
  79842. * 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.
  79843. * * 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.
  79844. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  79845. * * 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.
  79846. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  79847. * * 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
  79848. * * 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
  79849. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  79850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79851. * * 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
  79852. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  79853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79854. * @param name defines the name of the mesh
  79855. * @param options defines the options used to create the mesh
  79856. * @param scene defines the hosting scene
  79857. * @returns the extruded shape mesh
  79858. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79860. */
  79861. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  79862. if (scene === void 0) { scene = null; }
  79863. var path = options.path;
  79864. var shape = options.shape;
  79865. var scale = options.scale || 1;
  79866. var rotation = options.rotation || 0;
  79867. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79868. var updatable = options.updatable;
  79869. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79870. var instance = options.instance || null;
  79871. var invertUV = options.invertUV || false;
  79872. return ShapeBuilder._ExtrudeShapeGeneric(name, shape, path, scale, rotation, null, null, false, false, cap, false, scene, updatable ? true : false, sideOrientation, instance, invertUV, options.frontUVs || null, options.backUVs || null);
  79873. };
  79874. /**
  79875. * Creates an custom extruded shape mesh.
  79876. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  79877. * * 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.
  79878. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  79879. * * 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
  79880. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  79881. * * 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
  79882. * * It must returns a float value that will be the scale value applied to the shape on each path point
  79883. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79884. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  79885. * * 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
  79886. * * 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
  79887. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  79888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79889. * * 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
  79890. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79892. * @param name defines the name of the mesh
  79893. * @param options defines the options used to create the mesh
  79894. * @param scene defines the hosting scene
  79895. * @returns the custom extruded shape mesh
  79896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  79897. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79899. */
  79900. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  79901. var path = options.path;
  79902. var shape = options.shape;
  79903. var scaleFunction = options.scaleFunction || (function () { return 1; });
  79904. var rotationFunction = options.rotationFunction || (function () { return 0; });
  79905. var ribbonCloseArray = options.ribbonCloseArray || false;
  79906. var ribbonClosePath = options.ribbonClosePath || false;
  79907. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79908. var updatable = options.updatable;
  79909. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79910. var instance = options.instance;
  79911. var invertUV = options.invertUV || false;
  79912. return ShapeBuilder._ExtrudeShapeGeneric(name, shape, path, null, null, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, true, scene, updatable ? true : false, sideOrientation, instance || null, invertUV, options.frontUVs || null, options.backUVs || null);
  79913. };
  79914. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  79915. // extrusion geometry
  79916. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  79917. var tangents = path3D.getTangents();
  79918. var normals = path3D.getNormals();
  79919. var binormals = path3D.getBinormals();
  79920. var distances = path3D.getDistances();
  79921. var angle = 0;
  79922. var returnScale = function () { return scale !== null ? scale : 1; };
  79923. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  79924. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  79925. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  79926. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  79927. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  79928. for (var i = 0; i < curve.length; i++) {
  79929. var shapePath = new Array();
  79930. var angleStep = rotate(i, distances[i]);
  79931. var scaleRatio = scl(i, distances[i]);
  79932. for (var p = 0; p < shape.length; p++) {
  79933. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  79934. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  79935. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79936. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  79937. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  79938. shapePath[p] = rotated;
  79939. }
  79940. shapePaths[index] = shapePath;
  79941. angle += angleStep;
  79942. index++;
  79943. }
  79944. // cap
  79945. var capPath = function (shapePath) {
  79946. var pointCap = Array();
  79947. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79948. var i;
  79949. for (i = 0; i < shapePath.length; i++) {
  79950. barycenter.addInPlace(shapePath[i]);
  79951. }
  79952. barycenter.scaleInPlace(1.0 / shapePath.length);
  79953. for (i = 0; i < shapePath.length; i++) {
  79954. pointCap.push(barycenter);
  79955. }
  79956. return pointCap;
  79957. };
  79958. switch (cap) {
  79959. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  79960. break;
  79961. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  79962. shapePaths[0] = capPath(shapePaths[2]);
  79963. shapePaths[1] = shapePaths[2];
  79964. break;
  79965. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  79966. shapePaths[index] = shapePaths[index - 1];
  79967. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  79968. break;
  79969. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  79970. shapePaths[0] = capPath(shapePaths[2]);
  79971. shapePaths[1] = shapePaths[2];
  79972. shapePaths[index] = shapePaths[index - 1];
  79973. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  79974. break;
  79975. default:
  79976. break;
  79977. }
  79978. return shapePaths;
  79979. };
  79980. var path3D;
  79981. var pathArray;
  79982. if (instance) { // instance update
  79983. var storage = instance._creationDataStorage;
  79984. path3D = storage.path3D.update(curve);
  79985. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  79986. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  79987. return instance;
  79988. }
  79989. // extruded shape creation
  79990. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  79991. var newShapePaths = new Array();
  79992. cap = (cap < 0 || cap > 3) ? 0 : cap;
  79993. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  79994. var extrudedGeneric = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon(name, { pathArray: pathArray, closeArray: rbCA, closePath: rbCP, updatable: updtbl, sideOrientation: side, invertUV: invertUV, frontUVs: frontUVs || undefined, backUVs: backUVs || undefined }, scene);
  79995. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  79996. extrudedGeneric._creationDataStorage.path3D = path3D;
  79997. extrudedGeneric._creationDataStorage.cap = cap;
  79998. return extrudedGeneric;
  79999. };
  80000. return ShapeBuilder;
  80001. }());
  80002. /***/ }),
  80003. /***/ "./Meshes/Builders/sphereBuilder.ts":
  80004. /*!******************************************!*\
  80005. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  80006. \******************************************/
  80007. /*! exports provided: SphereBuilder */
  80008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80009. "use strict";
  80010. __webpack_require__.r(__webpack_exports__);
  80011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  80012. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80013. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80014. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80015. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  80016. var segments = options.segments || 32;
  80017. var diameterX = options.diameterX || options.diameter || 1;
  80018. var diameterY = options.diameterY || options.diameter || 1;
  80019. var diameterZ = options.diameterZ || options.diameter || 1;
  80020. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  80021. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  80022. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80023. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  80024. var totalZRotationSteps = 2 + segments;
  80025. var totalYRotationSteps = 2 * totalZRotationSteps;
  80026. var indices = [];
  80027. var positions = [];
  80028. var normals = [];
  80029. var uvs = [];
  80030. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  80031. var normalizedZ = zRotationStep / totalZRotationSteps;
  80032. var angleZ = normalizedZ * Math.PI * slice;
  80033. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  80034. var normalizedY = yRotationStep / totalYRotationSteps;
  80035. var angleY = normalizedY * Math.PI * 2 * arc;
  80036. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  80037. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  80038. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  80039. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  80040. var vertex = complete.multiply(radius);
  80041. var normal = complete.divide(radius).normalize();
  80042. positions.push(vertex.x, vertex.y, vertex.z);
  80043. normals.push(normal.x, normal.y, normal.z);
  80044. uvs.push(normalizedY, normalizedZ);
  80045. }
  80046. if (zRotationStep > 0) {
  80047. var verticesCount = positions.length / 3;
  80048. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  80049. indices.push((firstIndex));
  80050. indices.push((firstIndex + 1));
  80051. indices.push(firstIndex + totalYRotationSteps + 1);
  80052. indices.push((firstIndex + totalYRotationSteps + 1));
  80053. indices.push((firstIndex + 1));
  80054. indices.push((firstIndex + totalYRotationSteps + 2));
  80055. }
  80056. }
  80057. }
  80058. // Sides
  80059. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80060. // Result
  80061. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80062. vertexData.indices = indices;
  80063. vertexData.positions = positions;
  80064. vertexData.normals = normals;
  80065. vertexData.uvs = uvs;
  80066. return vertexData;
  80067. };
  80068. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  80069. var options = {
  80070. segments: segments,
  80071. diameterX: diameter,
  80072. diameterY: diameter,
  80073. diameterZ: diameter,
  80074. sideOrientation: sideOrientation,
  80075. updatable: updatable
  80076. };
  80077. return SphereBuilder.CreateSphere(name, options, scene);
  80078. };
  80079. /**
  80080. * Class containing static functions to help procedurally build meshes
  80081. */
  80082. var SphereBuilder = /** @class */ (function () {
  80083. function SphereBuilder() {
  80084. }
  80085. /**
  80086. * Creates a sphere mesh
  80087. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  80088. * * 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`)
  80089. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  80090. * * 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
  80091. * * 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)
  80092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80093. * * 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
  80094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80095. * @param name defines the name of the mesh
  80096. * @param options defines the options used to create the mesh
  80097. * @param scene defines the hosting scene
  80098. * @returns the sphere mesh
  80099. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  80100. */
  80101. SphereBuilder.CreateSphere = function (name, options, scene) {
  80102. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80103. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80104. sphere._originalBuilderSideOrientation = options.sideOrientation;
  80105. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  80106. vertexData.applyToMesh(sphere, options.updatable);
  80107. return sphere;
  80108. };
  80109. return SphereBuilder;
  80110. }());
  80111. /***/ }),
  80112. /***/ "./Meshes/Builders/torusBuilder.ts":
  80113. /*!*****************************************!*\
  80114. !*** ./Meshes/Builders/torusBuilder.ts ***!
  80115. \*****************************************/
  80116. /*! exports provided: TorusBuilder */
  80117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80118. "use strict";
  80119. __webpack_require__.r(__webpack_exports__);
  80120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  80121. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80122. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80123. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80124. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  80125. var indices = [];
  80126. var positions = [];
  80127. var normals = [];
  80128. var uvs = [];
  80129. var diameter = options.diameter || 1;
  80130. var thickness = options.thickness || 0.5;
  80131. var tessellation = options.tessellation || 16;
  80132. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80133. var stride = tessellation + 1;
  80134. for (var i = 0; i <= tessellation; i++) {
  80135. var u = i / tessellation;
  80136. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  80137. 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));
  80138. for (var j = 0; j <= tessellation; j++) {
  80139. var v = 1 - j / tessellation;
  80140. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  80141. var dx = Math.cos(innerAngle);
  80142. var dy = Math.sin(innerAngle);
  80143. // Create a vertex.
  80144. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  80145. var position = normal.scale(thickness / 2);
  80146. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  80147. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  80148. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  80149. positions.push(position.x, position.y, position.z);
  80150. normals.push(normal.x, normal.y, normal.z);
  80151. uvs.push(textureCoordinate.x, textureCoordinate.y);
  80152. // And create indices for two triangles.
  80153. var nextI = (i + 1) % stride;
  80154. var nextJ = (j + 1) % stride;
  80155. indices.push(i * stride + j);
  80156. indices.push(i * stride + nextJ);
  80157. indices.push(nextI * stride + j);
  80158. indices.push(i * stride + nextJ);
  80159. indices.push(nextI * stride + nextJ);
  80160. indices.push(nextI * stride + j);
  80161. }
  80162. }
  80163. // Sides
  80164. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80165. // Result
  80166. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80167. vertexData.indices = indices;
  80168. vertexData.positions = positions;
  80169. vertexData.normals = normals;
  80170. vertexData.uvs = uvs;
  80171. return vertexData;
  80172. };
  80173. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  80174. var options = {
  80175. diameter: diameter,
  80176. thickness: thickness,
  80177. tessellation: tessellation,
  80178. sideOrientation: sideOrientation,
  80179. updatable: updatable
  80180. };
  80181. return TorusBuilder.CreateTorus(name, options, scene);
  80182. };
  80183. /**
  80184. * Class containing static functions to help procedurally build meshes
  80185. */
  80186. var TorusBuilder = /** @class */ (function () {
  80187. function TorusBuilder() {
  80188. }
  80189. /**
  80190. * Creates a torus mesh
  80191. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  80192. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  80193. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  80194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80195. * * 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
  80196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80197. * @param name defines the name of the mesh
  80198. * @param options defines the options used to create the mesh
  80199. * @param scene defines the hosting scene
  80200. * @returns the torus mesh
  80201. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  80202. */
  80203. TorusBuilder.CreateTorus = function (name, options, scene) {
  80204. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80205. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80206. torus._originalBuilderSideOrientation = options.sideOrientation;
  80207. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  80208. vertexData.applyToMesh(torus, options.updatable);
  80209. return torus;
  80210. };
  80211. return TorusBuilder;
  80212. }());
  80213. /***/ }),
  80214. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  80215. /*!*********************************************!*\
  80216. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  80217. \*********************************************/
  80218. /*! exports provided: TorusKnotBuilder */
  80219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80220. "use strict";
  80221. __webpack_require__.r(__webpack_exports__);
  80222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  80223. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80224. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80225. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80226. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  80227. var indices = new Array();
  80228. var positions = new Array();
  80229. var normals = new Array();
  80230. var uvs = new Array();
  80231. var radius = options.radius || 2;
  80232. var tube = options.tube || 0.5;
  80233. var radialSegments = options.radialSegments || 32;
  80234. var tubularSegments = options.tubularSegments || 32;
  80235. var p = options.p || 2;
  80236. var q = options.q || 3;
  80237. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80238. // Helper
  80239. var getPos = function (angle) {
  80240. var cu = Math.cos(angle);
  80241. var su = Math.sin(angle);
  80242. var quOverP = q / p * angle;
  80243. var cs = Math.cos(quOverP);
  80244. var tx = radius * (2 + cs) * 0.5 * cu;
  80245. var ty = radius * (2 + cs) * su * 0.5;
  80246. var tz = radius * Math.sin(quOverP) * 0.5;
  80247. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  80248. };
  80249. // Vertices
  80250. var i;
  80251. var j;
  80252. for (i = 0; i <= radialSegments; i++) {
  80253. var modI = i % radialSegments;
  80254. var u = modI / radialSegments * 2 * p * Math.PI;
  80255. var p1 = getPos(u);
  80256. var p2 = getPos(u + 0.01);
  80257. var tang = p2.subtract(p1);
  80258. var n = p2.add(p1);
  80259. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  80260. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  80261. bitan.normalize();
  80262. n.normalize();
  80263. for (j = 0; j < tubularSegments; j++) {
  80264. var modJ = j % tubularSegments;
  80265. var v = modJ / tubularSegments * 2 * Math.PI;
  80266. var cx = -tube * Math.cos(v);
  80267. var cy = tube * Math.sin(v);
  80268. positions.push(p1.x + cx * n.x + cy * bitan.x);
  80269. positions.push(p1.y + cx * n.y + cy * bitan.y);
  80270. positions.push(p1.z + cx * n.z + cy * bitan.z);
  80271. uvs.push(i / radialSegments);
  80272. uvs.push(j / tubularSegments);
  80273. }
  80274. }
  80275. for (i = 0; i < radialSegments; i++) {
  80276. for (j = 0; j < tubularSegments; j++) {
  80277. var jNext = (j + 1) % tubularSegments;
  80278. var a = i * tubularSegments + j;
  80279. var b = (i + 1) * tubularSegments + j;
  80280. var c = (i + 1) * tubularSegments + jNext;
  80281. var d = i * tubularSegments + jNext;
  80282. indices.push(d);
  80283. indices.push(b);
  80284. indices.push(a);
  80285. indices.push(d);
  80286. indices.push(c);
  80287. indices.push(b);
  80288. }
  80289. }
  80290. // Normals
  80291. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  80292. // Sides
  80293. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80294. // Result
  80295. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80296. vertexData.indices = indices;
  80297. vertexData.positions = positions;
  80298. vertexData.normals = normals;
  80299. vertexData.uvs = uvs;
  80300. return vertexData;
  80301. };
  80302. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  80303. var options = {
  80304. radius: radius,
  80305. tube: tube,
  80306. radialSegments: radialSegments,
  80307. tubularSegments: tubularSegments,
  80308. p: p,
  80309. q: q,
  80310. sideOrientation: sideOrientation,
  80311. updatable: updatable
  80312. };
  80313. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  80314. };
  80315. /**
  80316. * Class containing static functions to help procedurally build meshes
  80317. */
  80318. var TorusKnotBuilder = /** @class */ (function () {
  80319. function TorusKnotBuilder() {
  80320. }
  80321. /**
  80322. * Creates a torus knot mesh
  80323. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  80324. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  80325. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  80326. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  80327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80328. * * 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
  80329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80330. * @param name defines the name of the mesh
  80331. * @param options defines the options used to create the mesh
  80332. * @param scene defines the hosting scene
  80333. * @returns the torus knot mesh
  80334. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  80335. */
  80336. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  80337. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80338. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80339. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  80340. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  80341. vertexData.applyToMesh(torusKnot, options.updatable);
  80342. return torusKnot;
  80343. };
  80344. return TorusKnotBuilder;
  80345. }());
  80346. /***/ }),
  80347. /***/ "./Meshes/Builders/tubeBuilder.ts":
  80348. /*!****************************************!*\
  80349. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  80350. \****************************************/
  80351. /*! exports provided: TubeBuilder */
  80352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80353. "use strict";
  80354. __webpack_require__.r(__webpack_exports__);
  80355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  80356. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80357. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80358. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  80359. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  80360. var options = {
  80361. path: path,
  80362. radius: radius,
  80363. tessellation: tessellation,
  80364. radiusFunction: radiusFunction,
  80365. arc: 1,
  80366. cap: cap,
  80367. updatable: updatable,
  80368. sideOrientation: sideOrientation,
  80369. instance: instance
  80370. };
  80371. return TubeBuilder.CreateTube(name, options, scene);
  80372. };
  80373. /**
  80374. * Class containing static functions to help procedurally build meshes
  80375. */
  80376. var TubeBuilder = /** @class */ (function () {
  80377. function TubeBuilder() {
  80378. }
  80379. /**
  80380. * Creates a tube mesh.
  80381. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  80382. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  80383. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  80384. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  80385. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  80386. * * 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)
  80387. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  80388. * * 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
  80389. * * 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
  80390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80391. * * 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
  80392. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80394. * @param name defines the name of the mesh
  80395. * @param options defines the options used to create the mesh
  80396. * @param scene defines the hosting scene
  80397. * @returns the tube mesh
  80398. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80399. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  80400. */
  80401. TubeBuilder.CreateTube = function (name, options, scene) {
  80402. var path = options.path;
  80403. var instance = options.instance;
  80404. var radius = 1.0;
  80405. if (options.radius !== undefined) {
  80406. radius = options.radius;
  80407. }
  80408. else if (instance) {
  80409. radius = instance._creationDataStorage.radius;
  80410. }
  80411. var tessellation = options.tessellation || 64 | 0;
  80412. var radiusFunction = options.radiusFunction || null;
  80413. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  80414. var invertUV = options.invertUV || false;
  80415. var updatable = options.updatable;
  80416. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80417. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  80418. // tube geometry
  80419. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  80420. var tangents = path3D.getTangents();
  80421. var normals = path3D.getNormals();
  80422. var distances = path3D.getDistances();
  80423. var pi2 = Math.PI * 2;
  80424. var step = pi2 / tessellation * arc;
  80425. var returnRadius = function () { return radius; };
  80426. var radiusFunctionFinal = radiusFunction || returnRadius;
  80427. var circlePath;
  80428. var rad;
  80429. var normal;
  80430. var rotated;
  80431. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  80432. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  80433. for (var i = 0; i < path.length; i++) {
  80434. rad = radiusFunctionFinal(i, distances[i]); // current radius
  80435. circlePath = Array(); // current circle array
  80436. normal = normals[i]; // current normal
  80437. for (var t = 0; t < tessellation; t++) {
  80438. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  80439. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80440. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  80441. rotated.scaleInPlace(rad).addInPlace(path[i]);
  80442. circlePath[t] = rotated;
  80443. }
  80444. circlePaths[index] = circlePath;
  80445. index++;
  80446. }
  80447. // cap
  80448. var capPath = function (nbPoints, pathIndex) {
  80449. var pointCap = Array();
  80450. for (var i = 0; i < nbPoints; i++) {
  80451. pointCap.push(path[pathIndex]);
  80452. }
  80453. return pointCap;
  80454. };
  80455. switch (cap) {
  80456. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  80457. break;
  80458. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  80459. circlePaths[0] = capPath(tessellation, 0);
  80460. circlePaths[1] = circlePaths[2].slice(0);
  80461. break;
  80462. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  80463. circlePaths[index] = circlePaths[index - 1].slice(0);
  80464. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  80465. break;
  80466. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  80467. circlePaths[0] = capPath(tessellation, 0);
  80468. circlePaths[1] = circlePaths[2].slice(0);
  80469. circlePaths[index] = circlePaths[index - 1].slice(0);
  80470. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  80471. break;
  80472. default:
  80473. break;
  80474. }
  80475. return circlePaths;
  80476. };
  80477. var path3D;
  80478. var pathArray;
  80479. if (instance) { // tube update
  80480. var storage = instance._creationDataStorage;
  80481. var arc = options.arc || storage.arc;
  80482. path3D = storage.path3D.update(path);
  80483. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  80484. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  80485. // Update mode, no need to recreate the storage.
  80486. storage.path3D = path3D;
  80487. storage.pathArray = pathArray;
  80488. storage.arc = arc;
  80489. storage.radius = radius;
  80490. return instance;
  80491. }
  80492. // tube creation
  80493. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  80494. var newPathArray = new Array();
  80495. cap = (cap < 0 || cap > 3) ? 0 : cap;
  80496. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  80497. var tube = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon(name, { pathArray: pathArray, closePath: true, closeArray: false, updatable: updatable, sideOrientation: sideOrientation, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  80498. tube._creationDataStorage.pathArray = pathArray;
  80499. tube._creationDataStorage.path3D = path3D;
  80500. tube._creationDataStorage.tessellation = tessellation;
  80501. tube._creationDataStorage.cap = cap;
  80502. tube._creationDataStorage.arc = options.arc;
  80503. tube._creationDataStorage.radius = radius;
  80504. return tube;
  80505. };
  80506. return TubeBuilder;
  80507. }());
  80508. /***/ }),
  80509. /***/ "./Meshes/Compression/dracoCompression.ts":
  80510. /*!************************************************!*\
  80511. !*** ./Meshes/Compression/dracoCompression.ts ***!
  80512. \************************************************/
  80513. /*! exports provided: DracoCompression */
  80514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80515. "use strict";
  80516. __webpack_require__.r(__webpack_exports__);
  80517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  80518. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  80519. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80520. /**
  80521. * Draco compression (https://google.github.io/draco/)
  80522. *
  80523. * This class wraps the Draco module.
  80524. *
  80525. * **Encoder**
  80526. *
  80527. * The encoder is not currently implemented.
  80528. *
  80529. * **Decoder**
  80530. *
  80531. * 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.
  80532. *
  80533. * To update the configuration, use the following code:
  80534. * ```javascript
  80535. * DracoCompression.Configuration = {
  80536. * decoder: {
  80537. * wasmUrl: "<url to the WebAssembly library>",
  80538. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  80539. * fallbackUrl: "<url to the fallback JavaScript library>",
  80540. * }
  80541. * };
  80542. * ```
  80543. *
  80544. * 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.
  80545. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  80546. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  80547. *
  80548. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  80549. * ```javascript
  80550. * var dracoCompression = new DracoCompression();
  80551. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  80552. * [VertexBuffer.PositionKind]: 0
  80553. * });
  80554. * ```
  80555. *
  80556. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  80557. */
  80558. var DracoCompression = /** @class */ (function () {
  80559. /**
  80560. * Constructor
  80561. */
  80562. function DracoCompression() {
  80563. }
  80564. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  80565. /**
  80566. * Returns true if the decoder is available.
  80567. */
  80568. get: function () {
  80569. if (typeof DracoDecoderModule !== "undefined") {
  80570. return true;
  80571. }
  80572. var decoder = DracoCompression.Configuration.decoder;
  80573. if (decoder) {
  80574. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  80575. return true;
  80576. }
  80577. if (decoder.fallbackUrl) {
  80578. return true;
  80579. }
  80580. }
  80581. return false;
  80582. },
  80583. enumerable: true,
  80584. configurable: true
  80585. });
  80586. /**
  80587. * Stop all async operations and release resources.
  80588. */
  80589. DracoCompression.prototype.dispose = function () {
  80590. };
  80591. /**
  80592. * Decode Draco compressed mesh data to vertex data.
  80593. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  80594. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  80595. * @returns A promise that resolves with the decoded vertex data
  80596. */
  80597. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  80598. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  80599. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  80600. var module = wrappedModule.module;
  80601. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  80602. var buffer = new module.DecoderBuffer();
  80603. buffer.Init(dataView, dataView.byteLength);
  80604. var decoder = new module.Decoder();
  80605. var geometry;
  80606. var status;
  80607. try {
  80608. var type = decoder.GetEncodedGeometryType(buffer);
  80609. switch (type) {
  80610. case module.TRIANGULAR_MESH:
  80611. geometry = new module.Mesh();
  80612. status = decoder.DecodeBufferToMesh(buffer, geometry);
  80613. break;
  80614. case module.POINT_CLOUD:
  80615. geometry = new module.PointCloud();
  80616. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  80617. break;
  80618. default:
  80619. throw new Error("Invalid geometry type " + type);
  80620. }
  80621. if (!status.ok() || !geometry.ptr) {
  80622. throw new Error(status.error_msg());
  80623. }
  80624. var numPoints = geometry.num_points();
  80625. if (type === module.TRIANGULAR_MESH) {
  80626. var numFaces = geometry.num_faces();
  80627. var faceIndices = new module.DracoInt32Array();
  80628. try {
  80629. var indices = new Uint32Array(numFaces * 3);
  80630. for (var i = 0; i < numFaces; i++) {
  80631. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  80632. var offset = i * 3;
  80633. indices[offset + 0] = faceIndices.GetValue(0);
  80634. indices[offset + 1] = faceIndices.GetValue(1);
  80635. indices[offset + 2] = faceIndices.GetValue(2);
  80636. }
  80637. vertexData.indices = indices;
  80638. }
  80639. finally {
  80640. module.destroy(faceIndices);
  80641. }
  80642. }
  80643. for (var kind in attributes) {
  80644. var uniqueId = attributes[kind];
  80645. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  80646. var dracoData = new module.DracoFloat32Array();
  80647. try {
  80648. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  80649. var babylonData = new Float32Array(numPoints * attribute.num_components());
  80650. for (var i = 0; i < babylonData.length; i++) {
  80651. babylonData[i] = dracoData.GetValue(i);
  80652. }
  80653. vertexData.set(babylonData, kind);
  80654. }
  80655. finally {
  80656. module.destroy(dracoData);
  80657. }
  80658. }
  80659. }
  80660. finally {
  80661. if (geometry) {
  80662. module.destroy(geometry);
  80663. }
  80664. module.destroy(decoder);
  80665. module.destroy(buffer);
  80666. }
  80667. return vertexData;
  80668. });
  80669. };
  80670. DracoCompression._GetDecoderModule = function () {
  80671. if (!DracoCompression._DecoderModulePromise) {
  80672. var promise = null;
  80673. var config_1 = {};
  80674. if (typeof DracoDecoderModule !== "undefined") {
  80675. promise = Promise.resolve();
  80676. }
  80677. else {
  80678. var decoder = DracoCompression.Configuration.decoder;
  80679. if (decoder) {
  80680. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  80681. promise = Promise.all([
  80682. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  80683. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  80684. config_1.wasmBinary = data;
  80685. })
  80686. ]);
  80687. }
  80688. else if (decoder.fallbackUrl) {
  80689. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  80690. }
  80691. }
  80692. }
  80693. if (!promise) {
  80694. throw new Error("Draco decoder module is not available");
  80695. }
  80696. DracoCompression._DecoderModulePromise = promise.then(function () {
  80697. return new Promise(function (resolve) {
  80698. config_1.onModuleLoaded = function (decoderModule) {
  80699. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  80700. resolve({ module: decoderModule });
  80701. };
  80702. DracoDecoderModule(config_1);
  80703. });
  80704. });
  80705. }
  80706. return DracoCompression._DecoderModulePromise;
  80707. };
  80708. DracoCompression._LoadScriptAsync = function (url) {
  80709. return new Promise(function (resolve, reject) {
  80710. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  80711. resolve();
  80712. }, function (message) {
  80713. reject(new Error(message));
  80714. });
  80715. });
  80716. };
  80717. DracoCompression._LoadFileAsync = function (url) {
  80718. return new Promise(function (resolve, reject) {
  80719. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  80720. resolve(data);
  80721. }, undefined, undefined, true, function (request, exception) {
  80722. reject(exception);
  80723. });
  80724. });
  80725. };
  80726. /**
  80727. * The configuration. Defaults to the following urls:
  80728. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  80729. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  80730. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  80731. */
  80732. DracoCompression.Configuration = {
  80733. decoder: {
  80734. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  80735. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  80736. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  80737. }
  80738. };
  80739. return DracoCompression;
  80740. }());
  80741. /***/ }),
  80742. /***/ "./Meshes/Compression/index.ts":
  80743. /*!*************************************!*\
  80744. !*** ./Meshes/Compression/index.ts ***!
  80745. \*************************************/
  80746. /*! exports provided: DracoCompression */
  80747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80748. "use strict";
  80749. __webpack_require__.r(__webpack_exports__);
  80750. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  80751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  80752. /***/ }),
  80753. /***/ "./Meshes/abstractMesh.ts":
  80754. /*!********************************!*\
  80755. !*** ./Meshes/abstractMesh.ts ***!
  80756. \********************************/
  80757. /*! exports provided: AbstractMesh */
  80758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80759. "use strict";
  80760. __webpack_require__.r(__webpack_exports__);
  80761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  80762. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  80763. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  80764. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  80765. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80766. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  80767. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80768. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80769. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  80770. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  80771. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  80772. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  80773. /** @hidden */
  80774. var _FacetDataStorage = /** @class */ (function () {
  80775. function _FacetDataStorage() {
  80776. this.facetNb = 0; // facet number
  80777. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  80778. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  80779. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  80780. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  80781. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  80782. this.subDiv = {
  80783. max: 1,
  80784. X: 1,
  80785. Y: 1,
  80786. Z: 1
  80787. };
  80788. this.facetDepthSort = false; // is the facet depth sort to be computed
  80789. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  80790. }
  80791. return _FacetDataStorage;
  80792. }());
  80793. /**
  80794. * Class used to store all common mesh properties
  80795. */
  80796. var AbstractMesh = /** @class */ (function (_super) {
  80797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  80798. // Constructor
  80799. /**
  80800. * Creates a new AbstractMesh
  80801. * @param name defines the name of the mesh
  80802. * @param scene defines the hosting scene
  80803. */
  80804. function AbstractMesh(name, scene) {
  80805. if (scene === void 0) { scene = null; }
  80806. var _this = _super.call(this, name, scene, false) || this;
  80807. _this._facetData = new _FacetDataStorage();
  80808. /**
  80809. * The culling strategy to use to check whether the mesh must be rendered or not.
  80810. * This value can be changed at any time and will be used on the next render mesh selection.
  80811. * The possible values are :
  80812. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80813. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80814. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80815. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80816. * Please read each static variable documentation to get details about the culling process.
  80817. * */
  80818. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  80819. // Events
  80820. /**
  80821. * An event triggered when this mesh collides with another one
  80822. */
  80823. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80824. /**
  80825. * An event triggered when the collision's position changes
  80826. */
  80827. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80828. /**
  80829. * An event triggered when material is changed
  80830. */
  80831. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80832. // Properties
  80833. /**
  80834. * Gets or sets the orientation for POV movement & rotation
  80835. */
  80836. _this.definedFacingForward = true;
  80837. _this._visibility = 1.0;
  80838. /** Gets or sets the alpha index used to sort transparent meshes
  80839. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80840. */
  80841. _this.alphaIndex = Number.MAX_VALUE;
  80842. /**
  80843. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80844. */
  80845. _this.isVisible = true;
  80846. /**
  80847. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80848. */
  80849. _this.isPickable = true;
  80850. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80851. _this.showSubMeshesBoundingBox = false;
  80852. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80853. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80854. */
  80855. _this.isBlocker = false;
  80856. /**
  80857. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80858. */
  80859. _this.enablePointerMoveEvents = false;
  80860. /**
  80861. * Specifies the rendering group id for this mesh (0 by default)
  80862. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80863. */
  80864. _this.renderingGroupId = 0;
  80865. _this._receiveShadows = false;
  80866. /** Defines color to use when rendering outline */
  80867. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  80868. /** Define width to use when rendering outline */
  80869. _this.outlineWidth = 0.02;
  80870. /** Defines color to use when rendering overlay */
  80871. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  80872. /** Defines alpha to use when rendering overlay */
  80873. _this.overlayAlpha = 0.5;
  80874. _this._hasVertexAlpha = false;
  80875. _this._useVertexColors = true;
  80876. _this._computeBonesUsingShaders = true;
  80877. _this._numBoneInfluencers = 4;
  80878. _this._applyFog = true;
  80879. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80880. _this.useOctreeForRenderingSelection = true;
  80881. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80882. _this.useOctreeForPicking = true;
  80883. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80884. _this.useOctreeForCollisions = true;
  80885. _this._layerMask = 0x0FFFFFFF;
  80886. /**
  80887. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80888. */
  80889. _this.alwaysSelectAsActiveMesh = false;
  80890. /**
  80891. * Gets or sets the current action manager
  80892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80893. */
  80894. _this.actionManager = null;
  80895. // Collisions
  80896. _this._checkCollisions = false;
  80897. _this._collisionMask = -1;
  80898. _this._collisionGroup = -1;
  80899. /**
  80900. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80901. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80902. */
  80903. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  80904. /**
  80905. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80906. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80907. */
  80908. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  80909. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  80910. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  80911. // Edges
  80912. /**
  80913. * Defines edge width used when edgesRenderer is enabled
  80914. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80915. */
  80916. _this.edgesWidth = 1;
  80917. /**
  80918. * Defines edge color used when edgesRenderer is enabled
  80919. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80920. */
  80921. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  80922. /** @hidden */
  80923. _this._renderId = 0;
  80924. /** @hidden */
  80925. _this._intersectionsInProgress = new Array();
  80926. /** @hidden */
  80927. _this._unIndexed = false;
  80928. /** @hidden */
  80929. _this._lightSources = new Array();
  80930. /**
  80931. * An event triggered when the mesh is rebuilt.
  80932. */
  80933. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80934. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  80935. if (collidedMesh === void 0) { collidedMesh = null; }
  80936. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  80937. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  80938. _this.position.addInPlace(_this._diffPositionForCollisions);
  80939. }
  80940. if (collidedMesh) {
  80941. _this.onCollideObservable.notifyObservers(collidedMesh);
  80942. }
  80943. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  80944. };
  80945. _this.getScene().addMesh(_this);
  80946. _this._resyncLightSources();
  80947. return _this;
  80948. }
  80949. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  80950. /**
  80951. * No billboard
  80952. */
  80953. get: function () {
  80954. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  80955. },
  80956. enumerable: true,
  80957. configurable: true
  80958. });
  80959. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  80960. /** Billboard on X axis */
  80961. get: function () {
  80962. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  80963. },
  80964. enumerable: true,
  80965. configurable: true
  80966. });
  80967. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  80968. /** Billboard on Y axis */
  80969. get: function () {
  80970. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  80971. },
  80972. enumerable: true,
  80973. configurable: true
  80974. });
  80975. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  80976. /** Billboard on Z axis */
  80977. get: function () {
  80978. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  80979. },
  80980. enumerable: true,
  80981. configurable: true
  80982. });
  80983. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  80984. /** Billboard on all axes */
  80985. get: function () {
  80986. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  80987. },
  80988. enumerable: true,
  80989. configurable: true
  80990. });
  80991. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  80992. /**
  80993. * Gets the number of facets in the mesh
  80994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80995. */
  80996. get: function () {
  80997. return this._facetData.facetNb;
  80998. },
  80999. enumerable: true,
  81000. configurable: true
  81001. });
  81002. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  81003. /**
  81004. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  81005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81006. */
  81007. get: function () {
  81008. return this._facetData.partitioningSubdivisions;
  81009. },
  81010. set: function (nb) {
  81011. this._facetData.partitioningSubdivisions = nb;
  81012. },
  81013. enumerable: true,
  81014. configurable: true
  81015. });
  81016. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  81017. /**
  81018. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  81019. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  81020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81021. */
  81022. get: function () {
  81023. return this._facetData.partitioningBBoxRatio;
  81024. },
  81025. set: function (ratio) {
  81026. this._facetData.partitioningBBoxRatio = ratio;
  81027. },
  81028. enumerable: true,
  81029. configurable: true
  81030. });
  81031. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  81032. /**
  81033. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  81034. * Works only for updatable meshes.
  81035. * Doesn't work with multi-materials
  81036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81037. */
  81038. get: function () {
  81039. return this._facetData.facetDepthSort;
  81040. },
  81041. set: function (sort) {
  81042. this._facetData.facetDepthSort = sort;
  81043. },
  81044. enumerable: true,
  81045. configurable: true
  81046. });
  81047. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  81048. /**
  81049. * The location (Vector3) where the facet depth sort must be computed from.
  81050. * By default, the active camera position.
  81051. * Used only when facet depth sort is enabled
  81052. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81053. */
  81054. get: function () {
  81055. return this._facetData.facetDepthSortFrom;
  81056. },
  81057. set: function (location) {
  81058. this._facetData.facetDepthSortFrom = location;
  81059. },
  81060. enumerable: true,
  81061. configurable: true
  81062. });
  81063. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  81064. /**
  81065. * gets a boolean indicating if facetData is enabled
  81066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81067. */
  81068. get: function () {
  81069. return this._facetData.facetDataEnabled;
  81070. },
  81071. enumerable: true,
  81072. configurable: true
  81073. });
  81074. /** @hidden */
  81075. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  81076. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  81077. return false;
  81078. }
  81079. this._markSubMeshesAsMiscDirty();
  81080. return true;
  81081. };
  81082. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  81083. /** Set a function to call when this mesh collides with another one */
  81084. set: function (callback) {
  81085. if (this._onCollideObserver) {
  81086. this.onCollideObservable.remove(this._onCollideObserver);
  81087. }
  81088. this._onCollideObserver = this.onCollideObservable.add(callback);
  81089. },
  81090. enumerable: true,
  81091. configurable: true
  81092. });
  81093. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  81094. /** Set a function to call when the collision's position changes */
  81095. set: function (callback) {
  81096. if (this._onCollisionPositionChangeObserver) {
  81097. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  81098. }
  81099. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  81100. },
  81101. enumerable: true,
  81102. configurable: true
  81103. });
  81104. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  81105. /**
  81106. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81107. */
  81108. get: function () {
  81109. return this._visibility;
  81110. },
  81111. /**
  81112. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81113. */
  81114. set: function (value) {
  81115. if (this._visibility === value) {
  81116. return;
  81117. }
  81118. this._visibility = value;
  81119. this._markSubMeshesAsMiscDirty();
  81120. },
  81121. enumerable: true,
  81122. configurable: true
  81123. });
  81124. Object.defineProperty(AbstractMesh.prototype, "material", {
  81125. /** Gets or sets current material */
  81126. get: function () {
  81127. return this._material;
  81128. },
  81129. set: function (value) {
  81130. if (this._material === value) {
  81131. return;
  81132. }
  81133. // remove from material mesh map id needed
  81134. if (this._material && this._material.meshMap) {
  81135. this._material.meshMap[this.uniqueId] = undefined;
  81136. }
  81137. this._material = value;
  81138. if (value && value.meshMap) {
  81139. value.meshMap[this.uniqueId] = this;
  81140. }
  81141. if (this.onMaterialChangedObservable.hasObservers) {
  81142. this.onMaterialChangedObservable.notifyObservers(this);
  81143. }
  81144. if (!this.subMeshes) {
  81145. return;
  81146. }
  81147. this._unBindEffect();
  81148. },
  81149. enumerable: true,
  81150. configurable: true
  81151. });
  81152. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  81153. /**
  81154. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81155. * @see http://doc.babylonjs.com/babylon101/shadows
  81156. */
  81157. get: function () {
  81158. return this._receiveShadows;
  81159. },
  81160. set: function (value) {
  81161. if (this._receiveShadows === value) {
  81162. return;
  81163. }
  81164. this._receiveShadows = value;
  81165. this._markSubMeshesAsLightDirty();
  81166. },
  81167. enumerable: true,
  81168. configurable: true
  81169. });
  81170. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  81171. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81172. get: function () {
  81173. return this._hasVertexAlpha;
  81174. },
  81175. set: function (value) {
  81176. if (this._hasVertexAlpha === value) {
  81177. return;
  81178. }
  81179. this._hasVertexAlpha = value;
  81180. this._markSubMeshesAsAttributesDirty();
  81181. this._markSubMeshesAsMiscDirty();
  81182. },
  81183. enumerable: true,
  81184. configurable: true
  81185. });
  81186. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  81187. /** 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) */
  81188. get: function () {
  81189. return this._useVertexColors;
  81190. },
  81191. set: function (value) {
  81192. if (this._useVertexColors === value) {
  81193. return;
  81194. }
  81195. this._useVertexColors = value;
  81196. this._markSubMeshesAsAttributesDirty();
  81197. },
  81198. enumerable: true,
  81199. configurable: true
  81200. });
  81201. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  81202. /**
  81203. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81204. */
  81205. get: function () {
  81206. return this._computeBonesUsingShaders;
  81207. },
  81208. set: function (value) {
  81209. if (this._computeBonesUsingShaders === value) {
  81210. return;
  81211. }
  81212. this._computeBonesUsingShaders = value;
  81213. this._markSubMeshesAsAttributesDirty();
  81214. },
  81215. enumerable: true,
  81216. configurable: true
  81217. });
  81218. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  81219. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81220. get: function () {
  81221. return this._numBoneInfluencers;
  81222. },
  81223. set: function (value) {
  81224. if (this._numBoneInfluencers === value) {
  81225. return;
  81226. }
  81227. this._numBoneInfluencers = value;
  81228. this._markSubMeshesAsAttributesDirty();
  81229. },
  81230. enumerable: true,
  81231. configurable: true
  81232. });
  81233. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  81234. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81235. get: function () {
  81236. return this._applyFog;
  81237. },
  81238. set: function (value) {
  81239. if (this._applyFog === value) {
  81240. return;
  81241. }
  81242. this._applyFog = value;
  81243. this._markSubMeshesAsMiscDirty();
  81244. },
  81245. enumerable: true,
  81246. configurable: true
  81247. });
  81248. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  81249. /**
  81250. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81251. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81252. */
  81253. get: function () {
  81254. return this._layerMask;
  81255. },
  81256. set: function (value) {
  81257. if (value === this._layerMask) {
  81258. return;
  81259. }
  81260. this._layerMask = value;
  81261. this._resyncLightSources();
  81262. },
  81263. enumerable: true,
  81264. configurable: true
  81265. });
  81266. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  81267. /**
  81268. * Gets or sets a collision mask used to mask collisions (default is -1).
  81269. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81270. */
  81271. get: function () {
  81272. return this._collisionMask;
  81273. },
  81274. set: function (mask) {
  81275. this._collisionMask = !isNaN(mask) ? mask : -1;
  81276. },
  81277. enumerable: true,
  81278. configurable: true
  81279. });
  81280. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  81281. /**
  81282. * Gets or sets the current collision group mask (-1 by default).
  81283. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81284. */
  81285. get: function () {
  81286. return this._collisionGroup;
  81287. },
  81288. set: function (mask) {
  81289. this._collisionGroup = !isNaN(mask) ? mask : -1;
  81290. },
  81291. enumerable: true,
  81292. configurable: true
  81293. });
  81294. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  81295. /** @hidden */
  81296. get: function () {
  81297. return null;
  81298. },
  81299. enumerable: true,
  81300. configurable: true
  81301. });
  81302. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  81303. get: function () {
  81304. return this._skeleton;
  81305. },
  81306. /**
  81307. * Gets or sets a skeleton to apply skining transformations
  81308. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81309. */
  81310. set: function (value) {
  81311. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  81312. this._skeleton._unregisterMeshWithPoseMatrix(this);
  81313. }
  81314. if (value && value.needInitialSkinMatrix) {
  81315. value._registerMeshWithPoseMatrix(this);
  81316. }
  81317. this._skeleton = value;
  81318. if (!this._skeleton) {
  81319. this._bonesTransformMatrices = null;
  81320. }
  81321. this._markSubMeshesAsAttributesDirty();
  81322. },
  81323. enumerable: true,
  81324. configurable: true
  81325. });
  81326. /**
  81327. * Returns the string "AbstractMesh"
  81328. * @returns "AbstractMesh"
  81329. */
  81330. AbstractMesh.prototype.getClassName = function () {
  81331. return "AbstractMesh";
  81332. };
  81333. /**
  81334. * Gets a string representation of the current mesh
  81335. * @param fullDetails defines a boolean indicating if full details must be included
  81336. * @returns a string representation of the current mesh
  81337. */
  81338. AbstractMesh.prototype.toString = function (fullDetails) {
  81339. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  81340. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  81341. if (this._skeleton) {
  81342. ret += ", skeleton: " + this._skeleton.name;
  81343. }
  81344. if (fullDetails) {
  81345. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  81346. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  81347. }
  81348. return ret;
  81349. };
  81350. /** @hidden */
  81351. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  81352. if (initialCall === void 0) { initialCall = true; }
  81353. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  81354. if (trigger) {
  81355. if (this.actionManager.hasSpecificTrigger(trigger)) {
  81356. return this.actionManager;
  81357. }
  81358. }
  81359. else {
  81360. return this.actionManager;
  81361. }
  81362. }
  81363. if (!this.parent) {
  81364. return null;
  81365. }
  81366. return this.parent._getActionManagerForTrigger(trigger, false);
  81367. };
  81368. /** @hidden */
  81369. AbstractMesh.prototype._rebuild = function () {
  81370. this.onRebuildObservable.notifyObservers(this);
  81371. if (this._occlusionQuery) {
  81372. this._occlusionQuery = null;
  81373. }
  81374. if (!this.subMeshes) {
  81375. return;
  81376. }
  81377. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81378. var subMesh = _a[_i];
  81379. subMesh._rebuild();
  81380. }
  81381. };
  81382. /** @hidden */
  81383. AbstractMesh.prototype._resyncLightSources = function () {
  81384. this._lightSources.length = 0;
  81385. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  81386. var light = _a[_i];
  81387. if (!light.isEnabled()) {
  81388. continue;
  81389. }
  81390. if (light.canAffectMesh(this)) {
  81391. this._lightSources.push(light);
  81392. }
  81393. }
  81394. this._markSubMeshesAsLightDirty();
  81395. };
  81396. /** @hidden */
  81397. AbstractMesh.prototype._resyncLighSource = function (light) {
  81398. var isIn = light.isEnabled() && light.canAffectMesh(this);
  81399. var index = this._lightSources.indexOf(light);
  81400. if (index === -1) {
  81401. if (!isIn) {
  81402. return;
  81403. }
  81404. this._lightSources.push(light);
  81405. }
  81406. else {
  81407. if (isIn) {
  81408. return;
  81409. }
  81410. this._lightSources.splice(index, 1);
  81411. }
  81412. this._markSubMeshesAsLightDirty();
  81413. };
  81414. /** @hidden */
  81415. AbstractMesh.prototype._unBindEffect = function () {
  81416. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81417. var subMesh = _a[_i];
  81418. subMesh.setEffect(null);
  81419. }
  81420. };
  81421. /** @hidden */
  81422. AbstractMesh.prototype._removeLightSource = function (light) {
  81423. var index = this._lightSources.indexOf(light);
  81424. if (index === -1) {
  81425. return;
  81426. }
  81427. this._lightSources.splice(index, 1);
  81428. this._markSubMeshesAsLightDirty();
  81429. };
  81430. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  81431. if (!this.subMeshes) {
  81432. return;
  81433. }
  81434. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81435. var subMesh = _a[_i];
  81436. if (subMesh._materialDefines) {
  81437. func(subMesh._materialDefines);
  81438. }
  81439. }
  81440. };
  81441. /** @hidden */
  81442. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  81443. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  81444. };
  81445. /** @hidden */
  81446. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  81447. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  81448. };
  81449. /** @hidden */
  81450. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  81451. if (!this.subMeshes) {
  81452. return;
  81453. }
  81454. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81455. var subMesh = _a[_i];
  81456. var material = subMesh.getMaterial();
  81457. if (material) {
  81458. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  81459. }
  81460. }
  81461. };
  81462. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  81463. /**
  81464. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81465. */
  81466. get: function () {
  81467. return this._scaling;
  81468. },
  81469. set: function (newScaling) {
  81470. this._scaling = newScaling;
  81471. if (this.physicsImpostor) {
  81472. this.physicsImpostor.forceUpdate();
  81473. }
  81474. },
  81475. enumerable: true,
  81476. configurable: true
  81477. });
  81478. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  81479. // Methods
  81480. /**
  81481. * Returns true if the mesh is blocked. Implemented by child classes
  81482. */
  81483. get: function () {
  81484. return false;
  81485. },
  81486. enumerable: true,
  81487. configurable: true
  81488. });
  81489. /**
  81490. * Returns the mesh itself by default. Implemented by child classes
  81491. * @param camera defines the camera to use to pick the right LOD level
  81492. * @returns the currentAbstractMesh
  81493. */
  81494. AbstractMesh.prototype.getLOD = function (camera) {
  81495. return this;
  81496. };
  81497. /**
  81498. * Returns 0 by default. Implemented by child classes
  81499. * @returns an integer
  81500. */
  81501. AbstractMesh.prototype.getTotalVertices = function () {
  81502. return 0;
  81503. };
  81504. /**
  81505. * Returns a positive integer : the total number of indices in this mesh geometry.
  81506. * @returns the numner of indices or zero if the mesh has no geometry.
  81507. */
  81508. AbstractMesh.prototype.getTotalIndices = function () {
  81509. return 0;
  81510. };
  81511. /**
  81512. * Returns null by default. Implemented by child classes
  81513. * @returns null
  81514. */
  81515. AbstractMesh.prototype.getIndices = function () {
  81516. return null;
  81517. };
  81518. /**
  81519. * Returns the array of the requested vertex data kind. Implemented by child classes
  81520. * @param kind defines the vertex data kind to use
  81521. * @returns null
  81522. */
  81523. AbstractMesh.prototype.getVerticesData = function (kind) {
  81524. return null;
  81525. };
  81526. /**
  81527. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81528. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81529. * Note that a new underlying VertexBuffer object is created each call.
  81530. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81531. * @param kind defines vertex data kind:
  81532. * * VertexBuffer.PositionKind
  81533. * * VertexBuffer.UVKind
  81534. * * VertexBuffer.UV2Kind
  81535. * * VertexBuffer.UV3Kind
  81536. * * VertexBuffer.UV4Kind
  81537. * * VertexBuffer.UV5Kind
  81538. * * VertexBuffer.UV6Kind
  81539. * * VertexBuffer.ColorKind
  81540. * * VertexBuffer.MatricesIndicesKind
  81541. * * VertexBuffer.MatricesIndicesExtraKind
  81542. * * VertexBuffer.MatricesWeightsKind
  81543. * * VertexBuffer.MatricesWeightsExtraKind
  81544. * @param data defines the data source
  81545. * @param updatable defines if the data must be flagged as updatable (or static)
  81546. * @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
  81547. * @returns the current mesh
  81548. */
  81549. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81550. return this;
  81551. };
  81552. /**
  81553. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81554. * If the mesh has no geometry, it is simply returned as it is.
  81555. * @param kind defines vertex data kind:
  81556. * * VertexBuffer.PositionKind
  81557. * * VertexBuffer.UVKind
  81558. * * VertexBuffer.UV2Kind
  81559. * * VertexBuffer.UV3Kind
  81560. * * VertexBuffer.UV4Kind
  81561. * * VertexBuffer.UV5Kind
  81562. * * VertexBuffer.UV6Kind
  81563. * * VertexBuffer.ColorKind
  81564. * * VertexBuffer.MatricesIndicesKind
  81565. * * VertexBuffer.MatricesIndicesExtraKind
  81566. * * VertexBuffer.MatricesWeightsKind
  81567. * * VertexBuffer.MatricesWeightsExtraKind
  81568. * @param data defines the data source
  81569. * @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
  81570. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81571. * @returns the current mesh
  81572. */
  81573. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  81574. return this;
  81575. };
  81576. /**
  81577. * Sets the mesh indices,
  81578. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81579. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81580. * @param totalVertices Defines the total number of vertices
  81581. * @returns the current mesh
  81582. */
  81583. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  81584. return this;
  81585. };
  81586. /**
  81587. * Gets a boolean indicating if specific vertex data is present
  81588. * @param kind defines the vertex data kind to use
  81589. * @returns true is data kind is present
  81590. */
  81591. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  81592. return false;
  81593. };
  81594. /**
  81595. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81596. * @returns a BoundingInfo
  81597. */
  81598. AbstractMesh.prototype.getBoundingInfo = function () {
  81599. if (this._masterMesh) {
  81600. return this._masterMesh.getBoundingInfo();
  81601. }
  81602. if (!this._boundingInfo) {
  81603. // this._boundingInfo is being created here
  81604. this._updateBoundingInfo();
  81605. }
  81606. // cannot be null.
  81607. return this._boundingInfo;
  81608. };
  81609. /**
  81610. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81611. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81612. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81613. * @returns the current mesh
  81614. */
  81615. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants, ignoreRotation) {
  81616. if (includeDescendants === void 0) { includeDescendants = true; }
  81617. if (ignoreRotation === void 0) { ignoreRotation = false; }
  81618. var storedRotation = null;
  81619. var storedRotationQuaternion = null;
  81620. if (ignoreRotation) {
  81621. if (this.rotationQuaternion) {
  81622. storedRotationQuaternion = this.rotationQuaternion.clone();
  81623. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
  81624. }
  81625. else if (this.rotation) {
  81626. storedRotation = this.rotation.clone();
  81627. this.rotation.copyFromFloats(0, 0, 0);
  81628. }
  81629. }
  81630. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  81631. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  81632. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  81633. if (maxDimension === 0) {
  81634. return this;
  81635. }
  81636. var scale = 1 / maxDimension;
  81637. this.scaling.scaleInPlace(scale);
  81638. if (ignoreRotation) {
  81639. if (this.rotationQuaternion && storedRotationQuaternion) {
  81640. this.rotationQuaternion.copyFrom(storedRotationQuaternion);
  81641. }
  81642. else if (this.rotation && storedRotation) {
  81643. this.rotation.copyFrom(storedRotation);
  81644. }
  81645. }
  81646. return this;
  81647. };
  81648. /**
  81649. * Overwrite the current bounding info
  81650. * @param boundingInfo defines the new bounding info
  81651. * @returns the current mesh
  81652. */
  81653. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  81654. this._boundingInfo = boundingInfo;
  81655. return this;
  81656. };
  81657. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  81658. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81659. get: function () {
  81660. 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));
  81661. },
  81662. enumerable: true,
  81663. configurable: true
  81664. });
  81665. /** @hidden */
  81666. AbstractMesh.prototype._preActivate = function () {
  81667. };
  81668. /** @hidden */
  81669. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  81670. };
  81671. /** @hidden */
  81672. AbstractMesh.prototype._activate = function (renderId) {
  81673. this._renderId = renderId;
  81674. };
  81675. /**
  81676. * Gets the current world matrix
  81677. * @returns a Matrix
  81678. */
  81679. AbstractMesh.prototype.getWorldMatrix = function () {
  81680. if (this._masterMesh) {
  81681. return this._masterMesh.getWorldMatrix();
  81682. }
  81683. return _super.prototype.getWorldMatrix.call(this);
  81684. };
  81685. /** @hidden */
  81686. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  81687. if (this._masterMesh) {
  81688. return this._masterMesh._getWorldMatrixDeterminant();
  81689. }
  81690. return _super.prototype._getWorldMatrixDeterminant.call(this);
  81691. };
  81692. // ================================== Point of View Movement =================================
  81693. /**
  81694. * Perform relative position change from the point of view of behind the front of the mesh.
  81695. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81696. * Supports definition of mesh facing forward or backward
  81697. * @param amountRight defines the distance on the right axis
  81698. * @param amountUp defines the distance on the up axis
  81699. * @param amountForward defines the distance on the forward axis
  81700. * @returns the current mesh
  81701. */
  81702. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  81703. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  81704. return this;
  81705. };
  81706. /**
  81707. * Calculate relative position change from the point of view of behind the front of the mesh.
  81708. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81709. * Supports definition of mesh facing forward or backward
  81710. * @param amountRight defines the distance on the right axis
  81711. * @param amountUp defines the distance on the up axis
  81712. * @param amountForward defines the distance on the forward axis
  81713. * @returns the new displacement vector
  81714. */
  81715. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  81716. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  81717. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  81718. rotQuaternion.toRotationMatrix(rotMatrix);
  81719. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81720. var defForwardMult = this.definedFacingForward ? -1 : 1;
  81721. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  81722. return translationDelta;
  81723. };
  81724. // ================================== Point of View Rotation =================================
  81725. /**
  81726. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81727. * Supports definition of mesh facing forward or backward
  81728. * @param flipBack defines the flip
  81729. * @param twirlClockwise defines the twirl
  81730. * @param tiltRight defines the tilt
  81731. * @returns the current mesh
  81732. */
  81733. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  81734. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  81735. return this;
  81736. };
  81737. /**
  81738. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81739. * Supports definition of mesh facing forward or backward.
  81740. * @param flipBack defines the flip
  81741. * @param twirlClockwise defines the twirl
  81742. * @param tiltRight defines the tilt
  81743. * @returns the new rotation vector
  81744. */
  81745. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  81746. var defForwardMult = this.definedFacingForward ? 1 : -1;
  81747. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  81748. };
  81749. /**
  81750. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81751. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81752. * @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
  81753. * @returns the new bounding vectors
  81754. */
  81755. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  81756. if (includeDescendants === void 0) { includeDescendants = true; }
  81757. if (predicate === void 0) { predicate = null; }
  81758. // Ensures that all world matrix will be recomputed.
  81759. this.getScene().incrementRenderId();
  81760. this.computeWorldMatrix(true);
  81761. var min;
  81762. var max;
  81763. var boundingInfo = this.getBoundingInfo();
  81764. if (!this.subMeshes) {
  81765. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  81766. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  81767. }
  81768. else {
  81769. min = boundingInfo.boundingBox.minimumWorld;
  81770. max = boundingInfo.boundingBox.maximumWorld;
  81771. }
  81772. if (includeDescendants) {
  81773. var descendants = this.getDescendants(false);
  81774. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  81775. var descendant = descendants_1[_i];
  81776. var childMesh = descendant;
  81777. childMesh.computeWorldMatrix(true);
  81778. // Filters meshes based on custom predicate function.
  81779. if (predicate && !predicate(childMesh)) {
  81780. continue;
  81781. }
  81782. //make sure we have the needed params to get mix and max
  81783. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  81784. continue;
  81785. }
  81786. var childBoundingInfo = childMesh.getBoundingInfo();
  81787. var boundingBox = childBoundingInfo.boundingBox;
  81788. var minBox = boundingBox.minimumWorld;
  81789. var maxBox = boundingBox.maximumWorld;
  81790. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  81791. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  81792. }
  81793. }
  81794. return {
  81795. min: min,
  81796. max: max
  81797. };
  81798. };
  81799. /**
  81800. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81801. * This means the mesh underlying bounding box and sphere are recomputed.
  81802. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81803. * @returns the current mesh
  81804. */
  81805. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  81806. if (applySkeleton === void 0) { applySkeleton = false; }
  81807. if (this._boundingInfo && this._boundingInfo.isLocked) {
  81808. return this;
  81809. }
  81810. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  81811. return this;
  81812. };
  81813. /** @hidden */
  81814. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  81815. if (data) {
  81816. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  81817. if (this._boundingInfo) {
  81818. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  81819. }
  81820. else {
  81821. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  81822. }
  81823. }
  81824. if (this.subMeshes) {
  81825. for (var index = 0; index < this.subMeshes.length; index++) {
  81826. this.subMeshes[index].refreshBoundingInfo();
  81827. }
  81828. }
  81829. this._updateBoundingInfo();
  81830. };
  81831. /** @hidden */
  81832. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  81833. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  81834. if (data && applySkeleton && this.skeleton) {
  81835. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  81836. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  81837. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  81838. if (matricesWeightsData && matricesIndicesData) {
  81839. var needExtras = this.numBoneInfluencers > 4;
  81840. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  81841. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  81842. this.skeleton.prepare();
  81843. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  81844. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  81845. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  81846. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  81847. var matWeightIdx = 0;
  81848. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  81849. finalMatrix.reset();
  81850. var inf;
  81851. var weight;
  81852. for (inf = 0; inf < 4; inf++) {
  81853. weight = matricesWeightsData[matWeightIdx + inf];
  81854. if (weight > 0) {
  81855. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  81856. finalMatrix.addToSelf(tempMatrix);
  81857. }
  81858. }
  81859. if (needExtras) {
  81860. for (inf = 0; inf < 4; inf++) {
  81861. weight = matricesWeightsExtraData[matWeightIdx + inf];
  81862. if (weight > 0) {
  81863. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  81864. finalMatrix.addToSelf(tempMatrix);
  81865. }
  81866. }
  81867. }
  81868. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  81869. tempVector.toArray(data, index);
  81870. }
  81871. }
  81872. }
  81873. return data;
  81874. };
  81875. /** @hidden */
  81876. AbstractMesh.prototype._updateBoundingInfo = function () {
  81877. var effectiveMesh = this._effectiveMesh;
  81878. if (this._boundingInfo) {
  81879. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  81880. }
  81881. else {
  81882. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  81883. }
  81884. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  81885. return this;
  81886. };
  81887. /** @hidden */
  81888. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  81889. if (!this.subMeshes) {
  81890. return this;
  81891. }
  81892. var count = this.subMeshes.length;
  81893. for (var subIndex = 0; subIndex < count; subIndex++) {
  81894. var subMesh = this.subMeshes[subIndex];
  81895. if (count > 1 || !subMesh.IsGlobal) {
  81896. subMesh.updateBoundingInfo(matrix);
  81897. }
  81898. }
  81899. return this;
  81900. };
  81901. /** @hidden */
  81902. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  81903. // Bounding info
  81904. this._updateBoundingInfo();
  81905. };
  81906. Object.defineProperty(AbstractMesh.prototype, "_effectiveMesh", {
  81907. /** @hidden */
  81908. get: function () {
  81909. return (this.skeleton && this.skeleton.overrideMesh) || this;
  81910. },
  81911. enumerable: true,
  81912. configurable: true
  81913. });
  81914. /**
  81915. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81916. * A mesh is in the frustum if its bounding box intersects the frustum
  81917. * @param frustumPlanes defines the frustum to test
  81918. * @returns true if the mesh is in the frustum planes
  81919. */
  81920. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  81921. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  81922. };
  81923. /**
  81924. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81925. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81926. * @param frustumPlanes defines the frustum to test
  81927. * @returns true if the mesh is completely in the frustum planes
  81928. */
  81929. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  81930. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  81931. };
  81932. /**
  81933. * True if the mesh intersects another mesh or a SolidParticle object
  81934. * @param mesh defines a target mesh or SolidParticle to test
  81935. * @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)
  81936. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81937. * @returns true if there is an intersection
  81938. */
  81939. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  81940. if (precise === void 0) { precise = false; }
  81941. if (!this._boundingInfo || !mesh._boundingInfo) {
  81942. return false;
  81943. }
  81944. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  81945. return true;
  81946. }
  81947. if (includeDescendants) {
  81948. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  81949. var child = _a[_i];
  81950. if (child.intersectsMesh(mesh, precise, true)) {
  81951. return true;
  81952. }
  81953. }
  81954. }
  81955. return false;
  81956. };
  81957. /**
  81958. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81959. * @param point defines the point to test
  81960. * @returns true if there is an intersection
  81961. */
  81962. AbstractMesh.prototype.intersectsPoint = function (point) {
  81963. if (!this._boundingInfo) {
  81964. return false;
  81965. }
  81966. return this._boundingInfo.intersectsPoint(point);
  81967. };
  81968. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  81969. // Collisions
  81970. /**
  81971. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81972. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81973. */
  81974. get: function () {
  81975. return this._checkCollisions;
  81976. },
  81977. set: function (collisionEnabled) {
  81978. this._checkCollisions = collisionEnabled;
  81979. },
  81980. enumerable: true,
  81981. configurable: true
  81982. });
  81983. Object.defineProperty(AbstractMesh.prototype, "collider", {
  81984. /**
  81985. * Gets Collider object used to compute collisions (not physics)
  81986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81987. */
  81988. get: function () {
  81989. return this._collider;
  81990. },
  81991. enumerable: true,
  81992. configurable: true
  81993. });
  81994. /**
  81995. * Move the mesh using collision engine
  81996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81997. * @param displacement defines the requested displacement vector
  81998. * @returns the current mesh
  81999. */
  82000. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  82001. var globalPosition = this.getAbsolutePosition();
  82002. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  82003. var coordinator = this.getScene().collisionCoordinator;
  82004. if (!this._collider) {
  82005. this._collider = coordinator.createCollider();
  82006. }
  82007. this._collider._radius = this.ellipsoid;
  82008. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  82009. return this;
  82010. };
  82011. // Collisions
  82012. /** @hidden */
  82013. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  82014. this._generatePointsArray();
  82015. if (!this._positions) {
  82016. return this;
  82017. }
  82018. // Transformation
  82019. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  82020. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  82021. subMesh._lastColliderWorldVertices = [];
  82022. subMesh._trianglePlanes = [];
  82023. var start = subMesh.verticesStart;
  82024. var end = (subMesh.verticesStart + subMesh.verticesCount);
  82025. for (var i = start; i < end; i++) {
  82026. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  82027. }
  82028. }
  82029. // Collide
  82030. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  82031. if (collider.collisionFound) {
  82032. collider.collidedMesh = this;
  82033. }
  82034. return this;
  82035. };
  82036. /** @hidden */
  82037. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  82038. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  82039. var len = subMeshes.length;
  82040. for (var index = 0; index < len; index++) {
  82041. var subMesh = subMeshes.data[index];
  82042. // Bounding test
  82043. if (len > 1 && !subMesh._checkCollision(collider)) {
  82044. continue;
  82045. }
  82046. this._collideForSubMesh(subMesh, transformMatrix, collider);
  82047. }
  82048. return this;
  82049. };
  82050. /** @hidden */
  82051. AbstractMesh.prototype._checkCollision = function (collider) {
  82052. // Bounding box test
  82053. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  82054. return this;
  82055. }
  82056. // Transformation matrix
  82057. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  82058. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  82059. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  82060. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  82061. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  82062. return this;
  82063. };
  82064. // Picking
  82065. /** @hidden */
  82066. AbstractMesh.prototype._generatePointsArray = function () {
  82067. return false;
  82068. };
  82069. /**
  82070. * Checks if the passed Ray intersects with the mesh
  82071. * @param ray defines the ray to use
  82072. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  82073. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82074. * @returns the picking info
  82075. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82076. */
  82077. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  82078. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  82079. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  82080. var boundingInfo = this._boundingInfo;
  82081. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  82082. return pickingInfo;
  82083. }
  82084. if (!this._generatePointsArray()) {
  82085. return pickingInfo;
  82086. }
  82087. var intersectInfo = null;
  82088. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  82089. var len = subMeshes.length;
  82090. for (var index = 0; index < len; index++) {
  82091. var subMesh = subMeshes.data[index];
  82092. // Bounding test
  82093. if (len > 1 && !subMesh.canIntersects(ray)) {
  82094. continue;
  82095. }
  82096. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  82097. if (currentIntersectInfo) {
  82098. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  82099. intersectInfo = currentIntersectInfo;
  82100. intersectInfo.subMeshId = index;
  82101. if (fastCheck) {
  82102. break;
  82103. }
  82104. }
  82105. }
  82106. }
  82107. if (intersectInfo) {
  82108. // Get picked point
  82109. var world = this.getWorldMatrix();
  82110. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  82111. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  82112. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  82113. ray.direction.scaleToRef(intersectInfo.distance, direction);
  82114. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  82115. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  82116. // Return result
  82117. pickingInfo.hit = true;
  82118. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  82119. pickingInfo.pickedPoint = pickedPoint;
  82120. pickingInfo.pickedMesh = this;
  82121. pickingInfo.bu = intersectInfo.bu || 0;
  82122. pickingInfo.bv = intersectInfo.bv || 0;
  82123. pickingInfo.faceId = intersectInfo.faceId;
  82124. pickingInfo.subMeshId = intersectInfo.subMeshId;
  82125. return pickingInfo;
  82126. }
  82127. return pickingInfo;
  82128. };
  82129. /**
  82130. * Clones the current mesh
  82131. * @param name defines the mesh name
  82132. * @param newParent defines the new mesh parent
  82133. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  82134. * @returns the new mesh
  82135. */
  82136. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  82137. return null;
  82138. };
  82139. /**
  82140. * Disposes all the submeshes of the current meshnp
  82141. * @returns the current mesh
  82142. */
  82143. AbstractMesh.prototype.releaseSubMeshes = function () {
  82144. if (this.subMeshes) {
  82145. while (this.subMeshes.length) {
  82146. this.subMeshes[0].dispose();
  82147. }
  82148. }
  82149. else {
  82150. this.subMeshes = new Array();
  82151. }
  82152. return this;
  82153. };
  82154. /**
  82155. * Releases resources associated with this abstract mesh.
  82156. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82157. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82158. */
  82159. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  82160. var _this = this;
  82161. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  82162. var index;
  82163. // Smart Array Retainers.
  82164. this.getScene().freeActiveMeshes();
  82165. this.getScene().freeRenderingGroups();
  82166. // Action manager
  82167. if (this.actionManager !== undefined && this.actionManager !== null) {
  82168. this.actionManager.dispose();
  82169. this.actionManager = null;
  82170. }
  82171. // Skeleton
  82172. this._skeleton = null;
  82173. // Intersections in progress
  82174. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  82175. var other = this._intersectionsInProgress[index];
  82176. var pos = other._intersectionsInProgress.indexOf(this);
  82177. other._intersectionsInProgress.splice(pos, 1);
  82178. }
  82179. this._intersectionsInProgress = [];
  82180. // Lights
  82181. var lights = this.getScene().lights;
  82182. lights.forEach(function (light) {
  82183. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  82184. if (meshIndex !== -1) {
  82185. light.includedOnlyMeshes.splice(meshIndex, 1);
  82186. }
  82187. meshIndex = light.excludedMeshes.indexOf(_this);
  82188. if (meshIndex !== -1) {
  82189. light.excludedMeshes.splice(meshIndex, 1);
  82190. }
  82191. // Shadow generators
  82192. var generator = light.getShadowGenerator();
  82193. if (generator) {
  82194. var shadowMap = generator.getShadowMap();
  82195. if (shadowMap && shadowMap.renderList) {
  82196. meshIndex = shadowMap.renderList.indexOf(_this);
  82197. if (meshIndex !== -1) {
  82198. shadowMap.renderList.splice(meshIndex, 1);
  82199. }
  82200. }
  82201. }
  82202. });
  82203. // SubMeshes
  82204. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  82205. this.releaseSubMeshes();
  82206. }
  82207. // Query
  82208. var engine = this.getScene().getEngine();
  82209. if (this._occlusionQuery) {
  82210. this.isOcclusionQueryInProgress = false;
  82211. engine.deleteQuery(this._occlusionQuery);
  82212. this._occlusionQuery = null;
  82213. }
  82214. // Engine
  82215. engine.wipeCaches();
  82216. // Remove from scene
  82217. this.getScene().removeMesh(this);
  82218. if (disposeMaterialAndTextures) {
  82219. if (this.material) {
  82220. if (this.material.getClassName() === "MultiMaterial") {
  82221. this.material.dispose(false, true, true);
  82222. }
  82223. else {
  82224. this.material.dispose(false, true);
  82225. }
  82226. }
  82227. }
  82228. if (!doNotRecurse) {
  82229. // Particles
  82230. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  82231. if (this.getScene().particleSystems[index].emitter === this) {
  82232. this.getScene().particleSystems[index].dispose();
  82233. index--;
  82234. }
  82235. }
  82236. }
  82237. // facet data
  82238. if (this._facetData.facetDataEnabled) {
  82239. this.disableFacetData();
  82240. }
  82241. this.onAfterWorldMatrixUpdateObservable.clear();
  82242. this.onCollideObservable.clear();
  82243. this.onCollisionPositionChangeObservable.clear();
  82244. this.onRebuildObservable.clear();
  82245. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  82246. };
  82247. /**
  82248. * Adds the passed mesh as a child to the current mesh
  82249. * @param mesh defines the child mesh
  82250. * @returns the current mesh
  82251. */
  82252. AbstractMesh.prototype.addChild = function (mesh) {
  82253. mesh.setParent(this);
  82254. return this;
  82255. };
  82256. /**
  82257. * Removes the passed mesh from the current mesh children list
  82258. * @param mesh defines the child mesh
  82259. * @returns the current mesh
  82260. */
  82261. AbstractMesh.prototype.removeChild = function (mesh) {
  82262. mesh.setParent(null);
  82263. return this;
  82264. };
  82265. // Facet data
  82266. /** @hidden */
  82267. AbstractMesh.prototype._initFacetData = function () {
  82268. var data = this._facetData;
  82269. if (!data.facetNormals) {
  82270. data.facetNormals = new Array();
  82271. }
  82272. if (!data.facetPositions) {
  82273. data.facetPositions = new Array();
  82274. }
  82275. if (!data.facetPartitioning) {
  82276. data.facetPartitioning = new Array();
  82277. }
  82278. data.facetNb = (this.getIndices().length / 3) | 0;
  82279. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  82280. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  82281. for (var f = 0; f < data.facetNb; f++) {
  82282. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82283. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82284. }
  82285. data.facetDataEnabled = true;
  82286. return this;
  82287. };
  82288. /**
  82289. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  82290. * This method can be called within the render loop.
  82291. * 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
  82292. * @returns the current mesh
  82293. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82294. */
  82295. AbstractMesh.prototype.updateFacetData = function () {
  82296. var data = this._facetData;
  82297. if (!data.facetDataEnabled) {
  82298. this._initFacetData();
  82299. }
  82300. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  82301. var indices = this.getIndices();
  82302. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  82303. var bInfo = this.getBoundingInfo();
  82304. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  82305. // init arrays, matrix and sort function on first call
  82306. data.facetDepthSortEnabled = true;
  82307. if (indices instanceof Uint16Array) {
  82308. data.depthSortedIndices = new Uint16Array(indices);
  82309. }
  82310. else if (indices instanceof Uint32Array) {
  82311. data.depthSortedIndices = new Uint32Array(indices);
  82312. }
  82313. else {
  82314. var needs32bits = false;
  82315. for (var i = 0; i < indices.length; i++) {
  82316. if (indices[i] > 65535) {
  82317. needs32bits = true;
  82318. break;
  82319. }
  82320. }
  82321. if (needs32bits) {
  82322. data.depthSortedIndices = new Uint32Array(indices);
  82323. }
  82324. else {
  82325. data.depthSortedIndices = new Uint16Array(indices);
  82326. }
  82327. }
  82328. data.facetDepthSortFunction = function (f1, f2) {
  82329. return (f2.sqDistance - f1.sqDistance);
  82330. };
  82331. if (!data.facetDepthSortFrom) {
  82332. var camera = this.getScene().activeCamera;
  82333. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82334. }
  82335. data.depthSortedFacets = [];
  82336. for (var f = 0; f < data.facetNb; f++) {
  82337. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  82338. data.depthSortedFacets.push(depthSortedFacet);
  82339. }
  82340. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  82341. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82342. }
  82343. 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"];
  82344. 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"];
  82345. 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"];
  82346. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  82347. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  82348. data.subDiv.max = data.partitioningSubdivisions;
  82349. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  82350. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  82351. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  82352. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  82353. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  82354. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  82355. // set the parameters for ComputeNormals()
  82356. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  82357. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  82358. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  82359. data.facetParameters.bInfo = bInfo;
  82360. data.facetParameters.bbSize = data.bbSize;
  82361. data.facetParameters.subDiv = data.subDiv;
  82362. data.facetParameters.ratio = this.partitioningBBoxRatio;
  82363. data.facetParameters.depthSort = data.facetDepthSort;
  82364. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  82365. this.computeWorldMatrix(true);
  82366. this._worldMatrix.invertToRef(data.invertedMatrix);
  82367. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  82368. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  82369. }
  82370. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  82371. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  82372. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  82373. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  82374. var l = (data.depthSortedIndices.length / 3) | 0;
  82375. for (var f = 0; f < l; f++) {
  82376. var sind = data.depthSortedFacets[f].ind;
  82377. data.depthSortedIndices[f * 3] = indices[sind];
  82378. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  82379. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  82380. }
  82381. this.updateIndices(data.depthSortedIndices, undefined, true);
  82382. }
  82383. return this;
  82384. };
  82385. /**
  82386. * Returns the facetLocalNormals array.
  82387. * The normals are expressed in the mesh local spac
  82388. * @returns an array of Vector3
  82389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82390. */
  82391. AbstractMesh.prototype.getFacetLocalNormals = function () {
  82392. if (!this._facetData.facetNormals) {
  82393. this.updateFacetData();
  82394. }
  82395. return this._facetData.facetNormals;
  82396. };
  82397. /**
  82398. * Returns the facetLocalPositions array.
  82399. * The facet positions are expressed in the mesh local space
  82400. * @returns an array of Vector3
  82401. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82402. */
  82403. AbstractMesh.prototype.getFacetLocalPositions = function () {
  82404. if (!this._facetData.facetPositions) {
  82405. this.updateFacetData();
  82406. }
  82407. return this._facetData.facetPositions;
  82408. };
  82409. /**
  82410. * Returns the facetLocalPartioning array
  82411. * @returns an array of array of numbers
  82412. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82413. */
  82414. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  82415. if (!this._facetData.facetPartitioning) {
  82416. this.updateFacetData();
  82417. }
  82418. return this._facetData.facetPartitioning;
  82419. };
  82420. /**
  82421. * Returns the i-th facet position in the world system.
  82422. * This method allocates a new Vector3 per call
  82423. * @param i defines the facet index
  82424. * @returns a new Vector3
  82425. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82426. */
  82427. AbstractMesh.prototype.getFacetPosition = function (i) {
  82428. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82429. this.getFacetPositionToRef(i, pos);
  82430. return pos;
  82431. };
  82432. /**
  82433. * Sets the reference Vector3 with the i-th facet position in the world system
  82434. * @param i defines the facet index
  82435. * @param ref defines the target vector
  82436. * @returns the current mesh
  82437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82438. */
  82439. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  82440. var localPos = (this.getFacetLocalPositions())[i];
  82441. var world = this.getWorldMatrix();
  82442. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  82443. return this;
  82444. };
  82445. /**
  82446. * Returns the i-th facet normal in the world system.
  82447. * This method allocates a new Vector3 per call
  82448. * @param i defines the facet index
  82449. * @returns a new Vector3
  82450. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82451. */
  82452. AbstractMesh.prototype.getFacetNormal = function (i) {
  82453. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82454. this.getFacetNormalToRef(i, norm);
  82455. return norm;
  82456. };
  82457. /**
  82458. * Sets the reference Vector3 with the i-th facet normal in the world system
  82459. * @param i defines the facet index
  82460. * @param ref defines the target vector
  82461. * @returns the current mesh
  82462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82463. */
  82464. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  82465. var localNorm = (this.getFacetLocalNormals())[i];
  82466. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  82467. return this;
  82468. };
  82469. /**
  82470. * 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)
  82471. * @param x defines x coordinate
  82472. * @param y defines y coordinate
  82473. * @param z defines z coordinate
  82474. * @returns the array of facet indexes
  82475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82476. */
  82477. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  82478. var bInfo = this.getBoundingInfo();
  82479. var data = this._facetData;
  82480. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  82481. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  82482. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  82483. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  82484. return null;
  82485. }
  82486. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  82487. };
  82488. /**
  82489. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  82490. * @param projected sets as the (x,y,z) world projection on the facet
  82491. * @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
  82492. * @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
  82493. * @param x defines x coordinate
  82494. * @param y defines y coordinate
  82495. * @param z defines z coordinate
  82496. * @returns the face index if found (or null instead)
  82497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82498. */
  82499. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  82500. if (checkFace === void 0) { checkFace = false; }
  82501. if (facing === void 0) { facing = true; }
  82502. var world = this.getWorldMatrix();
  82503. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  82504. world.invertToRef(invMat);
  82505. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  82506. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  82507. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  82508. if (projected) {
  82509. // tranform the local computed projected vector to world coordinates
  82510. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  82511. }
  82512. return closest;
  82513. };
  82514. /**
  82515. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  82516. * @param projected sets as the (x,y,z) local projection on the facet
  82517. * @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
  82518. * @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
  82519. * @param x defines x coordinate
  82520. * @param y defines y coordinate
  82521. * @param z defines z coordinate
  82522. * @returns the face index if found (or null instead)
  82523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82524. */
  82525. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  82526. if (checkFace === void 0) { checkFace = false; }
  82527. if (facing === void 0) { facing = true; }
  82528. var closest = null;
  82529. var tmpx = 0.0;
  82530. var tmpy = 0.0;
  82531. var tmpz = 0.0;
  82532. var d = 0.0; // tmp dot facet normal * facet position
  82533. var t0 = 0.0;
  82534. var projx = 0.0;
  82535. var projy = 0.0;
  82536. var projz = 0.0;
  82537. // Get all the facets in the same partitioning block than (x, y, z)
  82538. var facetPositions = this.getFacetLocalPositions();
  82539. var facetNormals = this.getFacetLocalNormals();
  82540. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  82541. if (!facetsInBlock) {
  82542. return null;
  82543. }
  82544. // Get the closest facet to (x, y, z)
  82545. var shortest = Number.MAX_VALUE; // init distance vars
  82546. var tmpDistance = shortest;
  82547. var fib; // current facet in the block
  82548. var norm; // current facet normal
  82549. var p0; // current facet barycenter position
  82550. // loop on all the facets in the current partitioning block
  82551. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  82552. fib = facetsInBlock[idx];
  82553. norm = facetNormals[fib];
  82554. p0 = facetPositions[fib];
  82555. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  82556. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  82557. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  82558. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  82559. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  82560. projx = x + norm.x * t0;
  82561. projy = y + norm.y * t0;
  82562. projz = z + norm.z * t0;
  82563. tmpx = projx - x;
  82564. tmpy = projy - y;
  82565. tmpz = projz - z;
  82566. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  82567. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  82568. shortest = tmpDistance;
  82569. closest = fib;
  82570. if (projected) {
  82571. projected.x = projx;
  82572. projected.y = projy;
  82573. projected.z = projz;
  82574. }
  82575. }
  82576. }
  82577. }
  82578. return closest;
  82579. };
  82580. /**
  82581. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  82582. * @returns the parameters
  82583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82584. */
  82585. AbstractMesh.prototype.getFacetDataParameters = function () {
  82586. return this._facetData.facetParameters;
  82587. };
  82588. /**
  82589. * Disables the feature FacetData and frees the related memory
  82590. * @returns the current mesh
  82591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82592. */
  82593. AbstractMesh.prototype.disableFacetData = function () {
  82594. if (this._facetData.facetDataEnabled) {
  82595. this._facetData.facetDataEnabled = false;
  82596. this._facetData.facetPositions = new Array();
  82597. this._facetData.facetNormals = new Array();
  82598. this._facetData.facetPartitioning = new Array();
  82599. this._facetData.facetParameters = null;
  82600. this._facetData.depthSortedIndices = new Uint32Array(0);
  82601. }
  82602. return this;
  82603. };
  82604. /**
  82605. * Updates the AbstractMesh indices array
  82606. * @param indices defines the data source
  82607. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  82608. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  82609. * @returns the current mesh
  82610. */
  82611. AbstractMesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  82612. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  82613. return this;
  82614. };
  82615. /**
  82616. * Creates new normals data for the mesh
  82617. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  82618. * @returns the current mesh
  82619. */
  82620. AbstractMesh.prototype.createNormals = function (updatable) {
  82621. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  82622. var indices = this.getIndices();
  82623. var normals;
  82624. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  82625. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  82626. }
  82627. else {
  82628. normals = [];
  82629. }
  82630. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  82631. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  82632. return this;
  82633. };
  82634. /**
  82635. * Align the mesh with a normal
  82636. * @param normal defines the normal to use
  82637. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  82638. * @returns the current mesh
  82639. */
  82640. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  82641. if (!upDirection) {
  82642. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  82643. }
  82644. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  82645. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  82646. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  82647. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  82648. if (this.rotationQuaternion) {
  82649. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  82650. }
  82651. else {
  82652. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  82653. }
  82654. return this;
  82655. };
  82656. /** @hidden */
  82657. AbstractMesh.prototype._checkOcclusionQuery = function () {
  82658. return false;
  82659. };
  82660. /** No occlusion */
  82661. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  82662. /** Occlusion set to optimisitic */
  82663. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  82664. /** Occlusion set to strict */
  82665. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  82666. /** Use an accurante occlusion algorithm */
  82667. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  82668. /** Use a conservative occlusion algorithm */
  82669. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  82670. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82671. * Test order :
  82672. * Is the bounding sphere outside the frustum ?
  82673. * If not, are the bounding box vertices outside the frustum ?
  82674. * It not, then the cullable object is in the frustum.
  82675. */
  82676. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  82677. /** Culling strategy : Bounding Sphere Only.
  82678. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82679. * It's also less accurate than the standard because some not visible objects can still be selected.
  82680. * Test : is the bounding sphere outside the frustum ?
  82681. * If not, then the cullable object is in the frustum.
  82682. */
  82683. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  82684. /** Culling strategy : Optimistic Inclusion.
  82685. * This in an inclusion test first, then the standard exclusion test.
  82686. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82687. * 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.
  82688. * Anyway, it's as accurate as the standard strategy.
  82689. * Test :
  82690. * Is the cullable object bounding sphere center in the frustum ?
  82691. * If not, apply the default culling strategy.
  82692. */
  82693. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  82694. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82695. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82696. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82697. * 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.
  82698. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82699. * Test :
  82700. * Is the cullable object bounding sphere center in the frustum ?
  82701. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82702. */
  82703. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  82704. return AbstractMesh;
  82705. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  82706. /***/ }),
  82707. /***/ "./Meshes/buffer.ts":
  82708. /*!**************************!*\
  82709. !*** ./Meshes/buffer.ts ***!
  82710. \**************************/
  82711. /*! exports provided: Buffer, VertexBuffer */
  82712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82713. "use strict";
  82714. __webpack_require__.r(__webpack_exports__);
  82715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  82716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  82717. /**
  82718. * Class used to store data that will be store in GPU memory
  82719. */
  82720. var Buffer = /** @class */ (function () {
  82721. /**
  82722. * Constructor
  82723. * @param engine the engine
  82724. * @param data the data to use for this buffer
  82725. * @param updatable whether the data is updatable
  82726. * @param stride the stride (optional)
  82727. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82728. * @param instanced whether the buffer is instanced (optional)
  82729. * @param useBytes set to true if the stride in in bytes (optional)
  82730. */
  82731. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  82732. if (stride === void 0) { stride = 0; }
  82733. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  82734. if (instanced === void 0) { instanced = false; }
  82735. if (useBytes === void 0) { useBytes = false; }
  82736. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  82737. this._engine = engine.getScene().getEngine();
  82738. }
  82739. else {
  82740. this._engine = engine;
  82741. }
  82742. this._updatable = updatable;
  82743. this._instanced = instanced;
  82744. this._data = data;
  82745. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  82746. if (!postponeInternalCreation) { // by default
  82747. this.create();
  82748. }
  82749. }
  82750. /**
  82751. * Create a new VertexBuffer based on the current buffer
  82752. * @param kind defines the vertex buffer kind (position, normal, etc.)
  82753. * @param offset defines offset in the buffer (0 by default)
  82754. * @param size defines the size in floats of attributes (position is 3 for instance)
  82755. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  82756. * @param instanced defines if the vertex buffer contains indexed data
  82757. * @param useBytes defines if the offset and stride are in bytes
  82758. * @returns the new vertex buffer
  82759. */
  82760. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  82761. if (useBytes === void 0) { useBytes = false; }
  82762. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  82763. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  82764. // a lot of these parameters are ignored as they are overriden by the buffer
  82765. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  82766. };
  82767. // Properties
  82768. /**
  82769. * Gets a boolean indicating if the Buffer is updatable?
  82770. * @returns true if the buffer is updatable
  82771. */
  82772. Buffer.prototype.isUpdatable = function () {
  82773. return this._updatable;
  82774. };
  82775. /**
  82776. * Gets current buffer's data
  82777. * @returns a DataArray or null
  82778. */
  82779. Buffer.prototype.getData = function () {
  82780. return this._data;
  82781. };
  82782. /**
  82783. * Gets underlying native buffer
  82784. * @returns underlying native buffer
  82785. */
  82786. Buffer.prototype.getBuffer = function () {
  82787. return this._buffer;
  82788. };
  82789. /**
  82790. * Gets the stride in float32 units (i.e. byte stride / 4).
  82791. * May not be an integer if the byte stride is not divisible by 4.
  82792. * DEPRECATED. Use byteStride instead.
  82793. * @returns the stride in float32 units
  82794. */
  82795. Buffer.prototype.getStrideSize = function () {
  82796. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  82797. };
  82798. // Methods
  82799. /**
  82800. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82801. * @param data defines the data to store
  82802. */
  82803. Buffer.prototype.create = function (data) {
  82804. if (data === void 0) { data = null; }
  82805. if (!data && this._buffer) {
  82806. return; // nothing to do
  82807. }
  82808. data = data || this._data;
  82809. if (!data) {
  82810. return;
  82811. }
  82812. if (!this._buffer) { // create buffer
  82813. if (this._updatable) {
  82814. this._buffer = this._engine.createDynamicVertexBuffer(data);
  82815. this._data = data;
  82816. }
  82817. else {
  82818. this._buffer = this._engine.createVertexBuffer(data);
  82819. }
  82820. }
  82821. else if (this._updatable) { // update buffer
  82822. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  82823. this._data = data;
  82824. }
  82825. };
  82826. /** @hidden */
  82827. Buffer.prototype._rebuild = function () {
  82828. this._buffer = null;
  82829. this.create(this._data);
  82830. };
  82831. /**
  82832. * Update current buffer data
  82833. * @param data defines the data to store
  82834. */
  82835. Buffer.prototype.update = function (data) {
  82836. this.create(data);
  82837. };
  82838. /**
  82839. * Updates the data directly.
  82840. * @param data the new data
  82841. * @param offset the new offset
  82842. * @param vertexCount the vertex count (optional)
  82843. * @param useBytes set to true if the offset is in bytes
  82844. */
  82845. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  82846. if (useBytes === void 0) { useBytes = false; }
  82847. if (!this._buffer) {
  82848. return;
  82849. }
  82850. if (this._updatable) { // update buffer
  82851. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  82852. this._data = null;
  82853. }
  82854. };
  82855. /**
  82856. * Release all resources
  82857. */
  82858. Buffer.prototype.dispose = function () {
  82859. if (!this._buffer) {
  82860. return;
  82861. }
  82862. if (this._engine._releaseBuffer(this._buffer)) {
  82863. this._buffer = null;
  82864. }
  82865. };
  82866. return Buffer;
  82867. }());
  82868. /**
  82869. * Specialized buffer used to store vertex data
  82870. */
  82871. var VertexBuffer = /** @class */ (function () {
  82872. /**
  82873. * Constructor
  82874. * @param engine the engine
  82875. * @param data the data to use for this vertex buffer
  82876. * @param kind the vertex buffer kind
  82877. * @param updatable whether the data is updatable
  82878. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82879. * @param stride the stride (optional)
  82880. * @param instanced whether the buffer is instanced (optional)
  82881. * @param offset the offset of the data (optional)
  82882. * @param size the number of components (optional)
  82883. * @param type the type of the component (optional)
  82884. * @param normalized whether the data contains normalized data (optional)
  82885. * @param useBytes set to true if stride and offset are in bytes (optional)
  82886. */
  82887. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  82888. if (normalized === void 0) { normalized = false; }
  82889. if (useBytes === void 0) { useBytes = false; }
  82890. if (data instanceof Buffer) {
  82891. this._buffer = data;
  82892. this._ownsBuffer = false;
  82893. }
  82894. else {
  82895. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  82896. this._ownsBuffer = true;
  82897. }
  82898. this._kind = kind;
  82899. if (type == undefined) {
  82900. var data_1 = this.getData();
  82901. this.type = VertexBuffer.FLOAT;
  82902. if (data_1 instanceof Int8Array) {
  82903. this.type = VertexBuffer.BYTE;
  82904. }
  82905. else if (data_1 instanceof Uint8Array) {
  82906. this.type = VertexBuffer.UNSIGNED_BYTE;
  82907. }
  82908. else if (data_1 instanceof Int16Array) {
  82909. this.type = VertexBuffer.SHORT;
  82910. }
  82911. else if (data_1 instanceof Uint16Array) {
  82912. this.type = VertexBuffer.UNSIGNED_SHORT;
  82913. }
  82914. else if (data_1 instanceof Int32Array) {
  82915. this.type = VertexBuffer.INT;
  82916. }
  82917. else if (data_1 instanceof Uint32Array) {
  82918. this.type = VertexBuffer.UNSIGNED_INT;
  82919. }
  82920. }
  82921. else {
  82922. this.type = type;
  82923. }
  82924. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  82925. if (useBytes) {
  82926. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  82927. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  82928. this.byteOffset = offset || 0;
  82929. }
  82930. else {
  82931. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  82932. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  82933. this.byteOffset = (offset || 0) * typeByteLength;
  82934. }
  82935. this.normalized = normalized;
  82936. this._instanced = instanced !== undefined ? instanced : false;
  82937. this._instanceDivisor = instanced ? 1 : 0;
  82938. }
  82939. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  82940. /**
  82941. * Gets or sets the instance divisor when in instanced mode
  82942. */
  82943. get: function () {
  82944. return this._instanceDivisor;
  82945. },
  82946. set: function (value) {
  82947. this._instanceDivisor = value;
  82948. if (value == 0) {
  82949. this._instanced = false;
  82950. }
  82951. else {
  82952. this._instanced = true;
  82953. }
  82954. },
  82955. enumerable: true,
  82956. configurable: true
  82957. });
  82958. /** @hidden */
  82959. VertexBuffer.prototype._rebuild = function () {
  82960. if (!this._buffer) {
  82961. return;
  82962. }
  82963. this._buffer._rebuild();
  82964. };
  82965. /**
  82966. * Returns the kind of the VertexBuffer (string)
  82967. * @returns a string
  82968. */
  82969. VertexBuffer.prototype.getKind = function () {
  82970. return this._kind;
  82971. };
  82972. // Properties
  82973. /**
  82974. * Gets a boolean indicating if the VertexBuffer is updatable?
  82975. * @returns true if the buffer is updatable
  82976. */
  82977. VertexBuffer.prototype.isUpdatable = function () {
  82978. return this._buffer.isUpdatable();
  82979. };
  82980. /**
  82981. * Gets current buffer's data
  82982. * @returns a DataArray or null
  82983. */
  82984. VertexBuffer.prototype.getData = function () {
  82985. return this._buffer.getData();
  82986. };
  82987. /**
  82988. * Gets underlying native buffer
  82989. * @returns underlying native buffer
  82990. */
  82991. VertexBuffer.prototype.getBuffer = function () {
  82992. return this._buffer.getBuffer();
  82993. };
  82994. /**
  82995. * Gets the stride in float32 units (i.e. byte stride / 4).
  82996. * May not be an integer if the byte stride is not divisible by 4.
  82997. * DEPRECATED. Use byteStride instead.
  82998. * @returns the stride in float32 units
  82999. */
  83000. VertexBuffer.prototype.getStrideSize = function () {
  83001. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  83002. };
  83003. /**
  83004. * Returns the offset as a multiple of the type byte length.
  83005. * DEPRECATED. Use byteOffset instead.
  83006. * @returns the offset in bytes
  83007. */
  83008. VertexBuffer.prototype.getOffset = function () {
  83009. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  83010. };
  83011. /**
  83012. * Returns the number of components per vertex attribute (integer)
  83013. * @returns the size in float
  83014. */
  83015. VertexBuffer.prototype.getSize = function () {
  83016. return this._size;
  83017. };
  83018. /**
  83019. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  83020. * @returns true if this buffer is instanced
  83021. */
  83022. VertexBuffer.prototype.getIsInstanced = function () {
  83023. return this._instanced;
  83024. };
  83025. /**
  83026. * Returns the instancing divisor, zero for non-instanced (integer).
  83027. * @returns a number
  83028. */
  83029. VertexBuffer.prototype.getInstanceDivisor = function () {
  83030. return this._instanceDivisor;
  83031. };
  83032. // Methods
  83033. /**
  83034. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83035. * @param data defines the data to store
  83036. */
  83037. VertexBuffer.prototype.create = function (data) {
  83038. this._buffer.create(data);
  83039. };
  83040. /**
  83041. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  83042. * This function will create a new buffer if the current one is not updatable
  83043. * @param data defines the data to store
  83044. */
  83045. VertexBuffer.prototype.update = function (data) {
  83046. this._buffer.update(data);
  83047. };
  83048. /**
  83049. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  83050. * Returns the directly updated WebGLBuffer.
  83051. * @param data the new data
  83052. * @param offset the new offset
  83053. * @param useBytes set to true if the offset is in bytes
  83054. */
  83055. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  83056. if (useBytes === void 0) { useBytes = false; }
  83057. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  83058. };
  83059. /**
  83060. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  83061. */
  83062. VertexBuffer.prototype.dispose = function () {
  83063. if (this._ownsBuffer) {
  83064. this._buffer.dispose();
  83065. }
  83066. };
  83067. /**
  83068. * Enumerates each value of this vertex buffer as numbers.
  83069. * @param count the number of values to enumerate
  83070. * @param callback the callback function called for each value
  83071. */
  83072. VertexBuffer.prototype.forEach = function (count, callback) {
  83073. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  83074. };
  83075. /**
  83076. * Deduces the stride given a kind.
  83077. * @param kind The kind string to deduce
  83078. * @returns The deduced stride
  83079. */
  83080. VertexBuffer.DeduceStride = function (kind) {
  83081. switch (kind) {
  83082. case VertexBuffer.UVKind:
  83083. case VertexBuffer.UV2Kind:
  83084. case VertexBuffer.UV3Kind:
  83085. case VertexBuffer.UV4Kind:
  83086. case VertexBuffer.UV5Kind:
  83087. case VertexBuffer.UV6Kind:
  83088. return 2;
  83089. case VertexBuffer.NormalKind:
  83090. case VertexBuffer.PositionKind:
  83091. return 3;
  83092. case VertexBuffer.ColorKind:
  83093. case VertexBuffer.MatricesIndicesKind:
  83094. case VertexBuffer.MatricesIndicesExtraKind:
  83095. case VertexBuffer.MatricesWeightsKind:
  83096. case VertexBuffer.MatricesWeightsExtraKind:
  83097. case VertexBuffer.TangentKind:
  83098. return 4;
  83099. default:
  83100. throw new Error("Invalid kind '" + kind + "'");
  83101. }
  83102. };
  83103. /**
  83104. * Gets the byte length of the given type.
  83105. * @param type the type
  83106. * @returns the number of bytes
  83107. */
  83108. VertexBuffer.GetTypeByteLength = function (type) {
  83109. switch (type) {
  83110. case VertexBuffer.BYTE:
  83111. case VertexBuffer.UNSIGNED_BYTE:
  83112. return 1;
  83113. case VertexBuffer.SHORT:
  83114. case VertexBuffer.UNSIGNED_SHORT:
  83115. return 2;
  83116. case VertexBuffer.INT:
  83117. case VertexBuffer.FLOAT:
  83118. return 4;
  83119. default:
  83120. throw new Error("Invalid type '" + type + "'");
  83121. }
  83122. };
  83123. /**
  83124. * Enumerates each value of the given parameters as numbers.
  83125. * @param data the data to enumerate
  83126. * @param byteOffset the byte offset of the data
  83127. * @param byteStride the byte stride of the data
  83128. * @param componentCount the number of components per element
  83129. * @param componentType the type of the component
  83130. * @param count the total number of components
  83131. * @param normalized whether the data is normalized
  83132. * @param callback the callback function called for each value
  83133. */
  83134. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  83135. if (data instanceof Array) {
  83136. var offset = byteOffset / 4;
  83137. var stride = byteStride / 4;
  83138. for (var index = 0; index < count; index += componentCount) {
  83139. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  83140. callback(data[offset + componentIndex], index + componentIndex);
  83141. }
  83142. offset += stride;
  83143. }
  83144. }
  83145. else {
  83146. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  83147. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  83148. for (var index = 0; index < count; index += componentCount) {
  83149. var componentByteOffset = byteOffset;
  83150. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  83151. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  83152. callback(value, index + componentIndex);
  83153. componentByteOffset += componentByteLength;
  83154. }
  83155. byteOffset += byteStride;
  83156. }
  83157. }
  83158. };
  83159. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  83160. switch (type) {
  83161. case VertexBuffer.BYTE: {
  83162. var value = dataView.getInt8(byteOffset);
  83163. if (normalized) {
  83164. value = Math.max(value / 127, -1);
  83165. }
  83166. return value;
  83167. }
  83168. case VertexBuffer.UNSIGNED_BYTE: {
  83169. var value = dataView.getUint8(byteOffset);
  83170. if (normalized) {
  83171. value = value / 255;
  83172. }
  83173. return value;
  83174. }
  83175. case VertexBuffer.SHORT: {
  83176. var value = dataView.getInt16(byteOffset, true);
  83177. if (normalized) {
  83178. value = Math.max(value / 16383, -1);
  83179. }
  83180. return value;
  83181. }
  83182. case VertexBuffer.UNSIGNED_SHORT: {
  83183. var value = dataView.getUint16(byteOffset, true);
  83184. if (normalized) {
  83185. value = value / 65535;
  83186. }
  83187. return value;
  83188. }
  83189. case VertexBuffer.FLOAT: {
  83190. return dataView.getFloat32(byteOffset, true);
  83191. }
  83192. default: {
  83193. throw new Error("Invalid component type " + type);
  83194. }
  83195. }
  83196. };
  83197. /**
  83198. * The byte type.
  83199. */
  83200. VertexBuffer.BYTE = 5120;
  83201. /**
  83202. * The unsigned byte type.
  83203. */
  83204. VertexBuffer.UNSIGNED_BYTE = 5121;
  83205. /**
  83206. * The short type.
  83207. */
  83208. VertexBuffer.SHORT = 5122;
  83209. /**
  83210. * The unsigned short type.
  83211. */
  83212. VertexBuffer.UNSIGNED_SHORT = 5123;
  83213. /**
  83214. * The integer type.
  83215. */
  83216. VertexBuffer.INT = 5124;
  83217. /**
  83218. * The unsigned integer type.
  83219. */
  83220. VertexBuffer.UNSIGNED_INT = 5125;
  83221. /**
  83222. * The float type.
  83223. */
  83224. VertexBuffer.FLOAT = 5126;
  83225. // Enums
  83226. /**
  83227. * Positions
  83228. */
  83229. VertexBuffer.PositionKind = "position";
  83230. /**
  83231. * Normals
  83232. */
  83233. VertexBuffer.NormalKind = "normal";
  83234. /**
  83235. * Tangents
  83236. */
  83237. VertexBuffer.TangentKind = "tangent";
  83238. /**
  83239. * Texture coordinates
  83240. */
  83241. VertexBuffer.UVKind = "uv";
  83242. /**
  83243. * Texture coordinates 2
  83244. */
  83245. VertexBuffer.UV2Kind = "uv2";
  83246. /**
  83247. * Texture coordinates 3
  83248. */
  83249. VertexBuffer.UV3Kind = "uv3";
  83250. /**
  83251. * Texture coordinates 4
  83252. */
  83253. VertexBuffer.UV4Kind = "uv4";
  83254. /**
  83255. * Texture coordinates 5
  83256. */
  83257. VertexBuffer.UV5Kind = "uv5";
  83258. /**
  83259. * Texture coordinates 6
  83260. */
  83261. VertexBuffer.UV6Kind = "uv6";
  83262. /**
  83263. * Colors
  83264. */
  83265. VertexBuffer.ColorKind = "color";
  83266. /**
  83267. * Matrix indices (for bones)
  83268. */
  83269. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  83270. /**
  83271. * Matrix weights (for bones)
  83272. */
  83273. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  83274. /**
  83275. * Additional matrix indices (for bones)
  83276. */
  83277. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  83278. /**
  83279. * Additional matrix weights (for bones)
  83280. */
  83281. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  83282. return VertexBuffer;
  83283. }());
  83284. /***/ }),
  83285. /***/ "./Meshes/csg.ts":
  83286. /*!***********************!*\
  83287. !*** ./Meshes/csg.ts ***!
  83288. \***********************/
  83289. /*! exports provided: CSG */
  83290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83291. "use strict";
  83292. __webpack_require__.r(__webpack_exports__);
  83293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  83294. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83295. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83296. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  83297. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83298. /**
  83299. * Unique ID when we import meshes from Babylon to CSG
  83300. */
  83301. var currentCSGMeshId = 0;
  83302. /**
  83303. * Represents a vertex of a polygon. Use your own vertex class instead of this
  83304. * one to provide additional features like texture coordinates and vertex
  83305. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  83306. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  83307. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  83308. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  83309. * is not used anywhere else.
  83310. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  83311. */
  83312. var Vertex = /** @class */ (function () {
  83313. /**
  83314. * Initializes the vertex
  83315. * @param pos The position of the vertex
  83316. * @param normal The normal of the vertex
  83317. * @param uv The texture coordinate of the vertex
  83318. */
  83319. function Vertex(
  83320. /**
  83321. * The position of the vertex
  83322. */
  83323. pos,
  83324. /**
  83325. * The normal of the vertex
  83326. */
  83327. normal,
  83328. /**
  83329. * The texture coordinate of the vertex
  83330. */
  83331. uv) {
  83332. this.pos = pos;
  83333. this.normal = normal;
  83334. this.uv = uv;
  83335. }
  83336. /**
  83337. * Make a clone, or deep copy, of the vertex
  83338. * @returns A new Vertex
  83339. */
  83340. Vertex.prototype.clone = function () {
  83341. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  83342. };
  83343. /**
  83344. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  83345. * orientation of a polygon is flipped.
  83346. */
  83347. Vertex.prototype.flip = function () {
  83348. this.normal = this.normal.scale(-1);
  83349. };
  83350. /**
  83351. * Create a new vertex between this vertex and `other` by linearly
  83352. * interpolating all properties using a parameter of `t`. Subclasses should
  83353. * override this to interpolate additional properties.
  83354. * @param other the vertex to interpolate against
  83355. * @param t The factor used to linearly interpolate between the vertices
  83356. */
  83357. Vertex.prototype.interpolate = function (other, t) {
  83358. 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));
  83359. };
  83360. return Vertex;
  83361. }());
  83362. /**
  83363. * Represents a plane in 3D space.
  83364. */
  83365. var Plane = /** @class */ (function () {
  83366. /**
  83367. * Initializes the plane
  83368. * @param normal The normal for the plane
  83369. * @param w
  83370. */
  83371. function Plane(normal, w) {
  83372. this.normal = normal;
  83373. this.w = w;
  83374. }
  83375. /**
  83376. * Construct a plane from three points
  83377. * @param a Point a
  83378. * @param b Point b
  83379. * @param c Point c
  83380. */
  83381. Plane.FromPoints = function (a, b, c) {
  83382. var v0 = c.subtract(a);
  83383. var v1 = b.subtract(a);
  83384. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  83385. return null;
  83386. }
  83387. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  83388. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  83389. };
  83390. /**
  83391. * Clone, or make a deep copy of the plane
  83392. * @returns a new Plane
  83393. */
  83394. Plane.prototype.clone = function () {
  83395. return new Plane(this.normal.clone(), this.w);
  83396. };
  83397. /**
  83398. * Flip the face of the plane
  83399. */
  83400. Plane.prototype.flip = function () {
  83401. this.normal.scaleInPlace(-1);
  83402. this.w = -this.w;
  83403. };
  83404. /**
  83405. * Split `polygon` by this plane if needed, then put the polygon or polygon
  83406. * fragments in the appropriate lists. Coplanar polygons go into either
  83407. `* coplanarFront` or `coplanarBack` depending on their orientation with
  83408. * respect to this plane. Polygons in front or in back of this plane go into
  83409. * either `front` or `back`
  83410. * @param polygon The polygon to be split
  83411. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  83412. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  83413. * @param front Will contain the polygons in front of the plane
  83414. * @param back Will contain the polygons begind the plane
  83415. */
  83416. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  83417. var COPLANAR = 0;
  83418. var FRONT = 1;
  83419. var BACK = 2;
  83420. var SPANNING = 3;
  83421. // Classify each point as well as the entire polygon into one of the above
  83422. // four classes.
  83423. var polygonType = 0;
  83424. var types = [];
  83425. var i;
  83426. var t;
  83427. for (i = 0; i < polygon.vertices.length; i++) {
  83428. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  83429. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  83430. polygonType |= type;
  83431. types.push(type);
  83432. }
  83433. // Put the polygon in the correct list, splitting it when necessary
  83434. switch (polygonType) {
  83435. case COPLANAR:
  83436. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  83437. break;
  83438. case FRONT:
  83439. front.push(polygon);
  83440. break;
  83441. case BACK:
  83442. back.push(polygon);
  83443. break;
  83444. case SPANNING:
  83445. var f = [], b = [];
  83446. for (i = 0; i < polygon.vertices.length; i++) {
  83447. var j = (i + 1) % polygon.vertices.length;
  83448. var ti = types[i], tj = types[j];
  83449. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  83450. if (ti !== BACK) {
  83451. f.push(vi);
  83452. }
  83453. if (ti !== FRONT) {
  83454. b.push(ti !== BACK ? vi.clone() : vi);
  83455. }
  83456. if ((ti | tj) === SPANNING) {
  83457. 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));
  83458. var v = vi.interpolate(vj, t);
  83459. f.push(v);
  83460. b.push(v.clone());
  83461. }
  83462. }
  83463. var poly;
  83464. if (f.length >= 3) {
  83465. poly = new Polygon(f, polygon.shared);
  83466. if (poly.plane) {
  83467. front.push(poly);
  83468. }
  83469. }
  83470. if (b.length >= 3) {
  83471. poly = new Polygon(b, polygon.shared);
  83472. if (poly.plane) {
  83473. back.push(poly);
  83474. }
  83475. }
  83476. break;
  83477. }
  83478. };
  83479. /**
  83480. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  83481. * point is on the plane
  83482. */
  83483. Plane.EPSILON = 1e-5;
  83484. return Plane;
  83485. }());
  83486. /**
  83487. * Represents a convex polygon. The vertices used to initialize a polygon must
  83488. * be coplanar and form a convex loop.
  83489. *
  83490. * Each convex polygon has a `shared` property, which is shared between all
  83491. * polygons that are clones of each other or were split from the same polygon.
  83492. * This can be used to define per-polygon properties (such as surface color)
  83493. */
  83494. var Polygon = /** @class */ (function () {
  83495. /**
  83496. * Initializes the polygon
  83497. * @param vertices The vertices of the polygon
  83498. * @param shared The properties shared across all polygons
  83499. */
  83500. function Polygon(vertices, shared) {
  83501. this.vertices = vertices;
  83502. this.shared = shared;
  83503. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  83504. }
  83505. /**
  83506. * Clones, or makes a deep copy, or the polygon
  83507. */
  83508. Polygon.prototype.clone = function () {
  83509. var vertices = this.vertices.map(function (v) { return v.clone(); });
  83510. return new Polygon(vertices, this.shared);
  83511. };
  83512. /**
  83513. * Flips the faces of the polygon
  83514. */
  83515. Polygon.prototype.flip = function () {
  83516. this.vertices.reverse().map(function (v) { v.flip(); });
  83517. this.plane.flip();
  83518. };
  83519. return Polygon;
  83520. }());
  83521. /**
  83522. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  83523. * by picking a polygon to split along. That polygon (and all other coplanar
  83524. * polygons) are added directly to that node and the other polygons are added to
  83525. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  83526. * no distinction between internal and leaf nodes
  83527. */
  83528. var Node = /** @class */ (function () {
  83529. /**
  83530. * Initializes the node
  83531. * @param polygons A collection of polygons held in the node
  83532. */
  83533. function Node(polygons) {
  83534. this.plane = null;
  83535. this.front = null;
  83536. this.back = null;
  83537. this.polygons = new Array();
  83538. if (polygons) {
  83539. this.build(polygons);
  83540. }
  83541. }
  83542. /**
  83543. * Clones, or makes a deep copy, of the node
  83544. * @returns The cloned node
  83545. */
  83546. Node.prototype.clone = function () {
  83547. var node = new Node();
  83548. node.plane = this.plane && this.plane.clone();
  83549. node.front = this.front && this.front.clone();
  83550. node.back = this.back && this.back.clone();
  83551. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  83552. return node;
  83553. };
  83554. /**
  83555. * Convert solid space to empty space and empty space to solid space
  83556. */
  83557. Node.prototype.invert = function () {
  83558. for (var i = 0; i < this.polygons.length; i++) {
  83559. this.polygons[i].flip();
  83560. }
  83561. if (this.plane) {
  83562. this.plane.flip();
  83563. }
  83564. if (this.front) {
  83565. this.front.invert();
  83566. }
  83567. if (this.back) {
  83568. this.back.invert();
  83569. }
  83570. var temp = this.front;
  83571. this.front = this.back;
  83572. this.back = temp;
  83573. };
  83574. /**
  83575. * Recursively remove all polygons in `polygons` that are inside this BSP
  83576. * tree.
  83577. * @param polygons Polygons to remove from the BSP
  83578. * @returns Polygons clipped from the BSP
  83579. */
  83580. Node.prototype.clipPolygons = function (polygons) {
  83581. if (!this.plane) {
  83582. return polygons.slice();
  83583. }
  83584. var front = new Array(), back = new Array();
  83585. for (var i = 0; i < polygons.length; i++) {
  83586. this.plane.splitPolygon(polygons[i], front, back, front, back);
  83587. }
  83588. if (this.front) {
  83589. front = this.front.clipPolygons(front);
  83590. }
  83591. if (this.back) {
  83592. back = this.back.clipPolygons(back);
  83593. }
  83594. else {
  83595. back = [];
  83596. }
  83597. return front.concat(back);
  83598. };
  83599. /**
  83600. * Remove all polygons in this BSP tree that are inside the other BSP tree
  83601. * `bsp`.
  83602. * @param bsp BSP containing polygons to remove from this BSP
  83603. */
  83604. Node.prototype.clipTo = function (bsp) {
  83605. this.polygons = bsp.clipPolygons(this.polygons);
  83606. if (this.front) {
  83607. this.front.clipTo(bsp);
  83608. }
  83609. if (this.back) {
  83610. this.back.clipTo(bsp);
  83611. }
  83612. };
  83613. /**
  83614. * Return a list of all polygons in this BSP tree
  83615. * @returns List of all polygons in this BSP tree
  83616. */
  83617. Node.prototype.allPolygons = function () {
  83618. var polygons = this.polygons.slice();
  83619. if (this.front) {
  83620. polygons = polygons.concat(this.front.allPolygons());
  83621. }
  83622. if (this.back) {
  83623. polygons = polygons.concat(this.back.allPolygons());
  83624. }
  83625. return polygons;
  83626. };
  83627. /**
  83628. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  83629. * new polygons are filtered down to the bottom of the tree and become new
  83630. * nodes there. Each set of polygons is partitioned using the first polygon
  83631. * (no heuristic is used to pick a good split)
  83632. * @param polygons Polygons used to construct the BSP tree
  83633. */
  83634. Node.prototype.build = function (polygons) {
  83635. if (!polygons.length) {
  83636. return;
  83637. }
  83638. if (!this.plane) {
  83639. this.plane = polygons[0].plane.clone();
  83640. }
  83641. var front = new Array(), back = new Array();
  83642. for (var i = 0; i < polygons.length; i++) {
  83643. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  83644. }
  83645. if (front.length) {
  83646. if (!this.front) {
  83647. this.front = new Node();
  83648. }
  83649. this.front.build(front);
  83650. }
  83651. if (back.length) {
  83652. if (!this.back) {
  83653. this.back = new Node();
  83654. }
  83655. this.back.build(back);
  83656. }
  83657. };
  83658. return Node;
  83659. }());
  83660. /**
  83661. * Class for building Constructive Solid Geometry
  83662. */
  83663. var CSG = /** @class */ (function () {
  83664. function CSG() {
  83665. this.polygons = new Array();
  83666. }
  83667. /**
  83668. * Convert the Mesh to CSG
  83669. * @param mesh The Mesh to convert to CSG
  83670. * @returns A new CSG from the Mesh
  83671. */
  83672. CSG.FromMesh = function (mesh) {
  83673. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  83674. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  83675. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  83676. mesh.computeWorldMatrix(true);
  83677. matrix = mesh.getWorldMatrix();
  83678. meshPosition = mesh.position.clone();
  83679. meshRotation = mesh.rotation.clone();
  83680. if (mesh.rotationQuaternion) {
  83681. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  83682. }
  83683. meshScaling = mesh.scaling.clone();
  83684. }
  83685. else {
  83686. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  83687. }
  83688. 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);
  83689. var subMeshes = mesh.subMeshes;
  83690. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  83691. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  83692. vertices = [];
  83693. for (var j = 0; j < 3; j++) {
  83694. 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]);
  83695. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  83696. 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]);
  83697. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  83698. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  83699. vertex = new Vertex(position, normal, uv);
  83700. vertices.push(vertex);
  83701. }
  83702. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  83703. // To handle the case of degenerated triangle
  83704. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  83705. if (polygon.plane) {
  83706. polygons.push(polygon);
  83707. }
  83708. }
  83709. }
  83710. var csg = CSG.FromPolygons(polygons);
  83711. csg.matrix = matrix;
  83712. csg.position = meshPosition;
  83713. csg.rotation = meshRotation;
  83714. csg.scaling = meshScaling;
  83715. csg.rotationQuaternion = meshRotationQuaternion;
  83716. currentCSGMeshId++;
  83717. return csg;
  83718. };
  83719. /**
  83720. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  83721. * @param polygons Polygons used to construct a CSG solid
  83722. */
  83723. CSG.FromPolygons = function (polygons) {
  83724. var csg = new CSG();
  83725. csg.polygons = polygons;
  83726. return csg;
  83727. };
  83728. /**
  83729. * Clones, or makes a deep copy, of the CSG
  83730. * @returns A new CSG
  83731. */
  83732. CSG.prototype.clone = function () {
  83733. var csg = new CSG();
  83734. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  83735. csg.copyTransformAttributes(this);
  83736. return csg;
  83737. };
  83738. /**
  83739. * Unions this CSG with another CSG
  83740. * @param csg The CSG to union against this CSG
  83741. * @returns The unioned CSG
  83742. */
  83743. CSG.prototype.union = function (csg) {
  83744. var a = new Node(this.clone().polygons);
  83745. var b = new Node(csg.clone().polygons);
  83746. a.clipTo(b);
  83747. b.clipTo(a);
  83748. b.invert();
  83749. b.clipTo(a);
  83750. b.invert();
  83751. a.build(b.allPolygons());
  83752. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  83753. };
  83754. /**
  83755. * Unions this CSG with another CSG in place
  83756. * @param csg The CSG to union against this CSG
  83757. */
  83758. CSG.prototype.unionInPlace = function (csg) {
  83759. var a = new Node(this.polygons);
  83760. var b = new Node(csg.polygons);
  83761. a.clipTo(b);
  83762. b.clipTo(a);
  83763. b.invert();
  83764. b.clipTo(a);
  83765. b.invert();
  83766. a.build(b.allPolygons());
  83767. this.polygons = a.allPolygons();
  83768. };
  83769. /**
  83770. * Subtracts this CSG with another CSG
  83771. * @param csg The CSG to subtract against this CSG
  83772. * @returns A new CSG
  83773. */
  83774. CSG.prototype.subtract = function (csg) {
  83775. var a = new Node(this.clone().polygons);
  83776. var b = new Node(csg.clone().polygons);
  83777. a.invert();
  83778. a.clipTo(b);
  83779. b.clipTo(a);
  83780. b.invert();
  83781. b.clipTo(a);
  83782. b.invert();
  83783. a.build(b.allPolygons());
  83784. a.invert();
  83785. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  83786. };
  83787. /**
  83788. * Subtracts this CSG with another CSG in place
  83789. * @param csg The CSG to subtact against this CSG
  83790. */
  83791. CSG.prototype.subtractInPlace = function (csg) {
  83792. var a = new Node(this.polygons);
  83793. var b = new Node(csg.polygons);
  83794. a.invert();
  83795. a.clipTo(b);
  83796. b.clipTo(a);
  83797. b.invert();
  83798. b.clipTo(a);
  83799. b.invert();
  83800. a.build(b.allPolygons());
  83801. a.invert();
  83802. this.polygons = a.allPolygons();
  83803. };
  83804. /**
  83805. * Intersect this CSG with another CSG
  83806. * @param csg The CSG to intersect against this CSG
  83807. * @returns A new CSG
  83808. */
  83809. CSG.prototype.intersect = function (csg) {
  83810. var a = new Node(this.clone().polygons);
  83811. var b = new Node(csg.clone().polygons);
  83812. a.invert();
  83813. b.clipTo(a);
  83814. b.invert();
  83815. a.clipTo(b);
  83816. b.clipTo(a);
  83817. a.build(b.allPolygons());
  83818. a.invert();
  83819. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  83820. };
  83821. /**
  83822. * Intersects this CSG with another CSG in place
  83823. * @param csg The CSG to intersect against this CSG
  83824. */
  83825. CSG.prototype.intersectInPlace = function (csg) {
  83826. var a = new Node(this.polygons);
  83827. var b = new Node(csg.polygons);
  83828. a.invert();
  83829. b.clipTo(a);
  83830. b.invert();
  83831. a.clipTo(b);
  83832. b.clipTo(a);
  83833. a.build(b.allPolygons());
  83834. a.invert();
  83835. this.polygons = a.allPolygons();
  83836. };
  83837. /**
  83838. * Return a new CSG solid with solid and empty space switched. This solid is
  83839. * not modified.
  83840. * @returns A new CSG solid with solid and empty space switched
  83841. */
  83842. CSG.prototype.inverse = function () {
  83843. var csg = this.clone();
  83844. csg.inverseInPlace();
  83845. return csg;
  83846. };
  83847. /**
  83848. * Inverses the CSG in place
  83849. */
  83850. CSG.prototype.inverseInPlace = function () {
  83851. this.polygons.map(function (p) { p.flip(); });
  83852. };
  83853. /**
  83854. * This is used to keep meshes transformations so they can be restored
  83855. * when we build back a Babylon Mesh
  83856. * NB : All CSG operations are performed in world coordinates
  83857. * @param csg The CSG to copy the transform attributes from
  83858. * @returns This CSG
  83859. */
  83860. CSG.prototype.copyTransformAttributes = function (csg) {
  83861. this.matrix = csg.matrix;
  83862. this.position = csg.position;
  83863. this.rotation = csg.rotation;
  83864. this.scaling = csg.scaling;
  83865. this.rotationQuaternion = csg.rotationQuaternion;
  83866. return this;
  83867. };
  83868. /**
  83869. * Build Raw mesh from CSG
  83870. * Coordinates here are in world space
  83871. * @param name The name of the mesh geometry
  83872. * @param scene The Scene
  83873. * @param keepSubMeshes Specifies if the submeshes should be kept
  83874. * @returns A new Mesh
  83875. */
  83876. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  83877. var matrix = this.matrix.clone();
  83878. matrix.invert();
  83879. 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;
  83880. if (keepSubMeshes) {
  83881. // Sort Polygons, since subMeshes are indices range
  83882. polygons.sort(function (a, b) {
  83883. if (a.shared.meshId === b.shared.meshId) {
  83884. return a.shared.subMeshId - b.shared.subMeshId;
  83885. }
  83886. else {
  83887. return a.shared.meshId - b.shared.meshId;
  83888. }
  83889. });
  83890. }
  83891. for (var i = 0, il = polygons.length; i < il; i++) {
  83892. polygon = polygons[i];
  83893. // Building SubMeshes
  83894. if (!subMesh_dict[polygon.shared.meshId]) {
  83895. subMesh_dict[polygon.shared.meshId] = {};
  83896. }
  83897. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  83898. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  83899. indexStart: +Infinity,
  83900. indexEnd: -Infinity,
  83901. materialIndex: polygon.shared.materialIndex
  83902. };
  83903. }
  83904. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  83905. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  83906. polygonIndices[0] = 0;
  83907. polygonIndices[1] = j - 1;
  83908. polygonIndices[2] = j;
  83909. for (var k = 0; k < 3; k++) {
  83910. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  83911. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  83912. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  83913. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  83914. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  83915. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  83916. // Check if 2 points can be merged
  83917. if (!(typeof vertex_idx !== 'undefined' &&
  83918. normals[vertex_idx * 3] === localNormal.x &&
  83919. normals[vertex_idx * 3 + 1] === localNormal.y &&
  83920. normals[vertex_idx * 3 + 2] === localNormal.z &&
  83921. uvs[vertex_idx * 2] === uv.x &&
  83922. uvs[vertex_idx * 2 + 1] === uv.y)) {
  83923. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  83924. uvs.push(uv.x, uv.y);
  83925. normals.push(normal.x, normal.y, normal.z);
  83926. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  83927. }
  83928. indices.push(vertex_idx);
  83929. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  83930. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  83931. currentIndex++;
  83932. }
  83933. }
  83934. }
  83935. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  83936. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  83937. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  83938. mesh.setIndices(indices, null);
  83939. if (keepSubMeshes) {
  83940. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  83941. var materialIndexOffset = 0, materialMaxIndex;
  83942. mesh.subMeshes = new Array();
  83943. for (var m in subMesh_dict) {
  83944. materialMaxIndex = -1;
  83945. for (var sm in subMesh_dict[m]) {
  83946. subMesh_obj = subMesh_dict[m][sm];
  83947. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  83948. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  83949. }
  83950. materialIndexOffset += ++materialMaxIndex;
  83951. }
  83952. }
  83953. return mesh;
  83954. };
  83955. /**
  83956. * Build Mesh from CSG taking material and transforms into account
  83957. * @param name The name of the Mesh
  83958. * @param material The material of the Mesh
  83959. * @param scene The Scene
  83960. * @param keepSubMeshes Specifies if submeshes should be kept
  83961. * @returns The new Mesh
  83962. */
  83963. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  83964. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  83965. mesh.material = material;
  83966. mesh.position.copyFrom(this.position);
  83967. mesh.rotation.copyFrom(this.rotation);
  83968. if (this.rotationQuaternion) {
  83969. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  83970. }
  83971. mesh.scaling.copyFrom(this.scaling);
  83972. mesh.computeWorldMatrix(true);
  83973. return mesh;
  83974. };
  83975. return CSG;
  83976. }());
  83977. /***/ }),
  83978. /***/ "./Meshes/geometry.ts":
  83979. /*!****************************!*\
  83980. !*** ./Meshes/geometry.ts ***!
  83981. \****************************/
  83982. /*! exports provided: Geometry */
  83983. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83984. "use strict";
  83985. __webpack_require__.r(__webpack_exports__);
  83986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  83987. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83988. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83989. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83990. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  83991. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  83992. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  83993. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  83994. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  83995. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  83996. /**
  83997. * Class used to store geometry data (vertex buffers + index buffer)
  83998. */
  83999. var Geometry = /** @class */ (function () {
  84000. /**
  84001. * Creates a new geometry
  84002. * @param id defines the unique ID
  84003. * @param scene defines the hosting scene
  84004. * @param vertexData defines the VertexData used to get geometry data
  84005. * @param updatable defines if geometry must be updatable (false by default)
  84006. * @param mesh defines the mesh that will be associated with the geometry
  84007. */
  84008. function Geometry(id, scene, vertexData, updatable, mesh) {
  84009. if (updatable === void 0) { updatable = false; }
  84010. if (mesh === void 0) { mesh = null; }
  84011. /**
  84012. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84013. */
  84014. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  84015. this._totalVertices = 0;
  84016. this._isDisposed = false;
  84017. this._indexBufferIsUpdatable = false;
  84018. this.id = id;
  84019. this.uniqueId = scene.getUniqueId();
  84020. this._engine = scene.getEngine();
  84021. this._meshes = [];
  84022. this._scene = scene;
  84023. //Init vertex buffer cache
  84024. this._vertexBuffers = {};
  84025. this._indices = [];
  84026. this._updatable = updatable;
  84027. // vertexData
  84028. if (vertexData) {
  84029. this.setAllVerticesData(vertexData, updatable);
  84030. }
  84031. else {
  84032. this._totalVertices = 0;
  84033. this._indices = [];
  84034. }
  84035. if (this._engine.getCaps().vertexArrayObject) {
  84036. this._vertexArrayObjects = {};
  84037. }
  84038. // applyToMesh
  84039. if (mesh) {
  84040. this.applyToMesh(mesh);
  84041. mesh.computeWorldMatrix(true);
  84042. }
  84043. }
  84044. Object.defineProperty(Geometry.prototype, "boundingBias", {
  84045. /**
  84046. * 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
  84047. */
  84048. get: function () {
  84049. return this._boundingBias;
  84050. },
  84051. /**
  84052. * 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
  84053. */
  84054. set: function (value) {
  84055. if (this._boundingBias) {
  84056. this._boundingBias.copyFrom(value);
  84057. }
  84058. else {
  84059. this._boundingBias = value.clone();
  84060. }
  84061. this._updateBoundingInfo(true, null);
  84062. },
  84063. enumerable: true,
  84064. configurable: true
  84065. });
  84066. /**
  84067. * Static function used to attach a new empty geometry to a mesh
  84068. * @param mesh defines the mesh to attach the geometry to
  84069. * @returns the new Geometry
  84070. */
  84071. Geometry.CreateGeometryForMesh = function (mesh) {
  84072. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  84073. geometry.applyToMesh(mesh);
  84074. return geometry;
  84075. };
  84076. Object.defineProperty(Geometry.prototype, "extend", {
  84077. /**
  84078. * Gets the current extend of the geometry
  84079. */
  84080. get: function () {
  84081. return this._extend;
  84082. },
  84083. enumerable: true,
  84084. configurable: true
  84085. });
  84086. /**
  84087. * Gets the hosting scene
  84088. * @returns the hosting Scene
  84089. */
  84090. Geometry.prototype.getScene = function () {
  84091. return this._scene;
  84092. };
  84093. /**
  84094. * Gets the hosting engine
  84095. * @returns the hosting Engine
  84096. */
  84097. Geometry.prototype.getEngine = function () {
  84098. return this._engine;
  84099. };
  84100. /**
  84101. * Defines if the geometry is ready to use
  84102. * @returns true if the geometry is ready to be used
  84103. */
  84104. Geometry.prototype.isReady = function () {
  84105. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  84106. };
  84107. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  84108. /**
  84109. * Gets a value indicating that the geometry should not be serialized
  84110. */
  84111. get: function () {
  84112. for (var index = 0; index < this._meshes.length; index++) {
  84113. if (!this._meshes[index].doNotSerialize) {
  84114. return false;
  84115. }
  84116. }
  84117. return true;
  84118. },
  84119. enumerable: true,
  84120. configurable: true
  84121. });
  84122. /** @hidden */
  84123. Geometry.prototype._rebuild = function () {
  84124. if (this._vertexArrayObjects) {
  84125. this._vertexArrayObjects = {};
  84126. }
  84127. // Index buffer
  84128. if (this._meshes.length !== 0 && this._indices) {
  84129. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  84130. }
  84131. // Vertex buffers
  84132. for (var key in this._vertexBuffers) {
  84133. var vertexBuffer = this._vertexBuffers[key];
  84134. vertexBuffer._rebuild();
  84135. }
  84136. };
  84137. /**
  84138. * Affects all geometry data in one call
  84139. * @param vertexData defines the geometry data
  84140. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84141. */
  84142. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  84143. vertexData.applyToGeometry(this, updatable);
  84144. this.notifyUpdate();
  84145. };
  84146. /**
  84147. * Set specific vertex data
  84148. * @param kind defines the data kind (Position, normal, etc...)
  84149. * @param data defines the vertex data to use
  84150. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84151. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84152. */
  84153. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  84154. if (updatable === void 0) { updatable = false; }
  84155. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  84156. this.setVerticesBuffer(buffer);
  84157. };
  84158. /**
  84159. * Removes a specific vertex data
  84160. * @param kind defines the data kind (Position, normal, etc...)
  84161. */
  84162. Geometry.prototype.removeVerticesData = function (kind) {
  84163. if (this._vertexBuffers[kind]) {
  84164. this._vertexBuffers[kind].dispose();
  84165. delete this._vertexBuffers[kind];
  84166. }
  84167. };
  84168. /**
  84169. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84170. * @param buffer defines the vertex buffer to use
  84171. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84172. */
  84173. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  84174. if (totalVertices === void 0) { totalVertices = null; }
  84175. var kind = buffer.getKind();
  84176. if (this._vertexBuffers[kind]) {
  84177. this._vertexBuffers[kind].dispose();
  84178. }
  84179. this._vertexBuffers[kind] = buffer;
  84180. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  84181. var data = buffer.getData();
  84182. if (totalVertices != null) {
  84183. this._totalVertices = totalVertices;
  84184. }
  84185. else {
  84186. if (data != null) {
  84187. this._totalVertices = data.length / (buffer.byteStride / 4);
  84188. }
  84189. }
  84190. this._updateExtend(data);
  84191. this._resetPointsArrayCache();
  84192. var meshes = this._meshes;
  84193. var numOfMeshes = meshes.length;
  84194. for (var index = 0; index < numOfMeshes; index++) {
  84195. var mesh = meshes[index];
  84196. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84197. mesh._createGlobalSubMesh(false);
  84198. mesh.computeWorldMatrix(true);
  84199. }
  84200. }
  84201. this.notifyUpdate(kind);
  84202. if (this._vertexArrayObjects) {
  84203. this._disposeVertexArrayObjects();
  84204. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  84205. }
  84206. };
  84207. /**
  84208. * Update a specific vertex buffer
  84209. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  84210. * It will do nothing if the buffer is not updatable
  84211. * @param kind defines the data kind (Position, normal, etc...)
  84212. * @param data defines the data to use
  84213. * @param offset defines the offset in the target buffer where to store the data
  84214. * @param useBytes set to true if the offset is in bytes
  84215. */
  84216. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  84217. if (useBytes === void 0) { useBytes = false; }
  84218. var vertexBuffer = this.getVertexBuffer(kind);
  84219. if (!vertexBuffer) {
  84220. return;
  84221. }
  84222. vertexBuffer.updateDirectly(data, offset, useBytes);
  84223. this.notifyUpdate(kind);
  84224. };
  84225. /**
  84226. * Update a specific vertex buffer
  84227. * This function will create a new buffer if the current one is not updatable
  84228. * @param kind defines the data kind (Position, normal, etc...)
  84229. * @param data defines the data to use
  84230. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84231. */
  84232. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  84233. if (updateExtends === void 0) { updateExtends = false; }
  84234. var vertexBuffer = this.getVertexBuffer(kind);
  84235. if (!vertexBuffer) {
  84236. return;
  84237. }
  84238. vertexBuffer.update(data);
  84239. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  84240. this._updateBoundingInfo(updateExtends, data);
  84241. }
  84242. this.notifyUpdate(kind);
  84243. };
  84244. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  84245. if (updateExtends) {
  84246. this._updateExtend(data);
  84247. }
  84248. this._resetPointsArrayCache();
  84249. if (updateExtends) {
  84250. var meshes = this._meshes;
  84251. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  84252. var mesh = meshes_1[_i];
  84253. if (mesh._boundingInfo) {
  84254. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  84255. }
  84256. else {
  84257. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84258. }
  84259. var subMeshes = mesh.subMeshes;
  84260. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  84261. var subMesh = subMeshes_1[_a];
  84262. subMesh.refreshBoundingInfo();
  84263. }
  84264. }
  84265. }
  84266. };
  84267. /** @hidden */
  84268. Geometry.prototype._bind = function (effect, indexToBind) {
  84269. if (!effect) {
  84270. return;
  84271. }
  84272. if (indexToBind === undefined) {
  84273. indexToBind = this._indexBuffer;
  84274. }
  84275. var vbs = this.getVertexBuffers();
  84276. if (!vbs) {
  84277. return;
  84278. }
  84279. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  84280. this._engine.bindBuffers(vbs, indexToBind, effect);
  84281. return;
  84282. }
  84283. // Using VAO
  84284. if (!this._vertexArrayObjects[effect.key]) {
  84285. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  84286. }
  84287. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  84288. };
  84289. /**
  84290. * Gets total number of vertices
  84291. * @returns the total number of vertices
  84292. */
  84293. Geometry.prototype.getTotalVertices = function () {
  84294. if (!this.isReady()) {
  84295. return 0;
  84296. }
  84297. return this._totalVertices;
  84298. };
  84299. /**
  84300. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84301. * @param kind defines the data kind (Position, normal, etc...)
  84302. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84303. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84304. * @returns a float array containing vertex data
  84305. */
  84306. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  84307. var vertexBuffer = this.getVertexBuffer(kind);
  84308. if (!vertexBuffer) {
  84309. return null;
  84310. }
  84311. var data = vertexBuffer.getData();
  84312. if (!data) {
  84313. return null;
  84314. }
  84315. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  84316. var count = this._totalVertices * vertexBuffer.getSize();
  84317. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  84318. var copy_1 = [];
  84319. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  84320. return copy_1;
  84321. }
  84322. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  84323. if (data instanceof Array) {
  84324. var offset = vertexBuffer.byteOffset / 4;
  84325. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  84326. }
  84327. else if (data instanceof ArrayBuffer) {
  84328. return new Float32Array(data, vertexBuffer.byteOffset, count);
  84329. }
  84330. else {
  84331. var offset = data.byteOffset + vertexBuffer.byteOffset;
  84332. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  84333. var result = new Float32Array(count);
  84334. var source = new Float32Array(data.buffer, offset, count);
  84335. result.set(source);
  84336. return result;
  84337. }
  84338. return new Float32Array(data.buffer, offset, count);
  84339. }
  84340. }
  84341. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  84342. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  84343. }
  84344. return data;
  84345. };
  84346. /**
  84347. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84348. * @param kind defines the data kind (Position, normal, etc...)
  84349. * @returns true if the vertex buffer with the specified kind is updatable
  84350. */
  84351. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  84352. var vb = this._vertexBuffers[kind];
  84353. if (!vb) {
  84354. return false;
  84355. }
  84356. return vb.isUpdatable();
  84357. };
  84358. /**
  84359. * Gets a specific vertex buffer
  84360. * @param kind defines the data kind (Position, normal, etc...)
  84361. * @returns a VertexBuffer
  84362. */
  84363. Geometry.prototype.getVertexBuffer = function (kind) {
  84364. if (!this.isReady()) {
  84365. return null;
  84366. }
  84367. return this._vertexBuffers[kind];
  84368. };
  84369. /**
  84370. * Returns all vertex buffers
  84371. * @return an object holding all vertex buffers indexed by kind
  84372. */
  84373. Geometry.prototype.getVertexBuffers = function () {
  84374. if (!this.isReady()) {
  84375. return null;
  84376. }
  84377. return this._vertexBuffers;
  84378. };
  84379. /**
  84380. * Gets a boolean indicating if specific vertex buffer is present
  84381. * @param kind defines the data kind (Position, normal, etc...)
  84382. * @returns true if data is present
  84383. */
  84384. Geometry.prototype.isVerticesDataPresent = function (kind) {
  84385. if (!this._vertexBuffers) {
  84386. if (this._delayInfo) {
  84387. return this._delayInfo.indexOf(kind) !== -1;
  84388. }
  84389. return false;
  84390. }
  84391. return this._vertexBuffers[kind] !== undefined;
  84392. };
  84393. /**
  84394. * Gets a list of all attached data kinds (Position, normal, etc...)
  84395. * @returns a list of string containing all kinds
  84396. */
  84397. Geometry.prototype.getVerticesDataKinds = function () {
  84398. var result = [];
  84399. var kind;
  84400. if (!this._vertexBuffers && this._delayInfo) {
  84401. for (kind in this._delayInfo) {
  84402. result.push(kind);
  84403. }
  84404. }
  84405. else {
  84406. for (kind in this._vertexBuffers) {
  84407. result.push(kind);
  84408. }
  84409. }
  84410. return result;
  84411. };
  84412. /**
  84413. * Update index buffer
  84414. * @param indices defines the indices to store in the index buffer
  84415. * @param offset defines the offset in the target buffer where to store the data
  84416. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  84417. */
  84418. Geometry.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  84419. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  84420. if (!this._indexBuffer) {
  84421. return;
  84422. }
  84423. if (!this._indexBufferIsUpdatable) {
  84424. this.setIndices(indices, null, true);
  84425. }
  84426. else {
  84427. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  84428. if (!gpuMemoryOnly) {
  84429. this._indices = indices.slice();
  84430. }
  84431. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  84432. if (needToUpdateSubMeshes) {
  84433. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  84434. var mesh = _a[_i];
  84435. mesh._createGlobalSubMesh(true);
  84436. }
  84437. }
  84438. }
  84439. };
  84440. /**
  84441. * Creates a new index buffer
  84442. * @param indices defines the indices to store in the index buffer
  84443. * @param totalVertices defines the total number of vertices (could be null)
  84444. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84445. */
  84446. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  84447. if (totalVertices === void 0) { totalVertices = null; }
  84448. if (updatable === void 0) { updatable = false; }
  84449. if (this._indexBuffer) {
  84450. this._engine._releaseBuffer(this._indexBuffer);
  84451. }
  84452. this._disposeVertexArrayObjects();
  84453. this._indices = indices;
  84454. this._indexBufferIsUpdatable = updatable;
  84455. if (this._meshes.length !== 0 && this._indices) {
  84456. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  84457. }
  84458. if (totalVertices != undefined) { // including null and undefined
  84459. this._totalVertices = totalVertices;
  84460. }
  84461. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  84462. var mesh = _a[_i];
  84463. mesh._createGlobalSubMesh(true);
  84464. }
  84465. this.notifyUpdate();
  84466. };
  84467. /**
  84468. * Return the total number of indices
  84469. * @returns the total number of indices
  84470. */
  84471. Geometry.prototype.getTotalIndices = function () {
  84472. if (!this.isReady()) {
  84473. return 0;
  84474. }
  84475. return this._indices.length;
  84476. };
  84477. /**
  84478. * Gets the index buffer array
  84479. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84481. * @returns the index buffer array
  84482. */
  84483. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  84484. if (!this.isReady()) {
  84485. return null;
  84486. }
  84487. var orig = this._indices;
  84488. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  84489. return orig;
  84490. }
  84491. else {
  84492. var len = orig.length;
  84493. var copy = [];
  84494. for (var i = 0; i < len; i++) {
  84495. copy.push(orig[i]);
  84496. }
  84497. return copy;
  84498. }
  84499. };
  84500. /**
  84501. * Gets the index buffer
  84502. * @return the index buffer
  84503. */
  84504. Geometry.prototype.getIndexBuffer = function () {
  84505. if (!this.isReady()) {
  84506. return null;
  84507. }
  84508. return this._indexBuffer;
  84509. };
  84510. /** @hidden */
  84511. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  84512. if (effect === void 0) { effect = null; }
  84513. if (!effect || !this._vertexArrayObjects) {
  84514. return;
  84515. }
  84516. if (this._vertexArrayObjects[effect.key]) {
  84517. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  84518. delete this._vertexArrayObjects[effect.key];
  84519. }
  84520. };
  84521. /**
  84522. * Release the associated resources for a specific mesh
  84523. * @param mesh defines the source mesh
  84524. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84525. */
  84526. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  84527. var meshes = this._meshes;
  84528. var index = meshes.indexOf(mesh);
  84529. if (index === -1) {
  84530. return;
  84531. }
  84532. meshes.splice(index, 1);
  84533. mesh._geometry = null;
  84534. if (meshes.length === 0 && shouldDispose) {
  84535. this.dispose();
  84536. }
  84537. };
  84538. /**
  84539. * Apply current geometry to a given mesh
  84540. * @param mesh defines the mesh to apply geometry to
  84541. */
  84542. Geometry.prototype.applyToMesh = function (mesh) {
  84543. if (mesh._geometry === this) {
  84544. return;
  84545. }
  84546. var previousGeometry = mesh._geometry;
  84547. if (previousGeometry) {
  84548. previousGeometry.releaseForMesh(mesh);
  84549. }
  84550. var meshes = this._meshes;
  84551. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  84552. mesh._geometry = this;
  84553. this._scene.pushGeometry(this);
  84554. meshes.push(mesh);
  84555. if (this.isReady()) {
  84556. this._applyToMesh(mesh);
  84557. }
  84558. else {
  84559. mesh._boundingInfo = this._boundingInfo;
  84560. }
  84561. };
  84562. Geometry.prototype._updateExtend = function (data) {
  84563. if (data === void 0) { data = null; }
  84564. if (!data) {
  84565. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  84566. }
  84567. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  84568. };
  84569. Geometry.prototype._applyToMesh = function (mesh) {
  84570. var numOfMeshes = this._meshes.length;
  84571. // vertexBuffers
  84572. for (var kind in this._vertexBuffers) {
  84573. if (numOfMeshes === 1) {
  84574. this._vertexBuffers[kind].create();
  84575. }
  84576. var buffer = this._vertexBuffers[kind].getBuffer();
  84577. if (buffer) {
  84578. buffer.references = numOfMeshes;
  84579. }
  84580. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  84581. if (!this._extend) {
  84582. this._updateExtend();
  84583. }
  84584. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84585. mesh._createGlobalSubMesh(false);
  84586. //bounding info was just created again, world matrix should be applied again.
  84587. mesh._updateBoundingInfo();
  84588. }
  84589. }
  84590. // indexBuffer
  84591. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  84592. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  84593. }
  84594. if (this._indexBuffer) {
  84595. this._indexBuffer.references = numOfMeshes;
  84596. }
  84597. // morphTargets
  84598. mesh._syncGeometryWithMorphTargetManager();
  84599. // instances
  84600. mesh.synchronizeInstances();
  84601. };
  84602. Geometry.prototype.notifyUpdate = function (kind) {
  84603. if (this.onGeometryUpdated) {
  84604. this.onGeometryUpdated(this, kind);
  84605. }
  84606. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  84607. var mesh = _a[_i];
  84608. mesh._markSubMeshesAsAttributesDirty();
  84609. }
  84610. };
  84611. /**
  84612. * Load the geometry if it was flagged as delay loaded
  84613. * @param scene defines the hosting scene
  84614. * @param onLoaded defines a callback called when the geometry is loaded
  84615. */
  84616. Geometry.prototype.load = function (scene, onLoaded) {
  84617. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  84618. return;
  84619. }
  84620. if (this.isReady()) {
  84621. if (onLoaded) {
  84622. onLoaded();
  84623. }
  84624. return;
  84625. }
  84626. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  84627. this._queueLoad(scene, onLoaded);
  84628. };
  84629. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  84630. var _this = this;
  84631. if (!this.delayLoadingFile) {
  84632. return;
  84633. }
  84634. scene._addPendingData(this);
  84635. scene._loadFile(this.delayLoadingFile, function (data) {
  84636. if (!_this._delayLoadingFunction) {
  84637. return;
  84638. }
  84639. _this._delayLoadingFunction(JSON.parse(data), _this);
  84640. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  84641. _this._delayInfo = [];
  84642. scene._removePendingData(_this);
  84643. var meshes = _this._meshes;
  84644. var numOfMeshes = meshes.length;
  84645. for (var index = 0; index < numOfMeshes; index++) {
  84646. _this._applyToMesh(meshes[index]);
  84647. }
  84648. if (onLoaded) {
  84649. onLoaded();
  84650. }
  84651. }, undefined, true);
  84652. };
  84653. /**
  84654. * Invert the geometry to move from a right handed system to a left handed one.
  84655. */
  84656. Geometry.prototype.toLeftHanded = function () {
  84657. // Flip faces
  84658. var tIndices = this.getIndices(false);
  84659. if (tIndices != null && tIndices.length > 0) {
  84660. for (var i = 0; i < tIndices.length; i += 3) {
  84661. var tTemp = tIndices[i + 0];
  84662. tIndices[i + 0] = tIndices[i + 2];
  84663. tIndices[i + 2] = tTemp;
  84664. }
  84665. this.setIndices(tIndices);
  84666. }
  84667. // Negate position.z
  84668. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  84669. if (tPositions != null && tPositions.length > 0) {
  84670. for (var i = 0; i < tPositions.length; i += 3) {
  84671. tPositions[i + 2] = -tPositions[i + 2];
  84672. }
  84673. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  84674. }
  84675. // Negate normal.z
  84676. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  84677. if (tNormals != null && tNormals.length > 0) {
  84678. for (var i = 0; i < tNormals.length; i += 3) {
  84679. tNormals[i + 2] = -tNormals[i + 2];
  84680. }
  84681. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  84682. }
  84683. };
  84684. // Cache
  84685. /** @hidden */
  84686. Geometry.prototype._resetPointsArrayCache = function () {
  84687. this._positions = null;
  84688. };
  84689. /** @hidden */
  84690. Geometry.prototype._generatePointsArray = function () {
  84691. if (this._positions) {
  84692. return true;
  84693. }
  84694. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  84695. if (!data || data.length === 0) {
  84696. return false;
  84697. }
  84698. this._positions = [];
  84699. for (var index = 0; index < data.length; index += 3) {
  84700. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  84701. }
  84702. return true;
  84703. };
  84704. /**
  84705. * Gets a value indicating if the geometry is disposed
  84706. * @returns true if the geometry was disposed
  84707. */
  84708. Geometry.prototype.isDisposed = function () {
  84709. return this._isDisposed;
  84710. };
  84711. Geometry.prototype._disposeVertexArrayObjects = function () {
  84712. if (this._vertexArrayObjects) {
  84713. for (var kind in this._vertexArrayObjects) {
  84714. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  84715. }
  84716. this._vertexArrayObjects = {};
  84717. }
  84718. };
  84719. /**
  84720. * Free all associated resources
  84721. */
  84722. Geometry.prototype.dispose = function () {
  84723. var meshes = this._meshes;
  84724. var numOfMeshes = meshes.length;
  84725. var index;
  84726. for (index = 0; index < numOfMeshes; index++) {
  84727. this.releaseForMesh(meshes[index]);
  84728. }
  84729. this._meshes = [];
  84730. this._disposeVertexArrayObjects();
  84731. for (var kind in this._vertexBuffers) {
  84732. this._vertexBuffers[kind].dispose();
  84733. }
  84734. this._vertexBuffers = {};
  84735. this._totalVertices = 0;
  84736. if (this._indexBuffer) {
  84737. this._engine._releaseBuffer(this._indexBuffer);
  84738. }
  84739. this._indexBuffer = null;
  84740. this._indices = [];
  84741. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  84742. this.delayLoadingFile = null;
  84743. this._delayLoadingFunction = null;
  84744. this._delayInfo = [];
  84745. this._boundingInfo = null;
  84746. this._scene.removeGeometry(this);
  84747. this._isDisposed = true;
  84748. };
  84749. /**
  84750. * Clone the current geometry into a new geometry
  84751. * @param id defines the unique ID of the new geometry
  84752. * @returns a new geometry object
  84753. */
  84754. Geometry.prototype.copy = function (id) {
  84755. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  84756. vertexData.indices = [];
  84757. var indices = this.getIndices();
  84758. if (indices) {
  84759. for (var index = 0; index < indices.length; index++) {
  84760. vertexData.indices.push(indices[index]);
  84761. }
  84762. }
  84763. var updatable = false;
  84764. var stopChecking = false;
  84765. var kind;
  84766. for (kind in this._vertexBuffers) {
  84767. // using slice() to make a copy of the array and not just reference it
  84768. var data = this.getVerticesData(kind);
  84769. if (data) {
  84770. if (data instanceof Float32Array) {
  84771. vertexData.set(new Float32Array(data), kind);
  84772. }
  84773. else {
  84774. vertexData.set(data.slice(0), kind);
  84775. }
  84776. if (!stopChecking) {
  84777. var vb = this.getVertexBuffer(kind);
  84778. if (vb) {
  84779. updatable = vb.isUpdatable();
  84780. stopChecking = !updatable;
  84781. }
  84782. }
  84783. }
  84784. }
  84785. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  84786. geometry.delayLoadState = this.delayLoadState;
  84787. geometry.delayLoadingFile = this.delayLoadingFile;
  84788. geometry._delayLoadingFunction = this._delayLoadingFunction;
  84789. for (kind in this._delayInfo) {
  84790. geometry._delayInfo = geometry._delayInfo || [];
  84791. geometry._delayInfo.push(kind);
  84792. }
  84793. // Bounding info
  84794. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84795. return geometry;
  84796. };
  84797. /**
  84798. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84799. * @return a JSON representation of the current geometry data (without the vertices data)
  84800. */
  84801. Geometry.prototype.serialize = function () {
  84802. var serializationObject = {};
  84803. serializationObject.id = this.id;
  84804. serializationObject.updatable = this._updatable;
  84805. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  84806. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  84807. }
  84808. return serializationObject;
  84809. };
  84810. Geometry.prototype.toNumberArray = function (origin) {
  84811. if (Array.isArray(origin)) {
  84812. return origin;
  84813. }
  84814. else {
  84815. return Array.prototype.slice.call(origin);
  84816. }
  84817. };
  84818. /**
  84819. * Serialize all vertices data into a JSON oject
  84820. * @returns a JSON representation of the current geometry data
  84821. */
  84822. Geometry.prototype.serializeVerticeData = function () {
  84823. var serializationObject = this.serialize();
  84824. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  84825. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  84826. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  84827. serializationObject.positions._updatable = true;
  84828. }
  84829. }
  84830. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  84831. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  84832. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  84833. serializationObject.normals._updatable = true;
  84834. }
  84835. }
  84836. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  84837. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  84838. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  84839. serializationObject.tangets._updatable = true;
  84840. }
  84841. }
  84842. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  84843. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  84844. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  84845. serializationObject.uvs._updatable = true;
  84846. }
  84847. }
  84848. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  84849. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  84850. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  84851. serializationObject.uv2s._updatable = true;
  84852. }
  84853. }
  84854. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  84855. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  84856. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  84857. serializationObject.uv3s._updatable = true;
  84858. }
  84859. }
  84860. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  84861. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  84862. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  84863. serializationObject.uv4s._updatable = true;
  84864. }
  84865. }
  84866. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  84867. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  84868. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  84869. serializationObject.uv5s._updatable = true;
  84870. }
  84871. }
  84872. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  84873. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  84874. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  84875. serializationObject.uv6s._updatable = true;
  84876. }
  84877. }
  84878. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  84879. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  84880. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  84881. serializationObject.colors._updatable = true;
  84882. }
  84883. }
  84884. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  84885. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  84886. serializationObject.matricesIndices._isExpanded = true;
  84887. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  84888. serializationObject.matricesIndices._updatable = true;
  84889. }
  84890. }
  84891. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  84892. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  84893. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  84894. serializationObject.matricesWeights._updatable = true;
  84895. }
  84896. }
  84897. serializationObject.indices = this.toNumberArray(this.getIndices());
  84898. return serializationObject;
  84899. };
  84900. // Statics
  84901. /**
  84902. * Extracts a clone of a mesh geometry
  84903. * @param mesh defines the source mesh
  84904. * @param id defines the unique ID of the new geometry object
  84905. * @returns the new geometry object
  84906. */
  84907. Geometry.ExtractFromMesh = function (mesh, id) {
  84908. var geometry = mesh._geometry;
  84909. if (!geometry) {
  84910. return null;
  84911. }
  84912. return geometry.copy(id);
  84913. };
  84914. /**
  84915. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84916. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84917. * Be aware Math.random() could cause collisions, but:
  84918. * "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"
  84919. * @returns a string containing a new GUID
  84920. */
  84921. Geometry.RandomId = function () {
  84922. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  84923. };
  84924. /** @hidden */
  84925. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  84926. var scene = mesh.getScene();
  84927. // Geometry
  84928. var geometryId = parsedGeometry.geometryId;
  84929. if (geometryId) {
  84930. var geometry = scene.getGeometryByID(geometryId);
  84931. if (geometry) {
  84932. geometry.applyToMesh(mesh);
  84933. }
  84934. }
  84935. else if (parsedGeometry instanceof ArrayBuffer) {
  84936. var binaryInfo = mesh._binaryInfo;
  84937. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  84938. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  84939. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  84940. }
  84941. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  84942. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  84943. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  84944. }
  84945. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  84946. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  84947. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  84948. }
  84949. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  84950. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  84951. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  84952. }
  84953. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  84954. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  84955. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  84956. }
  84957. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  84958. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  84959. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  84960. }
  84961. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  84962. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  84963. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  84964. }
  84965. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  84966. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  84967. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  84968. }
  84969. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  84970. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  84971. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  84972. }
  84973. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  84974. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  84975. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  84976. }
  84977. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  84978. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  84979. var floatIndices = [];
  84980. for (var i = 0; i < matricesIndicesData.length; i++) {
  84981. var index = matricesIndicesData[i];
  84982. floatIndices.push(index & 0x000000FF);
  84983. floatIndices.push((index & 0x0000FF00) >> 8);
  84984. floatIndices.push((index & 0x00FF0000) >> 16);
  84985. floatIndices.push(index >> 24);
  84986. }
  84987. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  84988. }
  84989. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  84990. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  84991. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  84992. }
  84993. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  84994. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  84995. mesh.setIndices(indicesData, null);
  84996. }
  84997. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  84998. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  84999. mesh.subMeshes = [];
  85000. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  85001. var materialIndex = subMeshesData[(i * 5) + 0];
  85002. var verticesStart = subMeshesData[(i * 5) + 1];
  85003. var verticesCount = subMeshesData[(i * 5) + 2];
  85004. var indexStart = subMeshesData[(i * 5) + 3];
  85005. var indexCount = subMeshesData[(i * 5) + 4];
  85006. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  85007. }
  85008. }
  85009. }
  85010. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  85011. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  85012. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  85013. if (parsedGeometry.tangents) {
  85014. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  85015. }
  85016. if (parsedGeometry.uvs) {
  85017. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  85018. }
  85019. if (parsedGeometry.uvs2) {
  85020. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  85021. }
  85022. if (parsedGeometry.uvs3) {
  85023. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  85024. }
  85025. if (parsedGeometry.uvs4) {
  85026. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  85027. }
  85028. if (parsedGeometry.uvs5) {
  85029. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  85030. }
  85031. if (parsedGeometry.uvs6) {
  85032. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  85033. }
  85034. if (parsedGeometry.colors) {
  85035. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(parsedGeometry.colors, parsedGeometry.positions.length / 3), parsedGeometry.colors._updatable);
  85036. }
  85037. if (parsedGeometry.matricesIndices) {
  85038. if (!parsedGeometry.matricesIndices._isExpanded) {
  85039. var floatIndices = [];
  85040. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  85041. var matricesIndex = parsedGeometry.matricesIndices[i];
  85042. floatIndices.push(matricesIndex & 0x000000FF);
  85043. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  85044. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  85045. floatIndices.push(matricesIndex >> 24);
  85046. }
  85047. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  85048. }
  85049. else {
  85050. delete parsedGeometry.matricesIndices._isExpanded;
  85051. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  85052. }
  85053. }
  85054. if (parsedGeometry.matricesIndicesExtra) {
  85055. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  85056. var floatIndices = [];
  85057. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  85058. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  85059. floatIndices.push(matricesIndex & 0x000000FF);
  85060. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  85061. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  85062. floatIndices.push(matricesIndex >> 24);
  85063. }
  85064. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  85065. }
  85066. else {
  85067. delete parsedGeometry.matricesIndices._isExpanded;
  85068. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  85069. }
  85070. }
  85071. if (parsedGeometry.matricesWeights) {
  85072. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  85073. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  85074. }
  85075. if (parsedGeometry.matricesWeightsExtra) {
  85076. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  85077. }
  85078. mesh.setIndices(parsedGeometry.indices, null);
  85079. }
  85080. // SubMeshes
  85081. if (parsedGeometry.subMeshes) {
  85082. mesh.subMeshes = [];
  85083. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  85084. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  85085. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  85086. }
  85087. }
  85088. // Flat shading
  85089. if (mesh._shouldGenerateFlatShading) {
  85090. mesh.convertToFlatShadedMesh();
  85091. delete mesh._shouldGenerateFlatShading;
  85092. }
  85093. // Update
  85094. mesh.computeWorldMatrix(true);
  85095. scene.onMeshImportedObservable.notifyObservers(mesh);
  85096. };
  85097. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  85098. var epsilon = 1e-3;
  85099. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  85100. return;
  85101. }
  85102. var noInfluenceBoneIndex = 0.0;
  85103. if (parsedGeometry.skeletonId > -1) {
  85104. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  85105. if (!skeleton) {
  85106. return;
  85107. }
  85108. noInfluenceBoneIndex = skeleton.bones.length;
  85109. }
  85110. else {
  85111. return;
  85112. }
  85113. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  85114. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  85115. var matricesWeights = parsedGeometry.matricesWeights;
  85116. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  85117. var influencers = parsedGeometry.numBoneInfluencer;
  85118. var size = matricesWeights.length;
  85119. for (var i = 0; i < size; i += 4) {
  85120. var weight = 0.0;
  85121. var firstZeroWeight = -1;
  85122. for (var j = 0; j < 4; j++) {
  85123. var w = matricesWeights[i + j];
  85124. weight += w;
  85125. if (w < epsilon && firstZeroWeight < 0) {
  85126. firstZeroWeight = j;
  85127. }
  85128. }
  85129. if (matricesWeightsExtra) {
  85130. for (var j = 0; j < 4; j++) {
  85131. var w = matricesWeightsExtra[i + j];
  85132. weight += w;
  85133. if (w < epsilon && firstZeroWeight < 0) {
  85134. firstZeroWeight = j + 4;
  85135. }
  85136. }
  85137. }
  85138. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  85139. firstZeroWeight = influencers - 1;
  85140. }
  85141. if (weight > epsilon) {
  85142. var mweight = 1.0 / weight;
  85143. for (var j = 0; j < 4; j++) {
  85144. matricesWeights[i + j] *= mweight;
  85145. }
  85146. if (matricesWeightsExtra) {
  85147. for (var j = 0; j < 4; j++) {
  85148. matricesWeightsExtra[i + j] *= mweight;
  85149. }
  85150. }
  85151. }
  85152. else {
  85153. if (firstZeroWeight >= 4) {
  85154. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  85155. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  85156. }
  85157. else {
  85158. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  85159. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  85160. }
  85161. }
  85162. }
  85163. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  85164. if (parsedGeometry.matricesWeightsExtra) {
  85165. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  85166. }
  85167. };
  85168. /**
  85169. * Create a new geometry from persisted data (Using .babylon file format)
  85170. * @param parsedVertexData defines the persisted data
  85171. * @param scene defines the hosting scene
  85172. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85173. * @returns the new geometry object
  85174. */
  85175. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  85176. if (scene.getGeometryByID(parsedVertexData.id)) {
  85177. return null; // null since geometry could be something else than a box...
  85178. }
  85179. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  85180. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  85181. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  85182. }
  85183. if (parsedVertexData.delayLoadingFile) {
  85184. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  85185. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  85186. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(parsedVertexData.boundingBoxMinimum), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(parsedVertexData.boundingBoxMaximum));
  85187. geometry._delayInfo = [];
  85188. if (parsedVertexData.hasUVs) {
  85189. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  85190. }
  85191. if (parsedVertexData.hasUVs2) {
  85192. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  85193. }
  85194. if (parsedVertexData.hasUVs3) {
  85195. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  85196. }
  85197. if (parsedVertexData.hasUVs4) {
  85198. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  85199. }
  85200. if (parsedVertexData.hasUVs5) {
  85201. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  85202. }
  85203. if (parsedVertexData.hasUVs6) {
  85204. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  85205. }
  85206. if (parsedVertexData.hasColors) {
  85207. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  85208. }
  85209. if (parsedVertexData.hasMatricesIndices) {
  85210. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  85211. }
  85212. if (parsedVertexData.hasMatricesWeights) {
  85213. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  85214. }
  85215. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  85216. }
  85217. else {
  85218. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  85219. }
  85220. scene.pushGeometry(geometry, true);
  85221. return geometry;
  85222. };
  85223. return Geometry;
  85224. }());
  85225. /***/ }),
  85226. /***/ "./Meshes/groundMesh.ts":
  85227. /*!******************************!*\
  85228. !*** ./Meshes/groundMesh.ts ***!
  85229. \******************************/
  85230. /*! exports provided: GroundMesh */
  85231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85232. "use strict";
  85233. __webpack_require__.r(__webpack_exports__);
  85234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  85235. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85236. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85237. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  85238. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  85239. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  85240. return GroundMesh.Parse(parsedMesh, scene);
  85241. };
  85242. /**
  85243. * Mesh representing the gorund
  85244. */
  85245. var GroundMesh = /** @class */ (function (_super) {
  85246. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  85247. function GroundMesh(name, scene) {
  85248. var _this = _super.call(this, name, scene) || this;
  85249. /** If octree should be generated */
  85250. _this.generateOctree = false;
  85251. return _this;
  85252. }
  85253. /**
  85254. * "GroundMesh"
  85255. * @returns "GroundMesh"
  85256. */
  85257. GroundMesh.prototype.getClassName = function () {
  85258. return "GroundMesh";
  85259. };
  85260. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  85261. /**
  85262. * The minimum of x and y subdivisions
  85263. */
  85264. get: function () {
  85265. return Math.min(this._subdivisionsX, this._subdivisionsY);
  85266. },
  85267. enumerable: true,
  85268. configurable: true
  85269. });
  85270. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  85271. /**
  85272. * X subdivisions
  85273. */
  85274. get: function () {
  85275. return this._subdivisionsX;
  85276. },
  85277. enumerable: true,
  85278. configurable: true
  85279. });
  85280. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  85281. /**
  85282. * Y subdivisions
  85283. */
  85284. get: function () {
  85285. return this._subdivisionsY;
  85286. },
  85287. enumerable: true,
  85288. configurable: true
  85289. });
  85290. /**
  85291. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  85292. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  85293. * @param chunksCount the number of subdivisions for x and y
  85294. * @param octreeBlocksSize (Default: 32)
  85295. */
  85296. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  85297. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  85298. this._subdivisionsX = chunksCount;
  85299. this._subdivisionsY = chunksCount;
  85300. this.subdivide(chunksCount);
  85301. // Call the octree system optimization if it is defined.
  85302. var thisAsAny = this;
  85303. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  85304. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  85305. }
  85306. };
  85307. /**
  85308. * Returns a height (y) value in the Worl system :
  85309. * the ground altitude at the coordinates (x, z) expressed in the World system.
  85310. * @param x x coordinate
  85311. * @param z z coordinate
  85312. * @returns the ground y position if (x, z) are outside the ground surface.
  85313. */
  85314. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  85315. var world = this.getWorldMatrix();
  85316. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  85317. world.invertToRef(invMat);
  85318. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  85319. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  85320. x = tmpVect.x;
  85321. z = tmpVect.z;
  85322. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  85323. return this.position.y;
  85324. }
  85325. if (!this._heightQuads || this._heightQuads.length == 0) {
  85326. this._initHeightQuads();
  85327. this._computeHeightQuads();
  85328. }
  85329. var facet = this._getFacetAt(x, z);
  85330. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  85331. // return y in the World system
  85332. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  85333. return tmpVect.y;
  85334. };
  85335. /**
  85336. * Returns a normalized vector (Vector3) orthogonal to the ground
  85337. * at the ground coordinates (x, z) expressed in the World system.
  85338. * @param x x coordinate
  85339. * @param z z coordinate
  85340. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  85341. */
  85342. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  85343. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  85344. this.getNormalAtCoordinatesToRef(x, z, normal);
  85345. return normal;
  85346. };
  85347. /**
  85348. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  85349. * at the ground coordinates (x, z) expressed in the World system.
  85350. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  85351. * @param x x coordinate
  85352. * @param z z coordinate
  85353. * @param ref vector to store the result
  85354. * @returns the GroundMesh.
  85355. */
  85356. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  85357. var world = this.getWorldMatrix();
  85358. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  85359. world.invertToRef(tmpMat);
  85360. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  85361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  85362. x = tmpVect.x;
  85363. z = tmpVect.z;
  85364. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  85365. return this;
  85366. }
  85367. if (!this._heightQuads || this._heightQuads.length == 0) {
  85368. this._initHeightQuads();
  85369. this._computeHeightQuads();
  85370. }
  85371. var facet = this._getFacetAt(x, z);
  85372. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  85373. return this;
  85374. };
  85375. /**
  85376. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  85377. * if the ground has been updated.
  85378. * This can be used in the render loop.
  85379. * @returns the GroundMesh.
  85380. */
  85381. GroundMesh.prototype.updateCoordinateHeights = function () {
  85382. if (!this._heightQuads || this._heightQuads.length == 0) {
  85383. this._initHeightQuads();
  85384. }
  85385. this._computeHeightQuads();
  85386. return this;
  85387. };
  85388. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  85389. GroundMesh.prototype._getFacetAt = function (x, z) {
  85390. // retrieve col and row from x, z coordinates in the ground local system
  85391. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  85392. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  85393. var quad = this._heightQuads[row * this._subdivisionsX + col];
  85394. var facet;
  85395. if (z < quad.slope.x * x + quad.slope.y) {
  85396. facet = quad.facet1;
  85397. }
  85398. else {
  85399. facet = quad.facet2;
  85400. }
  85401. return facet;
  85402. };
  85403. // Creates and populates the heightMap array with "facet" elements :
  85404. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  85405. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  85406. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  85407. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  85408. // Returns the GroundMesh.
  85409. GroundMesh.prototype._initHeightQuads = function () {
  85410. var subdivisionsX = this._subdivisionsX;
  85411. var subdivisionsY = this._subdivisionsY;
  85412. this._heightQuads = new Array();
  85413. for (var row = 0; row < subdivisionsY; row++) {
  85414. for (var col = 0; col < subdivisionsX; col++) {
  85415. 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) };
  85416. this._heightQuads[row * subdivisionsX + col] = quad;
  85417. }
  85418. }
  85419. return this;
  85420. };
  85421. // Compute each quad element values and update the the heightMap array :
  85422. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  85423. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  85424. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  85425. // Returns the GroundMesh.
  85426. GroundMesh.prototype._computeHeightQuads = function () {
  85427. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  85428. if (!positions) {
  85429. return this;
  85430. }
  85431. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  85432. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  85433. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  85434. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  85435. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  85436. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  85437. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  85438. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  85439. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  85440. var i = 0;
  85441. var j = 0;
  85442. var k = 0;
  85443. var cd = 0; // 2D slope coefficient : z = cd * x + h
  85444. var h = 0;
  85445. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  85446. var d2 = 0;
  85447. var subdivisionsX = this._subdivisionsX;
  85448. var subdivisionsY = this._subdivisionsY;
  85449. for (var row = 0; row < subdivisionsY; row++) {
  85450. for (var col = 0; col < subdivisionsX; col++) {
  85451. i = col * 3;
  85452. j = row * (subdivisionsX + 1) * 3;
  85453. k = (row + 1) * (subdivisionsX + 1) * 3;
  85454. v1.x = positions[j + i];
  85455. v1.y = positions[j + i + 1];
  85456. v1.z = positions[j + i + 2];
  85457. v2.x = positions[j + i + 3];
  85458. v2.y = positions[j + i + 4];
  85459. v2.z = positions[j + i + 5];
  85460. v3.x = positions[k + i];
  85461. v3.y = positions[k + i + 1];
  85462. v3.z = positions[k + i + 2];
  85463. v4.x = positions[k + i + 3];
  85464. v4.y = positions[k + i + 4];
  85465. v4.z = positions[k + i + 5];
  85466. // 2D slope V1V4
  85467. cd = (v4.z - v1.z) / (v4.x - v1.x);
  85468. h = v1.z - cd * v1.x; // v1 belongs to the slope
  85469. // facet equations :
  85470. // we compute each facet normal vector
  85471. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  85472. // we compute the value d by applying the equation to v1 which belongs to the plane
  85473. // then we store the facet equation in a Vector4
  85474. v2.subtractToRef(v1, v1v2);
  85475. v3.subtractToRef(v1, v1v3);
  85476. v4.subtractToRef(v1, v1v4);
  85477. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  85478. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  85479. norm1.normalize();
  85480. norm2.normalize();
  85481. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  85482. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  85483. var quad = this._heightQuads[row * subdivisionsX + col];
  85484. quad.slope.copyFromFloats(cd, h);
  85485. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  85486. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  85487. }
  85488. }
  85489. return this;
  85490. };
  85491. /**
  85492. * Serializes this ground mesh
  85493. * @param serializationObject object to write serialization to
  85494. */
  85495. GroundMesh.prototype.serialize = function (serializationObject) {
  85496. _super.prototype.serialize.call(this, serializationObject);
  85497. serializationObject.subdivisionsX = this._subdivisionsX;
  85498. serializationObject.subdivisionsY = this._subdivisionsY;
  85499. serializationObject.minX = this._minX;
  85500. serializationObject.maxX = this._maxX;
  85501. serializationObject.minZ = this._minZ;
  85502. serializationObject.maxZ = this._maxZ;
  85503. serializationObject.width = this._width;
  85504. serializationObject.height = this._height;
  85505. };
  85506. /**
  85507. * Parses a serialized ground mesh
  85508. * @param parsedMesh the serialized mesh
  85509. * @param scene the scene to create the ground mesh in
  85510. * @returns the created ground mesh
  85511. */
  85512. GroundMesh.Parse = function (parsedMesh, scene) {
  85513. var result = new GroundMesh(parsedMesh.name, scene);
  85514. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  85515. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  85516. result._minX = parsedMesh.minX;
  85517. result._maxX = parsedMesh.maxX;
  85518. result._minZ = parsedMesh.minZ;
  85519. result._maxZ = parsedMesh.maxZ;
  85520. result._width = parsedMesh.width;
  85521. result._height = parsedMesh.height;
  85522. return result;
  85523. };
  85524. return GroundMesh;
  85525. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  85526. /***/ }),
  85527. /***/ "./Meshes/index.ts":
  85528. /*!*************************!*\
  85529. !*** ./Meshes/index.ts ***!
  85530. \*************************/
  85531. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  85532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85533. "use strict";
  85534. __webpack_require__.r(__webpack_exports__);
  85535. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  85536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  85537. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  85538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  85539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  85540. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  85541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  85542. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  85543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  85544. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  85545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  85546. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  85547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  85548. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  85549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  85550. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  85551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  85552. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  85553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  85554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  85555. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  85556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["MeshLODLevel"]; });
  85557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  85558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  85559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  85560. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  85562. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  85563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  85564. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  85565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  85566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  85567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  85568. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  85569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  85570. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  85571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  85572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  85573. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  85574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  85575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  85576. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  85577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_16__["TransformNode"]; });
  85578. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  85579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["BoxBuilder"]; });
  85580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["SphereBuilder"]; });
  85581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["CylinderBuilder"]; });
  85582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LinesBuilder"]; });
  85583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PlaneBuilder"]; });
  85584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DiscBuilder"]; });
  85585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["RibbonBuilder"]; });
  85586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusBuilder"]; });
  85587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusKnotBuilder"]; });
  85588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolygonBuilder"]; });
  85589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["ShapeBuilder"]; });
  85590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LatheBuilder"]; });
  85591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["GroundBuilder"]; });
  85592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TubeBuilder"]; });
  85593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  85594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"]; });
  85595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  85596. /***/ }),
  85597. /***/ "./Meshes/instancedMesh.ts":
  85598. /*!*********************************!*\
  85599. !*** ./Meshes/instancedMesh.ts ***!
  85600. \*********************************/
  85601. /*! exports provided: InstancedMesh */
  85602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85603. "use strict";
  85604. __webpack_require__.r(__webpack_exports__);
  85605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  85606. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85607. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  85608. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  85609. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  85610. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  85611. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  85612. return new InstancedMesh(name, mesh);
  85613. };
  85614. /**
  85615. * Creates an instance based on a source mesh.
  85616. */
  85617. var InstancedMesh = /** @class */ (function (_super) {
  85618. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  85619. function InstancedMesh(name, source) {
  85620. var _this = _super.call(this, name, source.getScene()) || this;
  85621. /** @hidden */
  85622. _this._indexInSourceMeshInstanceArray = -1;
  85623. source.addInstance(_this);
  85624. _this._sourceMesh = source;
  85625. _this.position.copyFrom(source.position);
  85626. _this.rotation.copyFrom(source.rotation);
  85627. _this.scaling.copyFrom(source.scaling);
  85628. if (source.rotationQuaternion) {
  85629. _this.rotationQuaternion = source.rotationQuaternion.clone();
  85630. }
  85631. _this.infiniteDistance = source.infiniteDistance;
  85632. _this.setPivotMatrix(source.getPivotMatrix());
  85633. _this.refreshBoundingInfo();
  85634. _this._syncSubMeshes();
  85635. return _this;
  85636. }
  85637. /**
  85638. * Returns the string "InstancedMesh".
  85639. */
  85640. InstancedMesh.prototype.getClassName = function () {
  85641. return "InstancedMesh";
  85642. };
  85643. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  85644. // Methods
  85645. /**
  85646. * If the source mesh receives shadows
  85647. */
  85648. get: function () {
  85649. return this._sourceMesh.receiveShadows;
  85650. },
  85651. enumerable: true,
  85652. configurable: true
  85653. });
  85654. Object.defineProperty(InstancedMesh.prototype, "material", {
  85655. /**
  85656. * The material of the source mesh
  85657. */
  85658. get: function () {
  85659. return this._sourceMesh.material;
  85660. },
  85661. enumerable: true,
  85662. configurable: true
  85663. });
  85664. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  85665. /**
  85666. * Visibility of the source mesh
  85667. */
  85668. get: function () {
  85669. return this._sourceMesh.visibility;
  85670. },
  85671. enumerable: true,
  85672. configurable: true
  85673. });
  85674. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  85675. /**
  85676. * Skeleton of the source mesh
  85677. */
  85678. get: function () {
  85679. return this._sourceMesh.skeleton;
  85680. },
  85681. enumerable: true,
  85682. configurable: true
  85683. });
  85684. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  85685. /**
  85686. * Rendering ground id of the source mesh
  85687. */
  85688. get: function () {
  85689. return this._sourceMesh.renderingGroupId;
  85690. },
  85691. set: function (value) {
  85692. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  85693. return;
  85694. }
  85695. //no-op with warning
  85696. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  85697. },
  85698. enumerable: true,
  85699. configurable: true
  85700. });
  85701. /**
  85702. * Returns the total number of vertices (integer).
  85703. */
  85704. InstancedMesh.prototype.getTotalVertices = function () {
  85705. return this._sourceMesh.getTotalVertices();
  85706. };
  85707. /**
  85708. * Returns a positive integer : the total number of indices in this mesh geometry.
  85709. * @returns the numner of indices or zero if the mesh has no geometry.
  85710. */
  85711. InstancedMesh.prototype.getTotalIndices = function () {
  85712. return this._sourceMesh.getTotalIndices();
  85713. };
  85714. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  85715. /**
  85716. * The source mesh of the instance
  85717. */
  85718. get: function () {
  85719. return this._sourceMesh;
  85720. },
  85721. enumerable: true,
  85722. configurable: true
  85723. });
  85724. /**
  85725. * Is this node ready to be used/rendered
  85726. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85727. * @return {boolean} is it ready
  85728. */
  85729. InstancedMesh.prototype.isReady = function (completeCheck) {
  85730. if (completeCheck === void 0) { completeCheck = false; }
  85731. return this._sourceMesh.isReady(completeCheck, true);
  85732. };
  85733. /**
  85734. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85735. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85736. * @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.
  85737. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85738. */
  85739. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  85740. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  85741. };
  85742. /**
  85743. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85744. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85745. * The `data` are either a numeric array either a Float32Array.
  85746. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85747. * 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).
  85748. * Note that a new underlying VertexBuffer object is created each call.
  85749. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85750. *
  85751. * Possible `kind` values :
  85752. * - VertexBuffer.PositionKind
  85753. * - VertexBuffer.UVKind
  85754. * - VertexBuffer.UV2Kind
  85755. * - VertexBuffer.UV3Kind
  85756. * - VertexBuffer.UV4Kind
  85757. * - VertexBuffer.UV5Kind
  85758. * - VertexBuffer.UV6Kind
  85759. * - VertexBuffer.ColorKind
  85760. * - VertexBuffer.MatricesIndicesKind
  85761. * - VertexBuffer.MatricesIndicesExtraKind
  85762. * - VertexBuffer.MatricesWeightsKind
  85763. * - VertexBuffer.MatricesWeightsExtraKind
  85764. *
  85765. * Returns the Mesh.
  85766. */
  85767. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  85768. if (this.sourceMesh) {
  85769. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  85770. }
  85771. return this.sourceMesh;
  85772. };
  85773. /**
  85774. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85775. * If the mesh has no geometry, it is simply returned as it is.
  85776. * The `data` are either a numeric array either a Float32Array.
  85777. * No new underlying VertexBuffer object is created.
  85778. * 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.
  85779. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85780. *
  85781. * Possible `kind` values :
  85782. * - VertexBuffer.PositionKind
  85783. * - VertexBuffer.UVKind
  85784. * - VertexBuffer.UV2Kind
  85785. * - VertexBuffer.UV3Kind
  85786. * - VertexBuffer.UV4Kind
  85787. * - VertexBuffer.UV5Kind
  85788. * - VertexBuffer.UV6Kind
  85789. * - VertexBuffer.ColorKind
  85790. * - VertexBuffer.MatricesIndicesKind
  85791. * - VertexBuffer.MatricesIndicesExtraKind
  85792. * - VertexBuffer.MatricesWeightsKind
  85793. * - VertexBuffer.MatricesWeightsExtraKind
  85794. *
  85795. * Returns the Mesh.
  85796. */
  85797. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  85798. if (this.sourceMesh) {
  85799. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  85800. }
  85801. return this.sourceMesh;
  85802. };
  85803. /**
  85804. * Sets the mesh indices.
  85805. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85806. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85807. * This method creates a new index buffer each call.
  85808. * Returns the Mesh.
  85809. */
  85810. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  85811. if (totalVertices === void 0) { totalVertices = null; }
  85812. if (this.sourceMesh) {
  85813. this.sourceMesh.setIndices(indices, totalVertices);
  85814. }
  85815. return this.sourceMesh;
  85816. };
  85817. /**
  85818. * Boolean : True if the mesh owns the requested kind of data.
  85819. */
  85820. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  85821. return this._sourceMesh.isVerticesDataPresent(kind);
  85822. };
  85823. /**
  85824. * Returns an array of indices (IndicesArray).
  85825. */
  85826. InstancedMesh.prototype.getIndices = function () {
  85827. return this._sourceMesh.getIndices();
  85828. };
  85829. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  85830. get: function () {
  85831. return this._sourceMesh._positions;
  85832. },
  85833. enumerable: true,
  85834. configurable: true
  85835. });
  85836. /**
  85837. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85838. * This means the mesh underlying bounding box and sphere are recomputed.
  85839. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85840. * @returns the current mesh
  85841. */
  85842. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  85843. if (applySkeleton === void 0) { applySkeleton = false; }
  85844. if (this._boundingInfo && this._boundingInfo.isLocked) {
  85845. return this;
  85846. }
  85847. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  85848. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  85849. return this;
  85850. };
  85851. /** @hidden */
  85852. InstancedMesh.prototype._preActivate = function () {
  85853. if (this._currentLOD) {
  85854. this._currentLOD._preActivate();
  85855. }
  85856. return this;
  85857. };
  85858. /** @hidden */
  85859. InstancedMesh.prototype._activate = function (renderId) {
  85860. if (this._currentLOD) {
  85861. this._currentLOD._registerInstanceForRenderId(this, renderId);
  85862. }
  85863. return this;
  85864. };
  85865. /**
  85866. * Returns the current associated LOD AbstractMesh.
  85867. */
  85868. InstancedMesh.prototype.getLOD = function (camera) {
  85869. if (!camera) {
  85870. return this;
  85871. }
  85872. var boundingInfo = this.getBoundingInfo();
  85873. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  85874. if (this._currentLOD === this.sourceMesh) {
  85875. return this;
  85876. }
  85877. return this._currentLOD;
  85878. };
  85879. /** @hidden */
  85880. InstancedMesh.prototype._syncSubMeshes = function () {
  85881. this.releaseSubMeshes();
  85882. if (this._sourceMesh.subMeshes) {
  85883. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  85884. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  85885. }
  85886. }
  85887. return this;
  85888. };
  85889. /** @hidden */
  85890. InstancedMesh.prototype._generatePointsArray = function () {
  85891. return this._sourceMesh._generatePointsArray();
  85892. };
  85893. /**
  85894. * Creates a new InstancedMesh from the current mesh.
  85895. * - name (string) : the cloned mesh name
  85896. * - newParent (optional Node) : the optional Node to parent the clone to.
  85897. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85898. *
  85899. * Returns the clone.
  85900. */
  85901. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  85902. var result = this._sourceMesh.createInstance(name);
  85903. // Deep copy
  85904. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  85905. // Bounding info
  85906. this.refreshBoundingInfo();
  85907. // Parent
  85908. if (newParent) {
  85909. result.parent = newParent;
  85910. }
  85911. if (!doNotCloneChildren) {
  85912. // Children
  85913. for (var index = 0; index < this.getScene().meshes.length; index++) {
  85914. var mesh = this.getScene().meshes[index];
  85915. if (mesh.parent === this) {
  85916. mesh.clone(mesh.name, result);
  85917. }
  85918. }
  85919. }
  85920. result.computeWorldMatrix(true);
  85921. return result;
  85922. };
  85923. /**
  85924. * Disposes the InstancedMesh.
  85925. * Returns nothing.
  85926. */
  85927. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85928. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85929. // Remove from mesh
  85930. this._sourceMesh.removeInstance(this);
  85931. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85932. };
  85933. return InstancedMesh;
  85934. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  85935. /***/ }),
  85936. /***/ "./Meshes/linesMesh.ts":
  85937. /*!*****************************!*\
  85938. !*** ./Meshes/linesMesh.ts ***!
  85939. \*****************************/
  85940. /*! exports provided: LinesMesh, InstancedLinesMesh */
  85941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85942. "use strict";
  85943. __webpack_require__.r(__webpack_exports__);
  85944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  85945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  85946. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85947. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85948. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  85949. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  85950. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  85951. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  85952. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  85953. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  85954. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  85955. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  85956. /**
  85957. * Line mesh
  85958. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85959. */
  85960. var LinesMesh = /** @class */ (function (_super) {
  85961. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  85962. /**
  85963. * Creates a new LinesMesh
  85964. * @param name defines the name
  85965. * @param scene defines the hosting scene
  85966. * @param parent defines the parent mesh if any
  85967. * @param source defines the optional source LinesMesh used to clone data from
  85968. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85969. * When false, achieved by calling a clone(), also passing False.
  85970. * This will make creation of children, recursive.
  85971. * @param useVertexColor defines if this LinesMesh supports vertex color
  85972. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85973. */
  85974. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  85975. /**
  85976. * If vertex color should be applied to the mesh
  85977. */
  85978. useVertexColor,
  85979. /**
  85980. * If vertex alpha should be applied to the mesh
  85981. */
  85982. useVertexAlpha) {
  85983. if (scene === void 0) { scene = null; }
  85984. if (parent === void 0) { parent = null; }
  85985. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  85986. _this.useVertexColor = useVertexColor;
  85987. _this.useVertexAlpha = useVertexAlpha;
  85988. /**
  85989. * Color of the line (Default: White)
  85990. */
  85991. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  85992. /**
  85993. * Alpha of the line (Default: 1)
  85994. */
  85995. _this.alpha = 1;
  85996. if (source) {
  85997. _this.color = source.color.clone();
  85998. _this.alpha = source.alpha;
  85999. _this.useVertexColor = source.useVertexColor;
  86000. _this.useVertexAlpha = source.useVertexAlpha;
  86001. }
  86002. _this.intersectionThreshold = 0.1;
  86003. var defines = [];
  86004. var options = {
  86005. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  86006. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "world", "viewProjection"],
  86007. needAlphaBlending: true,
  86008. defines: defines
  86009. };
  86010. if (useVertexAlpha === false) {
  86011. options.needAlphaBlending = false;
  86012. }
  86013. if (!useVertexColor) {
  86014. options.uniforms.push("color");
  86015. }
  86016. else {
  86017. options.defines.push("#define VERTEXCOLOR");
  86018. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  86019. }
  86020. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  86021. return _this;
  86022. }
  86023. LinesMesh.prototype._addClipPlaneDefine = function (label) {
  86024. var define = "#define " + label;
  86025. var index = this._colorShader.options.defines.indexOf(define);
  86026. if (index !== -1) {
  86027. return;
  86028. }
  86029. this._colorShader.options.defines.push(define);
  86030. };
  86031. LinesMesh.prototype._removeClipPlaneDefine = function (label) {
  86032. var define = "#define " + label;
  86033. var index = this._colorShader.options.defines.indexOf(define);
  86034. if (index === -1) {
  86035. return;
  86036. }
  86037. this._colorShader.options.defines.splice(index, 1);
  86038. };
  86039. LinesMesh.prototype.isReady = function () {
  86040. var scene = this.getScene();
  86041. // Clip planes
  86042. scene.clipPlane ? this._addClipPlaneDefine("CLIPPLANE") : this._removeClipPlaneDefine("CLIPPLANE");
  86043. scene.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2");
  86044. scene.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3");
  86045. scene.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4");
  86046. if (!this._colorShader.isReady()) {
  86047. return false;
  86048. }
  86049. return _super.prototype.isReady.call(this);
  86050. };
  86051. /**
  86052. * Returns the string "LineMesh"
  86053. */
  86054. LinesMesh.prototype.getClassName = function () {
  86055. return "LinesMesh";
  86056. };
  86057. Object.defineProperty(LinesMesh.prototype, "material", {
  86058. /**
  86059. * @hidden
  86060. */
  86061. get: function () {
  86062. return this._colorShader;
  86063. },
  86064. /**
  86065. * @hidden
  86066. */
  86067. set: function (value) {
  86068. // Do nothing
  86069. },
  86070. enumerable: true,
  86071. configurable: true
  86072. });
  86073. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  86074. /**
  86075. * @hidden
  86076. */
  86077. get: function () {
  86078. return false;
  86079. },
  86080. enumerable: true,
  86081. configurable: true
  86082. });
  86083. /** @hidden */
  86084. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  86085. if (!this._geometry) {
  86086. return this;
  86087. }
  86088. var colorEffect = this._colorShader.getEffect();
  86089. // VBOs
  86090. this._geometry._bind(colorEffect);
  86091. // Color
  86092. if (!this.useVertexColor) {
  86093. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  86094. }
  86095. // Clip planes
  86096. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__["MaterialHelper"].BindClipPlane(colorEffect, this.getScene());
  86097. return this;
  86098. };
  86099. /** @hidden */
  86100. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  86101. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  86102. return this;
  86103. }
  86104. var engine = this.getScene().getEngine();
  86105. // Draw order
  86106. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  86107. return this;
  86108. };
  86109. /**
  86110. * Disposes of the line mesh
  86111. * @param doNotRecurse If children should be disposed
  86112. */
  86113. LinesMesh.prototype.dispose = function (doNotRecurse) {
  86114. this._colorShader.dispose(false, false, true);
  86115. _super.prototype.dispose.call(this, doNotRecurse);
  86116. };
  86117. /**
  86118. * Returns a new LineMesh object cloned from the current one.
  86119. */
  86120. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  86121. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  86122. };
  86123. /**
  86124. * Creates a new InstancedLinesMesh object from the mesh model.
  86125. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86126. * @param name defines the name of the new instance
  86127. * @returns a new InstancedLinesMesh
  86128. */
  86129. LinesMesh.prototype.createInstance = function (name) {
  86130. return new InstancedLinesMesh(name, this);
  86131. };
  86132. return LinesMesh;
  86133. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  86134. /**
  86135. * Creates an instance based on a source LinesMesh
  86136. */
  86137. var InstancedLinesMesh = /** @class */ (function (_super) {
  86138. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  86139. function InstancedLinesMesh(name, source) {
  86140. var _this = _super.call(this, name, source) || this;
  86141. _this.intersectionThreshold = source.intersectionThreshold;
  86142. return _this;
  86143. }
  86144. /**
  86145. * Returns the string "InstancedLinesMesh".
  86146. */
  86147. InstancedLinesMesh.prototype.getClassName = function () {
  86148. return "InstancedLinesMesh";
  86149. };
  86150. return InstancedLinesMesh;
  86151. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  86152. /***/ }),
  86153. /***/ "./Meshes/mesh.ts":
  86154. /*!************************!*\
  86155. !*** ./Meshes/mesh.ts ***!
  86156. \************************/
  86157. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  86158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86159. "use strict";
  86160. __webpack_require__.r(__webpack_exports__);
  86161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  86162. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  86163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  86164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  86165. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  86166. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  86167. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  86168. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  86169. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  86170. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86171. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  86172. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  86173. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  86174. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  86175. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  86176. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  86177. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  86178. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  86179. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  86180. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  86181. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  86182. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  86183. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  86184. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  86185. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  86186. /**
  86187. * Class used to represent a specific level of detail of a mesh
  86188. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86189. */
  86190. var MeshLODLevel = /** @class */ (function () {
  86191. /**
  86192. * Creates a new LOD level
  86193. * @param distance defines the distance where this level should star being displayed
  86194. * @param mesh defines the mesh to use to render this level
  86195. */
  86196. function MeshLODLevel(
  86197. /** Defines the distance where this level should star being displayed */
  86198. distance,
  86199. /** Defines the mesh to use to render this level */
  86200. mesh) {
  86201. this.distance = distance;
  86202. this.mesh = mesh;
  86203. }
  86204. return MeshLODLevel;
  86205. }());
  86206. /**
  86207. * @hidden
  86208. **/
  86209. var _CreationDataStorage = /** @class */ (function () {
  86210. function _CreationDataStorage() {
  86211. }
  86212. return _CreationDataStorage;
  86213. }());
  86214. /**
  86215. * @hidden
  86216. **/
  86217. var _InstanceDataStorage = /** @class */ (function () {
  86218. function _InstanceDataStorage() {
  86219. this.visibleInstances = {};
  86220. this.renderIdForInstances = new Array();
  86221. this.batchCache = new _InstancesBatch();
  86222. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  86223. }
  86224. return _InstanceDataStorage;
  86225. }());
  86226. /**
  86227. * @hidden
  86228. **/
  86229. var _InstancesBatch = /** @class */ (function () {
  86230. function _InstancesBatch() {
  86231. this.mustReturn = false;
  86232. this.visibleInstances = new Array();
  86233. this.renderSelf = new Array();
  86234. }
  86235. return _InstancesBatch;
  86236. }());
  86237. /**
  86238. * Class used to represent renderable models
  86239. */
  86240. var Mesh = /** @class */ (function (_super) {
  86241. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  86242. /**
  86243. * @constructor
  86244. * @param name The value used by scene.getMeshByName() to do a lookup.
  86245. * @param scene The scene to add this mesh to.
  86246. * @param parent The parent of this mesh, if it has one
  86247. * @param source An optional Mesh from which geometry is shared, cloned.
  86248. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86249. * When false, achieved by calling a clone(), also passing False.
  86250. * This will make creation of children, recursive.
  86251. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  86252. */
  86253. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  86254. if (scene === void 0) { scene = null; }
  86255. if (parent === void 0) { parent = null; }
  86256. if (source === void 0) { source = null; }
  86257. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  86258. var _this = _super.call(this, name, scene) || this;
  86259. // Members
  86260. /**
  86261. * Gets the delay loading state of the mesh (when delay loading is turned on)
  86262. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  86263. */
  86264. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  86265. /**
  86266. * Gets the list of instances created from this mesh
  86267. * it is not supposed to be modified manually.
  86268. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  86269. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86270. */
  86271. _this.instances = new Array();
  86272. _this._LODLevels = new Array();
  86273. /** @hidden */
  86274. _this._instanceDataStorage = new _InstanceDataStorage();
  86275. // Use by builder only to know what orientation were the mesh build in.
  86276. /** @hidden */
  86277. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  86278. /**
  86279. * Use this property to change the original side orientation defined at construction time
  86280. */
  86281. _this.overrideMaterialSideOrientation = null;
  86282. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  86283. // Will be used to save a source mesh reference, If any
  86284. _this._source = null;
  86285. /** @hidden */
  86286. _this._isMesh = true;
  86287. scene = _this.getScene();
  86288. if (source) {
  86289. // Geometry
  86290. if (source._geometry) {
  86291. source._geometry.applyToMesh(_this);
  86292. }
  86293. // Deep copy
  86294. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  86295. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  86296. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  86297. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  86298. "onDisposeObservable"
  86299. ], ["_poseMatrix"]);
  86300. // Source mesh
  86301. _this._source = source;
  86302. if (scene.useClonedMeshhMap) {
  86303. if (!source.meshMap) {
  86304. source.meshMap = {};
  86305. }
  86306. source.meshMap[_this.uniqueId] = _this;
  86307. }
  86308. // Construction Params
  86309. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  86310. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  86311. _this._creationDataStorage = source._creationDataStorage;
  86312. // Animation ranges
  86313. if (_this._source._ranges) {
  86314. var ranges = _this._source._ranges;
  86315. for (var name in ranges) {
  86316. if (!ranges.hasOwnProperty(name)) {
  86317. continue;
  86318. }
  86319. if (!ranges[name]) {
  86320. continue;
  86321. }
  86322. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  86323. }
  86324. }
  86325. // Metadata
  86326. if (source.metadata && source.metadata.clone) {
  86327. _this.metadata = source.metadata.clone();
  86328. }
  86329. else {
  86330. _this.metadata = source.metadata;
  86331. }
  86332. // Tags
  86333. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  86334. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  86335. }
  86336. // Parent
  86337. _this.parent = source.parent;
  86338. // Pivot
  86339. _this.setPivotMatrix(source.getPivotMatrix());
  86340. _this.id = name + "." + source.id;
  86341. // Material
  86342. _this.material = source.material;
  86343. var index;
  86344. if (!doNotCloneChildren) {
  86345. // Children
  86346. var directDescendants = source.getDescendants(true);
  86347. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  86348. var child = directDescendants[index_1];
  86349. if (child.clone) {
  86350. child.clone(name + "." + child.name, _this);
  86351. }
  86352. }
  86353. }
  86354. // Physics clone
  86355. var physicsEngine = _this.getScene().getPhysicsEngine();
  86356. if (clonePhysicsImpostor && physicsEngine) {
  86357. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  86358. if (impostor) {
  86359. _this.physicsImpostor = impostor.clone(_this);
  86360. }
  86361. }
  86362. // Particles
  86363. for (index = 0; index < scene.particleSystems.length; index++) {
  86364. var system = scene.particleSystems[index];
  86365. if (system.emitter === source) {
  86366. system.clone(system.name, _this);
  86367. }
  86368. }
  86369. _this.refreshBoundingInfo();
  86370. _this.computeWorldMatrix(true);
  86371. }
  86372. // Parent
  86373. if (parent !== null) {
  86374. _this.parent = parent;
  86375. }
  86376. return _this;
  86377. }
  86378. /**
  86379. * Gets the default side orientation.
  86380. * @param orientation the orientation to value to attempt to get
  86381. * @returns the default orientation
  86382. * @hidden
  86383. */
  86384. Mesh._GetDefaultSideOrientation = function (orientation) {
  86385. return orientation || Mesh.FRONTSIDE; // works as Mesh.FRONTSIDE is 0
  86386. };
  86387. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  86388. /**
  86389. * An event triggered before rendering the mesh
  86390. */
  86391. get: function () {
  86392. if (!this._onBeforeRenderObservable) {
  86393. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86394. }
  86395. return this._onBeforeRenderObservable;
  86396. },
  86397. enumerable: true,
  86398. configurable: true
  86399. });
  86400. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  86401. /**
  86402. * An event triggered before binding the mesh
  86403. */
  86404. get: function () {
  86405. if (!this._onBeforeBindObservable) {
  86406. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86407. }
  86408. return this._onBeforeBindObservable;
  86409. },
  86410. enumerable: true,
  86411. configurable: true
  86412. });
  86413. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  86414. /**
  86415. * An event triggered after rendering the mesh
  86416. */
  86417. get: function () {
  86418. if (!this._onAfterRenderObservable) {
  86419. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86420. }
  86421. return this._onAfterRenderObservable;
  86422. },
  86423. enumerable: true,
  86424. configurable: true
  86425. });
  86426. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  86427. /**
  86428. * An event triggered before drawing the mesh
  86429. */
  86430. get: function () {
  86431. if (!this._onBeforeDrawObservable) {
  86432. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86433. }
  86434. return this._onBeforeDrawObservable;
  86435. },
  86436. enumerable: true,
  86437. configurable: true
  86438. });
  86439. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  86440. /**
  86441. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  86442. */
  86443. set: function (callback) {
  86444. if (this._onBeforeDrawObserver) {
  86445. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  86446. }
  86447. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  86448. },
  86449. enumerable: true,
  86450. configurable: true
  86451. });
  86452. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  86453. /**
  86454. * Gets or sets the morph target manager
  86455. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86456. */
  86457. get: function () {
  86458. return this._morphTargetManager;
  86459. },
  86460. set: function (value) {
  86461. if (this._morphTargetManager === value) {
  86462. return;
  86463. }
  86464. this._morphTargetManager = value;
  86465. this._syncGeometryWithMorphTargetManager();
  86466. },
  86467. enumerable: true,
  86468. configurable: true
  86469. });
  86470. Object.defineProperty(Mesh.prototype, "source", {
  86471. /**
  86472. * Gets the source mesh (the one used to clone this one from)
  86473. */
  86474. get: function () {
  86475. return this._source;
  86476. },
  86477. enumerable: true,
  86478. configurable: true
  86479. });
  86480. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  86481. /**
  86482. * Gets or sets a boolean indicating that this mesh does not use index buffer
  86483. */
  86484. get: function () {
  86485. return this._unIndexed;
  86486. },
  86487. set: function (value) {
  86488. if (this._unIndexed !== value) {
  86489. this._unIndexed = value;
  86490. this._markSubMeshesAsAttributesDirty();
  86491. }
  86492. },
  86493. enumerable: true,
  86494. configurable: true
  86495. });
  86496. // Methods
  86497. /**
  86498. * Gets the class name
  86499. * @returns the string "Mesh".
  86500. */
  86501. Mesh.prototype.getClassName = function () {
  86502. return "Mesh";
  86503. };
  86504. /**
  86505. * Returns a description of this mesh
  86506. * @param fullDetails define if full details about this mesh must be used
  86507. * @returns a descriptive string representing this mesh
  86508. */
  86509. Mesh.prototype.toString = function (fullDetails) {
  86510. var ret = _super.prototype.toString.call(this, fullDetails);
  86511. ret += ", n vertices: " + this.getTotalVertices();
  86512. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  86513. if (this.animations) {
  86514. for (var i = 0; i < this.animations.length; i++) {
  86515. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  86516. }
  86517. }
  86518. if (fullDetails) {
  86519. if (this._geometry) {
  86520. var ib = this.getIndices();
  86521. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86522. if (vb && ib) {
  86523. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  86524. }
  86525. }
  86526. else {
  86527. ret += ", flat shading: UNKNOWN";
  86528. }
  86529. }
  86530. return ret;
  86531. };
  86532. /** @hidden */
  86533. Mesh.prototype._unBindEffect = function () {
  86534. _super.prototype._unBindEffect.call(this);
  86535. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  86536. var instance = _a[_i];
  86537. instance._unBindEffect();
  86538. }
  86539. };
  86540. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  86541. /**
  86542. * Gets a boolean indicating if this mesh has LOD
  86543. */
  86544. get: function () {
  86545. return this._LODLevels.length > 0;
  86546. },
  86547. enumerable: true,
  86548. configurable: true
  86549. });
  86550. /**
  86551. * Gets the list of MeshLODLevel associated with the current mesh
  86552. * @returns an array of MeshLODLevel
  86553. */
  86554. Mesh.prototype.getLODLevels = function () {
  86555. return this._LODLevels;
  86556. };
  86557. Mesh.prototype._sortLODLevels = function () {
  86558. this._LODLevels.sort(function (a, b) {
  86559. if (a.distance < b.distance) {
  86560. return 1;
  86561. }
  86562. if (a.distance > b.distance) {
  86563. return -1;
  86564. }
  86565. return 0;
  86566. });
  86567. };
  86568. /**
  86569. * Add a mesh as LOD level triggered at the given distance.
  86570. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86571. * @param distance The distance from the center of the object to show this level
  86572. * @param mesh The mesh to be added as LOD level (can be null)
  86573. * @return This mesh (for chaining)
  86574. */
  86575. Mesh.prototype.addLODLevel = function (distance, mesh) {
  86576. if (mesh && mesh._masterMesh) {
  86577. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  86578. return this;
  86579. }
  86580. var level = new MeshLODLevel(distance, mesh);
  86581. this._LODLevels.push(level);
  86582. if (mesh) {
  86583. mesh._masterMesh = this;
  86584. }
  86585. this._sortLODLevels();
  86586. return this;
  86587. };
  86588. /**
  86589. * Returns the LOD level mesh at the passed distance or null if not found.
  86590. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86591. * @param distance The distance from the center of the object to show this level
  86592. * @returns a Mesh or `null`
  86593. */
  86594. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  86595. for (var index = 0; index < this._LODLevels.length; index++) {
  86596. var level = this._LODLevels[index];
  86597. if (level.distance === distance) {
  86598. return level.mesh;
  86599. }
  86600. }
  86601. return null;
  86602. };
  86603. /**
  86604. * Remove a mesh from the LOD array
  86605. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86606. * @param mesh defines the mesh to be removed
  86607. * @return This mesh (for chaining)
  86608. */
  86609. Mesh.prototype.removeLODLevel = function (mesh) {
  86610. for (var index = 0; index < this._LODLevels.length; index++) {
  86611. if (this._LODLevels[index].mesh === mesh) {
  86612. this._LODLevels.splice(index, 1);
  86613. if (mesh) {
  86614. mesh._masterMesh = null;
  86615. }
  86616. }
  86617. }
  86618. this._sortLODLevels();
  86619. return this;
  86620. };
  86621. /**
  86622. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  86623. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86624. * @param camera defines the camera to use to compute distance
  86625. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  86626. * @return This mesh (for chaining)
  86627. */
  86628. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  86629. if (!this._LODLevels || this._LODLevels.length === 0) {
  86630. return this;
  86631. }
  86632. var bSphere;
  86633. if (boundingSphere) {
  86634. bSphere = boundingSphere;
  86635. }
  86636. else {
  86637. var boundingInfo = this.getBoundingInfo();
  86638. bSphere = boundingInfo.boundingSphere;
  86639. }
  86640. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  86641. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  86642. if (this.onLODLevelSelection) {
  86643. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  86644. }
  86645. return this;
  86646. }
  86647. for (var index = 0; index < this._LODLevels.length; index++) {
  86648. var level = this._LODLevels[index];
  86649. if (level.distance < distanceToCamera) {
  86650. if (level.mesh) {
  86651. level.mesh._preActivate();
  86652. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  86653. }
  86654. if (this.onLODLevelSelection) {
  86655. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  86656. }
  86657. return level.mesh;
  86658. }
  86659. }
  86660. if (this.onLODLevelSelection) {
  86661. this.onLODLevelSelection(distanceToCamera, this, this);
  86662. }
  86663. return this;
  86664. };
  86665. Object.defineProperty(Mesh.prototype, "geometry", {
  86666. /**
  86667. * Gets the mesh internal Geometry object
  86668. */
  86669. get: function () {
  86670. return this._geometry;
  86671. },
  86672. enumerable: true,
  86673. configurable: true
  86674. });
  86675. /**
  86676. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  86677. * @returns the total number of vertices
  86678. */
  86679. Mesh.prototype.getTotalVertices = function () {
  86680. if (this._geometry === null || this._geometry === undefined) {
  86681. return 0;
  86682. }
  86683. return this._geometry.getTotalVertices();
  86684. };
  86685. /**
  86686. * Returns the content of an associated vertex buffer
  86687. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86688. * - VertexBuffer.PositionKind
  86689. * - VertexBuffer.UVKind
  86690. * - VertexBuffer.UV2Kind
  86691. * - VertexBuffer.UV3Kind
  86692. * - VertexBuffer.UV4Kind
  86693. * - VertexBuffer.UV5Kind
  86694. * - VertexBuffer.UV6Kind
  86695. * - VertexBuffer.ColorKind
  86696. * - VertexBuffer.MatricesIndicesKind
  86697. * - VertexBuffer.MatricesIndicesExtraKind
  86698. * - VertexBuffer.MatricesWeightsKind
  86699. * - VertexBuffer.MatricesWeightsExtraKind
  86700. * @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
  86701. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  86702. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  86703. */
  86704. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  86705. if (!this._geometry) {
  86706. return null;
  86707. }
  86708. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  86709. };
  86710. /**
  86711. * Returns the mesh VertexBuffer object from the requested `kind`
  86712. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86713. * - VertexBuffer.PositionKind
  86714. * - VertexBuffer.UVKind
  86715. * - VertexBuffer.UV2Kind
  86716. * - VertexBuffer.UV3Kind
  86717. * - VertexBuffer.UV4Kind
  86718. * - VertexBuffer.UV5Kind
  86719. * - VertexBuffer.UV6Kind
  86720. * - VertexBuffer.ColorKind
  86721. * - VertexBuffer.MatricesIndicesKind
  86722. * - VertexBuffer.MatricesIndicesExtraKind
  86723. * - VertexBuffer.MatricesWeightsKind
  86724. * - VertexBuffer.MatricesWeightsExtraKind
  86725. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  86726. */
  86727. Mesh.prototype.getVertexBuffer = function (kind) {
  86728. if (!this._geometry) {
  86729. return null;
  86730. }
  86731. return this._geometry.getVertexBuffer(kind);
  86732. };
  86733. /**
  86734. * Tests if a specific vertex buffer is associated with this mesh
  86735. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  86736. * - VertexBuffer.PositionKind
  86737. * - VertexBuffer.UVKind
  86738. * - VertexBuffer.UV2Kind
  86739. * - VertexBuffer.UV3Kind
  86740. * - VertexBuffer.UV4Kind
  86741. * - VertexBuffer.UV5Kind
  86742. * - VertexBuffer.UV6Kind
  86743. * - VertexBuffer.ColorKind
  86744. * - VertexBuffer.MatricesIndicesKind
  86745. * - VertexBuffer.MatricesIndicesExtraKind
  86746. * - VertexBuffer.MatricesWeightsKind
  86747. * - VertexBuffer.MatricesWeightsExtraKind
  86748. * @returns a boolean
  86749. */
  86750. Mesh.prototype.isVerticesDataPresent = function (kind) {
  86751. if (!this._geometry) {
  86752. if (this._delayInfo) {
  86753. return this._delayInfo.indexOf(kind) !== -1;
  86754. }
  86755. return false;
  86756. }
  86757. return this._geometry.isVerticesDataPresent(kind);
  86758. };
  86759. /**
  86760. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  86761. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  86762. * - VertexBuffer.PositionKind
  86763. * - VertexBuffer.UVKind
  86764. * - VertexBuffer.UV2Kind
  86765. * - VertexBuffer.UV3Kind
  86766. * - VertexBuffer.UV4Kind
  86767. * - VertexBuffer.UV5Kind
  86768. * - VertexBuffer.UV6Kind
  86769. * - VertexBuffer.ColorKind
  86770. * - VertexBuffer.MatricesIndicesKind
  86771. * - VertexBuffer.MatricesIndicesExtraKind
  86772. * - VertexBuffer.MatricesWeightsKind
  86773. * - VertexBuffer.MatricesWeightsExtraKind
  86774. * @returns a boolean
  86775. */
  86776. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  86777. if (!this._geometry) {
  86778. if (this._delayInfo) {
  86779. return this._delayInfo.indexOf(kind) !== -1;
  86780. }
  86781. return false;
  86782. }
  86783. return this._geometry.isVertexBufferUpdatable(kind);
  86784. };
  86785. /**
  86786. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  86787. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86788. * - VertexBuffer.PositionKind
  86789. * - VertexBuffer.UVKind
  86790. * - VertexBuffer.UV2Kind
  86791. * - VertexBuffer.UV3Kind
  86792. * - VertexBuffer.UV4Kind
  86793. * - VertexBuffer.UV5Kind
  86794. * - VertexBuffer.UV6Kind
  86795. * - VertexBuffer.ColorKind
  86796. * - VertexBuffer.MatricesIndicesKind
  86797. * - VertexBuffer.MatricesIndicesExtraKind
  86798. * - VertexBuffer.MatricesWeightsKind
  86799. * - VertexBuffer.MatricesWeightsExtraKind
  86800. * @returns an array of strings
  86801. */
  86802. Mesh.prototype.getVerticesDataKinds = function () {
  86803. if (!this._geometry) {
  86804. var result = new Array();
  86805. if (this._delayInfo) {
  86806. this._delayInfo.forEach(function (kind) {
  86807. result.push(kind);
  86808. });
  86809. }
  86810. return result;
  86811. }
  86812. return this._geometry.getVerticesDataKinds();
  86813. };
  86814. /**
  86815. * Returns a positive integer : the total number of indices in this mesh geometry.
  86816. * @returns the numner of indices or zero if the mesh has no geometry.
  86817. */
  86818. Mesh.prototype.getTotalIndices = function () {
  86819. if (!this._geometry) {
  86820. return 0;
  86821. }
  86822. return this._geometry.getTotalIndices();
  86823. };
  86824. /**
  86825. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86826. * @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.
  86827. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86828. * @returns the indices array or an empty array if the mesh has no geometry
  86829. */
  86830. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  86831. if (!this._geometry) {
  86832. return [];
  86833. }
  86834. return this._geometry.getIndices(copyWhenShared, forceCopy);
  86835. };
  86836. Object.defineProperty(Mesh.prototype, "isBlocked", {
  86837. get: function () {
  86838. return this._masterMesh !== null && this._masterMesh !== undefined;
  86839. },
  86840. enumerable: true,
  86841. configurable: true
  86842. });
  86843. /**
  86844. * Determine if the current mesh is ready to be rendered
  86845. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86846. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  86847. * @returns true if all associated assets are ready (material, textures, shaders)
  86848. */
  86849. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  86850. if (completeCheck === void 0) { completeCheck = false; }
  86851. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  86852. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  86853. return false;
  86854. }
  86855. if (!_super.prototype.isReady.call(this, completeCheck)) {
  86856. return false;
  86857. }
  86858. if (!this.subMeshes || this.subMeshes.length === 0) {
  86859. return true;
  86860. }
  86861. if (!completeCheck) {
  86862. return true;
  86863. }
  86864. var engine = this.getEngine();
  86865. var scene = this.getScene();
  86866. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  86867. this.computeWorldMatrix();
  86868. var mat = this.material || scene.defaultMaterial;
  86869. if (mat) {
  86870. if (mat._storeEffectOnSubMeshes) {
  86871. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  86872. var subMesh = _a[_i];
  86873. var effectiveMaterial = subMesh.getMaterial();
  86874. if (effectiveMaterial) {
  86875. if (effectiveMaterial._storeEffectOnSubMeshes) {
  86876. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  86877. return false;
  86878. }
  86879. }
  86880. else {
  86881. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  86882. return false;
  86883. }
  86884. }
  86885. }
  86886. }
  86887. }
  86888. else {
  86889. if (!mat.isReady(this, hardwareInstancedRendering)) {
  86890. return false;
  86891. }
  86892. }
  86893. }
  86894. // Shadows
  86895. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  86896. var light = _c[_b];
  86897. var generator = light.getShadowGenerator();
  86898. if (generator) {
  86899. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  86900. var subMesh = _e[_d];
  86901. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  86902. return false;
  86903. }
  86904. }
  86905. }
  86906. }
  86907. // LOD
  86908. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  86909. var lod = _g[_f];
  86910. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  86911. return false;
  86912. }
  86913. }
  86914. return true;
  86915. };
  86916. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  86917. /**
  86918. * 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.
  86919. */
  86920. get: function () {
  86921. return this._areNormalsFrozen;
  86922. },
  86923. enumerable: true,
  86924. configurable: true
  86925. });
  86926. /**
  86927. * 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.
  86928. * @returns the current mesh
  86929. */
  86930. Mesh.prototype.freezeNormals = function () {
  86931. this._areNormalsFrozen = true;
  86932. return this;
  86933. };
  86934. /**
  86935. * 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
  86936. * @returns the current mesh
  86937. */
  86938. Mesh.prototype.unfreezeNormals = function () {
  86939. this._areNormalsFrozen = false;
  86940. return this;
  86941. };
  86942. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  86943. /**
  86944. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  86945. */
  86946. set: function (count) {
  86947. this._instanceDataStorage.overridenInstanceCount = count;
  86948. },
  86949. enumerable: true,
  86950. configurable: true
  86951. });
  86952. // Methods
  86953. /** @hidden */
  86954. Mesh.prototype._preActivate = function () {
  86955. var sceneRenderId = this.getScene().getRenderId();
  86956. if (this._preActivateId === sceneRenderId) {
  86957. return this;
  86958. }
  86959. this._preActivateId = sceneRenderId;
  86960. this._instanceDataStorage.visibleInstances = null;
  86961. return this;
  86962. };
  86963. /** @hidden */
  86964. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  86965. if (this._instanceDataStorage.visibleInstances) {
  86966. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  86967. }
  86968. return this;
  86969. };
  86970. /** @hidden */
  86971. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  86972. if (!this._instanceDataStorage.visibleInstances) {
  86973. this._instanceDataStorage.visibleInstances = {
  86974. defaultRenderId: renderId,
  86975. selfDefaultRenderId: this._renderId
  86976. };
  86977. }
  86978. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  86979. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  86980. }
  86981. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  86982. return this;
  86983. };
  86984. /**
  86985. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86986. * This means the mesh underlying bounding box and sphere are recomputed.
  86987. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86988. * @returns the current mesh
  86989. */
  86990. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  86991. if (applySkeleton === void 0) { applySkeleton = false; }
  86992. if (this._boundingInfo && this._boundingInfo.isLocked) {
  86993. return this;
  86994. }
  86995. var bias = this.geometry ? this.geometry.boundingBias : null;
  86996. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  86997. return this;
  86998. };
  86999. /** @hidden */
  87000. Mesh.prototype._createGlobalSubMesh = function (force) {
  87001. var totalVertices = this.getTotalVertices();
  87002. if (!totalVertices || !this.getIndices()) {
  87003. return null;
  87004. }
  87005. // Check if we need to recreate the submeshes
  87006. if (this.subMeshes && this.subMeshes.length > 0) {
  87007. var ib = this.getIndices();
  87008. if (!ib) {
  87009. return null;
  87010. }
  87011. var totalIndices = ib.length;
  87012. var needToRecreate = false;
  87013. if (force) {
  87014. needToRecreate = true;
  87015. }
  87016. else {
  87017. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  87018. var submesh = _a[_i];
  87019. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  87020. needToRecreate = true;
  87021. break;
  87022. }
  87023. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  87024. needToRecreate = true;
  87025. break;
  87026. }
  87027. }
  87028. }
  87029. if (!needToRecreate) {
  87030. return this.subMeshes[0];
  87031. }
  87032. }
  87033. this.releaseSubMeshes();
  87034. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  87035. };
  87036. /**
  87037. * This function will subdivide the mesh into multiple submeshes
  87038. * @param count defines the expected number of submeshes
  87039. */
  87040. Mesh.prototype.subdivide = function (count) {
  87041. if (count < 1) {
  87042. return;
  87043. }
  87044. var totalIndices = this.getTotalIndices();
  87045. var subdivisionSize = (totalIndices / count) | 0;
  87046. var offset = 0;
  87047. // Ensure that subdivisionSize is a multiple of 3
  87048. while (subdivisionSize % 3 !== 0) {
  87049. subdivisionSize++;
  87050. }
  87051. this.releaseSubMeshes();
  87052. for (var index = 0; index < count; index++) {
  87053. if (offset >= totalIndices) {
  87054. break;
  87055. }
  87056. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  87057. offset += subdivisionSize;
  87058. }
  87059. this.synchronizeInstances();
  87060. };
  87061. /**
  87062. * Copy a FloatArray into a specific associated vertex buffer
  87063. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87064. * - VertexBuffer.PositionKind
  87065. * - VertexBuffer.UVKind
  87066. * - VertexBuffer.UV2Kind
  87067. * - VertexBuffer.UV3Kind
  87068. * - VertexBuffer.UV4Kind
  87069. * - VertexBuffer.UV5Kind
  87070. * - VertexBuffer.UV6Kind
  87071. * - VertexBuffer.ColorKind
  87072. * - VertexBuffer.MatricesIndicesKind
  87073. * - VertexBuffer.MatricesIndicesExtraKind
  87074. * - VertexBuffer.MatricesWeightsKind
  87075. * - VertexBuffer.MatricesWeightsExtraKind
  87076. * @param data defines the data source
  87077. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87078. * @param stride defines the data stride size (can be null)
  87079. * @returns the current mesh
  87080. */
  87081. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  87082. if (updatable === void 0) { updatable = false; }
  87083. if (!this._geometry) {
  87084. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  87085. vertexData.set(data, kind);
  87086. var scene = this.getScene();
  87087. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  87088. }
  87089. else {
  87090. this._geometry.setVerticesData(kind, data, updatable, stride);
  87091. }
  87092. return this;
  87093. };
  87094. /**
  87095. * Flags an associated vertex buffer as updatable
  87096. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87097. * - VertexBuffer.PositionKind
  87098. * - VertexBuffer.UVKind
  87099. * - VertexBuffer.UV2Kind
  87100. * - VertexBuffer.UV3Kind
  87101. * - VertexBuffer.UV4Kind
  87102. * - VertexBuffer.UV5Kind
  87103. * - VertexBuffer.UV6Kind
  87104. * - VertexBuffer.ColorKind
  87105. * - VertexBuffer.MatricesIndicesKind
  87106. * - VertexBuffer.MatricesIndicesExtraKind
  87107. * - VertexBuffer.MatricesWeightsKind
  87108. * - VertexBuffer.MatricesWeightsExtraKind
  87109. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87110. */
  87111. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  87112. if (updatable === void 0) { updatable = true; }
  87113. var vb = this.getVertexBuffer(kind);
  87114. if (!vb || vb.isUpdatable() === updatable) {
  87115. return;
  87116. }
  87117. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  87118. };
  87119. /**
  87120. * Sets the mesh global Vertex Buffer
  87121. * @param buffer defines the buffer to use
  87122. * @returns the current mesh
  87123. */
  87124. Mesh.prototype.setVerticesBuffer = function (buffer) {
  87125. if (!this._geometry) {
  87126. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  87127. }
  87128. this._geometry.setVerticesBuffer(buffer);
  87129. return this;
  87130. };
  87131. /**
  87132. * Update a specific associated vertex buffer
  87133. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87134. * - VertexBuffer.PositionKind
  87135. * - VertexBuffer.UVKind
  87136. * - VertexBuffer.UV2Kind
  87137. * - VertexBuffer.UV3Kind
  87138. * - VertexBuffer.UV4Kind
  87139. * - VertexBuffer.UV5Kind
  87140. * - VertexBuffer.UV6Kind
  87141. * - VertexBuffer.ColorKind
  87142. * - VertexBuffer.MatricesIndicesKind
  87143. * - VertexBuffer.MatricesIndicesExtraKind
  87144. * - VertexBuffer.MatricesWeightsKind
  87145. * - VertexBuffer.MatricesWeightsExtraKind
  87146. * @param data defines the data source
  87147. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87148. * @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)
  87149. * @returns the current mesh
  87150. */
  87151. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  87152. if (!this._geometry) {
  87153. return this;
  87154. }
  87155. if (!makeItUnique) {
  87156. this._geometry.updateVerticesData(kind, data, updateExtends);
  87157. }
  87158. else {
  87159. this.makeGeometryUnique();
  87160. this.updateVerticesData(kind, data, updateExtends, false);
  87161. }
  87162. return this;
  87163. };
  87164. /**
  87165. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87166. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87167. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87168. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87169. * @returns the current mesh
  87170. */
  87171. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  87172. if (computeNormals === void 0) { computeNormals = true; }
  87173. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87174. if (!positions) {
  87175. return this;
  87176. }
  87177. positionFunction(positions);
  87178. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  87179. if (computeNormals) {
  87180. var indices = this.getIndices();
  87181. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87182. if (!normals) {
  87183. return this;
  87184. }
  87185. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  87186. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  87187. }
  87188. return this;
  87189. };
  87190. /**
  87191. * Creates a un-shared specific occurence of the geometry for the mesh.
  87192. * @returns the current mesh
  87193. */
  87194. Mesh.prototype.makeGeometryUnique = function () {
  87195. if (!this._geometry) {
  87196. return this;
  87197. }
  87198. var oldGeometry = this._geometry;
  87199. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  87200. oldGeometry.releaseForMesh(this, true);
  87201. geometry.applyToMesh(this);
  87202. return this;
  87203. };
  87204. /**
  87205. * Set the index buffer of this mesh
  87206. * @param indices defines the source data
  87207. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87208. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87209. * @returns the current mesh
  87210. */
  87211. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  87212. if (totalVertices === void 0) { totalVertices = null; }
  87213. if (updatable === void 0) { updatable = false; }
  87214. if (!this._geometry) {
  87215. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  87216. vertexData.indices = indices;
  87217. var scene = this.getScene();
  87218. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  87219. }
  87220. else {
  87221. this._geometry.setIndices(indices, totalVertices, updatable);
  87222. }
  87223. return this;
  87224. };
  87225. /**
  87226. * Update the current index buffer
  87227. * @param indices defines the source data
  87228. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87229. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  87230. * @returns the current mesh
  87231. */
  87232. Mesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  87233. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  87234. if (!this._geometry) {
  87235. return this;
  87236. }
  87237. this._geometry.updateIndices(indices, offset, gpuMemoryOnly);
  87238. return this;
  87239. };
  87240. /**
  87241. * Invert the geometry to move from a right handed system to a left handed one.
  87242. * @returns the current mesh
  87243. */
  87244. Mesh.prototype.toLeftHanded = function () {
  87245. if (!this._geometry) {
  87246. return this;
  87247. }
  87248. this._geometry.toLeftHanded();
  87249. return this;
  87250. };
  87251. /** @hidden */
  87252. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  87253. if (!this._geometry) {
  87254. return this;
  87255. }
  87256. var engine = this.getScene().getEngine();
  87257. // Wireframe
  87258. var indexToBind;
  87259. if (this._unIndexed) {
  87260. indexToBind = null;
  87261. }
  87262. else {
  87263. switch (fillMode) {
  87264. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  87265. indexToBind = null;
  87266. break;
  87267. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  87268. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  87269. break;
  87270. default:
  87271. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  87272. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  87273. break;
  87274. }
  87275. }
  87276. // VBOs
  87277. this._geometry._bind(effect, indexToBind);
  87278. return this;
  87279. };
  87280. /** @hidden */
  87281. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  87282. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  87283. return this;
  87284. }
  87285. if (this._onBeforeDrawObservable) {
  87286. this._onBeforeDrawObservable.notifyObservers(this);
  87287. }
  87288. var scene = this.getScene();
  87289. var engine = scene.getEngine();
  87290. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  87291. // or triangles as points
  87292. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  87293. }
  87294. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  87295. // Triangles as wireframe
  87296. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  87297. }
  87298. else {
  87299. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  87300. }
  87301. return this;
  87302. };
  87303. /**
  87304. * Registers for this mesh a javascript function called just before the rendering process
  87305. * @param func defines the function to call before rendering this mesh
  87306. * @returns the current mesh
  87307. */
  87308. Mesh.prototype.registerBeforeRender = function (func) {
  87309. this.onBeforeRenderObservable.add(func);
  87310. return this;
  87311. };
  87312. /**
  87313. * Disposes a previously registered javascript function called before the rendering
  87314. * @param func defines the function to remove
  87315. * @returns the current mesh
  87316. */
  87317. Mesh.prototype.unregisterBeforeRender = function (func) {
  87318. this.onBeforeRenderObservable.removeCallback(func);
  87319. return this;
  87320. };
  87321. /**
  87322. * Registers for this mesh a javascript function called just after the rendering is complete
  87323. * @param func defines the function to call after rendering this mesh
  87324. * @returns the current mesh
  87325. */
  87326. Mesh.prototype.registerAfterRender = function (func) {
  87327. this.onAfterRenderObservable.add(func);
  87328. return this;
  87329. };
  87330. /**
  87331. * Disposes a previously registered javascript function called after the rendering.
  87332. * @param func defines the function to remove
  87333. * @returns the current mesh
  87334. */
  87335. Mesh.prototype.unregisterAfterRender = function (func) {
  87336. this.onAfterRenderObservable.removeCallback(func);
  87337. return this;
  87338. };
  87339. /** @hidden */
  87340. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  87341. var scene = this.getScene();
  87342. var batchCache = this._instanceDataStorage.batchCache;
  87343. batchCache.mustReturn = false;
  87344. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  87345. batchCache.visibleInstances[subMeshId] = null;
  87346. if (this._instanceDataStorage.visibleInstances) {
  87347. var visibleInstances = this._instanceDataStorage.visibleInstances;
  87348. var currentRenderId = scene.getRenderId();
  87349. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  87350. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  87351. var selfRenderId = this._renderId;
  87352. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  87353. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  87354. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  87355. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  87356. }
  87357. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  87358. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  87359. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  87360. batchCache.mustReturn = true;
  87361. return batchCache;
  87362. }
  87363. if (currentRenderId !== selfRenderId) {
  87364. batchCache.renderSelf[subMeshId] = false;
  87365. }
  87366. }
  87367. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  87368. }
  87369. return batchCache;
  87370. };
  87371. /** @hidden */
  87372. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  87373. var visibleInstances = batch.visibleInstances[subMesh._id];
  87374. if (!visibleInstances) {
  87375. return this;
  87376. }
  87377. var matricesCount = visibleInstances.length + 1;
  87378. var bufferSize = matricesCount * 16 * 4;
  87379. var instanceStorage = this._instanceDataStorage;
  87380. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  87381. var instancesBuffer = instanceStorage.instancesBuffer;
  87382. while (instanceStorage.instancesBufferSize < bufferSize) {
  87383. instanceStorage.instancesBufferSize *= 2;
  87384. }
  87385. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  87386. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  87387. }
  87388. var offset = 0;
  87389. var instancesCount = 0;
  87390. var world = this._effectiveMesh.getWorldMatrix();
  87391. if (batch.renderSelf[subMesh._id]) {
  87392. world.copyToArray(instanceStorage.instancesData, offset);
  87393. offset += 16;
  87394. instancesCount++;
  87395. }
  87396. if (visibleInstances) {
  87397. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  87398. var instance = visibleInstances[instanceIndex];
  87399. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  87400. offset += 16;
  87401. instancesCount++;
  87402. }
  87403. }
  87404. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  87405. if (instancesBuffer) {
  87406. instancesBuffer.dispose();
  87407. }
  87408. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  87409. instanceStorage.instancesBuffer = instancesBuffer;
  87410. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  87411. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  87412. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  87413. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  87414. }
  87415. else {
  87416. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  87417. }
  87418. this._bind(subMesh, effect, fillMode);
  87419. this._draw(subMesh, fillMode, instancesCount);
  87420. engine.unbindInstanceAttributes();
  87421. return this;
  87422. };
  87423. /** @hidden */
  87424. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  87425. var scene = this.getScene();
  87426. var engine = scene.getEngine();
  87427. if (hardwareInstancedRendering) {
  87428. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  87429. }
  87430. else {
  87431. if (batch.renderSelf[subMesh._id]) {
  87432. // Draw
  87433. if (onBeforeDraw) {
  87434. onBeforeDraw(false, this._effectiveMesh.getWorldMatrix(), effectiveMaterial);
  87435. }
  87436. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  87437. }
  87438. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  87439. if (visibleInstancesForSubMesh) {
  87440. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  87441. var instance = visibleInstancesForSubMesh[instanceIndex];
  87442. // World
  87443. var world = instance.getWorldMatrix();
  87444. if (onBeforeDraw) {
  87445. onBeforeDraw(true, world, effectiveMaterial);
  87446. }
  87447. // Draw
  87448. this._draw(subMesh, fillMode);
  87449. }
  87450. }
  87451. }
  87452. return this;
  87453. };
  87454. /**
  87455. * 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
  87456. * @param subMesh defines the subMesh to render
  87457. * @param enableAlphaMode defines if alpha mode can be changed
  87458. * @returns the current mesh
  87459. */
  87460. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  87461. if (this._checkOcclusionQuery()) {
  87462. return this;
  87463. }
  87464. var scene = this.getScene();
  87465. // Managing instances
  87466. var batch = this._getInstancesRenderList(subMesh._id);
  87467. if (batch.mustReturn) {
  87468. return this;
  87469. }
  87470. // Checking geometry state
  87471. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  87472. return this;
  87473. }
  87474. if (this._onBeforeRenderObservable) {
  87475. this._onBeforeRenderObservable.notifyObservers(this);
  87476. }
  87477. var engine = scene.getEngine();
  87478. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  87479. // Material
  87480. var material = subMesh.getMaterial();
  87481. if (!material) {
  87482. return this;
  87483. }
  87484. this._effectiveMaterial = material;
  87485. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  87486. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  87487. return this;
  87488. }
  87489. }
  87490. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  87491. return this;
  87492. }
  87493. // Alpha mode
  87494. if (enableAlphaMode) {
  87495. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  87496. }
  87497. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  87498. var step = _a[_i];
  87499. step.action(this, subMesh, batch);
  87500. }
  87501. var effect;
  87502. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  87503. effect = subMesh.effect;
  87504. }
  87505. else {
  87506. effect = this._effectiveMaterial.getEffect();
  87507. }
  87508. if (!effect) {
  87509. return this;
  87510. }
  87511. var effectiveMesh = this._effectiveMesh;
  87512. var sideOrientation = this.overrideMaterialSideOrientation;
  87513. if (sideOrientation == null) {
  87514. sideOrientation = this._effectiveMaterial.sideOrientation;
  87515. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  87516. 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);
  87517. }
  87518. }
  87519. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  87520. if (this._effectiveMaterial.forceDepthWrite) {
  87521. engine.setDepthWrite(true);
  87522. }
  87523. // Bind
  87524. 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);
  87525. if (this._onBeforeBindObservable) {
  87526. this._onBeforeBindObservable.notifyObservers(this);
  87527. }
  87528. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  87529. this._bind(subMesh, effect, fillMode);
  87530. }
  87531. var world = effectiveMesh.getWorldMatrix();
  87532. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  87533. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  87534. }
  87535. else {
  87536. this._effectiveMaterial.bind(world, this);
  87537. }
  87538. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  87539. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  87540. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  87541. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  87542. }
  87543. // Draw
  87544. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  87545. // Unbind
  87546. this._effectiveMaterial.unbind();
  87547. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  87548. var step = _c[_b];
  87549. step.action(this, subMesh, batch);
  87550. }
  87551. if (this._onAfterRenderObservable) {
  87552. this._onAfterRenderObservable.notifyObservers(this);
  87553. }
  87554. return this;
  87555. };
  87556. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  87557. if (isInstance && effectiveMaterial) {
  87558. effectiveMaterial.bindOnlyWorldMatrix(world);
  87559. }
  87560. };
  87561. /**
  87562. * Renormalize the mesh and patch it up if there are no weights
  87563. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87564. * However in the case of zero weights then we set just a single influence to 1.
  87565. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87566. */
  87567. Mesh.prototype.cleanMatrixWeights = function () {
  87568. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  87569. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  87570. this.normalizeSkinWeightsAndExtra();
  87571. }
  87572. else {
  87573. this.normalizeSkinFourWeights();
  87574. }
  87575. }
  87576. };
  87577. // faster 4 weight version.
  87578. Mesh.prototype.normalizeSkinFourWeights = function () {
  87579. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87580. var numWeights = matricesWeights.length;
  87581. for (var a = 0; a < numWeights; a += 4) {
  87582. // accumulate weights
  87583. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  87584. // check for invalid weight and just set it to 1.
  87585. if (t === 0) {
  87586. matricesWeights[a] = 1;
  87587. }
  87588. else {
  87589. // renormalize so everything adds to 1 use reciprical
  87590. var recip = 1 / t;
  87591. matricesWeights[a] *= recip;
  87592. matricesWeights[a + 1] *= recip;
  87593. matricesWeights[a + 2] *= recip;
  87594. matricesWeights[a + 3] *= recip;
  87595. }
  87596. }
  87597. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  87598. };
  87599. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  87600. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  87601. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  87602. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87603. var numWeights = matricesWeights.length;
  87604. for (var a = 0; a < numWeights; a += 4) {
  87605. // accumulate weights
  87606. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  87607. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  87608. // check for invalid weight and just set it to 1.
  87609. if (t === 0) {
  87610. matricesWeights[a] = 1;
  87611. }
  87612. else {
  87613. // renormalize so everything adds to 1 use reciprical
  87614. var recip = 1 / t;
  87615. matricesWeights[a] *= recip;
  87616. matricesWeights[a + 1] *= recip;
  87617. matricesWeights[a + 2] *= recip;
  87618. matricesWeights[a + 3] *= recip;
  87619. // same goes for extras
  87620. matricesWeightsExtra[a] *= recip;
  87621. matricesWeightsExtra[a + 1] *= recip;
  87622. matricesWeightsExtra[a + 2] *= recip;
  87623. matricesWeightsExtra[a + 3] *= recip;
  87624. }
  87625. }
  87626. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  87627. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  87628. };
  87629. /**
  87630. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  87631. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  87632. * the user know there was an issue with importing the mesh
  87633. * @returns a validation object with skinned, valid and report string
  87634. */
  87635. Mesh.prototype.validateSkinning = function () {
  87636. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  87637. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87638. if (matricesWeights === null || this.skeleton == null) {
  87639. return { skinned: false, valid: true, report: "not skinned" };
  87640. }
  87641. var numWeights = matricesWeights.length;
  87642. var numberNotSorted = 0;
  87643. var missingWeights = 0;
  87644. var maxUsedWeights = 0;
  87645. var numberNotNormalized = 0;
  87646. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  87647. var usedWeightCounts = new Array();
  87648. for (var a = 0; a <= numInfluences; a++) {
  87649. usedWeightCounts[a] = 0;
  87650. }
  87651. var toleranceEpsilon = 0.001;
  87652. for (var a = 0; a < numWeights; a += 4) {
  87653. var lastWeight = matricesWeights[a];
  87654. var t = lastWeight;
  87655. var usedWeights = t === 0 ? 0 : 1;
  87656. for (var b = 1; b < numInfluences; b++) {
  87657. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  87658. if (d > lastWeight) {
  87659. numberNotSorted++;
  87660. }
  87661. if (d !== 0) {
  87662. usedWeights++;
  87663. }
  87664. t += d;
  87665. lastWeight = d;
  87666. }
  87667. // count the buffer weights usage
  87668. usedWeightCounts[usedWeights]++;
  87669. // max influences
  87670. if (usedWeights > maxUsedWeights) {
  87671. maxUsedWeights = usedWeights;
  87672. }
  87673. // check for invalid weight and just set it to 1.
  87674. if (t === 0) {
  87675. missingWeights++;
  87676. }
  87677. else {
  87678. // renormalize so everything adds to 1 use reciprical
  87679. var recip = 1 / t;
  87680. var tolerance = 0;
  87681. for (b = 0; b < numInfluences; b++) {
  87682. if (b < 4) {
  87683. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  87684. }
  87685. else {
  87686. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  87687. }
  87688. }
  87689. // arbitary epsilon value for dicdating not normalized
  87690. if (tolerance > toleranceEpsilon) {
  87691. numberNotNormalized++;
  87692. }
  87693. }
  87694. }
  87695. // validate bone indices are in range of the skeleton
  87696. var numBones = this.skeleton.bones.length;
  87697. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  87698. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  87699. var numBadBoneIndices = 0;
  87700. for (var a = 0; a < numWeights; a++) {
  87701. for (var b = 0; b < numInfluences; b++) {
  87702. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  87703. if (index >= numBones || index < 0) {
  87704. numBadBoneIndices++;
  87705. }
  87706. }
  87707. }
  87708. // log mesh stats
  87709. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  87710. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  87711. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  87712. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  87713. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  87714. };
  87715. /** @hidden */
  87716. Mesh.prototype._checkDelayState = function () {
  87717. var scene = this.getScene();
  87718. if (this._geometry) {
  87719. this._geometry.load(scene);
  87720. }
  87721. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  87722. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  87723. this._queueLoad(scene);
  87724. }
  87725. return this;
  87726. };
  87727. Mesh.prototype._queueLoad = function (scene) {
  87728. var _this = this;
  87729. scene._addPendingData(this);
  87730. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  87731. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  87732. if (data instanceof ArrayBuffer) {
  87733. _this._delayLoadingFunction(data, _this);
  87734. }
  87735. else {
  87736. _this._delayLoadingFunction(JSON.parse(data), _this);
  87737. }
  87738. _this.instances.forEach(function (instance) {
  87739. instance._syncSubMeshes();
  87740. });
  87741. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  87742. scene._removePendingData(_this);
  87743. }, function () { }, scene.offlineProvider, getBinaryData);
  87744. return this;
  87745. };
  87746. /**
  87747. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87748. * A mesh is in the frustum if its bounding box intersects the frustum
  87749. * @param frustumPlanes defines the frustum to test
  87750. * @returns true if the mesh is in the frustum planes
  87751. */
  87752. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  87753. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  87754. return false;
  87755. }
  87756. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  87757. return false;
  87758. }
  87759. this._checkDelayState();
  87760. return true;
  87761. };
  87762. /**
  87763. * Sets the mesh material by the material or multiMaterial `id` property
  87764. * @param id is a string identifying the material or the multiMaterial
  87765. * @returns the current mesh
  87766. */
  87767. Mesh.prototype.setMaterialByID = function (id) {
  87768. var materials = this.getScene().materials;
  87769. var index;
  87770. for (index = materials.length - 1; index > -1; index--) {
  87771. if (materials[index].id === id) {
  87772. this.material = materials[index];
  87773. return this;
  87774. }
  87775. }
  87776. // Multi
  87777. var multiMaterials = this.getScene().multiMaterials;
  87778. for (index = multiMaterials.length - 1; index > -1; index--) {
  87779. if (multiMaterials[index].id === id) {
  87780. this.material = multiMaterials[index];
  87781. return this;
  87782. }
  87783. }
  87784. return this;
  87785. };
  87786. /**
  87787. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  87788. * @returns an array of IAnimatable
  87789. */
  87790. Mesh.prototype.getAnimatables = function () {
  87791. var results = new Array();
  87792. if (this.material) {
  87793. results.push(this.material);
  87794. }
  87795. if (this.skeleton) {
  87796. results.push(this.skeleton);
  87797. }
  87798. return results;
  87799. };
  87800. /**
  87801. * Modifies the mesh geometry according to the passed transformation matrix.
  87802. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  87803. * The mesh normals are modified using the same transformation.
  87804. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87805. * @param transform defines the transform matrix to use
  87806. * @see http://doc.babylonjs.com/resources/baking_transformations
  87807. * @returns the current mesh
  87808. */
  87809. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  87810. // Position
  87811. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  87812. return this;
  87813. }
  87814. var submeshes = this.subMeshes.splice(0);
  87815. this._resetPointsArrayCache();
  87816. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87817. var temp = new Array();
  87818. var index;
  87819. for (index = 0; index < data.length; index += 3) {
  87820. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  87821. }
  87822. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  87823. // Normals
  87824. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  87825. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87826. temp = [];
  87827. for (index = 0; index < data.length; index += 3) {
  87828. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  87829. }
  87830. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  87831. }
  87832. // flip faces?
  87833. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  87834. this.flipFaces();
  87835. }
  87836. // Restore submeshes
  87837. this.releaseSubMeshes();
  87838. this.subMeshes = submeshes;
  87839. return this;
  87840. };
  87841. /**
  87842. * Modifies the mesh geometry according to its own current World Matrix.
  87843. * The mesh World Matrix is then reset.
  87844. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  87845. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87846. * @see http://doc.babylonjs.com/resources/baking_transformations
  87847. * @returns the current mesh
  87848. */
  87849. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  87850. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  87851. this.scaling.copyFromFloats(1, 1, 1);
  87852. this.position.copyFromFloats(0, 0, 0);
  87853. this.rotation.copyFromFloats(0, 0, 0);
  87854. //only if quaternion is already set
  87855. if (this.rotationQuaternion) {
  87856. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  87857. }
  87858. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  87859. return this;
  87860. };
  87861. Object.defineProperty(Mesh.prototype, "_positions", {
  87862. // Cache
  87863. /** @hidden */
  87864. get: function () {
  87865. if (this._geometry) {
  87866. return this._geometry._positions;
  87867. }
  87868. return null;
  87869. },
  87870. enumerable: true,
  87871. configurable: true
  87872. });
  87873. /** @hidden */
  87874. Mesh.prototype._resetPointsArrayCache = function () {
  87875. if (this._geometry) {
  87876. this._geometry._resetPointsArrayCache();
  87877. }
  87878. return this;
  87879. };
  87880. /** @hidden */
  87881. Mesh.prototype._generatePointsArray = function () {
  87882. if (this._geometry) {
  87883. return this._geometry._generatePointsArray();
  87884. }
  87885. return false;
  87886. };
  87887. /**
  87888. * Returns a new Mesh object generated from the current mesh properties.
  87889. * This method must not get confused with createInstance()
  87890. * @param name is a string, the name given to the new mesh
  87891. * @param newParent can be any Node object (default `null`)
  87892. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87893. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87894. * @returns a new mesh
  87895. */
  87896. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  87897. if (name === void 0) { name = ""; }
  87898. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  87899. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  87900. };
  87901. /**
  87902. * Releases resources associated with this mesh.
  87903. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87904. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87905. */
  87906. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  87907. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  87908. this.morphTargetManager = null;
  87909. if (this._geometry) {
  87910. this._geometry.releaseForMesh(this, true);
  87911. }
  87912. if (this._onBeforeDrawObservable) {
  87913. this._onBeforeDrawObservable.clear();
  87914. }
  87915. if (this._onBeforeBindObservable) {
  87916. this._onBeforeBindObservable.clear();
  87917. }
  87918. if (this._onBeforeRenderObservable) {
  87919. this._onBeforeRenderObservable.clear();
  87920. }
  87921. if (this._onAfterRenderObservable) {
  87922. this._onAfterRenderObservable.clear();
  87923. }
  87924. // Sources
  87925. if (this._scene.useClonedMeshhMap) {
  87926. if (this.meshMap) {
  87927. for (var uniqueId in this.meshMap) {
  87928. var mesh = this.meshMap[uniqueId];
  87929. if (mesh) {
  87930. mesh._source = null;
  87931. this.meshMap[uniqueId] = undefined;
  87932. }
  87933. }
  87934. }
  87935. if (this._source && this._source.meshMap) {
  87936. this._source.meshMap[this.uniqueId] = undefined;
  87937. }
  87938. }
  87939. else {
  87940. var meshes = this.getScene().meshes;
  87941. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  87942. var abstractMesh = meshes_1[_i];
  87943. var mesh = abstractMesh;
  87944. if (mesh._source && mesh._source === this) {
  87945. mesh._source = null;
  87946. }
  87947. }
  87948. }
  87949. this._source = null;
  87950. // Instances
  87951. if (this._instanceDataStorage.instancesBuffer) {
  87952. this._instanceDataStorage.instancesBuffer.dispose();
  87953. this._instanceDataStorage.instancesBuffer = null;
  87954. }
  87955. while (this.instances.length) {
  87956. this.instances[0].dispose();
  87957. }
  87958. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  87959. };
  87960. /**
  87961. * Modifies the mesh geometry according to a displacement map.
  87962. * 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.
  87963. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87964. * @param url is a string, the URL from the image file is to be downloaded.
  87965. * @param minHeight is the lower limit of the displacement.
  87966. * @param maxHeight is the upper limit of the displacement.
  87967. * @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.
  87968. * @param uvOffset is an optional vector2 used to offset UV.
  87969. * @param uvScale is an optional vector2 used to scale UV.
  87970. * @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.
  87971. * @returns the Mesh.
  87972. */
  87973. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  87974. var _this = this;
  87975. if (forceUpdate === void 0) { forceUpdate = false; }
  87976. var scene = this.getScene();
  87977. var onload = function (img) {
  87978. // Getting height map data
  87979. var canvas = document.createElement("canvas");
  87980. var context = canvas.getContext("2d");
  87981. var heightMapWidth = img.width;
  87982. var heightMapHeight = img.height;
  87983. canvas.width = heightMapWidth;
  87984. canvas.height = heightMapHeight;
  87985. context.drawImage(img, 0, 0);
  87986. // Create VertexData from map data
  87987. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  87988. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  87989. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  87990. //execute success callback, if set
  87991. if (onSuccess) {
  87992. onSuccess(_this);
  87993. }
  87994. };
  87995. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  87996. return this;
  87997. };
  87998. /**
  87999. * Modifies the mesh geometry according to a displacementMap buffer.
  88000. * 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.
  88001. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88002. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88003. * @param heightMapWidth is the width of the buffer image.
  88004. * @param heightMapHeight is the height of the buffer image.
  88005. * @param minHeight is the lower limit of the displacement.
  88006. * @param maxHeight is the upper limit of the displacement.
  88007. * @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.
  88008. * @param uvOffset is an optional vector2 used to offset UV.
  88009. * @param uvScale is an optional vector2 used to scale UV.
  88010. * @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.
  88011. * @returns the Mesh.
  88012. */
  88013. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  88014. if (forceUpdate === void 0) { forceUpdate = false; }
  88015. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  88016. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  88017. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  88018. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  88019. return this;
  88020. }
  88021. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  88022. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88023. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  88024. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  88025. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  88026. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  88027. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  88028. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  88029. for (var index = 0; index < positions.length; index += 3) {
  88030. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  88031. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  88032. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  88033. // Compute height
  88034. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  88035. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  88036. var pos = (u + v * heightMapWidth) * 4;
  88037. var r = buffer[pos] / 255.0;
  88038. var g = buffer[pos + 1] / 255.0;
  88039. var b = buffer[pos + 2] / 255.0;
  88040. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  88041. normal.normalize();
  88042. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  88043. position = position.add(normal);
  88044. position.toArray(positions, index);
  88045. }
  88046. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  88047. if (forceUpdate) {
  88048. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  88049. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  88050. }
  88051. else {
  88052. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  88053. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  88054. }
  88055. return this;
  88056. };
  88057. /**
  88058. * Modify the mesh to get a flat shading rendering.
  88059. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88060. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88061. * @returns current mesh
  88062. */
  88063. Mesh.prototype.convertToFlatShadedMesh = function () {
  88064. var kinds = this.getVerticesDataKinds();
  88065. var vbs = {};
  88066. var data = {};
  88067. var newdata = {};
  88068. var updatableNormals = false;
  88069. var kindIndex;
  88070. var kind;
  88071. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88072. kind = kinds[kindIndex];
  88073. var vertexBuffer = this.getVertexBuffer(kind);
  88074. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  88075. updatableNormals = vertexBuffer.isUpdatable();
  88076. kinds.splice(kindIndex, 1);
  88077. kindIndex--;
  88078. continue;
  88079. }
  88080. vbs[kind] = vertexBuffer;
  88081. data[kind] = vbs[kind].getData();
  88082. newdata[kind] = [];
  88083. }
  88084. // Save previous submeshes
  88085. var previousSubmeshes = this.subMeshes.slice(0);
  88086. var indices = this.getIndices();
  88087. var totalIndices = this.getTotalIndices();
  88088. // Generating unique vertices per face
  88089. var index;
  88090. for (index = 0; index < totalIndices; index++) {
  88091. var vertexIndex = indices[index];
  88092. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88093. kind = kinds[kindIndex];
  88094. var stride = vbs[kind].getStrideSize();
  88095. for (var offset = 0; offset < stride; offset++) {
  88096. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  88097. }
  88098. }
  88099. }
  88100. // Updating faces & normal
  88101. var normals = [];
  88102. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  88103. for (index = 0; index < totalIndices; index += 3) {
  88104. indices[index] = index;
  88105. indices[index + 1] = index + 1;
  88106. indices[index + 2] = index + 2;
  88107. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  88108. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  88109. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  88110. var p1p2 = p1.subtract(p2);
  88111. var p3p2 = p3.subtract(p2);
  88112. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  88113. // Store same normals for every vertex
  88114. for (var localIndex = 0; localIndex < 3; localIndex++) {
  88115. normals.push(normal.x);
  88116. normals.push(normal.y);
  88117. normals.push(normal.z);
  88118. }
  88119. }
  88120. this.setIndices(indices);
  88121. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  88122. // Updating vertex buffers
  88123. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88124. kind = kinds[kindIndex];
  88125. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  88126. }
  88127. // Updating submeshes
  88128. this.releaseSubMeshes();
  88129. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  88130. var previousOne = previousSubmeshes[submeshIndex];
  88131. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  88132. }
  88133. this.synchronizeInstances();
  88134. return this;
  88135. };
  88136. /**
  88137. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88138. * In other words, more vertices, no more indices and a single bigger VBO.
  88139. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88140. * @returns current mesh
  88141. */
  88142. Mesh.prototype.convertToUnIndexedMesh = function () {
  88143. var kinds = this.getVerticesDataKinds();
  88144. var vbs = {};
  88145. var data = {};
  88146. var newdata = {};
  88147. var kindIndex;
  88148. var kind;
  88149. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88150. kind = kinds[kindIndex];
  88151. var vertexBuffer = this.getVertexBuffer(kind);
  88152. vbs[kind] = vertexBuffer;
  88153. data[kind] = vbs[kind].getData();
  88154. newdata[kind] = [];
  88155. }
  88156. // Save previous submeshes
  88157. var previousSubmeshes = this.subMeshes.slice(0);
  88158. var indices = this.getIndices();
  88159. var totalIndices = this.getTotalIndices();
  88160. // Generating unique vertices per face
  88161. var index;
  88162. for (index = 0; index < totalIndices; index++) {
  88163. var vertexIndex = indices[index];
  88164. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88165. kind = kinds[kindIndex];
  88166. var stride = vbs[kind].getStrideSize();
  88167. for (var offset = 0; offset < stride; offset++) {
  88168. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  88169. }
  88170. }
  88171. }
  88172. // Updating indices
  88173. for (index = 0; index < totalIndices; index += 3) {
  88174. indices[index] = index;
  88175. indices[index + 1] = index + 1;
  88176. indices[index + 2] = index + 2;
  88177. }
  88178. this.setIndices(indices);
  88179. // Updating vertex buffers
  88180. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88181. kind = kinds[kindIndex];
  88182. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  88183. }
  88184. // Updating submeshes
  88185. this.releaseSubMeshes();
  88186. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  88187. var previousOne = previousSubmeshes[submeshIndex];
  88188. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  88189. }
  88190. this._unIndexed = true;
  88191. this.synchronizeInstances();
  88192. return this;
  88193. };
  88194. /**
  88195. * Inverses facet orientations.
  88196. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88197. * @param flipNormals will also inverts the normals
  88198. * @returns current mesh
  88199. */
  88200. Mesh.prototype.flipFaces = function (flipNormals) {
  88201. if (flipNormals === void 0) { flipNormals = false; }
  88202. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  88203. var i;
  88204. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  88205. for (i = 0; i < vertex_data.normals.length; i++) {
  88206. vertex_data.normals[i] *= -1;
  88207. }
  88208. }
  88209. if (vertex_data.indices) {
  88210. var temp;
  88211. for (i = 0; i < vertex_data.indices.length; i += 3) {
  88212. // reassign indices
  88213. temp = vertex_data.indices[i + 1];
  88214. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  88215. vertex_data.indices[i + 2] = temp;
  88216. }
  88217. }
  88218. vertex_data.applyToMesh(this);
  88219. return this;
  88220. };
  88221. /**
  88222. * Increase the number of facets and hence vertices in a mesh
  88223. * Vertex normals are interpolated from existing vertex normals
  88224. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88225. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88226. */
  88227. Mesh.prototype.increaseVertices = function (numberPerEdge) {
  88228. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  88229. var uvs = vertex_data.uvs;
  88230. var currentIndices = vertex_data.indices;
  88231. var positions = vertex_data.positions;
  88232. var normals = vertex_data.normals;
  88233. if (currentIndices === null || positions === null || normals === null || uvs === null) {
  88234. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  88235. }
  88236. else {
  88237. var segments = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
  88238. var tempIndices = new Array();
  88239. for (var i = 0; i < segments + 1; i++) {
  88240. tempIndices[i] = new Array();
  88241. }
  88242. var a; //vertex index of one end of a side
  88243. var b; //vertex index of other end of the side
  88244. var deltaPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  88245. var deltaNormal = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  88246. var deltaUV = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 0);
  88247. var indices = new Array();
  88248. var vertexIndex = new Array();
  88249. var side = new Array();
  88250. var len;
  88251. var positionPtr = positions.length;
  88252. var uvPtr = uvs.length;
  88253. for (var i = 0; i < currentIndices.length; i += 3) {
  88254. vertexIndex[0] = currentIndices[i];
  88255. vertexIndex[1] = currentIndices[i + 1];
  88256. vertexIndex[2] = currentIndices[i + 2];
  88257. for (var j = 0; j < 3; j++) {
  88258. a = vertexIndex[j];
  88259. b = vertexIndex[(j + 1) % 3];
  88260. if (side[a] === undefined && side[b] === undefined) {
  88261. side[a] = new Array();
  88262. side[b] = new Array();
  88263. }
  88264. else {
  88265. if (side[a] === undefined) {
  88266. side[a] = new Array();
  88267. }
  88268. if (side[b] === undefined) {
  88269. side[b] = new Array();
  88270. }
  88271. }
  88272. if (side[a][b] === undefined && side[b][a] === undefined) {
  88273. side[a][b] = [];
  88274. deltaPosition.x = (positions[3 * b] - positions[3 * a]) / segments;
  88275. deltaPosition.y = (positions[3 * b + 1] - positions[3 * a + 1]) / segments;
  88276. deltaPosition.z = (positions[3 * b + 2] - positions[3 * a + 2]) / segments;
  88277. deltaNormal.x = (normals[3 * b] - normals[3 * a]) / segments;
  88278. deltaNormal.y = (normals[3 * b + 1] - normals[3 * a + 1]) / segments;
  88279. deltaNormal.z = (normals[3 * b + 2] - normals[3 * a + 2]) / segments;
  88280. deltaUV.x = (uvs[2 * b] - uvs[2 * a]) / segments;
  88281. deltaUV.y = (uvs[2 * b + 1] - uvs[2 * a + 1]) / segments;
  88282. side[a][b].push(a);
  88283. for (var k = 1; k < segments; k++) {
  88284. side[a][b].push(positions.length / 3);
  88285. positions[positionPtr] = positions[3 * a] + k * deltaPosition.x;
  88286. normals[positionPtr++] = normals[3 * a] + k * deltaNormal.x;
  88287. positions[positionPtr] = positions[3 * a + 1] + k * deltaPosition.y;
  88288. normals[positionPtr++] = normals[3 * a + 1] + k * deltaNormal.y;
  88289. positions[positionPtr] = positions[3 * a + 2] + k * deltaPosition.z;
  88290. normals[positionPtr++] = normals[3 * a + 2] + k * deltaNormal.z;
  88291. uvs[uvPtr++] = uvs[2 * a] + k * deltaUV.x;
  88292. uvs[uvPtr++] = uvs[2 * a + 1] + k * deltaUV.y;
  88293. }
  88294. side[a][b].push(b);
  88295. side[b][a] = new Array();
  88296. len = side[a][b].length;
  88297. for (var idx = 0; idx < len; idx++) {
  88298. side[b][a][idx] = side[a][b][len - 1 - idx];
  88299. }
  88300. }
  88301. }
  88302. //Calculate positions, normals and uvs of new internal vertices
  88303. tempIndices[0][0] = currentIndices[i];
  88304. tempIndices[1][0] = side[currentIndices[i]][currentIndices[i + 1]][1];
  88305. tempIndices[1][1] = side[currentIndices[i]][currentIndices[i + 2]][1];
  88306. for (var k = 2; k < segments; k++) {
  88307. tempIndices[k][0] = side[currentIndices[i]][currentIndices[i + 1]][k];
  88308. tempIndices[k][k] = side[currentIndices[i]][currentIndices[i + 2]][k];
  88309. deltaPosition.x = (positions[3 * tempIndices[k][k]] - positions[3 * tempIndices[k][0]]) / k;
  88310. deltaPosition.y = (positions[3 * tempIndices[k][k] + 1] - positions[3 * tempIndices[k][0] + 1]) / k;
  88311. deltaPosition.z = (positions[3 * tempIndices[k][k] + 2] - positions[3 * tempIndices[k][0] + 2]) / k;
  88312. deltaNormal.x = (normals[3 * tempIndices[k][k]] - normals[3 * tempIndices[k][0]]) / k;
  88313. deltaNormal.y = (normals[3 * tempIndices[k][k] + 1] - normals[3 * tempIndices[k][0] + 1]) / k;
  88314. deltaNormal.z = (normals[3 * tempIndices[k][k] + 2] - normals[3 * tempIndices[k][0] + 2]) / k;
  88315. deltaUV.x = (uvs[2 * tempIndices[k][k]] - uvs[2 * tempIndices[k][0]]) / k;
  88316. deltaUV.y = (uvs[2 * tempIndices[k][k] + 1] - uvs[2 * tempIndices[k][0] + 1]) / k;
  88317. for (var j = 1; j < k; j++) {
  88318. tempIndices[k][j] = positions.length / 3;
  88319. positions[positionPtr] = positions[3 * tempIndices[k][0]] + j * deltaPosition.x;
  88320. normals[positionPtr++] = normals[3 * tempIndices[k][0]] + j * deltaNormal.x;
  88321. positions[positionPtr] = positions[3 * tempIndices[k][0] + 1] + j * deltaPosition.y;
  88322. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 1] + j * deltaNormal.y;
  88323. positions[positionPtr] = positions[3 * tempIndices[k][0] + 2] + j * deltaPosition.z;
  88324. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 2] + j * deltaNormal.z;
  88325. uvs[uvPtr++] = uvs[2 * tempIndices[k][0]] + j * deltaUV.x;
  88326. uvs[uvPtr++] = uvs[2 * tempIndices[k][0] + 1] + j * deltaUV.y;
  88327. }
  88328. }
  88329. tempIndices[segments] = side[currentIndices[i + 1]][currentIndices[i + 2]];
  88330. // reform indices
  88331. indices.push(tempIndices[0][0], tempIndices[1][0], tempIndices[1][1]);
  88332. for (var k = 1; k < segments; k++) {
  88333. for (var j = 0; j < k; j++) {
  88334. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  88335. indices.push(tempIndices[k][j], tempIndices[k + 1][j + 1], tempIndices[k][j + 1]);
  88336. }
  88337. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  88338. }
  88339. }
  88340. vertex_data.indices = indices;
  88341. vertex_data.applyToMesh(this);
  88342. }
  88343. };
  88344. /**
  88345. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88346. * This will undo any application of covertToFlatShadedMesh
  88347. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88348. */
  88349. Mesh.prototype.forceSharedVertices = function () {
  88350. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  88351. var currentUVs = vertex_data.uvs;
  88352. var currentIndices = vertex_data.indices;
  88353. var currentPositions = vertex_data.positions;
  88354. var currentNormals = vertex_data.normals;
  88355. if (currentIndices === null || currentPositions === null || currentNormals === null || currentUVs === null) {
  88356. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  88357. }
  88358. else {
  88359. var positions = new Array();
  88360. var indices = new Array();
  88361. var uvs = new Array();
  88362. var pstring = new Array(); //lists facet vertex positions (a,b,c) as string "a|b|c"
  88363. var indexPtr = 0; // pointer to next available index value
  88364. var uniquePositions = new Array(); // unique vertex positions
  88365. var ptr; // pointer to element in uniquePositions
  88366. var facet;
  88367. for (var i = 0; i < currentIndices.length; i += 3) {
  88368. facet = [currentIndices[i], currentIndices[i + 1], currentIndices[i + 2]]; //facet vertex indices
  88369. pstring = new Array();
  88370. for (var j = 0; j < 3; j++) {
  88371. pstring[j] = "";
  88372. for (var k = 0; k < 3; k++) {
  88373. //small values make 0
  88374. if (Math.abs(currentPositions[3 * facet[j] + k]) < 0.00000001) {
  88375. currentPositions[3 * facet[j] + k] = 0;
  88376. }
  88377. pstring[j] += currentPositions[3 * facet[j] + k] + "|";
  88378. }
  88379. pstring[j] = pstring[j].slice(0, -1);
  88380. }
  88381. //check facet vertices to see that none are repeated
  88382. // do not process any facet that has a repeated vertex, ie is a line
  88383. if (!(pstring[0] == pstring[1] || pstring[0] == pstring[2] || pstring[1] == pstring[2])) {
  88384. //for each facet position check if already listed in uniquePositions
  88385. // if not listed add to uniquePositions and set index pointer
  88386. // if listed use its index in uniquePositions and new index pointer
  88387. for (var j = 0; j < 3; j++) {
  88388. ptr = uniquePositions.indexOf(pstring[j]);
  88389. if (ptr < 0) {
  88390. uniquePositions.push(pstring[j]);
  88391. ptr = indexPtr++;
  88392. //not listed so add individual x, y, z coordinates to positions
  88393. for (var k = 0; k < 3; k++) {
  88394. positions.push(currentPositions[3 * facet[j] + k]);
  88395. }
  88396. for (var k = 0; k < 2; k++) {
  88397. uvs.push(currentUVs[2 * facet[j] + k]);
  88398. }
  88399. }
  88400. // add new index pointer to indices array
  88401. indices.push(ptr);
  88402. }
  88403. }
  88404. }
  88405. var normals = new Array();
  88406. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  88407. //create new vertex data object and update
  88408. vertex_data.positions = positions;
  88409. vertex_data.indices = indices;
  88410. vertex_data.normals = normals;
  88411. vertex_data.uvs = uvs;
  88412. vertex_data.applyToMesh(this);
  88413. }
  88414. };
  88415. // Instances
  88416. /** @hidden */
  88417. Mesh._instancedMeshFactory = function (name, mesh) {
  88418. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  88419. };
  88420. /** @hidden */
  88421. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  88422. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  88423. };
  88424. /**
  88425. * Creates a new InstancedMesh object from the mesh model.
  88426. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88427. * @param name defines the name of the new instance
  88428. * @returns a new InstancedMesh
  88429. */
  88430. Mesh.prototype.createInstance = function (name) {
  88431. return Mesh._instancedMeshFactory(name, this);
  88432. };
  88433. /**
  88434. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88435. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88436. * @returns the current mesh
  88437. */
  88438. Mesh.prototype.synchronizeInstances = function () {
  88439. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  88440. var instance = this.instances[instanceIndex];
  88441. instance._syncSubMeshes();
  88442. }
  88443. return this;
  88444. };
  88445. /**
  88446. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88447. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88448. * This should be used together with the simplification to avoid disappearing triangles.
  88449. * @param successCallback an optional success callback to be called after the optimization finished.
  88450. * @returns the current mesh
  88451. */
  88452. Mesh.prototype.optimizeIndices = function (successCallback) {
  88453. var _this = this;
  88454. var indices = this.getIndices();
  88455. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88456. if (!positions || !indices) {
  88457. return this;
  88458. }
  88459. var vectorPositions = new Array();
  88460. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  88461. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  88462. }
  88463. var dupes = new Array();
  88464. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  88465. var realPos = vectorPositions.length - 1 - iteration;
  88466. var testedPosition = vectorPositions[realPos];
  88467. for (var j = 0; j < realPos; ++j) {
  88468. var againstPosition = vectorPositions[j];
  88469. if (testedPosition.equals(againstPosition)) {
  88470. dupes[realPos] = j;
  88471. break;
  88472. }
  88473. }
  88474. }, function () {
  88475. for (var i = 0; i < indices.length; ++i) {
  88476. indices[i] = dupes[indices[i]] || indices[i];
  88477. }
  88478. //indices are now reordered
  88479. var originalSubMeshes = _this.subMeshes.slice(0);
  88480. _this.setIndices(indices);
  88481. _this.subMeshes = originalSubMeshes;
  88482. if (successCallback) {
  88483. successCallback(_this);
  88484. }
  88485. });
  88486. return this;
  88487. };
  88488. /**
  88489. * Serialize current mesh
  88490. * @param serializationObject defines the object which will receive the serialization data
  88491. */
  88492. Mesh.prototype.serialize = function (serializationObject) {
  88493. serializationObject.name = this.name;
  88494. serializationObject.id = this.id;
  88495. serializationObject.type = this.getClassName();
  88496. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  88497. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  88498. }
  88499. serializationObject.position = this.position.asArray();
  88500. if (this.rotationQuaternion) {
  88501. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  88502. }
  88503. else if (this.rotation) {
  88504. serializationObject.rotation = this.rotation.asArray();
  88505. }
  88506. serializationObject.scaling = this.scaling.asArray();
  88507. if (this._postMultiplyPivotMatrix) {
  88508. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  88509. }
  88510. else {
  88511. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  88512. }
  88513. serializationObject.isEnabled = this.isEnabled(false);
  88514. serializationObject.isVisible = this.isVisible;
  88515. serializationObject.infiniteDistance = this.infiniteDistance;
  88516. serializationObject.pickable = this.isPickable;
  88517. serializationObject.receiveShadows = this.receiveShadows;
  88518. serializationObject.billboardMode = this.billboardMode;
  88519. serializationObject.visibility = this.visibility;
  88520. serializationObject.checkCollisions = this.checkCollisions;
  88521. serializationObject.isBlocker = this.isBlocker;
  88522. // Parent
  88523. if (this.parent) {
  88524. serializationObject.parentId = this.parent.id;
  88525. }
  88526. // Geometry
  88527. serializationObject.isUnIndexed = this.isUnIndexed;
  88528. var geometry = this._geometry;
  88529. if (geometry) {
  88530. var geometryId = geometry.id;
  88531. serializationObject.geometryId = geometryId;
  88532. // SubMeshes
  88533. serializationObject.subMeshes = [];
  88534. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  88535. var subMesh = this.subMeshes[subIndex];
  88536. serializationObject.subMeshes.push({
  88537. materialIndex: subMesh.materialIndex,
  88538. verticesStart: subMesh.verticesStart,
  88539. verticesCount: subMesh.verticesCount,
  88540. indexStart: subMesh.indexStart,
  88541. indexCount: subMesh.indexCount
  88542. });
  88543. }
  88544. }
  88545. // Material
  88546. if (this.material) {
  88547. serializationObject.materialId = this.material.id;
  88548. }
  88549. else {
  88550. this.material = null;
  88551. }
  88552. // Morph targets
  88553. if (this.morphTargetManager) {
  88554. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  88555. }
  88556. // Skeleton
  88557. if (this.skeleton) {
  88558. serializationObject.skeletonId = this.skeleton.id;
  88559. }
  88560. // Physics
  88561. //TODO implement correct serialization for physics impostors.
  88562. var impostor = this.getPhysicsImpostor();
  88563. if (impostor) {
  88564. serializationObject.physicsMass = impostor.getParam("mass");
  88565. serializationObject.physicsFriction = impostor.getParam("friction");
  88566. serializationObject.physicsRestitution = impostor.getParam("mass");
  88567. serializationObject.physicsImpostor = impostor.type;
  88568. }
  88569. // Metadata
  88570. if (this.metadata) {
  88571. serializationObject.metadata = this.metadata;
  88572. }
  88573. // Instances
  88574. serializationObject.instances = [];
  88575. for (var index = 0; index < this.instances.length; index++) {
  88576. var instance = this.instances[index];
  88577. if (instance.doNotSerialize) {
  88578. continue;
  88579. }
  88580. var serializationInstance = {
  88581. name: instance.name,
  88582. id: instance.id,
  88583. position: instance.position.asArray(),
  88584. scaling: instance.scaling.asArray()
  88585. };
  88586. if (instance.parent) {
  88587. serializationInstance.parentId = instance.parent.id;
  88588. }
  88589. if (instance.rotationQuaternion) {
  88590. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  88591. }
  88592. else if (instance.rotation) {
  88593. serializationInstance.rotation = instance.rotation.asArray();
  88594. }
  88595. serializationObject.instances.push(serializationInstance);
  88596. // Animations
  88597. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  88598. serializationInstance.ranges = instance.serializeAnimationRanges();
  88599. }
  88600. //
  88601. // Animations
  88602. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  88603. serializationObject.ranges = this.serializeAnimationRanges();
  88604. // Layer mask
  88605. serializationObject.layerMask = this.layerMask;
  88606. // Alpha
  88607. serializationObject.alphaIndex = this.alphaIndex;
  88608. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  88609. // Overlay
  88610. serializationObject.overlayAlpha = this.overlayAlpha;
  88611. serializationObject.overlayColor = this.overlayColor.asArray();
  88612. serializationObject.renderOverlay = this.renderOverlay;
  88613. // Fog
  88614. serializationObject.applyFog = this.applyFog;
  88615. // Action Manager
  88616. if (this.actionManager) {
  88617. serializationObject.actions = this.actionManager.serialize(this.name);
  88618. }
  88619. };
  88620. /** @hidden */
  88621. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  88622. if (!this.geometry) {
  88623. return;
  88624. }
  88625. this._markSubMeshesAsAttributesDirty();
  88626. var morphTargetManager = this._morphTargetManager;
  88627. if (morphTargetManager && morphTargetManager.vertexCount) {
  88628. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  88629. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  88630. this.morphTargetManager = null;
  88631. return;
  88632. }
  88633. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  88634. var morphTarget = morphTargetManager.getActiveTarget(index);
  88635. var positions = morphTarget.getPositions();
  88636. if (!positions) {
  88637. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  88638. return;
  88639. }
  88640. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  88641. var normals = morphTarget.getNormals();
  88642. if (normals) {
  88643. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  88644. }
  88645. var tangents = morphTarget.getTangents();
  88646. if (tangents) {
  88647. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  88648. }
  88649. }
  88650. }
  88651. else {
  88652. var index = 0;
  88653. // Positions
  88654. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  88655. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  88656. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  88657. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  88658. }
  88659. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  88660. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  88661. }
  88662. index++;
  88663. }
  88664. }
  88665. };
  88666. /**
  88667. * Returns a new Mesh object parsed from the source provided.
  88668. * @param parsedMesh is the source
  88669. * @param scene defines the hosting scene
  88670. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88671. * @returns a new Mesh
  88672. */
  88673. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  88674. var mesh;
  88675. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  88676. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  88677. }
  88678. else {
  88679. mesh = new Mesh(parsedMesh.name, scene);
  88680. }
  88681. mesh.id = parsedMesh.id;
  88682. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  88683. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  88684. }
  88685. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  88686. if (parsedMesh.metadata !== undefined) {
  88687. mesh.metadata = parsedMesh.metadata;
  88688. }
  88689. if (parsedMesh.rotationQuaternion) {
  88690. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  88691. }
  88692. else if (parsedMesh.rotation) {
  88693. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  88694. }
  88695. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  88696. if (parsedMesh.localMatrix) {
  88697. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  88698. }
  88699. else if (parsedMesh.pivotMatrix) {
  88700. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  88701. }
  88702. mesh.setEnabled(parsedMesh.isEnabled);
  88703. mesh.isVisible = parsedMesh.isVisible;
  88704. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  88705. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  88706. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  88707. if (parsedMesh.applyFog !== undefined) {
  88708. mesh.applyFog = parsedMesh.applyFog;
  88709. }
  88710. if (parsedMesh.pickable !== undefined) {
  88711. mesh.isPickable = parsedMesh.pickable;
  88712. }
  88713. if (parsedMesh.alphaIndex !== undefined) {
  88714. mesh.alphaIndex = parsedMesh.alphaIndex;
  88715. }
  88716. mesh.receiveShadows = parsedMesh.receiveShadows;
  88717. mesh.billboardMode = parsedMesh.billboardMode;
  88718. if (parsedMesh.visibility !== undefined) {
  88719. mesh.visibility = parsedMesh.visibility;
  88720. }
  88721. mesh.checkCollisions = parsedMesh.checkCollisions;
  88722. if (parsedMesh.isBlocker !== undefined) {
  88723. mesh.isBlocker = parsedMesh.isBlocker;
  88724. }
  88725. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  88726. // freezeWorldMatrix
  88727. if (parsedMesh.freezeWorldMatrix) {
  88728. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  88729. }
  88730. // Parent
  88731. if (parsedMesh.parentId) {
  88732. mesh._waitingParentId = parsedMesh.parentId;
  88733. }
  88734. // Actions
  88735. if (parsedMesh.actions !== undefined) {
  88736. mesh._waitingActions = parsedMesh.actions;
  88737. }
  88738. // Overlay
  88739. if (parsedMesh.overlayAlpha !== undefined) {
  88740. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  88741. }
  88742. if (parsedMesh.overlayColor !== undefined) {
  88743. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  88744. }
  88745. if (parsedMesh.renderOverlay !== undefined) {
  88746. mesh.renderOverlay = parsedMesh.renderOverlay;
  88747. }
  88748. // Geometry
  88749. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  88750. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  88751. if (parsedMesh.delayLoadingFile) {
  88752. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  88753. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  88754. 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));
  88755. if (parsedMesh._binaryInfo) {
  88756. mesh._binaryInfo = parsedMesh._binaryInfo;
  88757. }
  88758. mesh._delayInfo = [];
  88759. if (parsedMesh.hasUVs) {
  88760. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  88761. }
  88762. if (parsedMesh.hasUVs2) {
  88763. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  88764. }
  88765. if (parsedMesh.hasUVs3) {
  88766. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  88767. }
  88768. if (parsedMesh.hasUVs4) {
  88769. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  88770. }
  88771. if (parsedMesh.hasUVs5) {
  88772. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  88773. }
  88774. if (parsedMesh.hasUVs6) {
  88775. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  88776. }
  88777. if (parsedMesh.hasColors) {
  88778. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  88779. }
  88780. if (parsedMesh.hasMatricesIndices) {
  88781. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  88782. }
  88783. if (parsedMesh.hasMatricesWeights) {
  88784. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88785. }
  88786. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  88787. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  88788. mesh._checkDelayState();
  88789. }
  88790. }
  88791. else {
  88792. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  88793. }
  88794. // Material
  88795. if (parsedMesh.materialId) {
  88796. mesh.setMaterialByID(parsedMesh.materialId);
  88797. }
  88798. else {
  88799. mesh.material = null;
  88800. }
  88801. // Morph targets
  88802. if (parsedMesh.morphTargetManagerId > -1) {
  88803. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  88804. }
  88805. // Skeleton
  88806. if (parsedMesh.skeletonId > -1) {
  88807. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  88808. if (parsedMesh.numBoneInfluencers) {
  88809. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  88810. }
  88811. }
  88812. // Animations
  88813. if (parsedMesh.animations) {
  88814. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  88815. var parsedAnimation = parsedMesh.animations[animationIndex];
  88816. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  88817. if (internalClass) {
  88818. mesh.animations.push(internalClass.Parse(parsedAnimation));
  88819. }
  88820. }
  88821. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  88822. }
  88823. if (parsedMesh.autoAnimate) {
  88824. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  88825. }
  88826. // Layer Mask
  88827. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  88828. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  88829. }
  88830. else {
  88831. mesh.layerMask = 0x0FFFFFFF;
  88832. }
  88833. // Physics
  88834. if (parsedMesh.physicsImpostor) {
  88835. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  88836. }
  88837. // Instances
  88838. if (parsedMesh.instances) {
  88839. for (var index = 0; index < parsedMesh.instances.length; index++) {
  88840. var parsedInstance = parsedMesh.instances[index];
  88841. var instance = mesh.createInstance(parsedInstance.name);
  88842. if (parsedInstance.id) {
  88843. instance.id = parsedInstance.id;
  88844. }
  88845. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  88846. if (parsedInstance.tags) {
  88847. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  88848. }
  88849. else {
  88850. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  88851. }
  88852. }
  88853. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  88854. if (parsedInstance.parentId) {
  88855. instance._waitingParentId = parsedInstance.parentId;
  88856. }
  88857. if (parsedInstance.rotationQuaternion) {
  88858. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  88859. }
  88860. else if (parsedInstance.rotation) {
  88861. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  88862. }
  88863. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  88864. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  88865. instance.checkCollisions = parsedInstance.checkCollisions;
  88866. }
  88867. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  88868. instance.isPickable = parsedInstance.pickable;
  88869. }
  88870. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  88871. instance.showBoundingBox = parsedInstance.showBoundingBox;
  88872. }
  88873. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  88874. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  88875. }
  88876. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  88877. instance.alphaIndex = parsedInstance.alphaIndex;
  88878. }
  88879. // Physics
  88880. if (parsedInstance.physicsImpostor) {
  88881. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  88882. }
  88883. // Animation
  88884. if (parsedInstance.animations) {
  88885. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  88886. parsedAnimation = parsedInstance.animations[animationIndex];
  88887. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  88888. if (internalClass) {
  88889. instance.animations.push(internalClass.Parse(parsedAnimation));
  88890. }
  88891. }
  88892. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  88893. if (parsedInstance.autoAnimate) {
  88894. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  88895. }
  88896. }
  88897. }
  88898. }
  88899. return mesh;
  88900. };
  88901. /**
  88902. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88903. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88904. * @param name defines the name of the mesh to create
  88905. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88906. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88907. * @param closePath creates a seam between the first and the last points of each path of the path array
  88908. * @param offset is taken in account only if the `pathArray` is containing a single path
  88909. * @param scene defines the hosting scene
  88910. * @param updatable defines if the mesh must be flagged as updatable
  88911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88912. * @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)
  88913. * @returns a new Mesh
  88914. */
  88915. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  88916. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88917. };
  88918. /**
  88919. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88920. * @param name defines the name of the mesh to create
  88921. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88922. * @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
  88923. * @param scene defines the hosting scene
  88924. * @param updatable defines if the mesh must be flagged as updatable
  88925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88926. * @returns a new Mesh
  88927. */
  88928. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  88929. if (scene === void 0) { scene = null; }
  88930. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88931. };
  88932. /**
  88933. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88934. * @param name defines the name of the mesh to create
  88935. * @param size sets the size (float) of each box side (default 1)
  88936. * @param scene defines the hosting scene
  88937. * @param updatable defines if the mesh must be flagged as updatable
  88938. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88939. * @returns a new Mesh
  88940. */
  88941. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  88942. if (scene === void 0) { scene = null; }
  88943. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88944. };
  88945. /**
  88946. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88947. * @param name defines the name of the mesh to create
  88948. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88949. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88950. * @param scene defines the hosting scene
  88951. * @param updatable defines if the mesh must be flagged as updatable
  88952. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88953. * @returns a new Mesh
  88954. */
  88955. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  88956. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88957. };
  88958. /**
  88959. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88960. * @param name defines the name of the mesh to create
  88961. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88962. * @param diameterTop set the top cap diameter (floats, default 1)
  88963. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  88964. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  88965. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  88966. * @param scene defines the hosting scene
  88967. * @param updatable defines if the mesh must be flagged as updatable
  88968. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88969. * @returns a new Mesh
  88970. */
  88971. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  88972. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88973. };
  88974. // Torus (Code from SharpDX.org)
  88975. /**
  88976. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88977. * @param name defines the name of the mesh to create
  88978. * @param diameter sets the diameter size (float) of the torus (default 1)
  88979. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88980. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88981. * @param scene defines the hosting scene
  88982. * @param updatable defines if the mesh must be flagged as updatable
  88983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88984. * @returns a new Mesh
  88985. */
  88986. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  88987. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88988. };
  88989. /**
  88990. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88991. * @param name defines the name of the mesh to create
  88992. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88993. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88994. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88995. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88996. * @param p the number of windings on X axis (positive integers, default 2)
  88997. * @param q the number of windings on Y axis (positive integers, default 3)
  88998. * @param scene defines the hosting scene
  88999. * @param updatable defines if the mesh must be flagged as updatable
  89000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89001. * @returns a new Mesh
  89002. */
  89003. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  89004. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89005. };
  89006. /**
  89007. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89008. * @param name defines the name of the mesh to create
  89009. * @param points is an array successive Vector3
  89010. * @param scene defines the hosting scene
  89011. * @param updatable defines if the mesh must be flagged as updatable
  89012. * @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).
  89013. * @returns a new Mesh
  89014. */
  89015. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  89016. if (scene === void 0) { scene = null; }
  89017. if (updatable === void 0) { updatable = false; }
  89018. if (instance === void 0) { instance = null; }
  89019. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89020. };
  89021. /**
  89022. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89023. * @param name defines the name of the mesh to create
  89024. * @param points is an array successive Vector3
  89025. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89026. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89027. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89028. * @param scene defines the hosting scene
  89029. * @param updatable defines if the mesh must be flagged as updatable
  89030. * @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)
  89031. * @returns a new Mesh
  89032. */
  89033. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  89034. if (scene === void 0) { scene = null; }
  89035. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89036. };
  89037. /**
  89038. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89039. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89040. * 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.
  89041. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89042. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89043. * Remember you can only change the shape positions, not their number when updating a polygon.
  89044. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89045. * @param name defines the name of the mesh to create
  89046. * @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
  89047. * @param scene defines the hosting scene
  89048. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89049. * @param updatable defines if the mesh must be flagged as updatable
  89050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89051. * @param earcutInjection can be used to inject your own earcut reference
  89052. * @returns a new Mesh
  89053. */
  89054. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  89055. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89056. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89057. };
  89058. /**
  89059. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89060. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89061. * @param name defines the name of the mesh to create
  89062. * @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
  89063. * @param depth defines the height of extrusion
  89064. * @param scene defines the hosting scene
  89065. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89066. * @param updatable defines if the mesh must be flagged as updatable
  89067. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89068. * @param earcutInjection can be used to inject your own earcut reference
  89069. * @returns a new Mesh
  89070. */
  89071. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  89072. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89073. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89074. };
  89075. /**
  89076. * Creates an extruded shape mesh.
  89077. * 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
  89078. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89079. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89080. * @param name defines the name of the mesh to create
  89081. * @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
  89082. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89083. * @param scale is the value to scale the shape
  89084. * @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
  89085. * @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
  89086. * @param scene defines the hosting scene
  89087. * @param updatable defines if the mesh must be flagged as updatable
  89088. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89089. * @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)
  89090. * @returns a new Mesh
  89091. */
  89092. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  89093. if (scene === void 0) { scene = null; }
  89094. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89095. };
  89096. /**
  89097. * Creates an custom extruded shape mesh.
  89098. * The custom extrusion is a parametric shape.
  89099. * It has no predefined shape. Its final shape will depend on the input parameters.
  89100. * Please consider using the same method from the MeshBuilder class instead
  89101. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89102. * @param name defines the name of the mesh to create
  89103. * @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
  89104. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89105. * @param scaleFunction is a custom Javascript function called on each path point
  89106. * @param rotationFunction is a custom Javascript function called on each path point
  89107. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89108. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  89109. * @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
  89110. * @param scene defines the hosting scene
  89111. * @param updatable defines if the mesh must be flagged as updatable
  89112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89113. * @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)
  89114. * @returns a new Mesh
  89115. */
  89116. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  89117. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89118. };
  89119. /**
  89120. * Creates lathe mesh.
  89121. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  89122. * Please consider using the same method from the MeshBuilder class instead
  89123. * @param name defines the name of the mesh to create
  89124. * @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
  89125. * @param radius is the radius value of the lathe
  89126. * @param tessellation is the side number of the lathe.
  89127. * @param scene defines the hosting scene
  89128. * @param updatable defines if the mesh must be flagged as updatable
  89129. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89130. * @returns a new Mesh
  89131. */
  89132. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  89133. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89134. };
  89135. /**
  89136. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  89137. * @param name defines the name of the mesh to create
  89138. * @param size sets the size (float) of both sides of the plane at once (default 1)
  89139. * @param scene defines the hosting scene
  89140. * @param updatable defines if the mesh must be flagged as updatable
  89141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89142. * @returns a new Mesh
  89143. */
  89144. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  89145. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89146. };
  89147. /**
  89148. * Creates a ground mesh.
  89149. * Please consider using the same method from the MeshBuilder class instead
  89150. * @param name defines the name of the mesh to create
  89151. * @param width set the width of the ground
  89152. * @param height set the height of the ground
  89153. * @param subdivisions sets the number of subdivisions per side
  89154. * @param scene defines the hosting scene
  89155. * @param updatable defines if the mesh must be flagged as updatable
  89156. * @returns a new Mesh
  89157. */
  89158. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  89159. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89160. };
  89161. /**
  89162. * Creates a tiled ground mesh.
  89163. * Please consider using the same method from the MeshBuilder class instead
  89164. * @param name defines the name of the mesh to create
  89165. * @param xmin set the ground minimum X coordinate
  89166. * @param zmin set the ground minimum Y coordinate
  89167. * @param xmax set the ground maximum X coordinate
  89168. * @param zmax set the ground maximum Z coordinate
  89169. * @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
  89170. * @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
  89171. * @param scene defines the hosting scene
  89172. * @param updatable defines if the mesh must be flagged as updatable
  89173. * @returns a new Mesh
  89174. */
  89175. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  89176. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89177. };
  89178. /**
  89179. * Creates a ground mesh from a height map.
  89180. * Please consider using the same method from the MeshBuilder class instead
  89181. * @see http://doc.babylonjs.com/babylon101/height_map
  89182. * @param name defines the name of the mesh to create
  89183. * @param url sets the URL of the height map image resource
  89184. * @param width set the ground width size
  89185. * @param height set the ground height size
  89186. * @param subdivisions sets the number of subdivision per side
  89187. * @param minHeight is the minimum altitude on the ground
  89188. * @param maxHeight is the maximum altitude on the ground
  89189. * @param scene defines the hosting scene
  89190. * @param updatable defines if the mesh must be flagged as updatable
  89191. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  89192. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89193. * @returns a new Mesh
  89194. */
  89195. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  89196. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89197. };
  89198. /**
  89199. * Creates a tube mesh.
  89200. * The tube is a parametric shape.
  89201. * It has no predefined shape. Its final shape will depend on the input parameters.
  89202. * Please consider using the same method from the MeshBuilder class instead
  89203. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89204. * @param name defines the name of the mesh to create
  89205. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  89206. * @param radius sets the tube radius size
  89207. * @param tessellation is the number of sides on the tubular surface
  89208. * @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
  89209. * @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
  89210. * @param scene defines the hosting scene
  89211. * @param updatable defines if the mesh must be flagged as updatable
  89212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89213. * @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)
  89214. * @returns a new Mesh
  89215. */
  89216. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  89217. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89218. };
  89219. /**
  89220. * Creates a polyhedron mesh.
  89221. * Please consider using the same method from the MeshBuilder class instead.
  89222. * * 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
  89223. * * The parameter `size` (positive float, default 1) sets the polygon size
  89224. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89225. * * 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`
  89226. * * 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
  89227. * * 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)`)
  89228. * * 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
  89229. * * 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
  89230. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89231. * * 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
  89232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89233. * @param name defines the name of the mesh to create
  89234. * @param options defines the options used to create the mesh
  89235. * @param scene defines the hosting scene
  89236. * @returns a new Mesh
  89237. */
  89238. Mesh.CreatePolyhedron = function (name, options, scene) {
  89239. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89240. };
  89241. /**
  89242. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89243. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89244. * * 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`)
  89245. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89246. * * 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
  89247. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89248. * * 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
  89249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89250. * @param name defines the name of the mesh
  89251. * @param options defines the options used to create the mesh
  89252. * @param scene defines the hosting scene
  89253. * @returns a new Mesh
  89254. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89255. */
  89256. Mesh.CreateIcoSphere = function (name, options, scene) {
  89257. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89258. };
  89259. /**
  89260. * Creates a decal mesh.
  89261. * Please consider using the same method from the MeshBuilder class instead.
  89262. * A decal is a mesh usually applied as a model onto the surface of another mesh
  89263. * @param name defines the name of the mesh
  89264. * @param sourceMesh defines the mesh receiving the decal
  89265. * @param position sets the position of the decal in world coordinates
  89266. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89267. * @param size sets the decal scaling
  89268. * @param angle sets the angle to rotate the decal
  89269. * @returns a new Mesh
  89270. */
  89271. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  89272. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89273. };
  89274. // Skeletons
  89275. /**
  89276. * Prepare internal position array for software CPU skinning
  89277. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  89278. */
  89279. Mesh.prototype.setPositionsForCPUSkinning = function () {
  89280. if (!this._sourcePositions) {
  89281. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89282. if (!source) {
  89283. return this._sourcePositions;
  89284. }
  89285. this._sourcePositions = new Float32Array(source);
  89286. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  89287. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  89288. }
  89289. }
  89290. return this._sourcePositions;
  89291. };
  89292. /**
  89293. * Prepare internal normal array for software CPU skinning
  89294. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  89295. */
  89296. Mesh.prototype.setNormalsForCPUSkinning = function () {
  89297. if (!this._sourceNormals) {
  89298. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  89299. if (!source) {
  89300. return this._sourceNormals;
  89301. }
  89302. this._sourceNormals = new Float32Array(source);
  89303. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  89304. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  89305. }
  89306. }
  89307. return this._sourceNormals;
  89308. };
  89309. /**
  89310. * Updates the vertex buffer by applying transformation from the bones
  89311. * @param skeleton defines the skeleton to apply to current mesh
  89312. * @returns the current mesh
  89313. */
  89314. Mesh.prototype.applySkeleton = function (skeleton) {
  89315. if (!this.geometry) {
  89316. return this;
  89317. }
  89318. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  89319. return this;
  89320. }
  89321. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  89322. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  89323. return this;
  89324. }
  89325. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  89326. return this;
  89327. }
  89328. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  89329. return this;
  89330. }
  89331. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  89332. return this;
  89333. }
  89334. if (!this._sourcePositions) {
  89335. var submeshes = this.subMeshes.slice();
  89336. this.setPositionsForCPUSkinning();
  89337. this.subMeshes = submeshes;
  89338. }
  89339. if (!this._sourceNormals) {
  89340. this.setNormalsForCPUSkinning();
  89341. }
  89342. // positionsData checks for not being Float32Array will only pass at most once
  89343. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89344. if (!positionsData) {
  89345. return this;
  89346. }
  89347. if (!(positionsData instanceof Float32Array)) {
  89348. positionsData = new Float32Array(positionsData);
  89349. }
  89350. // normalsData checks for not being Float32Array will only pass at most once
  89351. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  89352. if (!normalsData) {
  89353. return this;
  89354. }
  89355. if (!(normalsData instanceof Float32Array)) {
  89356. normalsData = new Float32Array(normalsData);
  89357. }
  89358. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  89359. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  89360. if (!matricesWeightsData || !matricesIndicesData) {
  89361. return this;
  89362. }
  89363. var needExtras = this.numBoneInfluencers > 4;
  89364. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  89365. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  89366. var skeletonMatrices = skeleton.getTransformMatrices(this);
  89367. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  89368. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  89369. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  89370. var matWeightIdx = 0;
  89371. var inf;
  89372. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  89373. var weight;
  89374. for (inf = 0; inf < 4; inf++) {
  89375. weight = matricesWeightsData[matWeightIdx + inf];
  89376. if (weight > 0) {
  89377. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  89378. finalMatrix.addToSelf(tempMatrix);
  89379. }
  89380. }
  89381. if (needExtras) {
  89382. for (inf = 0; inf < 4; inf++) {
  89383. weight = matricesWeightsExtraData[matWeightIdx + inf];
  89384. if (weight > 0) {
  89385. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  89386. finalMatrix.addToSelf(tempMatrix);
  89387. }
  89388. }
  89389. }
  89390. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  89391. tempVector3.toArray(positionsData, index);
  89392. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  89393. tempVector3.toArray(normalsData, index);
  89394. finalMatrix.reset();
  89395. }
  89396. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  89397. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  89398. return this;
  89399. };
  89400. // Tools
  89401. /**
  89402. * 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
  89403. * @param meshes defines the list of meshes to scan
  89404. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89405. */
  89406. Mesh.MinMax = function (meshes) {
  89407. var minVector = null;
  89408. var maxVector = null;
  89409. meshes.forEach(function (mesh) {
  89410. var boundingInfo = mesh.getBoundingInfo();
  89411. var boundingBox = boundingInfo.boundingBox;
  89412. if (!minVector || !maxVector) {
  89413. minVector = boundingBox.minimumWorld;
  89414. maxVector = boundingBox.maximumWorld;
  89415. }
  89416. else {
  89417. minVector.minimizeInPlace(boundingBox.minimumWorld);
  89418. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  89419. }
  89420. });
  89421. if (!minVector || !maxVector) {
  89422. return {
  89423. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  89424. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  89425. };
  89426. }
  89427. return {
  89428. min: minVector,
  89429. max: maxVector
  89430. };
  89431. };
  89432. /**
  89433. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89434. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89435. * @returns a vector3
  89436. */
  89437. Mesh.Center = function (meshesOrMinMaxVector) {
  89438. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  89439. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  89440. };
  89441. /**
  89442. * Merge the array of meshes into a single mesh for performance reasons.
  89443. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89444. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89445. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89446. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89447. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89448. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89449. * @returns a new mesh
  89450. */
  89451. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  89452. if (disposeSource === void 0) { disposeSource = true; }
  89453. var index;
  89454. if (!allow32BitsIndices) {
  89455. var totalVertices = 0;
  89456. // Counting vertices
  89457. for (index = 0; index < meshes.length; index++) {
  89458. if (meshes[index]) {
  89459. totalVertices += meshes[index].getTotalVertices();
  89460. if (totalVertices > 65536) {
  89461. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices");
  89462. return null;
  89463. }
  89464. }
  89465. }
  89466. }
  89467. if (multiMultiMaterials) {
  89468. var newMultiMaterial = null;
  89469. var subIndex;
  89470. var matIndex;
  89471. subdivideWithSubMeshes = false;
  89472. }
  89473. var materialArray = new Array();
  89474. var materialIndexArray = new Array();
  89475. // Merge
  89476. var vertexData = null;
  89477. var otherVertexData;
  89478. var indiceArray = new Array();
  89479. var source = null;
  89480. for (index = 0; index < meshes.length; index++) {
  89481. if (meshes[index]) {
  89482. var mesh = meshes[index];
  89483. var wm = mesh.computeWorldMatrix(true);
  89484. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  89485. otherVertexData.transform(wm);
  89486. if (vertexData) {
  89487. vertexData.merge(otherVertexData, allow32BitsIndices);
  89488. }
  89489. else {
  89490. vertexData = otherVertexData;
  89491. source = mesh;
  89492. }
  89493. if (subdivideWithSubMeshes) {
  89494. indiceArray.push(mesh.getTotalIndices());
  89495. }
  89496. if (multiMultiMaterials) {
  89497. if (mesh.material) {
  89498. var material = mesh.material;
  89499. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  89500. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  89501. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  89502. materialArray.push(material.subMaterials[matIndex]);
  89503. }
  89504. }
  89505. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  89506. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  89507. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  89508. }
  89509. }
  89510. else {
  89511. if (materialArray.indexOf(material) < 0) {
  89512. materialArray.push(material);
  89513. }
  89514. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  89515. materialIndexArray.push(materialArray.indexOf(material));
  89516. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  89517. }
  89518. }
  89519. }
  89520. else {
  89521. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  89522. materialIndexArray.push(0);
  89523. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  89524. }
  89525. }
  89526. }
  89527. }
  89528. }
  89529. source = source;
  89530. if (!meshSubclass) {
  89531. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  89532. }
  89533. vertexData.applyToMesh(meshSubclass);
  89534. // Setting properties
  89535. meshSubclass.checkCollisions = source.checkCollisions;
  89536. // Cleaning
  89537. if (disposeSource) {
  89538. for (index = 0; index < meshes.length; index++) {
  89539. if (meshes[index]) {
  89540. meshes[index].dispose();
  89541. }
  89542. }
  89543. }
  89544. // Subdivide
  89545. if (subdivideWithSubMeshes || multiMultiMaterials) {
  89546. //-- removal of global submesh
  89547. meshSubclass.releaseSubMeshes();
  89548. index = 0;
  89549. var offset = 0;
  89550. //-- apply subdivision according to index table
  89551. while (index < indiceArray.length) {
  89552. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  89553. offset += indiceArray[index];
  89554. index++;
  89555. }
  89556. }
  89557. if (multiMultiMaterials) {
  89558. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  89559. newMultiMaterial.subMaterials = materialArray;
  89560. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  89561. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  89562. }
  89563. meshSubclass.material = newMultiMaterial;
  89564. }
  89565. else {
  89566. meshSubclass.material = source.material;
  89567. }
  89568. return meshSubclass;
  89569. };
  89570. /** @hidden */
  89571. Mesh.prototype.addInstance = function (instance) {
  89572. instance._indexInSourceMeshInstanceArray = this.instances.length;
  89573. this.instances.push(instance);
  89574. };
  89575. /** @hidden */
  89576. Mesh.prototype.removeInstance = function (instance) {
  89577. // Remove from mesh
  89578. var index = instance._indexInSourceMeshInstanceArray;
  89579. if (index != -1) {
  89580. if (index !== this.instances.length - 1) {
  89581. var last = this.instances[this.instances.length - 1];
  89582. this.instances[index] = last;
  89583. last._indexInSourceMeshInstanceArray = index;
  89584. }
  89585. instance._indexInSourceMeshInstanceArray = -1;
  89586. this.instances.pop();
  89587. }
  89588. };
  89589. // Consts
  89590. /**
  89591. * Mesh side orientation : usually the external or front surface
  89592. */
  89593. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  89594. /**
  89595. * Mesh side orientation : usually the internal or back surface
  89596. */
  89597. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  89598. /**
  89599. * Mesh side orientation : both internal and external or front and back surfaces
  89600. */
  89601. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  89602. /**
  89603. * Mesh side orientation : by default, `FRONTSIDE`
  89604. */
  89605. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  89606. /**
  89607. * Mesh cap setting : no cap
  89608. */
  89609. Mesh.NO_CAP = 0;
  89610. /**
  89611. * Mesh cap setting : one cap at the beginning of the mesh
  89612. */
  89613. Mesh.CAP_START = 1;
  89614. /**
  89615. * Mesh cap setting : one cap at the end of the mesh
  89616. */
  89617. Mesh.CAP_END = 2;
  89618. /**
  89619. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89620. */
  89621. Mesh.CAP_ALL = 3;
  89622. // Statics
  89623. /** @hidden */
  89624. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  89625. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  89626. };
  89627. return Mesh;
  89628. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  89629. /***/ }),
  89630. /***/ "./Meshes/mesh.vertexData.ts":
  89631. /*!***********************************!*\
  89632. !*** ./Meshes/mesh.vertexData.ts ***!
  89633. \***********************************/
  89634. /*! exports provided: VertexData */
  89635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89636. "use strict";
  89637. __webpack_require__.r(__webpack_exports__);
  89638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  89639. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89640. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89641. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  89642. /**
  89643. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89644. */
  89645. var VertexData = /** @class */ (function () {
  89646. function VertexData() {
  89647. }
  89648. /**
  89649. * Uses the passed data array to set the set the values for the specified kind of data
  89650. * @param data a linear array of floating numbers
  89651. * @param kind the type of data that is being set, eg positions, colors etc
  89652. */
  89653. VertexData.prototype.set = function (data, kind) {
  89654. switch (kind) {
  89655. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  89656. this.positions = data;
  89657. break;
  89658. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  89659. this.normals = data;
  89660. break;
  89661. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  89662. this.tangents = data;
  89663. break;
  89664. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  89665. this.uvs = data;
  89666. break;
  89667. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  89668. this.uvs2 = data;
  89669. break;
  89670. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  89671. this.uvs3 = data;
  89672. break;
  89673. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  89674. this.uvs4 = data;
  89675. break;
  89676. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  89677. this.uvs5 = data;
  89678. break;
  89679. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  89680. this.uvs6 = data;
  89681. break;
  89682. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  89683. this.colors = data;
  89684. break;
  89685. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  89686. this.matricesIndices = data;
  89687. break;
  89688. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  89689. this.matricesWeights = data;
  89690. break;
  89691. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  89692. this.matricesIndicesExtra = data;
  89693. break;
  89694. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  89695. this.matricesWeightsExtra = data;
  89696. break;
  89697. }
  89698. };
  89699. /**
  89700. * Associates the vertexData to the passed Mesh.
  89701. * Sets it as updatable or not (default `false`)
  89702. * @param mesh the mesh the vertexData is applied to
  89703. * @param updatable when used and having the value true allows new data to update the vertexData
  89704. * @returns the VertexData
  89705. */
  89706. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  89707. this._applyTo(mesh, updatable);
  89708. return this;
  89709. };
  89710. /**
  89711. * Associates the vertexData to the passed Geometry.
  89712. * Sets it as updatable or not (default `false`)
  89713. * @param geometry the geometry the vertexData is applied to
  89714. * @param updatable when used and having the value true allows new data to update the vertexData
  89715. * @returns VertexData
  89716. */
  89717. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  89718. this._applyTo(geometry, updatable);
  89719. return this;
  89720. };
  89721. /**
  89722. * Updates the associated mesh
  89723. * @param mesh the mesh to be updated
  89724. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89725. * @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
  89726. * @returns VertexData
  89727. */
  89728. VertexData.prototype.updateMesh = function (mesh) {
  89729. this._update(mesh);
  89730. return this;
  89731. };
  89732. /**
  89733. * Updates the associated geometry
  89734. * @param geometry the geometry to be updated
  89735. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89736. * @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
  89737. * @returns VertexData.
  89738. */
  89739. VertexData.prototype.updateGeometry = function (geometry) {
  89740. this._update(geometry);
  89741. return this;
  89742. };
  89743. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  89744. if (updatable === void 0) { updatable = false; }
  89745. if (this.positions) {
  89746. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  89747. }
  89748. if (this.normals) {
  89749. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  89750. }
  89751. if (this.tangents) {
  89752. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  89753. }
  89754. if (this.uvs) {
  89755. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  89756. }
  89757. if (this.uvs2) {
  89758. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  89759. }
  89760. if (this.uvs3) {
  89761. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  89762. }
  89763. if (this.uvs4) {
  89764. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  89765. }
  89766. if (this.uvs5) {
  89767. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  89768. }
  89769. if (this.uvs6) {
  89770. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  89771. }
  89772. if (this.colors) {
  89773. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  89774. }
  89775. if (this.matricesIndices) {
  89776. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  89777. }
  89778. if (this.matricesWeights) {
  89779. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  89780. }
  89781. if (this.matricesIndicesExtra) {
  89782. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  89783. }
  89784. if (this.matricesWeightsExtra) {
  89785. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  89786. }
  89787. if (this.indices) {
  89788. meshOrGeometry.setIndices(this.indices, null, updatable);
  89789. }
  89790. else {
  89791. meshOrGeometry.setIndices([], null);
  89792. }
  89793. return this;
  89794. };
  89795. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  89796. if (this.positions) {
  89797. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  89798. }
  89799. if (this.normals) {
  89800. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  89801. }
  89802. if (this.tangents) {
  89803. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  89804. }
  89805. if (this.uvs) {
  89806. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  89807. }
  89808. if (this.uvs2) {
  89809. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  89810. }
  89811. if (this.uvs3) {
  89812. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  89813. }
  89814. if (this.uvs4) {
  89815. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  89816. }
  89817. if (this.uvs5) {
  89818. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  89819. }
  89820. if (this.uvs6) {
  89821. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  89822. }
  89823. if (this.colors) {
  89824. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  89825. }
  89826. if (this.matricesIndices) {
  89827. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  89828. }
  89829. if (this.matricesWeights) {
  89830. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  89831. }
  89832. if (this.matricesIndicesExtra) {
  89833. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  89834. }
  89835. if (this.matricesWeightsExtra) {
  89836. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  89837. }
  89838. if (this.indices) {
  89839. meshOrGeometry.setIndices(this.indices, null);
  89840. }
  89841. return this;
  89842. };
  89843. /**
  89844. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89845. * @param matrix the transforming matrix
  89846. * @returns the VertexData
  89847. */
  89848. VertexData.prototype.transform = function (matrix) {
  89849. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  89850. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89851. var index;
  89852. if (this.positions) {
  89853. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89854. for (index = 0; index < this.positions.length; index += 3) {
  89855. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  89856. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  89857. this.positions[index] = transformed.x;
  89858. this.positions[index + 1] = transformed.y;
  89859. this.positions[index + 2] = transformed.z;
  89860. }
  89861. }
  89862. if (this.normals) {
  89863. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89864. for (index = 0; index < this.normals.length; index += 3) {
  89865. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  89866. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  89867. this.normals[index] = transformed.x;
  89868. this.normals[index + 1] = transformed.y;
  89869. this.normals[index + 2] = transformed.z;
  89870. }
  89871. }
  89872. if (this.tangents) {
  89873. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  89874. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  89875. for (index = 0; index < this.tangents.length; index += 4) {
  89876. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  89877. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  89878. this.tangents[index] = tangentTransformed.x;
  89879. this.tangents[index + 1] = tangentTransformed.y;
  89880. this.tangents[index + 2] = tangentTransformed.z;
  89881. this.tangents[index + 3] = tangentTransformed.w;
  89882. }
  89883. }
  89884. if (flip && this.indices) {
  89885. for (index = 0; index < this.indices.length; index += 3) {
  89886. var tmp = this.indices[index + 1];
  89887. this.indices[index + 1] = this.indices[index + 2];
  89888. this.indices[index + 2] = tmp;
  89889. }
  89890. }
  89891. return this;
  89892. };
  89893. /**
  89894. * Merges the passed VertexData into the current one
  89895. * @param other the VertexData to be merged into the current one
  89896. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89897. * @returns the modified VertexData
  89898. */
  89899. VertexData.prototype.merge = function (other, use32BitsIndices) {
  89900. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  89901. this._validate();
  89902. other._validate();
  89903. if (!this.normals !== !other.normals ||
  89904. !this.tangents !== !other.tangents ||
  89905. !this.uvs !== !other.uvs ||
  89906. !this.uvs2 !== !other.uvs2 ||
  89907. !this.uvs3 !== !other.uvs3 ||
  89908. !this.uvs4 !== !other.uvs4 ||
  89909. !this.uvs5 !== !other.uvs5 ||
  89910. !this.uvs6 !== !other.uvs6 ||
  89911. !this.colors !== !other.colors ||
  89912. !this.matricesIndices !== !other.matricesIndices ||
  89913. !this.matricesWeights !== !other.matricesWeights ||
  89914. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  89915. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  89916. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  89917. }
  89918. if (other.indices) {
  89919. if (!this.indices) {
  89920. this.indices = [];
  89921. }
  89922. var offset = this.positions ? this.positions.length / 3 : 0;
  89923. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  89924. if (isSrcTypedArray) {
  89925. var len = this.indices.length + other.indices.length;
  89926. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  89927. temp.set(this.indices);
  89928. var decal = this.indices.length;
  89929. for (var index = 0; index < other.indices.length; index++) {
  89930. temp[decal + index] = other.indices[index] + offset;
  89931. }
  89932. this.indices = temp;
  89933. }
  89934. else {
  89935. for (var index = 0; index < other.indices.length; index++) {
  89936. this.indices.push(other.indices[index] + offset);
  89937. }
  89938. }
  89939. }
  89940. this.positions = this._mergeElement(this.positions, other.positions);
  89941. this.normals = this._mergeElement(this.normals, other.normals);
  89942. this.tangents = this._mergeElement(this.tangents, other.tangents);
  89943. this.uvs = this._mergeElement(this.uvs, other.uvs);
  89944. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  89945. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  89946. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  89947. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  89948. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  89949. this.colors = this._mergeElement(this.colors, other.colors);
  89950. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  89951. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  89952. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  89953. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  89954. return this;
  89955. };
  89956. VertexData.prototype._mergeElement = function (source, other) {
  89957. if (!source) {
  89958. return other;
  89959. }
  89960. if (!other) {
  89961. return source;
  89962. }
  89963. var len = other.length + source.length;
  89964. var isSrcTypedArray = source instanceof Float32Array;
  89965. var isOthTypedArray = other instanceof Float32Array;
  89966. // use non-loop method when the source is Float32Array
  89967. if (isSrcTypedArray) {
  89968. var ret32 = new Float32Array(len);
  89969. ret32.set(source);
  89970. ret32.set(other, source.length);
  89971. return ret32;
  89972. // source is number[], when other is also use concat
  89973. }
  89974. else if (!isOthTypedArray) {
  89975. return source.concat(other);
  89976. // source is a number[], but other is a Float32Array, loop required
  89977. }
  89978. else {
  89979. var ret = source.slice(0); // copy source to a separate array
  89980. for (var i = 0, len = other.length; i < len; i++) {
  89981. ret.push(other[i]);
  89982. }
  89983. return ret;
  89984. }
  89985. };
  89986. VertexData.prototype._validate = function () {
  89987. if (!this.positions) {
  89988. throw new Error("Positions are required");
  89989. }
  89990. var getElementCount = function (kind, values) {
  89991. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  89992. if ((values.length % stride) !== 0) {
  89993. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  89994. }
  89995. return values.length / stride;
  89996. };
  89997. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  89998. var validateElementCount = function (kind, values) {
  89999. var elementCount = getElementCount(kind, values);
  90000. if (elementCount !== positionsElementCount) {
  90001. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  90002. }
  90003. };
  90004. if (this.normals) {
  90005. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  90006. }
  90007. if (this.tangents) {
  90008. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  90009. }
  90010. if (this.uvs) {
  90011. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  90012. }
  90013. if (this.uvs2) {
  90014. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  90015. }
  90016. if (this.uvs3) {
  90017. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  90018. }
  90019. if (this.uvs4) {
  90020. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  90021. }
  90022. if (this.uvs5) {
  90023. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  90024. }
  90025. if (this.uvs6) {
  90026. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  90027. }
  90028. if (this.colors) {
  90029. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  90030. }
  90031. if (this.matricesIndices) {
  90032. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  90033. }
  90034. if (this.matricesWeights) {
  90035. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  90036. }
  90037. if (this.matricesIndicesExtra) {
  90038. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  90039. }
  90040. if (this.matricesWeightsExtra) {
  90041. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  90042. }
  90043. };
  90044. /**
  90045. * Serializes the VertexData
  90046. * @returns a serialized object
  90047. */
  90048. VertexData.prototype.serialize = function () {
  90049. var serializationObject = this.serialize();
  90050. if (this.positions) {
  90051. serializationObject.positions = this.positions;
  90052. }
  90053. if (this.normals) {
  90054. serializationObject.normals = this.normals;
  90055. }
  90056. if (this.tangents) {
  90057. serializationObject.tangents = this.tangents;
  90058. }
  90059. if (this.uvs) {
  90060. serializationObject.uvs = this.uvs;
  90061. }
  90062. if (this.uvs2) {
  90063. serializationObject.uvs2 = this.uvs2;
  90064. }
  90065. if (this.uvs3) {
  90066. serializationObject.uvs3 = this.uvs3;
  90067. }
  90068. if (this.uvs4) {
  90069. serializationObject.uvs4 = this.uvs4;
  90070. }
  90071. if (this.uvs5) {
  90072. serializationObject.uvs5 = this.uvs5;
  90073. }
  90074. if (this.uvs6) {
  90075. serializationObject.uvs6 = this.uvs6;
  90076. }
  90077. if (this.colors) {
  90078. serializationObject.colors = this.colors;
  90079. }
  90080. if (this.matricesIndices) {
  90081. serializationObject.matricesIndices = this.matricesIndices;
  90082. serializationObject.matricesIndices._isExpanded = true;
  90083. }
  90084. if (this.matricesWeights) {
  90085. serializationObject.matricesWeights = this.matricesWeights;
  90086. }
  90087. if (this.matricesIndicesExtra) {
  90088. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  90089. serializationObject.matricesIndicesExtra._isExpanded = true;
  90090. }
  90091. if (this.matricesWeightsExtra) {
  90092. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  90093. }
  90094. serializationObject.indices = this.indices;
  90095. return serializationObject;
  90096. };
  90097. // Statics
  90098. /**
  90099. * Extracts the vertexData from a mesh
  90100. * @param mesh the mesh from which to extract the VertexData
  90101. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90102. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90103. * @returns the object VertexData associated to the passed mesh
  90104. */
  90105. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  90106. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  90107. };
  90108. /**
  90109. * Extracts the vertexData from the geometry
  90110. * @param geometry the geometry from which to extract the VertexData
  90111. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90112. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90113. * @returns the object VertexData associated to the passed mesh
  90114. */
  90115. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  90116. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  90117. };
  90118. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  90119. var result = new VertexData();
  90120. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  90121. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  90122. }
  90123. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  90124. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  90125. }
  90126. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  90127. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  90128. }
  90129. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  90130. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  90131. }
  90132. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  90133. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  90134. }
  90135. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  90136. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  90137. }
  90138. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  90139. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  90140. }
  90141. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  90142. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  90143. }
  90144. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  90145. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  90146. }
  90147. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  90148. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  90149. }
  90150. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  90151. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  90152. }
  90153. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  90154. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  90155. }
  90156. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  90157. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  90158. }
  90159. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  90160. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  90161. }
  90162. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  90163. return result;
  90164. };
  90165. /**
  90166. * Creates the VertexData for a Ribbon
  90167. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90168. * * pathArray array of paths, each of which an array of successive Vector3
  90169. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90170. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90171. * * 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
  90172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90173. * * 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)
  90174. * * 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)
  90175. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90176. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90177. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90178. * @returns the VertexData of the ribbon
  90179. */
  90180. VertexData.CreateRibbon = function (options) {
  90181. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  90182. };
  90183. /**
  90184. * Creates the VertexData for a box
  90185. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90186. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90187. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90188. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90189. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90190. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90191. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90193. * * 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)
  90194. * * 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)
  90195. * @returns the VertexData of the box
  90196. */
  90197. VertexData.CreateBox = function (options) {
  90198. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  90199. };
  90200. /**
  90201. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90202. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90203. * * segments sets the number of horizontal strips optional, default 32
  90204. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90205. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90206. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90207. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90208. * * 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
  90209. * * 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
  90210. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90211. * * 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)
  90212. * * 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)
  90213. * @returns the VertexData of the ellipsoid
  90214. */
  90215. VertexData.CreateSphere = function (options) {
  90216. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  90217. };
  90218. /**
  90219. * Creates the VertexData for a cylinder, cone or prism
  90220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90221. * * height sets the height (y direction) of the cylinder, optional, default 2
  90222. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90223. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90224. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90225. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90226. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90227. * * 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
  90228. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90229. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90230. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90231. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90233. * * 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)
  90234. * * 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)
  90235. * @returns the VertexData of the cylinder, cone or prism
  90236. */
  90237. VertexData.CreateCylinder = function (options) {
  90238. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  90239. };
  90240. /**
  90241. * Creates the VertexData for a torus
  90242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90243. * * diameter the diameter of the torus, optional default 1
  90244. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90245. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90247. * * 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)
  90248. * * 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)
  90249. * @returns the VertexData of the torus
  90250. */
  90251. VertexData.CreateTorus = function (options) {
  90252. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  90253. };
  90254. /**
  90255. * Creates the VertexData of the LineSystem
  90256. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90257. * - lines an array of lines, each line being an array of successive Vector3
  90258. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90259. * @returns the VertexData of the LineSystem
  90260. */
  90261. VertexData.CreateLineSystem = function (options) {
  90262. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  90263. };
  90264. /**
  90265. * Create the VertexData for a DashedLines
  90266. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90267. * - points an array successive Vector3
  90268. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90269. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90270. * - dashNb the intended total number of dashes, optional, default 200
  90271. * @returns the VertexData for the DashedLines
  90272. */
  90273. VertexData.CreateDashedLines = function (options) {
  90274. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  90275. };
  90276. /**
  90277. * Creates the VertexData for a Ground
  90278. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90279. * - width the width (x direction) of the ground, optional, default 1
  90280. * - height the height (z direction) of the ground, optional, default 1
  90281. * - subdivisions the number of subdivisions per side, optional, default 1
  90282. * @returns the VertexData of the Ground
  90283. */
  90284. VertexData.CreateGround = function (options) {
  90285. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  90286. };
  90287. /**
  90288. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90289. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90290. * * xmin the ground minimum X coordinate, optional, default -1
  90291. * * zmin the ground minimum Z coordinate, optional, default -1
  90292. * * xmax the ground maximum X coordinate, optional, default 1
  90293. * * zmax the ground maximum Z coordinate, optional, default 1
  90294. * * 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}
  90295. * * 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}
  90296. * @returns the VertexData of the TiledGround
  90297. */
  90298. VertexData.CreateTiledGround = function (options) {
  90299. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  90300. };
  90301. /**
  90302. * Creates the VertexData of the Ground designed from a heightmap
  90303. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90304. * * width the width (x direction) of the ground
  90305. * * height the height (z direction) of the ground
  90306. * * subdivisions the number of subdivisions per side
  90307. * * minHeight the minimum altitude on the ground, optional, default 0
  90308. * * maxHeight the maximum altitude on the ground, optional default 1
  90309. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90310. * * buffer the array holding the image color data
  90311. * * bufferWidth the width of image
  90312. * * bufferHeight the height of image
  90313. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90314. * @returns the VertexData of the Ground designed from a heightmap
  90315. */
  90316. VertexData.CreateGroundFromHeightMap = function (options) {
  90317. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  90318. };
  90319. /**
  90320. * Creates the VertexData for a Plane
  90321. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90322. * * size sets the width and height of the plane to the value of size, optional default 1
  90323. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90324. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90326. * * 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)
  90327. * * 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)
  90328. * @returns the VertexData of the box
  90329. */
  90330. VertexData.CreatePlane = function (options) {
  90331. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  90332. };
  90333. /**
  90334. * Creates the VertexData of the Disc or regular Polygon
  90335. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90336. * * radius the radius of the disc, optional default 0.5
  90337. * * tessellation the number of polygon sides, optional, default 64
  90338. * * 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
  90339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90340. * * 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)
  90341. * * 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)
  90342. * @returns the VertexData of the box
  90343. */
  90344. VertexData.CreateDisc = function (options) {
  90345. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  90346. };
  90347. /**
  90348. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90349. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90350. * @param polygon a mesh built from polygonTriangulation.build()
  90351. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90352. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90353. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90354. * @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)
  90355. * @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)
  90356. * @returns the VertexData of the Polygon
  90357. */
  90358. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  90359. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  90360. };
  90361. /**
  90362. * Creates the VertexData of the IcoSphere
  90363. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90364. * * radius the radius of the IcoSphere, optional default 1
  90365. * * radiusX allows stretching in the x direction, optional, default radius
  90366. * * radiusY allows stretching in the y direction, optional, default radius
  90367. * * radiusZ allows stretching in the z direction, optional, default radius
  90368. * * flat when true creates a flat shaded mesh, optional, default true
  90369. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90371. * * 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)
  90372. * * 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)
  90373. * @returns the VertexData of the IcoSphere
  90374. */
  90375. VertexData.CreateIcoSphere = function (options) {
  90376. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  90377. };
  90378. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  90379. /**
  90380. * Creates the VertexData for a Polyhedron
  90381. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90382. * * type provided types are:
  90383. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90384. * * 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)
  90385. * * size the size of the IcoSphere, optional default 1
  90386. * * sizeX allows stretching in the x direction, optional, default size
  90387. * * sizeY allows stretching in the y direction, optional, default size
  90388. * * sizeZ allows stretching in the z direction, optional, default size
  90389. * * 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
  90390. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90391. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90392. * * flat when true creates a flat shaded mesh, optional, default true
  90393. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90394. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90395. * * 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)
  90396. * * 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)
  90397. * @returns the VertexData of the Polyhedron
  90398. */
  90399. VertexData.CreatePolyhedron = function (options) {
  90400. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  90401. };
  90402. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  90403. /**
  90404. * Creates the VertexData for a TorusKnot
  90405. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90406. * * radius the radius of the torus knot, optional, default 2
  90407. * * tube the thickness of the tube, optional, default 0.5
  90408. * * radialSegments the number of sides on each tube segments, optional, default 32
  90409. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90410. * * p the number of windings around the z axis, optional, default 2
  90411. * * q the number of windings around the x axis, optional, default 3
  90412. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90413. * * 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)
  90414. * * 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)
  90415. * @returns the VertexData of the Torus Knot
  90416. */
  90417. VertexData.CreateTorusKnot = function (options) {
  90418. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  90419. };
  90420. // Tools
  90421. /**
  90422. * Compute normals for given positions and indices
  90423. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90424. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90425. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90426. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90427. * * facetNormals : optional array of facet normals (vector3)
  90428. * * facetPositions : optional array of facet positions (vector3)
  90429. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90430. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90431. * * bInfo : optional bounding info, required for facetPartitioning computation
  90432. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90433. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90434. * * useRightHandedSystem: optional boolean to for right handed system computation
  90435. * * depthSort : optional boolean to enable the facet depth sort computation
  90436. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90437. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90438. */
  90439. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  90440. // temporary scalar variables
  90441. var index = 0; // facet index
  90442. var p1p2x = 0.0; // p1p2 vector x coordinate
  90443. var p1p2y = 0.0; // p1p2 vector y coordinate
  90444. var p1p2z = 0.0; // p1p2 vector z coordinate
  90445. var p3p2x = 0.0; // p3p2 vector x coordinate
  90446. var p3p2y = 0.0; // p3p2 vector y coordinate
  90447. var p3p2z = 0.0; // p3p2 vector z coordinate
  90448. var faceNormalx = 0.0; // facet normal x coordinate
  90449. var faceNormaly = 0.0; // facet normal y coordinate
  90450. var faceNormalz = 0.0; // facet normal z coordinate
  90451. var length = 0.0; // facet normal length before normalization
  90452. var v1x = 0; // vector1 x index in the positions array
  90453. var v1y = 0; // vector1 y index in the positions array
  90454. var v1z = 0; // vector1 z index in the positions array
  90455. var v2x = 0; // vector2 x index in the positions array
  90456. var v2y = 0; // vector2 y index in the positions array
  90457. var v2z = 0; // vector2 z index in the positions array
  90458. var v3x = 0; // vector3 x index in the positions array
  90459. var v3y = 0; // vector3 y index in the positions array
  90460. var v3z = 0; // vector3 z index in the positions array
  90461. var computeFacetNormals = false;
  90462. var computeFacetPositions = false;
  90463. var computeFacetPartitioning = false;
  90464. var computeDepthSort = false;
  90465. var faceNormalSign = 1;
  90466. var ratio = 0;
  90467. var distanceTo = null;
  90468. if (options) {
  90469. computeFacetNormals = (options.facetNormals) ? true : false;
  90470. computeFacetPositions = (options.facetPositions) ? true : false;
  90471. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  90472. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  90473. ratio = options.ratio || 0;
  90474. computeDepthSort = (options.depthSort) ? true : false;
  90475. distanceTo = (options.distanceTo);
  90476. if (computeDepthSort) {
  90477. if (distanceTo === undefined) {
  90478. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90479. }
  90480. var depthSortedFacets = options.depthSortedFacets;
  90481. }
  90482. }
  90483. // facetPartitioning reinit if needed
  90484. var xSubRatio = 0;
  90485. var ySubRatio = 0;
  90486. var zSubRatio = 0;
  90487. var subSq = 0;
  90488. if (computeFacetPartitioning && options && options.bbSize) {
  90489. var ox = 0; // X partitioning index for facet position
  90490. var oy = 0; // Y partinioning index for facet position
  90491. var oz = 0; // Z partinioning index for facet position
  90492. var b1x = 0; // X partitioning index for facet v1 vertex
  90493. var b1y = 0; // Y partitioning index for facet v1 vertex
  90494. var b1z = 0; // z partitioning index for facet v1 vertex
  90495. var b2x = 0; // X partitioning index for facet v2 vertex
  90496. var b2y = 0; // Y partitioning index for facet v2 vertex
  90497. var b2z = 0; // Z partitioning index for facet v2 vertex
  90498. var b3x = 0; // X partitioning index for facet v3 vertex
  90499. var b3y = 0; // Y partitioning index for facet v3 vertex
  90500. var b3z = 0; // Z partitioning index for facet v3 vertex
  90501. var block_idx_o = 0; // facet barycenter block index
  90502. var block_idx_v1 = 0; // v1 vertex block index
  90503. var block_idx_v2 = 0; // v2 vertex block index
  90504. var block_idx_v3 = 0; // v3 vertex block index
  90505. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  90506. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  90507. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  90508. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  90509. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  90510. subSq = options.subDiv.max * options.subDiv.max;
  90511. options.facetPartitioning.length = 0;
  90512. }
  90513. // reset the normals
  90514. for (index = 0; index < positions.length; index++) {
  90515. normals[index] = 0.0;
  90516. }
  90517. // Loop : 1 indice triplet = 1 facet
  90518. var nbFaces = (indices.length / 3) | 0;
  90519. for (index = 0; index < nbFaces; index++) {
  90520. // get the indexes of the coordinates of each vertex of the facet
  90521. v1x = indices[index * 3] * 3;
  90522. v1y = v1x + 1;
  90523. v1z = v1x + 2;
  90524. v2x = indices[index * 3 + 1] * 3;
  90525. v2y = v2x + 1;
  90526. v2z = v2x + 2;
  90527. v3x = indices[index * 3 + 2] * 3;
  90528. v3y = v3x + 1;
  90529. v3z = v3x + 2;
  90530. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  90531. p1p2y = positions[v1y] - positions[v2y];
  90532. p1p2z = positions[v1z] - positions[v2z];
  90533. p3p2x = positions[v3x] - positions[v2x];
  90534. p3p2y = positions[v3y] - positions[v2y];
  90535. p3p2z = positions[v3z] - positions[v2z];
  90536. // compute the face normal with the cross product
  90537. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  90538. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  90539. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  90540. // normalize this normal and store it in the array facetData
  90541. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  90542. length = (length === 0) ? 1.0 : length;
  90543. faceNormalx /= length;
  90544. faceNormaly /= length;
  90545. faceNormalz /= length;
  90546. if (computeFacetNormals && options) {
  90547. options.facetNormals[index].x = faceNormalx;
  90548. options.facetNormals[index].y = faceNormaly;
  90549. options.facetNormals[index].z = faceNormalz;
  90550. }
  90551. if (computeFacetPositions && options) {
  90552. // compute and the facet barycenter coordinates in the array facetPositions
  90553. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  90554. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  90555. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  90556. }
  90557. if (computeFacetPartitioning && options) {
  90558. // store the facet indexes in arrays in the main facetPartitioning array :
  90559. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  90560. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  90561. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  90562. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  90563. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  90564. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  90565. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  90566. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  90567. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  90568. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  90569. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  90570. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  90571. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  90572. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  90573. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  90574. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  90575. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  90576. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  90577. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  90578. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  90579. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  90580. // push each facet index in each block containing the vertex
  90581. options.facetPartitioning[block_idx_v1].push(index);
  90582. if (block_idx_v2 != block_idx_v1) {
  90583. options.facetPartitioning[block_idx_v2].push(index);
  90584. }
  90585. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  90586. options.facetPartitioning[block_idx_v3].push(index);
  90587. }
  90588. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  90589. options.facetPartitioning[block_idx_o].push(index);
  90590. }
  90591. }
  90592. if (computeDepthSort && options && options.facetPositions) {
  90593. var dsf = depthSortedFacets[index];
  90594. dsf.ind = index * 3;
  90595. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  90596. }
  90597. // compute the normals anyway
  90598. normals[v1x] += faceNormalx; // accumulate all the normals per face
  90599. normals[v1y] += faceNormaly;
  90600. normals[v1z] += faceNormalz;
  90601. normals[v2x] += faceNormalx;
  90602. normals[v2y] += faceNormaly;
  90603. normals[v2z] += faceNormalz;
  90604. normals[v3x] += faceNormalx;
  90605. normals[v3y] += faceNormaly;
  90606. normals[v3z] += faceNormalz;
  90607. }
  90608. // last normalization of each normal
  90609. for (index = 0; index < normals.length / 3; index++) {
  90610. faceNormalx = normals[index * 3];
  90611. faceNormaly = normals[index * 3 + 1];
  90612. faceNormalz = normals[index * 3 + 2];
  90613. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  90614. length = (length === 0) ? 1.0 : length;
  90615. faceNormalx /= length;
  90616. faceNormaly /= length;
  90617. faceNormalz /= length;
  90618. normals[index * 3] = faceNormalx;
  90619. normals[index * 3 + 1] = faceNormaly;
  90620. normals[index * 3 + 2] = faceNormalz;
  90621. }
  90622. };
  90623. /** @hidden */
  90624. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  90625. var li = indices.length;
  90626. var ln = normals.length;
  90627. var i;
  90628. var n;
  90629. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  90630. switch (sideOrientation) {
  90631. case VertexData.FRONTSIDE:
  90632. // nothing changed
  90633. break;
  90634. case VertexData.BACKSIDE:
  90635. var tmp;
  90636. // indices
  90637. for (i = 0; i < li; i += 3) {
  90638. tmp = indices[i];
  90639. indices[i] = indices[i + 2];
  90640. indices[i + 2] = tmp;
  90641. }
  90642. // normals
  90643. for (n = 0; n < ln; n++) {
  90644. normals[n] = -normals[n];
  90645. }
  90646. break;
  90647. case VertexData.DOUBLESIDE:
  90648. // positions
  90649. var lp = positions.length;
  90650. var l = lp / 3;
  90651. for (var p = 0; p < lp; p++) {
  90652. positions[lp + p] = positions[p];
  90653. }
  90654. // indices
  90655. for (i = 0; i < li; i += 3) {
  90656. indices[i + li] = indices[i + 2] + l;
  90657. indices[i + 1 + li] = indices[i + 1] + l;
  90658. indices[i + 2 + li] = indices[i] + l;
  90659. }
  90660. // normals
  90661. for (n = 0; n < ln; n++) {
  90662. normals[ln + n] = -normals[n];
  90663. }
  90664. // uvs
  90665. var lu = uvs.length;
  90666. var u = 0;
  90667. for (u = 0; u < lu; u++) {
  90668. uvs[u + lu] = uvs[u];
  90669. }
  90670. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  90671. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  90672. u = 0;
  90673. for (i = 0; i < lu / 2; i++) {
  90674. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  90675. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  90676. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  90677. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  90678. u += 2;
  90679. }
  90680. break;
  90681. }
  90682. };
  90683. /**
  90684. * Applies VertexData created from the imported parameters to the geometry
  90685. * @param parsedVertexData the parsed data from an imported file
  90686. * @param geometry the geometry to apply the VertexData to
  90687. */
  90688. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  90689. var vertexData = new VertexData();
  90690. // positions
  90691. var positions = parsedVertexData.positions;
  90692. if (positions) {
  90693. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  90694. }
  90695. // normals
  90696. var normals = parsedVertexData.normals;
  90697. if (normals) {
  90698. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  90699. }
  90700. // tangents
  90701. var tangents = parsedVertexData.tangents;
  90702. if (tangents) {
  90703. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  90704. }
  90705. // uvs
  90706. var uvs = parsedVertexData.uvs;
  90707. if (uvs) {
  90708. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  90709. }
  90710. // uv2s
  90711. var uv2s = parsedVertexData.uv2s;
  90712. if (uv2s) {
  90713. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  90714. }
  90715. // uv3s
  90716. var uv3s = parsedVertexData.uv3s;
  90717. if (uv3s) {
  90718. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  90719. }
  90720. // uv4s
  90721. var uv4s = parsedVertexData.uv4s;
  90722. if (uv4s) {
  90723. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  90724. }
  90725. // uv5s
  90726. var uv5s = parsedVertexData.uv5s;
  90727. if (uv5s) {
  90728. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  90729. }
  90730. // uv6s
  90731. var uv6s = parsedVertexData.uv6s;
  90732. if (uv6s) {
  90733. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  90734. }
  90735. // colors
  90736. var colors = parsedVertexData.colors;
  90737. if (colors) {
  90738. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  90739. }
  90740. // matricesIndices
  90741. var matricesIndices = parsedVertexData.matricesIndices;
  90742. if (matricesIndices) {
  90743. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  90744. }
  90745. // matricesWeights
  90746. var matricesWeights = parsedVertexData.matricesWeights;
  90747. if (matricesWeights) {
  90748. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  90749. }
  90750. // indices
  90751. var indices = parsedVertexData.indices;
  90752. if (indices) {
  90753. vertexData.indices = indices;
  90754. }
  90755. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  90756. };
  90757. /**
  90758. * Mesh side orientation : usually the external or front surface
  90759. */
  90760. VertexData.FRONTSIDE = 0;
  90761. /**
  90762. * Mesh side orientation : usually the internal or back surface
  90763. */
  90764. VertexData.BACKSIDE = 1;
  90765. /**
  90766. * Mesh side orientation : both internal and external or front and back surfaces
  90767. */
  90768. VertexData.DOUBLESIDE = 2;
  90769. /**
  90770. * Mesh side orientation : by default, `FRONTSIDE`
  90771. */
  90772. VertexData.DEFAULTSIDE = 0;
  90773. return VertexData;
  90774. }());
  90775. /***/ }),
  90776. /***/ "./Meshes/meshBuilder.ts":
  90777. /*!*******************************!*\
  90778. !*** ./Meshes/meshBuilder.ts ***!
  90779. \*******************************/
  90780. /*! exports provided: MeshBuilder */
  90781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90782. "use strict";
  90783. __webpack_require__.r(__webpack_exports__);
  90784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  90785. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  90786. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  90787. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  90788. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  90789. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  90790. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  90791. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  90792. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  90793. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  90794. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  90795. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  90796. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  90797. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  90798. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  90799. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  90800. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  90801. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  90802. /**
  90803. * Class containing static functions to help procedurally build meshes
  90804. */
  90805. var MeshBuilder = /** @class */ (function () {
  90806. function MeshBuilder() {
  90807. }
  90808. /**
  90809. * Creates a box mesh
  90810. * * The parameter `size` sets the size (float) of each box side (default 1)
  90811. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  90812. * * 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)
  90813. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  90814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90815. * * 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
  90816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90817. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  90818. * @param name defines the name of the mesh
  90819. * @param options defines the options used to create the mesh
  90820. * @param scene defines the hosting scene
  90821. * @returns the box mesh
  90822. */
  90823. MeshBuilder.CreateBox = function (name, options, scene) {
  90824. if (scene === void 0) { scene = null; }
  90825. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  90826. };
  90827. /**
  90828. * Creates a sphere mesh
  90829. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  90830. * * 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`)
  90831. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  90832. * * 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
  90833. * * 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)
  90834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90835. * * 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
  90836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90837. * @param name defines the name of the mesh
  90838. * @param options defines the options used to create the mesh
  90839. * @param scene defines the hosting scene
  90840. * @returns the sphere mesh
  90841. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  90842. */
  90843. MeshBuilder.CreateSphere = function (name, options, scene) {
  90844. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  90845. };
  90846. /**
  90847. * Creates a plane polygonal mesh. By default, this is a disc
  90848. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90849. * * 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
  90850. * * 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
  90851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90852. * * 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
  90853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90854. * @param name defines the name of the mesh
  90855. * @param options defines the options used to create the mesh
  90856. * @param scene defines the hosting scene
  90857. * @returns the plane polygonal mesh
  90858. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90859. */
  90860. MeshBuilder.CreateDisc = function (name, options, scene) {
  90861. if (scene === void 0) { scene = null; }
  90862. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  90863. };
  90864. /**
  90865. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90866. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90867. * * 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`)
  90868. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90869. * * 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
  90870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90871. * * 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
  90872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90873. * @param name defines the name of the mesh
  90874. * @param options defines the options used to create the mesh
  90875. * @param scene defines the hosting scene
  90876. * @returns the icosahedron mesh
  90877. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90878. */
  90879. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  90880. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  90881. };
  90882. /**
  90883. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  90884. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  90885. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  90886. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  90887. * * 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
  90888. * * 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
  90889. * * 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
  90890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90891. * * 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
  90892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90893. * * 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
  90894. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  90895. * * 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
  90896. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  90897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90898. * @param name defines the name of the mesh
  90899. * @param options defines the options used to create the mesh
  90900. * @param scene defines the hosting scene
  90901. * @returns the ribbon mesh
  90902. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  90903. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90904. */
  90905. MeshBuilder.CreateRibbon = function (name, options, scene) {
  90906. if (scene === void 0) { scene = null; }
  90907. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  90908. };
  90909. /**
  90910. * Creates a cylinder or a cone mesh
  90911. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  90912. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  90913. * * 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.
  90914. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  90915. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  90916. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  90917. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  90918. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  90919. * * 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).
  90920. * * 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
  90921. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  90922. * * 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
  90923. * * 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.
  90924. * * If `enclose` is false, a ring surface is one element.
  90925. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  90926. * * 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
  90927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90928. * * 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
  90929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90930. * @param name defines the name of the mesh
  90931. * @param options defines the options used to create the mesh
  90932. * @param scene defines the hosting scene
  90933. * @returns the cylinder mesh
  90934. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  90935. */
  90936. MeshBuilder.CreateCylinder = function (name, options, scene) {
  90937. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  90938. };
  90939. /**
  90940. * Creates a torus mesh
  90941. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  90942. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  90943. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  90944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90945. * * 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
  90946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90947. * @param name defines the name of the mesh
  90948. * @param options defines the options used to create the mesh
  90949. * @param scene defines the hosting scene
  90950. * @returns the torus mesh
  90951. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  90952. */
  90953. MeshBuilder.CreateTorus = function (name, options, scene) {
  90954. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  90955. };
  90956. /**
  90957. * Creates a torus knot mesh
  90958. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  90959. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  90960. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  90961. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  90962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90963. * * 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
  90964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90965. * @param name defines the name of the mesh
  90966. * @param options defines the options used to create the mesh
  90967. * @param scene defines the hosting scene
  90968. * @returns the torus knot mesh
  90969. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  90970. */
  90971. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  90972. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  90973. };
  90974. /**
  90975. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  90976. * * 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
  90977. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  90978. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  90979. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  90980. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  90981. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  90982. * * 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
  90983. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  90984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90985. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  90986. * @param name defines the name of the new line system
  90987. * @param options defines the options used to create the line system
  90988. * @param scene defines the hosting scene
  90989. * @returns a new line system mesh
  90990. */
  90991. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  90992. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  90993. };
  90994. /**
  90995. * Creates a line mesh
  90996. * 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
  90997. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  90998. * * The parameter `points` is an array successive Vector3
  90999. * * 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
  91000. * * The optional parameter `colors` is an array of successive Color4, one per line point
  91001. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  91002. * * When updating an instance, remember that only point positions can change, not the number of points
  91003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  91005. * @param name defines the name of the new line system
  91006. * @param options defines the options used to create the line system
  91007. * @param scene defines the hosting scene
  91008. * @returns a new line mesh
  91009. */
  91010. MeshBuilder.CreateLines = function (name, options, scene) {
  91011. if (scene === void 0) { scene = null; }
  91012. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  91013. };
  91014. /**
  91015. * Creates a dashed line mesh
  91016. * * 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
  91017. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  91018. * * The parameter `points` is an array successive Vector3
  91019. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  91020. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  91021. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91022. * * 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
  91023. * * When updating an instance, remember that only point positions can change, not the number of points
  91024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91025. * @param name defines the name of the mesh
  91026. * @param options defines the options used to create the mesh
  91027. * @param scene defines the hosting scene
  91028. * @returns the dashed line mesh
  91029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  91030. */
  91031. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  91032. if (scene === void 0) { scene = null; }
  91033. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  91034. };
  91035. /**
  91036. * 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.
  91037. * * 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.
  91038. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  91039. * * 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.
  91040. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  91041. * * 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
  91042. * * 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
  91043. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  91044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91045. * * 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
  91046. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  91047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91048. * @param name defines the name of the mesh
  91049. * @param options defines the options used to create the mesh
  91050. * @param scene defines the hosting scene
  91051. * @returns the extruded shape mesh
  91052. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  91053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91054. */
  91055. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  91056. if (scene === void 0) { scene = null; }
  91057. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  91058. };
  91059. /**
  91060. * Creates an custom extruded shape mesh.
  91061. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  91062. * * 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.
  91063. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  91064. * * 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
  91065. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  91066. * * 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
  91067. * * It must returns a float value that will be the scale value applied to the shape on each path point
  91068. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91069. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  91070. * * 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
  91071. * * 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
  91072. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  91073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91074. * * 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
  91075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  91076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91077. * @param name defines the name of the mesh
  91078. * @param options defines the options used to create the mesh
  91079. * @param scene defines the hosting scene
  91080. * @returns the custom extruded shape mesh
  91081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  91082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  91083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91084. */
  91085. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  91086. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  91087. };
  91088. /**
  91089. * Creates lathe mesh.
  91090. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  91091. * * 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
  91092. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  91093. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  91094. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  91095. * * 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
  91096. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  91097. * * 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
  91098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91099. * * 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
  91100. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  91101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91102. * @param name defines the name of the mesh
  91103. * @param options defines the options used to create the mesh
  91104. * @param scene defines the hosting scene
  91105. * @returns the lathe mesh
  91106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  91107. */
  91108. MeshBuilder.CreateLathe = function (name, options, scene) {
  91109. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  91110. };
  91111. /**
  91112. * Creates a plane mesh
  91113. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  91114. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  91115. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  91116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91117. * * 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
  91118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91119. * @param name defines the name of the mesh
  91120. * @param options defines the options used to create the mesh
  91121. * @param scene defines the hosting scene
  91122. * @returns the plane mesh
  91123. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  91124. */
  91125. MeshBuilder.CreatePlane = function (name, options, scene) {
  91126. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  91127. };
  91128. /**
  91129. * Creates a ground mesh
  91130. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  91131. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  91132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91133. * @param name defines the name of the mesh
  91134. * @param options defines the options used to create the mesh
  91135. * @param scene defines the hosting scene
  91136. * @returns the ground mesh
  91137. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  91138. */
  91139. MeshBuilder.CreateGround = function (name, options, scene) {
  91140. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  91141. };
  91142. /**
  91143. * Creates a tiled ground mesh
  91144. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  91145. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  91146. * * 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
  91147. * * 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
  91148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91149. * @param name defines the name of the mesh
  91150. * @param options defines the options used to create the mesh
  91151. * @param scene defines the hosting scene
  91152. * @returns the tiled ground mesh
  91153. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  91154. */
  91155. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  91156. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  91157. };
  91158. /**
  91159. * Creates a ground mesh from a height map
  91160. * * The parameter `url` sets the URL of the height map image resource.
  91161. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  91162. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  91163. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  91164. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  91165. * * 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.
  91166. * * 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).
  91167. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91169. * @param name defines the name of the mesh
  91170. * @param url defines the url to the height map
  91171. * @param options defines the options used to create the mesh
  91172. * @param scene defines the hosting scene
  91173. * @returns the ground mesh
  91174. * @see https://doc.babylonjs.com/babylon101/height_map
  91175. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  91176. */
  91177. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  91178. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  91179. };
  91180. /**
  91181. * Creates a polygon mesh
  91182. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  91183. * * 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
  91184. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91186. * * 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)
  91187. * * Remember you can only change the shape positions, not their number when updating a polygon
  91188. * @param name defines the name of the mesh
  91189. * @param options defines the options used to create the mesh
  91190. * @param scene defines the hosting scene
  91191. * @param earcutInjection can be used to inject your own earcut reference
  91192. * @returns the polygon mesh
  91193. */
  91194. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  91195. if (earcutInjection === void 0) { earcutInjection = earcut; }
  91196. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  91197. };
  91198. /**
  91199. * Creates an extruded polygon mesh, with depth in the Y direction.
  91200. * * 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)
  91201. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  91202. * @param name defines the name of the mesh
  91203. * @param options defines the options used to create the mesh
  91204. * @param scene defines the hosting scene
  91205. * @param earcutInjection can be used to inject your own earcut reference
  91206. * @returns the polygon mesh
  91207. */
  91208. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  91209. if (earcutInjection === void 0) { earcutInjection = earcut; }
  91210. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  91211. };
  91212. /**
  91213. * Creates a tube mesh.
  91214. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  91215. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  91216. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  91217. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  91218. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  91219. * * 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)
  91220. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  91221. * * 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
  91222. * * 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
  91223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91224. * * 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
  91225. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  91226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91227. * @param name defines the name of the mesh
  91228. * @param options defines the options used to create the mesh
  91229. * @param scene defines the hosting scene
  91230. * @returns the tube mesh
  91231. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  91232. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  91233. */
  91234. MeshBuilder.CreateTube = function (name, options, scene) {
  91235. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  91236. };
  91237. /**
  91238. * Creates a polyhedron mesh
  91239. * * 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
  91240. * * The parameter `size` (positive float, default 1) sets the polygon size
  91241. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91242. * * 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`
  91243. * * 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
  91244. * * 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)`)
  91245. * * 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
  91246. * * 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
  91247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91248. * * 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
  91249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91250. * @param name defines the name of the mesh
  91251. * @param options defines the options used to create the mesh
  91252. * @param scene defines the hosting scene
  91253. * @returns the polyhedron mesh
  91254. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  91255. */
  91256. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  91257. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  91258. };
  91259. /**
  91260. * Creates a decal mesh.
  91261. * 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
  91262. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  91263. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  91264. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  91265. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  91266. * @param name defines the name of the mesh
  91267. * @param sourceMesh defines the mesh where the decal must be applied
  91268. * @param options defines the options used to create the mesh
  91269. * @param scene defines the hosting scene
  91270. * @returns the decal mesh
  91271. * @see https://doc.babylonjs.com/how_to/decals
  91272. */
  91273. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  91274. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  91275. };
  91276. return MeshBuilder;
  91277. }());
  91278. /***/ }),
  91279. /***/ "./Meshes/meshSimplification.ts":
  91280. /*!**************************************!*\
  91281. !*** ./Meshes/meshSimplification.ts ***!
  91282. \**************************************/
  91283. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  91284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91285. "use strict";
  91286. __webpack_require__.r(__webpack_exports__);
  91287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  91288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  91289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  91290. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  91291. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  91292. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  91293. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  91294. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  91295. /**
  91296. * Class used to specify simplification options
  91297. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91298. */
  91299. var SimplificationSettings = /** @class */ (function () {
  91300. /**
  91301. * Creates a SimplificationSettings
  91302. * @param quality expected quality
  91303. * @param distance distance when this optimized version should be used
  91304. * @param optimizeMesh already optimized mesh
  91305. */
  91306. function SimplificationSettings(
  91307. /** expected quality */
  91308. quality,
  91309. /** distance when this optimized version should be used */
  91310. distance,
  91311. /** already optimized mesh */
  91312. optimizeMesh) {
  91313. this.quality = quality;
  91314. this.distance = distance;
  91315. this.optimizeMesh = optimizeMesh;
  91316. }
  91317. return SimplificationSettings;
  91318. }());
  91319. /**
  91320. * Queue used to order the simplification tasks
  91321. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91322. */
  91323. var SimplificationQueue = /** @class */ (function () {
  91324. /**
  91325. * Creates a new queue
  91326. */
  91327. function SimplificationQueue() {
  91328. this.running = false;
  91329. this._simplificationArray = [];
  91330. }
  91331. /**
  91332. * Adds a new simplification task
  91333. * @param task defines a task to add
  91334. */
  91335. SimplificationQueue.prototype.addTask = function (task) {
  91336. this._simplificationArray.push(task);
  91337. };
  91338. /**
  91339. * Execute next task
  91340. */
  91341. SimplificationQueue.prototype.executeNext = function () {
  91342. var task = this._simplificationArray.pop();
  91343. if (task) {
  91344. this.running = true;
  91345. this.runSimplification(task);
  91346. }
  91347. else {
  91348. this.running = false;
  91349. }
  91350. };
  91351. /**
  91352. * Execute a simplification task
  91353. * @param task defines the task to run
  91354. */
  91355. SimplificationQueue.prototype.runSimplification = function (task) {
  91356. var _this = this;
  91357. if (task.parallelProcessing) {
  91358. //parallel simplifier
  91359. task.settings.forEach(function (setting) {
  91360. var simplifier = _this.getSimplifier(task);
  91361. simplifier.simplify(setting, function (newMesh) {
  91362. task.mesh.addLODLevel(setting.distance, newMesh);
  91363. newMesh.isVisible = true;
  91364. //check if it is the last
  91365. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  91366. //all done, run the success callback.
  91367. task.successCallback();
  91368. }
  91369. _this.executeNext();
  91370. });
  91371. });
  91372. }
  91373. else {
  91374. //single simplifier.
  91375. var simplifier = this.getSimplifier(task);
  91376. var runDecimation = function (setting, callback) {
  91377. simplifier.simplify(setting, function (newMesh) {
  91378. task.mesh.addLODLevel(setting.distance, newMesh);
  91379. newMesh.isVisible = true;
  91380. //run the next quality level
  91381. callback();
  91382. });
  91383. };
  91384. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  91385. runDecimation(task.settings[loop.index], function () {
  91386. loop.executeNext();
  91387. });
  91388. }, function () {
  91389. //execution ended, run the success callback.
  91390. if (task.successCallback) {
  91391. task.successCallback();
  91392. }
  91393. _this.executeNext();
  91394. });
  91395. }
  91396. };
  91397. SimplificationQueue.prototype.getSimplifier = function (task) {
  91398. switch (task.simplificationType) {
  91399. case SimplificationType.QUADRATIC:
  91400. default:
  91401. return new QuadraticErrorSimplification(task.mesh);
  91402. }
  91403. };
  91404. return SimplificationQueue;
  91405. }());
  91406. /**
  91407. * The implemented types of simplification
  91408. * At the moment only Quadratic Error Decimation is implemented
  91409. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91410. */
  91411. var SimplificationType;
  91412. (function (SimplificationType) {
  91413. /** Quadratic error decimation */
  91414. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  91415. })(SimplificationType || (SimplificationType = {}));
  91416. var DecimationTriangle = /** @class */ (function () {
  91417. function DecimationTriangle(vertices) {
  91418. this.vertices = vertices;
  91419. this.error = new Array(4);
  91420. this.deleted = false;
  91421. this.isDirty = false;
  91422. this.deletePending = false;
  91423. this.borderFactor = 0;
  91424. }
  91425. return DecimationTriangle;
  91426. }());
  91427. var DecimationVertex = /** @class */ (function () {
  91428. function DecimationVertex(position, id) {
  91429. this.position = position;
  91430. this.id = id;
  91431. this.isBorder = true;
  91432. this.q = new QuadraticMatrix();
  91433. this.triangleCount = 0;
  91434. this.triangleStart = 0;
  91435. this.originalOffsets = [];
  91436. }
  91437. DecimationVertex.prototype.updatePosition = function (newPosition) {
  91438. this.position.copyFrom(newPosition);
  91439. };
  91440. return DecimationVertex;
  91441. }());
  91442. var QuadraticMatrix = /** @class */ (function () {
  91443. function QuadraticMatrix(data) {
  91444. this.data = new Array(10);
  91445. for (var i = 0; i < 10; ++i) {
  91446. if (data && data[i]) {
  91447. this.data[i] = data[i];
  91448. }
  91449. else {
  91450. this.data[i] = 0;
  91451. }
  91452. }
  91453. }
  91454. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  91455. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  91456. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  91457. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  91458. return det;
  91459. };
  91460. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  91461. for (var i = 0; i < 10; ++i) {
  91462. this.data[i] += matrix.data[i];
  91463. }
  91464. };
  91465. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  91466. for (var i = 0; i < 10; ++i) {
  91467. this.data[i] += data[i];
  91468. }
  91469. };
  91470. QuadraticMatrix.prototype.add = function (matrix) {
  91471. var m = new QuadraticMatrix();
  91472. for (var i = 0; i < 10; ++i) {
  91473. m.data[i] = this.data[i] + matrix.data[i];
  91474. }
  91475. return m;
  91476. };
  91477. QuadraticMatrix.FromData = function (a, b, c, d) {
  91478. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  91479. };
  91480. //returning an array to avoid garbage collection
  91481. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  91482. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  91483. };
  91484. return QuadraticMatrix;
  91485. }());
  91486. var Reference = /** @class */ (function () {
  91487. function Reference(vertexId, triangleId) {
  91488. this.vertexId = vertexId;
  91489. this.triangleId = triangleId;
  91490. }
  91491. return Reference;
  91492. }());
  91493. /**
  91494. * An implementation of the Quadratic Error simplification algorithm.
  91495. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  91496. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  91497. * @author RaananW
  91498. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91499. */
  91500. var QuadraticErrorSimplification = /** @class */ (function () {
  91501. function QuadraticErrorSimplification(_mesh) {
  91502. this._mesh = _mesh;
  91503. this.syncIterations = 5000;
  91504. this.aggressiveness = 7;
  91505. this.decimationIterations = 100;
  91506. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  91507. }
  91508. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  91509. var _this = this;
  91510. this.initDecimatedMesh();
  91511. //iterating through the submeshes array, one after the other.
  91512. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  91513. _this.initWithMesh(loop.index, function () {
  91514. _this.runDecimation(settings, loop.index, function () {
  91515. loop.executeNext();
  91516. });
  91517. }, settings.optimizeMesh);
  91518. }, function () {
  91519. setTimeout(function () {
  91520. successCallback(_this._reconstructedMesh);
  91521. }, 0);
  91522. });
  91523. };
  91524. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  91525. var _this = this;
  91526. var targetCount = ~~(this.triangles.length * settings.quality);
  91527. var deletedTriangles = 0;
  91528. var triangleCount = this.triangles.length;
  91529. var iterationFunction = function (iteration, callback) {
  91530. setTimeout(function () {
  91531. if (iteration % 5 === 0) {
  91532. _this.updateMesh(iteration === 0);
  91533. }
  91534. for (var i = 0; i < _this.triangles.length; ++i) {
  91535. _this.triangles[i].isDirty = false;
  91536. }
  91537. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  91538. var trianglesIterator = function (i) {
  91539. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  91540. var t = _this.triangles[tIdx];
  91541. if (!t) {
  91542. return;
  91543. }
  91544. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  91545. return;
  91546. }
  91547. for (var j = 0; j < 3; ++j) {
  91548. if (t.error[j] < threshold) {
  91549. var deleted0 = [];
  91550. var deleted1 = [];
  91551. var v0 = t.vertices[j];
  91552. var v1 = t.vertices[(j + 1) % 3];
  91553. if (v0.isBorder || v1.isBorder) {
  91554. continue;
  91555. }
  91556. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91557. // var n = Vector3.Zero();
  91558. // var uv = Vector2.Zero();
  91559. // var color = new Color4(0, 0, 0, 1);
  91560. _this.calculateError(v0, v1, p);
  91561. var delTr = new Array();
  91562. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  91563. continue;
  91564. }
  91565. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  91566. continue;
  91567. }
  91568. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  91569. continue;
  91570. }
  91571. var uniqueArray = new Array();
  91572. delTr.forEach(function (deletedT) {
  91573. if (uniqueArray.indexOf(deletedT) === -1) {
  91574. deletedT.deletePending = true;
  91575. uniqueArray.push(deletedT);
  91576. }
  91577. });
  91578. if (uniqueArray.length % 2 !== 0) {
  91579. continue;
  91580. }
  91581. v0.q = v1.q.add(v0.q);
  91582. v0.updatePosition(p);
  91583. var tStart = _this.references.length;
  91584. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  91585. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  91586. var tCount = _this.references.length - tStart;
  91587. if (tCount <= v0.triangleCount) {
  91588. if (tCount) {
  91589. for (var c = 0; c < tCount; c++) {
  91590. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  91591. }
  91592. }
  91593. }
  91594. else {
  91595. v0.triangleStart = tStart;
  91596. }
  91597. v0.triangleCount = tCount;
  91598. break;
  91599. }
  91600. }
  91601. };
  91602. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  91603. }, 0);
  91604. };
  91605. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  91606. if (triangleCount - deletedTriangles <= targetCount) {
  91607. loop.breakLoop();
  91608. }
  91609. else {
  91610. iterationFunction(loop.index, function () {
  91611. loop.executeNext();
  91612. });
  91613. }
  91614. }, function () {
  91615. setTimeout(function () {
  91616. //reconstruct this part of the mesh
  91617. _this.reconstructMesh(submeshIndex);
  91618. successCallback();
  91619. }, 0);
  91620. });
  91621. };
  91622. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  91623. var _this = this;
  91624. this.vertices = [];
  91625. this.triangles = [];
  91626. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  91627. var indices = this._mesh.getIndices();
  91628. var submesh = this._mesh.subMeshes[submeshIndex];
  91629. var findInVertices = function (positionToSearch) {
  91630. if (optimizeMesh) {
  91631. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  91632. if (_this.vertices[ii].position.equals(positionToSearch)) {
  91633. return _this.vertices[ii];
  91634. }
  91635. }
  91636. }
  91637. return null;
  91638. };
  91639. var vertexReferences = [];
  91640. var vertexInit = function (i) {
  91641. if (!positionData) {
  91642. return;
  91643. }
  91644. var offset = i + submesh.verticesStart;
  91645. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  91646. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  91647. vertex.originalOffsets.push(offset);
  91648. if (vertex.id === _this.vertices.length) {
  91649. _this.vertices.push(vertex);
  91650. }
  91651. vertexReferences.push(vertex.id);
  91652. };
  91653. //var totalVertices = mesh.getTotalVertices();
  91654. var totalVertices = submesh.verticesCount;
  91655. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  91656. var indicesInit = function (i) {
  91657. if (!indices) {
  91658. return;
  91659. }
  91660. var offset = (submesh.indexStart / 3) + i;
  91661. var pos = (offset * 3);
  91662. var i0 = indices[pos + 0];
  91663. var i1 = indices[pos + 1];
  91664. var i2 = indices[pos + 2];
  91665. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  91666. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  91667. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  91668. var triangle = new DecimationTriangle([v0, v1, v2]);
  91669. triangle.originalOffset = pos;
  91670. _this.triangles.push(triangle);
  91671. };
  91672. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  91673. _this.init(callback);
  91674. });
  91675. });
  91676. };
  91677. QuadraticErrorSimplification.prototype.init = function (callback) {
  91678. var _this = this;
  91679. var triangleInit1 = function (i) {
  91680. var t = _this.triangles[i];
  91681. 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();
  91682. for (var j = 0; j < 3; j++) {
  91683. 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))));
  91684. }
  91685. };
  91686. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  91687. var triangleInit2 = function (i) {
  91688. var t = _this.triangles[i];
  91689. for (var j = 0; j < 3; ++j) {
  91690. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  91691. }
  91692. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  91693. };
  91694. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  91695. callback();
  91696. });
  91697. });
  91698. };
  91699. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  91700. var newTriangles = [];
  91701. var i;
  91702. for (i = 0; i < this.vertices.length; ++i) {
  91703. this.vertices[i].triangleCount = 0;
  91704. }
  91705. var t;
  91706. var j;
  91707. for (i = 0; i < this.triangles.length; ++i) {
  91708. if (!this.triangles[i].deleted) {
  91709. t = this.triangles[i];
  91710. for (j = 0; j < 3; ++j) {
  91711. t.vertices[j].triangleCount = 1;
  91712. }
  91713. newTriangles.push(t);
  91714. }
  91715. }
  91716. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  91717. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  91718. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  91719. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  91720. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  91721. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  91722. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  91723. var vertexCount = 0;
  91724. for (i = 0; i < this.vertices.length; ++i) {
  91725. var vertex = this.vertices[i];
  91726. vertex.id = vertexCount;
  91727. if (vertex.triangleCount) {
  91728. vertex.originalOffsets.forEach(function (originalOffset) {
  91729. if (!normalData) {
  91730. return;
  91731. }
  91732. newPositionData.push(vertex.position.x);
  91733. newPositionData.push(vertex.position.y);
  91734. newPositionData.push(vertex.position.z);
  91735. newNormalData.push(normalData[originalOffset * 3]);
  91736. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  91737. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  91738. if (uvs && uvs.length) {
  91739. newUVsData.push(uvs[(originalOffset * 2)]);
  91740. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  91741. }
  91742. else if (colorsData && colorsData.length) {
  91743. newColorsData.push(colorsData[(originalOffset * 4)]);
  91744. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  91745. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  91746. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  91747. }
  91748. ++vertexCount;
  91749. });
  91750. }
  91751. }
  91752. var startingIndex = this._reconstructedMesh.getTotalIndices();
  91753. var startingVertex = this._reconstructedMesh.getTotalVertices();
  91754. var submeshesArray = this._reconstructedMesh.subMeshes;
  91755. this._reconstructedMesh.subMeshes = [];
  91756. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  91757. var originalIndices = this._mesh.getIndices();
  91758. for (i = 0; i < newTriangles.length; ++i) {
  91759. t = newTriangles[i]; //now get the new referencing point for each vertex
  91760. [0, 1, 2].forEach(function (idx) {
  91761. var id = originalIndices[t.originalOffset + idx];
  91762. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  91763. if (offset < 0) {
  91764. offset = 0;
  91765. }
  91766. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  91767. });
  91768. }
  91769. //overwriting the old vertex buffers and indices.
  91770. this._reconstructedMesh.setIndices(newIndicesArray);
  91771. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  91772. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  91773. if (newUVsData.length > 0) {
  91774. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  91775. }
  91776. if (newColorsData.length > 0) {
  91777. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  91778. }
  91779. //create submesh
  91780. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  91781. if (submeshIndex > 0) {
  91782. this._reconstructedMesh.subMeshes = [];
  91783. submeshesArray.forEach(function (submesh) {
  91784. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  91785. });
  91786. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  91787. }
  91788. };
  91789. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  91790. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  91791. this._reconstructedMesh.material = this._mesh.material;
  91792. this._reconstructedMesh.parent = this._mesh.parent;
  91793. this._reconstructedMesh.isVisible = false;
  91794. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  91795. };
  91796. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  91797. for (var i = 0; i < vertex1.triangleCount; ++i) {
  91798. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  91799. if (t.deleted) {
  91800. continue;
  91801. }
  91802. var s = this.references[vertex1.triangleStart + i].vertexId;
  91803. var v1 = t.vertices[(s + 1) % 3];
  91804. var v2 = t.vertices[(s + 2) % 3];
  91805. if ((v1 === vertex2 || v2 === vertex2)) {
  91806. deletedArray[i] = true;
  91807. delTr.push(t);
  91808. continue;
  91809. }
  91810. var d1 = v1.position.subtract(point);
  91811. d1 = d1.normalize();
  91812. var d2 = v2.position.subtract(point);
  91813. d2 = d2.normalize();
  91814. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  91815. return true;
  91816. }
  91817. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  91818. deletedArray[i] = false;
  91819. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  91820. return true;
  91821. }
  91822. }
  91823. return false;
  91824. };
  91825. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  91826. var newDeleted = deletedTriangles;
  91827. for (var i = 0; i < vertex.triangleCount; ++i) {
  91828. var ref = this.references[vertex.triangleStart + i];
  91829. var t = this.triangles[ref.triangleId];
  91830. if (t.deleted) {
  91831. continue;
  91832. }
  91833. if (deletedArray[i] && t.deletePending) {
  91834. t.deleted = true;
  91835. newDeleted++;
  91836. continue;
  91837. }
  91838. t.vertices[ref.vertexId] = origVertex;
  91839. t.isDirty = true;
  91840. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  91841. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  91842. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  91843. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  91844. this.references.push(ref);
  91845. }
  91846. return newDeleted;
  91847. };
  91848. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  91849. for (var i = 0; i < this.vertices.length; ++i) {
  91850. var vCount = [];
  91851. var vId = [];
  91852. var v = this.vertices[i];
  91853. var j;
  91854. for (j = 0; j < v.triangleCount; ++j) {
  91855. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  91856. for (var ii = 0; ii < 3; ii++) {
  91857. var ofs = 0;
  91858. var vv = triangle.vertices[ii];
  91859. while (ofs < vCount.length) {
  91860. if (vId[ofs] === vv.id) {
  91861. break;
  91862. }
  91863. ++ofs;
  91864. }
  91865. if (ofs === vCount.length) {
  91866. vCount.push(1);
  91867. vId.push(vv.id);
  91868. }
  91869. else {
  91870. vCount[ofs]++;
  91871. }
  91872. }
  91873. }
  91874. for (j = 0; j < vCount.length; ++j) {
  91875. if (vCount[j] === 1) {
  91876. this.vertices[vId[j]].isBorder = true;
  91877. }
  91878. else {
  91879. this.vertices[vId[j]].isBorder = false;
  91880. }
  91881. }
  91882. }
  91883. };
  91884. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  91885. if (identifyBorders === void 0) { identifyBorders = false; }
  91886. var i;
  91887. if (!identifyBorders) {
  91888. var newTrianglesVector = [];
  91889. for (i = 0; i < this.triangles.length; ++i) {
  91890. if (!this.triangles[i].deleted) {
  91891. newTrianglesVector.push(this.triangles[i]);
  91892. }
  91893. }
  91894. this.triangles = newTrianglesVector;
  91895. }
  91896. for (i = 0; i < this.vertices.length; ++i) {
  91897. this.vertices[i].triangleCount = 0;
  91898. this.vertices[i].triangleStart = 0;
  91899. }
  91900. var t;
  91901. var j;
  91902. var v;
  91903. for (i = 0; i < this.triangles.length; ++i) {
  91904. t = this.triangles[i];
  91905. for (j = 0; j < 3; ++j) {
  91906. v = t.vertices[j];
  91907. v.triangleCount++;
  91908. }
  91909. }
  91910. var tStart = 0;
  91911. for (i = 0; i < this.vertices.length; ++i) {
  91912. this.vertices[i].triangleStart = tStart;
  91913. tStart += this.vertices[i].triangleCount;
  91914. this.vertices[i].triangleCount = 0;
  91915. }
  91916. var newReferences = new Array(this.triangles.length * 3);
  91917. for (i = 0; i < this.triangles.length; ++i) {
  91918. t = this.triangles[i];
  91919. for (j = 0; j < 3; ++j) {
  91920. v = t.vertices[j];
  91921. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  91922. v.triangleCount++;
  91923. }
  91924. }
  91925. this.references = newReferences;
  91926. if (identifyBorders) {
  91927. this.identifyBorder();
  91928. }
  91929. };
  91930. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  91931. var x = point.x;
  91932. var y = point.y;
  91933. var z = point.z;
  91934. 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
  91935. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  91936. };
  91937. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  91938. var q = vertex1.q.add(vertex2.q);
  91939. var border = vertex1.isBorder && vertex2.isBorder;
  91940. var error = 0;
  91941. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  91942. if (qDet !== 0 && !border) {
  91943. if (!pointResult) {
  91944. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91945. }
  91946. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  91947. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  91948. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  91949. error = this.vertexError(q, pointResult);
  91950. }
  91951. else {
  91952. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  91953. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  91954. var error1 = this.vertexError(q, vertex1.position);
  91955. var error2 = this.vertexError(q, vertex2.position);
  91956. var error3 = this.vertexError(q, p3);
  91957. error = Math.min(error1, error2, error3);
  91958. if (error === error1) {
  91959. if (pointResult) {
  91960. pointResult.copyFrom(vertex1.position);
  91961. }
  91962. }
  91963. else if (error === error2) {
  91964. if (pointResult) {
  91965. pointResult.copyFrom(vertex2.position);
  91966. }
  91967. }
  91968. else {
  91969. if (pointResult) {
  91970. pointResult.copyFrom(p3);
  91971. }
  91972. }
  91973. }
  91974. return error;
  91975. };
  91976. return QuadraticErrorSimplification;
  91977. }());
  91978. /***/ }),
  91979. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  91980. /*!****************************************************!*\
  91981. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  91982. \****************************************************/
  91983. /*! exports provided: SimplicationQueueSceneComponent */
  91984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91985. "use strict";
  91986. __webpack_require__.r(__webpack_exports__);
  91987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  91988. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  91989. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  91990. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  91991. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  91992. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  91993. get: function () {
  91994. if (!this._simplificationQueue) {
  91995. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  91996. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  91997. if (!component) {
  91998. component = new SimplicationQueueSceneComponent(this);
  91999. this._addComponent(component);
  92000. }
  92001. }
  92002. return this._simplificationQueue;
  92003. },
  92004. set: function (value) {
  92005. this._simplificationQueue = value;
  92006. },
  92007. enumerable: true,
  92008. configurable: true
  92009. });
  92010. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  92011. if (parallelProcessing === void 0) { parallelProcessing = true; }
  92012. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  92013. this.getScene().simplificationQueue.addTask({
  92014. settings: settings,
  92015. parallelProcessing: parallelProcessing,
  92016. mesh: this,
  92017. simplificationType: simplificationType,
  92018. successCallback: successCallback
  92019. });
  92020. return this;
  92021. };
  92022. /**
  92023. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  92024. * created in a scene
  92025. */
  92026. var SimplicationQueueSceneComponent = /** @class */ (function () {
  92027. /**
  92028. * Creates a new instance of the component for the given scene
  92029. * @param scene Defines the scene to register the component in
  92030. */
  92031. function SimplicationQueueSceneComponent(scene) {
  92032. /**
  92033. * The component name helpfull to identify the component in the list of scene components.
  92034. */
  92035. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  92036. this.scene = scene;
  92037. }
  92038. /**
  92039. * Registers the component in a given scene
  92040. */
  92041. SimplicationQueueSceneComponent.prototype.register = function () {
  92042. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  92043. };
  92044. /**
  92045. * Rebuilds the elements related to this component in case of
  92046. * context lost for instance.
  92047. */
  92048. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  92049. // Nothing to do for this component
  92050. };
  92051. /**
  92052. * Disposes the component and the associated ressources
  92053. */
  92054. SimplicationQueueSceneComponent.prototype.dispose = function () {
  92055. // Nothing to do for this component
  92056. };
  92057. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  92058. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  92059. this.scene._simplificationQueue.executeNext();
  92060. }
  92061. };
  92062. return SimplicationQueueSceneComponent;
  92063. }());
  92064. /***/ }),
  92065. /***/ "./Meshes/polygonMesh.ts":
  92066. /*!*******************************!*\
  92067. !*** ./Meshes/polygonMesh.ts ***!
  92068. \*******************************/
  92069. /*! exports provided: Polygon, PolygonMeshBuilder */
  92070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92071. "use strict";
  92072. __webpack_require__.r(__webpack_exports__);
  92073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  92074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  92075. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92076. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92077. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92078. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92079. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  92080. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  92081. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  92082. /**
  92083. * Vector2 wth index property
  92084. */
  92085. var IndexedVector2 = /** @class */ (function (_super) {
  92086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  92087. function IndexedVector2(original,
  92088. /** Index of the vector2 */
  92089. index) {
  92090. var _this = _super.call(this, original.x, original.y) || this;
  92091. _this.index = index;
  92092. return _this;
  92093. }
  92094. return IndexedVector2;
  92095. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  92096. /**
  92097. * Defines points to create a polygon
  92098. */
  92099. var PolygonPoints = /** @class */ (function () {
  92100. function PolygonPoints() {
  92101. this.elements = new Array();
  92102. }
  92103. PolygonPoints.prototype.add = function (originalPoints) {
  92104. var _this = this;
  92105. var result = new Array();
  92106. originalPoints.forEach(function (point) {
  92107. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  92108. var newPoint = new IndexedVector2(point, _this.elements.length);
  92109. result.push(newPoint);
  92110. _this.elements.push(newPoint);
  92111. }
  92112. });
  92113. return result;
  92114. };
  92115. PolygonPoints.prototype.computeBounds = function () {
  92116. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  92117. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  92118. this.elements.forEach(function (point) {
  92119. // x
  92120. if (point.x < lmin.x) {
  92121. lmin.x = point.x;
  92122. }
  92123. else if (point.x > lmax.x) {
  92124. lmax.x = point.x;
  92125. }
  92126. // y
  92127. if (point.y < lmin.y) {
  92128. lmin.y = point.y;
  92129. }
  92130. else if (point.y > lmax.y) {
  92131. lmax.y = point.y;
  92132. }
  92133. });
  92134. return {
  92135. min: lmin,
  92136. max: lmax,
  92137. width: lmax.x - lmin.x,
  92138. height: lmax.y - lmin.y
  92139. };
  92140. };
  92141. return PolygonPoints;
  92142. }());
  92143. /**
  92144. * Polygon
  92145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92146. */
  92147. var Polygon = /** @class */ (function () {
  92148. function Polygon() {
  92149. }
  92150. /**
  92151. * Creates a rectangle
  92152. * @param xmin bottom X coord
  92153. * @param ymin bottom Y coord
  92154. * @param xmax top X coord
  92155. * @param ymax top Y coord
  92156. * @returns points that make the resulting rectation
  92157. */
  92158. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  92159. return [
  92160. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  92161. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  92162. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  92163. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  92164. ];
  92165. };
  92166. /**
  92167. * Creates a circle
  92168. * @param radius radius of circle
  92169. * @param cx scale in x
  92170. * @param cy scale in y
  92171. * @param numberOfSides number of sides that make up the circle
  92172. * @returns points that make the resulting circle
  92173. */
  92174. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  92175. if (cx === void 0) { cx = 0; }
  92176. if (cy === void 0) { cy = 0; }
  92177. if (numberOfSides === void 0) { numberOfSides = 32; }
  92178. var result = new Array();
  92179. var angle = 0;
  92180. var increment = (Math.PI * 2) / numberOfSides;
  92181. for (var i = 0; i < numberOfSides; i++) {
  92182. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  92183. angle -= increment;
  92184. }
  92185. return result;
  92186. };
  92187. /**
  92188. * Creates a polygon from input string
  92189. * @param input Input polygon data
  92190. * @returns the parsed points
  92191. */
  92192. Polygon.Parse = function (input) {
  92193. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  92194. var i, result = [];
  92195. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  92196. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  92197. }
  92198. return result;
  92199. };
  92200. /**
  92201. * Starts building a polygon from x and y coordinates
  92202. * @param x x coordinate
  92203. * @param y y coordinate
  92204. * @returns the started path2
  92205. */
  92206. Polygon.StartingAt = function (x, y) {
  92207. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  92208. };
  92209. return Polygon;
  92210. }());
  92211. /**
  92212. * Builds a polygon
  92213. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  92214. */
  92215. var PolygonMeshBuilder = /** @class */ (function () {
  92216. /**
  92217. * Creates a PolygonMeshBuilder
  92218. * @param name name of the builder
  92219. * @param contours Path of the polygon
  92220. * @param scene scene to add to when creating the mesh
  92221. * @param earcutInjection can be used to inject your own earcut reference
  92222. */
  92223. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  92224. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92225. this._points = new PolygonPoints();
  92226. this._outlinepoints = new PolygonPoints();
  92227. this._holes = new Array();
  92228. this._epoints = new Array();
  92229. this._eholes = new Array();
  92230. this.bjsEarcut = earcutInjection;
  92231. this._name = name;
  92232. this._scene = scene || _Engines_engine__WEBPACK_IMPORTED_MODULE_6__["Engine"].LastCreatedScene;
  92233. var points;
  92234. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  92235. points = contours.getPoints();
  92236. }
  92237. else {
  92238. points = contours;
  92239. }
  92240. this._addToepoint(points);
  92241. this._points.add(points);
  92242. this._outlinepoints.add(points);
  92243. if (typeof this.bjsEarcut === 'undefined') {
  92244. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  92245. }
  92246. }
  92247. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  92248. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  92249. var p = points_1[_i];
  92250. this._epoints.push(p.x, p.y);
  92251. }
  92252. };
  92253. /**
  92254. * Adds a whole within the polygon
  92255. * @param hole Array of points defining the hole
  92256. * @returns this
  92257. */
  92258. PolygonMeshBuilder.prototype.addHole = function (hole) {
  92259. this._points.add(hole);
  92260. var holepoints = new PolygonPoints();
  92261. holepoints.add(hole);
  92262. this._holes.push(holepoints);
  92263. this._eholes.push(this._epoints.length / 2);
  92264. this._addToepoint(hole);
  92265. return this;
  92266. };
  92267. /**
  92268. * Creates the polygon
  92269. * @param updatable If the mesh should be updatable
  92270. * @param depth The depth of the mesh created
  92271. * @returns the created mesh
  92272. */
  92273. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  92274. if (updatable === void 0) { updatable = false; }
  92275. if (depth === void 0) { depth = 0; }
  92276. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  92277. var vertexData = this.buildVertexData(depth);
  92278. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, vertexData.positions, updatable);
  92279. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, vertexData.normals, updatable);
  92280. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, vertexData.uvs, updatable);
  92281. result.setIndices(vertexData.indices);
  92282. return result;
  92283. };
  92284. /**
  92285. * Creates the polygon
  92286. * @param depth The depth of the mesh created
  92287. * @returns the created VertexData
  92288. */
  92289. PolygonMeshBuilder.prototype.buildVertexData = function (depth) {
  92290. var _this = this;
  92291. if (depth === void 0) { depth = 0; }
  92292. var result = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  92293. var normals = new Array();
  92294. var positions = new Array();
  92295. var uvs = new Array();
  92296. var bounds = this._points.computeBounds();
  92297. this._points.elements.forEach(function (p) {
  92298. normals.push(0, 1.0, 0);
  92299. positions.push(p.x, 0, p.y);
  92300. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  92301. });
  92302. var indices = new Array();
  92303. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  92304. for (var i = 0; i < res.length; i++) {
  92305. indices.push(res[i]);
  92306. }
  92307. if (depth > 0) {
  92308. var positionscount = (positions.length / 3); //get the current pointcount
  92309. this._points.elements.forEach(function (p) {
  92310. normals.push(0, -1.0, 0);
  92311. positions.push(p.x, -depth, p.y);
  92312. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  92313. });
  92314. var totalCount = indices.length;
  92315. for (var i = 0; i < totalCount; i += 3) {
  92316. var i0 = indices[i + 0];
  92317. var i1 = indices[i + 1];
  92318. var i2 = indices[i + 2];
  92319. indices.push(i2 + positionscount);
  92320. indices.push(i1 + positionscount);
  92321. indices.push(i0 + positionscount);
  92322. }
  92323. //Add the sides
  92324. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  92325. this._holes.forEach(function (hole) {
  92326. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  92327. });
  92328. }
  92329. result.indices = indices;
  92330. result.positions = positions;
  92331. result.normals = normals;
  92332. result.uvs = uvs;
  92333. return result;
  92334. };
  92335. /**
  92336. * Adds a side to the polygon
  92337. * @param positions points that make the polygon
  92338. * @param normals normals of the polygon
  92339. * @param uvs uvs of the polygon
  92340. * @param indices indices of the polygon
  92341. * @param bounds bounds of the polygon
  92342. * @param points points of the polygon
  92343. * @param depth depth of the polygon
  92344. * @param flip flip of the polygon
  92345. */
  92346. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  92347. var StartIndex = positions.length / 3;
  92348. var ulength = 0;
  92349. for (var i = 0; i < points.elements.length; i++) {
  92350. var p = points.elements[i];
  92351. var p1;
  92352. if ((i + 1) > points.elements.length - 1) {
  92353. p1 = points.elements[0];
  92354. }
  92355. else {
  92356. p1 = points.elements[i + 1];
  92357. }
  92358. positions.push(p.x, 0, p.y);
  92359. positions.push(p.x, -depth, p.y);
  92360. positions.push(p1.x, 0, p1.y);
  92361. positions.push(p1.x, -depth, p1.y);
  92362. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  92363. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  92364. var v3 = v2.subtract(v1);
  92365. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  92366. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  92367. vn = vn.normalize();
  92368. uvs.push(ulength / bounds.width, 0);
  92369. uvs.push(ulength / bounds.width, 1);
  92370. ulength += v3.length();
  92371. uvs.push((ulength / bounds.width), 0);
  92372. uvs.push((ulength / bounds.width), 1);
  92373. if (!flip) {
  92374. normals.push(-vn.x, -vn.y, -vn.z);
  92375. normals.push(-vn.x, -vn.y, -vn.z);
  92376. normals.push(-vn.x, -vn.y, -vn.z);
  92377. normals.push(-vn.x, -vn.y, -vn.z);
  92378. indices.push(StartIndex);
  92379. indices.push(StartIndex + 1);
  92380. indices.push(StartIndex + 2);
  92381. indices.push(StartIndex + 1);
  92382. indices.push(StartIndex + 3);
  92383. indices.push(StartIndex + 2);
  92384. }
  92385. else {
  92386. normals.push(vn.x, vn.y, vn.z);
  92387. normals.push(vn.x, vn.y, vn.z);
  92388. normals.push(vn.x, vn.y, vn.z);
  92389. normals.push(vn.x, vn.y, vn.z);
  92390. indices.push(StartIndex);
  92391. indices.push(StartIndex + 2);
  92392. indices.push(StartIndex + 1);
  92393. indices.push(StartIndex + 1);
  92394. indices.push(StartIndex + 2);
  92395. indices.push(StartIndex + 3);
  92396. }
  92397. StartIndex += 4;
  92398. }
  92399. };
  92400. return PolygonMeshBuilder;
  92401. }());
  92402. /***/ }),
  92403. /***/ "./Meshes/subMesh.ts":
  92404. /*!***************************!*\
  92405. !*** ./Meshes/subMesh.ts ***!
  92406. \***************************/
  92407. /*! exports provided: BaseSubMesh, SubMesh */
  92408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92409. "use strict";
  92410. __webpack_require__.r(__webpack_exports__);
  92411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  92412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  92413. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92414. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  92415. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  92416. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  92417. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  92418. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92419. /**
  92420. * Base class for submeshes
  92421. */
  92422. var BaseSubMesh = /** @class */ (function () {
  92423. function BaseSubMesh() {
  92424. }
  92425. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  92426. /**
  92427. * Gets associated effect
  92428. */
  92429. get: function () {
  92430. return this._materialEffect;
  92431. },
  92432. enumerable: true,
  92433. configurable: true
  92434. });
  92435. /**
  92436. * Sets associated effect (effect used to render this submesh)
  92437. * @param effect defines the effect to associate with
  92438. * @param defines defines the set of defines used to compile this effect
  92439. */
  92440. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  92441. if (defines === void 0) { defines = null; }
  92442. if (this._materialEffect === effect) {
  92443. if (!effect) {
  92444. this._materialDefines = null;
  92445. }
  92446. return;
  92447. }
  92448. this._materialDefines = defines;
  92449. this._materialEffect = effect;
  92450. };
  92451. return BaseSubMesh;
  92452. }());
  92453. /**
  92454. * Defines a subdivision inside a mesh
  92455. */
  92456. var SubMesh = /** @class */ (function (_super) {
  92457. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  92458. /**
  92459. * Creates a new submesh
  92460. * @param materialIndex defines the material index to use
  92461. * @param verticesStart defines vertex index start
  92462. * @param verticesCount defines vertices count
  92463. * @param indexStart defines index start
  92464. * @param indexCount defines indices count
  92465. * @param mesh defines the parent mesh
  92466. * @param renderingMesh defines an optional rendering mesh
  92467. * @param createBoundingBox defines if bounding box should be created for this submesh
  92468. */
  92469. function SubMesh(
  92470. /** the material index to use */
  92471. materialIndex,
  92472. /** vertex index start */
  92473. verticesStart,
  92474. /** vertices count */
  92475. verticesCount,
  92476. /** index start */
  92477. indexStart,
  92478. /** indices count */
  92479. indexCount, mesh, renderingMesh, createBoundingBox) {
  92480. if (createBoundingBox === void 0) { createBoundingBox = true; }
  92481. var _this = _super.call(this) || this;
  92482. _this.materialIndex = materialIndex;
  92483. _this.verticesStart = verticesStart;
  92484. _this.verticesCount = verticesCount;
  92485. _this.indexStart = indexStart;
  92486. _this.indexCount = indexCount;
  92487. /** @hidden */
  92488. _this._renderId = 0;
  92489. _this._mesh = mesh;
  92490. _this._renderingMesh = renderingMesh || mesh;
  92491. mesh.subMeshes.push(_this);
  92492. _this._trianglePlanes = [];
  92493. _this._id = mesh.subMeshes.length - 1;
  92494. if (createBoundingBox) {
  92495. _this.refreshBoundingInfo();
  92496. mesh.computeWorldMatrix(true);
  92497. }
  92498. return _this;
  92499. }
  92500. /**
  92501. * Add a new submesh to a mesh
  92502. * @param materialIndex defines the material index to use
  92503. * @param verticesStart defines vertex index start
  92504. * @param verticesCount defines vertices count
  92505. * @param indexStart defines index start
  92506. * @param indexCount defines indices count
  92507. * @param mesh defines the parent mesh
  92508. * @param renderingMesh defines an optional rendering mesh
  92509. * @param createBoundingBox defines if bounding box should be created for this submesh
  92510. * @returns the new submesh
  92511. */
  92512. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  92513. if (createBoundingBox === void 0) { createBoundingBox = true; }
  92514. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  92515. };
  92516. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  92517. /**
  92518. * Returns true if this submesh covers the entire parent mesh
  92519. * @ignorenaming
  92520. */
  92521. get: function () {
  92522. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  92523. },
  92524. enumerable: true,
  92525. configurable: true
  92526. });
  92527. /**
  92528. * Returns the submesh BoudingInfo object
  92529. * @returns current bounding info (or mesh's one if the submesh is global)
  92530. */
  92531. SubMesh.prototype.getBoundingInfo = function () {
  92532. if (this.IsGlobal) {
  92533. return this._mesh.getBoundingInfo();
  92534. }
  92535. return this._boundingInfo;
  92536. };
  92537. /**
  92538. * Sets the submesh BoundingInfo
  92539. * @param boundingInfo defines the new bounding info to use
  92540. * @returns the SubMesh
  92541. */
  92542. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  92543. this._boundingInfo = boundingInfo;
  92544. return this;
  92545. };
  92546. /**
  92547. * Returns the mesh of the current submesh
  92548. * @return the parent mesh
  92549. */
  92550. SubMesh.prototype.getMesh = function () {
  92551. return this._mesh;
  92552. };
  92553. /**
  92554. * Returns the rendering mesh of the submesh
  92555. * @returns the rendering mesh (could be different from parent mesh)
  92556. */
  92557. SubMesh.prototype.getRenderingMesh = function () {
  92558. return this._renderingMesh;
  92559. };
  92560. /**
  92561. * Returns the submesh material
  92562. * @returns null or the current material
  92563. */
  92564. SubMesh.prototype.getMaterial = function () {
  92565. var rootMaterial = this._renderingMesh.material;
  92566. if (rootMaterial === null || rootMaterial === undefined) {
  92567. return this._mesh.getScene().defaultMaterial;
  92568. }
  92569. else if (rootMaterial.getSubMaterial) {
  92570. var multiMaterial = rootMaterial;
  92571. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  92572. if (this._currentMaterial !== effectiveMaterial) {
  92573. this._currentMaterial = effectiveMaterial;
  92574. this._materialDefines = null;
  92575. }
  92576. return effectiveMaterial;
  92577. }
  92578. return rootMaterial;
  92579. };
  92580. // Methods
  92581. /**
  92582. * Sets a new updated BoundingInfo object to the submesh
  92583. * @returns the SubMesh
  92584. */
  92585. SubMesh.prototype.refreshBoundingInfo = function () {
  92586. this._lastColliderWorldVertices = null;
  92587. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  92588. return this;
  92589. }
  92590. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  92591. if (!data) {
  92592. this._boundingInfo = this._mesh.getBoundingInfo();
  92593. return this;
  92594. }
  92595. var indices = this._renderingMesh.getIndices();
  92596. var extend;
  92597. //is this the only submesh?
  92598. if (this.indexStart === 0 && this.indexCount === indices.length) {
  92599. var boundingInfo = this._renderingMesh.getBoundingInfo();
  92600. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  92601. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  92602. }
  92603. else {
  92604. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  92605. }
  92606. if (this._boundingInfo) {
  92607. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  92608. }
  92609. else {
  92610. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  92611. }
  92612. return this;
  92613. };
  92614. /** @hidden */
  92615. SubMesh.prototype._checkCollision = function (collider) {
  92616. var boundingInfo = this.getBoundingInfo();
  92617. return boundingInfo._checkCollision(collider);
  92618. };
  92619. /**
  92620. * Updates the submesh BoundingInfo
  92621. * @param world defines the world matrix to use to update the bounding info
  92622. * @returns the submesh
  92623. */
  92624. SubMesh.prototype.updateBoundingInfo = function (world) {
  92625. var boundingInfo = this.getBoundingInfo();
  92626. if (!boundingInfo) {
  92627. this.refreshBoundingInfo();
  92628. boundingInfo = this.getBoundingInfo();
  92629. }
  92630. boundingInfo.update(world);
  92631. return this;
  92632. };
  92633. /**
  92634. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  92635. * @param frustumPlanes defines the frustum planes
  92636. * @returns true if the submesh is intersecting with the frustum
  92637. */
  92638. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  92639. var boundingInfo = this.getBoundingInfo();
  92640. if (!boundingInfo) {
  92641. return false;
  92642. }
  92643. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  92644. };
  92645. /**
  92646. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  92647. * @param frustumPlanes defines the frustum planes
  92648. * @returns true if the submesh is inside the frustum
  92649. */
  92650. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  92651. var boundingInfo = this.getBoundingInfo();
  92652. if (!boundingInfo) {
  92653. return false;
  92654. }
  92655. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  92656. };
  92657. /**
  92658. * Renders the submesh
  92659. * @param enableAlphaMode defines if alpha needs to be used
  92660. * @returns the submesh
  92661. */
  92662. SubMesh.prototype.render = function (enableAlphaMode) {
  92663. this._renderingMesh.render(this, enableAlphaMode);
  92664. return this;
  92665. };
  92666. /**
  92667. * @hidden
  92668. */
  92669. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  92670. if (!this._linesIndexBuffer) {
  92671. var linesIndices = [];
  92672. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  92673. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  92674. }
  92675. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  92676. this._linesIndexCount = linesIndices.length;
  92677. }
  92678. return this._linesIndexBuffer;
  92679. };
  92680. /**
  92681. * Checks if the submesh intersects with a ray
  92682. * @param ray defines the ray to test
  92683. * @returns true is the passed ray intersects the submesh bounding box
  92684. */
  92685. SubMesh.prototype.canIntersects = function (ray) {
  92686. var boundingInfo = this.getBoundingInfo();
  92687. if (!boundingInfo) {
  92688. return false;
  92689. }
  92690. return ray.intersectsBox(boundingInfo.boundingBox);
  92691. };
  92692. /**
  92693. * Intersects current submesh with a ray
  92694. * @param ray defines the ray to test
  92695. * @param positions defines mesh's positions array
  92696. * @param indices defines mesh's indices array
  92697. * @param fastCheck defines if only bounding info should be used
  92698. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92699. * @returns intersection info or null if no intersection
  92700. */
  92701. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  92702. var material = this.getMaterial();
  92703. if (!material) {
  92704. return null;
  92705. }
  92706. switch (material.fillMode) {
  92707. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  92708. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  92709. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  92710. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  92711. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  92712. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  92713. return null;
  92714. }
  92715. // LineMesh first as it's also a Mesh...
  92716. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  92717. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  92718. }
  92719. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  92720. };
  92721. /** @hidden */
  92722. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  92723. var intersectInfo = null;
  92724. // Line test
  92725. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  92726. var p0 = positions[indices[index]];
  92727. var p1 = positions[indices[index + 1]];
  92728. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  92729. if (length < 0) {
  92730. continue;
  92731. }
  92732. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  92733. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  92734. intersectInfo.faceId = index / 2;
  92735. if (fastCheck) {
  92736. break;
  92737. }
  92738. }
  92739. }
  92740. return intersectInfo;
  92741. };
  92742. /** @hidden */
  92743. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  92744. var intersectInfo = null;
  92745. // Triangles test
  92746. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  92747. var p0 = positions[indices[index]];
  92748. var p1 = positions[indices[index + 1]];
  92749. var p2 = positions[indices[index + 2]];
  92750. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  92751. continue;
  92752. }
  92753. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  92754. if (currentIntersectInfo) {
  92755. if (currentIntersectInfo.distance < 0) {
  92756. continue;
  92757. }
  92758. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  92759. intersectInfo = currentIntersectInfo;
  92760. intersectInfo.faceId = index / 3;
  92761. if (fastCheck) {
  92762. break;
  92763. }
  92764. }
  92765. }
  92766. }
  92767. return intersectInfo;
  92768. };
  92769. /** @hidden */
  92770. SubMesh.prototype._rebuild = function () {
  92771. if (this._linesIndexBuffer) {
  92772. this._linesIndexBuffer = null;
  92773. }
  92774. };
  92775. // Clone
  92776. /**
  92777. * Creates a new submesh from the passed mesh
  92778. * @param newMesh defines the new hosting mesh
  92779. * @param newRenderingMesh defines an optional rendering mesh
  92780. * @returns the new submesh
  92781. */
  92782. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  92783. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  92784. if (!this.IsGlobal) {
  92785. var boundingInfo = this.getBoundingInfo();
  92786. if (!boundingInfo) {
  92787. return result;
  92788. }
  92789. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  92790. }
  92791. return result;
  92792. };
  92793. // Dispose
  92794. /**
  92795. * Release associated resources
  92796. */
  92797. SubMesh.prototype.dispose = function () {
  92798. if (this._linesIndexBuffer) {
  92799. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  92800. this._linesIndexBuffer = null;
  92801. }
  92802. // Remove from mesh
  92803. var index = this._mesh.subMeshes.indexOf(this);
  92804. this._mesh.subMeshes.splice(index, 1);
  92805. };
  92806. /**
  92807. * Gets the class name
  92808. * @returns the string "SubMesh".
  92809. */
  92810. SubMesh.prototype.getClassName = function () {
  92811. return "SubMesh";
  92812. };
  92813. // Statics
  92814. /**
  92815. * Creates a new submesh from indices data
  92816. * @param materialIndex the index of the main mesh material
  92817. * @param startIndex the index where to start the copy in the mesh indices array
  92818. * @param indexCount the number of indices to copy then from the startIndex
  92819. * @param mesh the main mesh to create the submesh from
  92820. * @param renderingMesh the optional rendering mesh
  92821. * @returns a new submesh
  92822. */
  92823. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  92824. var minVertexIndex = Number.MAX_VALUE;
  92825. var maxVertexIndex = -Number.MAX_VALUE;
  92826. var whatWillRender = (renderingMesh || mesh);
  92827. var indices = whatWillRender.getIndices();
  92828. for (var index = startIndex; index < startIndex + indexCount; index++) {
  92829. var vertexIndex = indices[index];
  92830. if (vertexIndex < minVertexIndex) {
  92831. minVertexIndex = vertexIndex;
  92832. }
  92833. if (vertexIndex > maxVertexIndex) {
  92834. maxVertexIndex = vertexIndex;
  92835. }
  92836. }
  92837. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  92838. };
  92839. return SubMesh;
  92840. }(BaseSubMesh));
  92841. /***/ }),
  92842. /***/ "./Meshes/trailMesh.ts":
  92843. /*!*****************************!*\
  92844. !*** ./Meshes/trailMesh.ts ***!
  92845. \*****************************/
  92846. /*! exports provided: TrailMesh */
  92847. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92848. "use strict";
  92849. __webpack_require__.r(__webpack_exports__);
  92850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  92851. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92852. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  92853. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92854. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92855. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  92856. /**
  92857. * Class used to create a trail following a mesh
  92858. */
  92859. var TrailMesh = /** @class */ (function (_super) {
  92860. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  92861. /**
  92862. * @constructor
  92863. * @param name The value used by scene.getMeshByName() to do a lookup.
  92864. * @param generator The mesh to generate a trail.
  92865. * @param scene The scene to add this mesh to.
  92866. * @param diameter Diameter of trailing mesh. Default is 1.
  92867. * @param length Length of trailing mesh. Default is 60.
  92868. * @param autoStart Automatically start trailing mesh. Default true.
  92869. */
  92870. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  92871. if (diameter === void 0) { diameter = 1; }
  92872. if (length === void 0) { length = 60; }
  92873. if (autoStart === void 0) { autoStart = true; }
  92874. var _this = _super.call(this, name, scene) || this;
  92875. _this._sectionPolygonPointsCount = 4;
  92876. _this._running = false;
  92877. _this._autoStart = autoStart;
  92878. _this._generator = generator;
  92879. _this._diameter = diameter;
  92880. _this._length = length;
  92881. _this._sectionVectors = [];
  92882. _this._sectionNormalVectors = [];
  92883. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  92884. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  92885. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  92886. }
  92887. _this._createMesh();
  92888. return _this;
  92889. }
  92890. /**
  92891. * "TrailMesh"
  92892. * @returns "TrailMesh"
  92893. */
  92894. TrailMesh.prototype.getClassName = function () {
  92895. return "TrailMesh";
  92896. };
  92897. TrailMesh.prototype._createMesh = function () {
  92898. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  92899. var positions = [];
  92900. var normals = [];
  92901. var indices = [];
  92902. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  92903. if (this._generator._boundingInfo) {
  92904. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  92905. }
  92906. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  92907. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  92908. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  92909. }
  92910. for (var i = 1; i <= this._length; i++) {
  92911. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  92912. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  92913. }
  92914. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  92915. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  92916. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  92917. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  92918. }
  92919. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  92920. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  92921. }
  92922. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  92923. data.positions = positions;
  92924. data.normals = normals;
  92925. data.indices = indices;
  92926. data.applyToMesh(this, true);
  92927. if (this._autoStart) {
  92928. this.start();
  92929. }
  92930. };
  92931. /**
  92932. * Start trailing mesh.
  92933. */
  92934. TrailMesh.prototype.start = function () {
  92935. var _this = this;
  92936. if (!this._running) {
  92937. this._running = true;
  92938. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  92939. _this.update();
  92940. });
  92941. }
  92942. };
  92943. /**
  92944. * Stop trailing mesh.
  92945. */
  92946. TrailMesh.prototype.stop = function () {
  92947. if (this._beforeRenderObserver && this._running) {
  92948. this._running = false;
  92949. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  92950. }
  92951. };
  92952. /**
  92953. * Update trailing mesh geometry.
  92954. */
  92955. TrailMesh.prototype.update = function () {
  92956. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  92957. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  92958. var wm = this._generator.getWorldMatrix();
  92959. if (positions && normals) {
  92960. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  92961. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  92962. }
  92963. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  92964. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  92965. }
  92966. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  92967. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  92968. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  92969. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  92970. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  92971. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  92972. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  92973. }
  92974. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  92975. positions[l + 3 * i] = this._sectionVectors[i].x;
  92976. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  92977. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  92978. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  92979. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  92980. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  92981. }
  92982. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  92983. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  92984. }
  92985. };
  92986. /**
  92987. * Returns a new TrailMesh object.
  92988. * @param name is a string, the name given to the new mesh
  92989. * @param newGenerator use new generator object for cloned trail mesh
  92990. * @returns a new mesh
  92991. */
  92992. TrailMesh.prototype.clone = function (name, newGenerator) {
  92993. if (name === void 0) { name = ""; }
  92994. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  92995. };
  92996. /**
  92997. * Serializes this trail mesh
  92998. * @param serializationObject object to write serialization to
  92999. */
  93000. TrailMesh.prototype.serialize = function (serializationObject) {
  93001. _super.prototype.serialize.call(this, serializationObject);
  93002. };
  93003. /**
  93004. * Parses a serialized trail mesh
  93005. * @param parsedMesh the serialized mesh
  93006. * @param scene the scene to create the trail mesh in
  93007. * @returns the created trail mesh
  93008. */
  93009. TrailMesh.Parse = function (parsedMesh, scene) {
  93010. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  93011. };
  93012. return TrailMesh;
  93013. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  93014. /***/ }),
  93015. /***/ "./Meshes/transformNode.ts":
  93016. /*!*********************************!*\
  93017. !*** ./Meshes/transformNode.ts ***!
  93018. \*********************************/
  93019. /*! exports provided: TransformNode */
  93020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93021. "use strict";
  93022. __webpack_require__.r(__webpack_exports__);
  93023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  93024. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93025. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  93026. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  93027. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93028. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  93029. /**
  93030. * 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.
  93031. * @see https://doc.babylonjs.com/how_to/transformnode
  93032. */
  93033. var TransformNode = /** @class */ (function (_super) {
  93034. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  93035. function TransformNode(name, scene, isPure) {
  93036. if (scene === void 0) { scene = null; }
  93037. if (isPure === void 0) { isPure = true; }
  93038. var _this = _super.call(this, name, scene) || this;
  93039. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  93040. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  93041. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  93042. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  93043. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  93044. // Properties
  93045. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93046. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93047. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  93048. _this._isDirty = false;
  93049. /**
  93050. * Set the billboard mode. Default is 0.
  93051. *
  93052. * | Value | Type | Description |
  93053. * | --- | --- | --- |
  93054. * | 0 | BILLBOARDMODE_NONE | |
  93055. * | 1 | BILLBOARDMODE_X | |
  93056. * | 2 | BILLBOARDMODE_Y | |
  93057. * | 4 | BILLBOARDMODE_Z | |
  93058. * | 7 | BILLBOARDMODE_ALL | |
  93059. *
  93060. */
  93061. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  93062. /**
  93063. * 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
  93064. */
  93065. _this.scalingDeterminant = 1;
  93066. /**
  93067. * Sets the distance of the object to max, often used by skybox
  93068. */
  93069. _this.infiniteDistance = false;
  93070. /**
  93071. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93072. * By default the system will update normals to compensate
  93073. */
  93074. _this.ignoreNonUniformScaling = false;
  93075. /** @hidden */
  93076. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  93077. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93078. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  93079. _this._postMultiplyPivotMatrix = false;
  93080. _this._tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  93081. _this._tempMatrix2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  93082. _this._isWorldMatrixFrozen = false;
  93083. /** @hidden */
  93084. _this._indexInSceneTransformNodesArray = -1;
  93085. /**
  93086. * An event triggered after the world matrix is updated
  93087. */
  93088. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  93089. _this._nonUniformScaling = false;
  93090. if (isPure) {
  93091. _this.getScene().addTransformNode(_this);
  93092. }
  93093. return _this;
  93094. }
  93095. /**
  93096. * Gets a string identifying the name of the class
  93097. * @returns "TransformNode" string
  93098. */
  93099. TransformNode.prototype.getClassName = function () {
  93100. return "TransformNode";
  93101. };
  93102. Object.defineProperty(TransformNode.prototype, "position", {
  93103. /**
  93104. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93105. */
  93106. get: function () {
  93107. return this._position;
  93108. },
  93109. set: function (newPosition) {
  93110. this._position = newPosition;
  93111. this._isDirty = true;
  93112. },
  93113. enumerable: true,
  93114. configurable: true
  93115. });
  93116. Object.defineProperty(TransformNode.prototype, "rotation", {
  93117. /**
  93118. * 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)).
  93119. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93120. */
  93121. get: function () {
  93122. return this._rotation;
  93123. },
  93124. set: function (newRotation) {
  93125. this._rotation = newRotation;
  93126. this._isDirty = true;
  93127. },
  93128. enumerable: true,
  93129. configurable: true
  93130. });
  93131. Object.defineProperty(TransformNode.prototype, "scaling", {
  93132. /**
  93133. * 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)).
  93134. */
  93135. get: function () {
  93136. return this._scaling;
  93137. },
  93138. set: function (newScaling) {
  93139. this._scaling = newScaling;
  93140. this._isDirty = true;
  93141. },
  93142. enumerable: true,
  93143. configurable: true
  93144. });
  93145. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  93146. /**
  93147. * 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).
  93148. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93149. */
  93150. get: function () {
  93151. return this._rotationQuaternion;
  93152. },
  93153. set: function (quaternion) {
  93154. this._rotationQuaternion = quaternion;
  93155. //reset the rotation vector.
  93156. if (quaternion) {
  93157. this.rotation.setAll(0.0);
  93158. }
  93159. },
  93160. enumerable: true,
  93161. configurable: true
  93162. });
  93163. Object.defineProperty(TransformNode.prototype, "forward", {
  93164. /**
  93165. * The forward direction of that transform in world space.
  93166. */
  93167. get: function () {
  93168. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()));
  93169. },
  93170. enumerable: true,
  93171. configurable: true
  93172. });
  93173. Object.defineProperty(TransformNode.prototype, "up", {
  93174. /**
  93175. * The up direction of that transform in world space.
  93176. */
  93177. get: function () {
  93178. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  93179. },
  93180. enumerable: true,
  93181. configurable: true
  93182. });
  93183. Object.defineProperty(TransformNode.prototype, "right", {
  93184. /**
  93185. * The right direction of that transform in world space.
  93186. */
  93187. get: function () {
  93188. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()));
  93189. },
  93190. enumerable: true,
  93191. configurable: true
  93192. });
  93193. /**
  93194. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93195. * @param matrix the matrix to copy the pose from
  93196. * @returns this TransformNode.
  93197. */
  93198. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  93199. this._poseMatrix.copyFrom(matrix);
  93200. return this;
  93201. };
  93202. /**
  93203. * Returns the mesh Pose matrix.
  93204. * @returns the pose matrix
  93205. */
  93206. TransformNode.prototype.getPoseMatrix = function () {
  93207. return this._poseMatrix;
  93208. };
  93209. /** @hidden */
  93210. TransformNode.prototype._isSynchronized = function () {
  93211. if (this._isDirty) {
  93212. return false;
  93213. }
  93214. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  93215. return false;
  93216. }
  93217. if (this._cache.pivotMatrixUpdated) {
  93218. return false;
  93219. }
  93220. if (this.infiniteDistance) {
  93221. return false;
  93222. }
  93223. if (!this._cache.position.equals(this._position)) {
  93224. return false;
  93225. }
  93226. if (this._rotationQuaternion) {
  93227. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  93228. return false;
  93229. }
  93230. }
  93231. if (!this._cache.rotation.equals(this._rotation)) {
  93232. return false;
  93233. }
  93234. if (!this._cache.scaling.equals(this._scaling)) {
  93235. return false;
  93236. }
  93237. return true;
  93238. };
  93239. /** @hidden */
  93240. TransformNode.prototype._initCache = function () {
  93241. _super.prototype._initCache.call(this);
  93242. this._cache.localMatrixUpdated = false;
  93243. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93244. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93245. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93246. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  93247. this._cache.billboardMode = -1;
  93248. this._cache.infiniteDistance = false;
  93249. };
  93250. /**
  93251. * Flag the transform node as dirty (Forcing it to update everything)
  93252. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93253. * @returns this transform node
  93254. */
  93255. TransformNode.prototype.markAsDirty = function (property) {
  93256. if (property === "rotation") {
  93257. this.rotationQuaternion = null;
  93258. }
  93259. this._currentRenderId = Number.MAX_VALUE;
  93260. this._isDirty = true;
  93261. return this;
  93262. };
  93263. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  93264. /**
  93265. * Returns the current mesh absolute position.
  93266. * Returns a Vector3.
  93267. */
  93268. get: function () {
  93269. return this._absolutePosition;
  93270. },
  93271. enumerable: true,
  93272. configurable: true
  93273. });
  93274. /**
  93275. * Sets a new matrix to apply before all other transformation
  93276. * @param matrix defines the transform matrix
  93277. * @returns the current TransformNode
  93278. */
  93279. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  93280. return this.setPivotMatrix(matrix, false);
  93281. };
  93282. /**
  93283. * Sets a new pivot matrix to the current node
  93284. * @param matrix defines the new pivot matrix to use
  93285. * @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
  93286. * @returns the current TransformNode
  93287. */
  93288. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  93289. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  93290. this._pivotMatrix.copyFrom(matrix);
  93291. this._cache.pivotMatrixUpdated = true;
  93292. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  93293. if (this._postMultiplyPivotMatrix) {
  93294. if (!this._pivotMatrixInverse) {
  93295. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  93296. }
  93297. else {
  93298. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  93299. }
  93300. }
  93301. return this;
  93302. };
  93303. /**
  93304. * Returns the mesh pivot matrix.
  93305. * Default : Identity.
  93306. * @returns the matrix
  93307. */
  93308. TransformNode.prototype.getPivotMatrix = function () {
  93309. return this._pivotMatrix;
  93310. };
  93311. /**
  93312. * Prevents the World matrix to be computed any longer.
  93313. * @returns the TransformNode.
  93314. */
  93315. TransformNode.prototype.freezeWorldMatrix = function () {
  93316. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  93317. this.computeWorldMatrix(true);
  93318. this._isWorldMatrixFrozen = true;
  93319. return this;
  93320. };
  93321. /**
  93322. * Allows back the World matrix computation.
  93323. * @returns the TransformNode.
  93324. */
  93325. TransformNode.prototype.unfreezeWorldMatrix = function () {
  93326. this._isWorldMatrixFrozen = false;
  93327. this.computeWorldMatrix(true);
  93328. return this;
  93329. };
  93330. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  93331. /**
  93332. * True if the World matrix has been frozen.
  93333. */
  93334. get: function () {
  93335. return this._isWorldMatrixFrozen;
  93336. },
  93337. enumerable: true,
  93338. configurable: true
  93339. });
  93340. /**
  93341. * Retuns the mesh absolute position in the World.
  93342. * @returns a Vector3.
  93343. */
  93344. TransformNode.prototype.getAbsolutePosition = function () {
  93345. this.computeWorldMatrix();
  93346. return this._absolutePosition;
  93347. };
  93348. /**
  93349. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93350. * @param absolutePosition the absolute position to set
  93351. * @returns the TransformNode.
  93352. */
  93353. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  93354. if (!absolutePosition) {
  93355. return this;
  93356. }
  93357. var absolutePositionX;
  93358. var absolutePositionY;
  93359. var absolutePositionZ;
  93360. if (absolutePosition.x === undefined) {
  93361. if (arguments.length < 3) {
  93362. return this;
  93363. }
  93364. absolutePositionX = arguments[0];
  93365. absolutePositionY = arguments[1];
  93366. absolutePositionZ = arguments[2];
  93367. }
  93368. else {
  93369. absolutePositionX = absolutePosition.x;
  93370. absolutePositionY = absolutePosition.y;
  93371. absolutePositionZ = absolutePosition.z;
  93372. }
  93373. if (this.parent) {
  93374. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93375. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  93376. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  93377. }
  93378. else {
  93379. this.position.x = absolutePositionX;
  93380. this.position.y = absolutePositionY;
  93381. this.position.z = absolutePositionZ;
  93382. }
  93383. return this;
  93384. };
  93385. /**
  93386. * Sets the mesh position in its local space.
  93387. * @param vector3 the position to set in localspace
  93388. * @returns the TransformNode.
  93389. */
  93390. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  93391. this.computeWorldMatrix();
  93392. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  93393. return this;
  93394. };
  93395. /**
  93396. * Returns the mesh position in the local space from the current World matrix values.
  93397. * @returns a new Vector3.
  93398. */
  93399. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  93400. this.computeWorldMatrix();
  93401. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93402. this._localMatrix.invertToRef(invLocalWorldMatrix);
  93403. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  93404. };
  93405. /**
  93406. * Translates the mesh along the passed Vector3 in its local space.
  93407. * @param vector3 the distance to translate in localspace
  93408. * @returns the TransformNode.
  93409. */
  93410. TransformNode.prototype.locallyTranslate = function (vector3) {
  93411. this.computeWorldMatrix(true);
  93412. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  93413. return this;
  93414. };
  93415. /**
  93416. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93417. * @param targetPoint the position (must be in same space as current mesh) to look at
  93418. * @param yawCor optional yaw (y-axis) correction in radians
  93419. * @param pitchCor optional pitch (x-axis) correction in radians
  93420. * @param rollCor optional roll (z-axis) correction in radians
  93421. * @param space the choosen space of the target
  93422. * @returns the TransformNode.
  93423. */
  93424. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  93425. if (yawCor === void 0) { yawCor = 0; }
  93426. if (pitchCor === void 0) { pitchCor = 0; }
  93427. if (rollCor === void 0) { rollCor = 0; }
  93428. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  93429. var dv = TransformNode._lookAtVectorCache;
  93430. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  93431. targetPoint.subtractToRef(pos, dv);
  93432. this.setDirection(dv, yawCor, pitchCor, rollCor);
  93433. // Correct for parent's rotation offset
  93434. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  93435. if (this.rotationQuaternion) {
  93436. // Get local rotation matrix of the looking object
  93437. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93438. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  93439. // Offset rotation by parent's inverted rotation matrix to correct in world space
  93440. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  93441. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  93442. parentRotationMatrix.invert();
  93443. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  93444. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  93445. }
  93446. else {
  93447. // Get local rotation matrix of the looking object
  93448. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  93449. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  93450. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93451. quaternionRotation.toRotationMatrix(rotationMatrix);
  93452. // Offset rotation by parent's inverted rotation matrix to correct in world space
  93453. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  93454. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  93455. parentRotationMatrix.invert();
  93456. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  93457. quaternionRotation.fromRotationMatrix(rotationMatrix);
  93458. quaternionRotation.toEulerAnglesToRef(this.rotation);
  93459. }
  93460. }
  93461. return this;
  93462. };
  93463. /**
  93464. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93465. * This Vector3 is expressed in the World space.
  93466. * @param localAxis axis to rotate
  93467. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93468. */
  93469. TransformNode.prototype.getDirection = function (localAxis) {
  93470. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93471. this.getDirectionToRef(localAxis, result);
  93472. return result;
  93473. };
  93474. /**
  93475. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93476. * localAxis is expressed in the mesh local space.
  93477. * result is computed in the Wordl space from the mesh World matrix.
  93478. * @param localAxis axis to rotate
  93479. * @param result the resulting transformnode
  93480. * @returns this TransformNode.
  93481. */
  93482. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  93483. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  93484. return this;
  93485. };
  93486. /**
  93487. * Sets this transform node rotation to the given local axis.
  93488. * @param localAxis the axis in local space
  93489. * @param yawCor optional yaw (y-axis) correction in radians
  93490. * @param pitchCor optional pitch (x-axis) correction in radians
  93491. * @param rollCor optional roll (z-axis) correction in radians
  93492. * @returns this TransformNode
  93493. */
  93494. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  93495. if (yawCor === void 0) { yawCor = 0; }
  93496. if (pitchCor === void 0) { pitchCor = 0; }
  93497. if (rollCor === void 0) { rollCor = 0; }
  93498. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  93499. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  93500. var pitch = -Math.atan2(localAxis.y, len);
  93501. if (this.rotationQuaternion) {
  93502. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  93503. }
  93504. else {
  93505. this.rotation.x = pitch + pitchCor;
  93506. this.rotation.y = yaw + yawCor;
  93507. this.rotation.z = rollCor;
  93508. }
  93509. return this;
  93510. };
  93511. /**
  93512. * Sets a new pivot point to the current node
  93513. * @param point defines the new pivot point to use
  93514. * @param space defines if the point is in world or local space (local by default)
  93515. * @returns the current TransformNode
  93516. */
  93517. TransformNode.prototype.setPivotPoint = function (point, space) {
  93518. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  93519. if (this.getScene().getRenderId() == 0) {
  93520. this.computeWorldMatrix(true);
  93521. }
  93522. var wm = this.getWorldMatrix();
  93523. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  93524. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93525. wm.invertToRef(tmat);
  93526. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  93527. }
  93528. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  93529. };
  93530. /**
  93531. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93532. * @returns the pivot point
  93533. */
  93534. TransformNode.prototype.getPivotPoint = function () {
  93535. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93536. this.getPivotPointToRef(point);
  93537. return point;
  93538. };
  93539. /**
  93540. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93541. * @param result the vector3 to store the result
  93542. * @returns this TransformNode.
  93543. */
  93544. TransformNode.prototype.getPivotPointToRef = function (result) {
  93545. result.x = -this._pivotMatrix.m[12];
  93546. result.y = -this._pivotMatrix.m[13];
  93547. result.z = -this._pivotMatrix.m[14];
  93548. return this;
  93549. };
  93550. /**
  93551. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93552. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93553. */
  93554. TransformNode.prototype.getAbsolutePivotPoint = function () {
  93555. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93556. this.getAbsolutePivotPointToRef(point);
  93557. return point;
  93558. };
  93559. /**
  93560. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93561. * @param result vector3 to store the result
  93562. * @returns this TransformNode.
  93563. */
  93564. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  93565. result.x = this._pivotMatrix.m[12];
  93566. result.y = this._pivotMatrix.m[13];
  93567. result.z = this._pivotMatrix.m[14];
  93568. this.getPivotPointToRef(result);
  93569. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  93570. return this;
  93571. };
  93572. /**
  93573. * Defines the passed node as the parent of the current node.
  93574. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93575. * @see https://doc.babylonjs.com/how_to/parenting
  93576. * @param node the node ot set as the parent
  93577. * @returns this TransformNode.
  93578. */
  93579. TransformNode.prototype.setParent = function (node) {
  93580. if (!node && !this.parent) {
  93581. return this;
  93582. }
  93583. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  93584. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  93585. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  93586. if (!node) {
  93587. if (this.parent && this.parent.computeWorldMatrix) {
  93588. this.parent.computeWorldMatrix(true);
  93589. }
  93590. this.computeWorldMatrix(true);
  93591. this.getWorldMatrix().decompose(scale, quatRotation, position);
  93592. }
  93593. else {
  93594. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93595. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  93596. this.computeWorldMatrix(true);
  93597. node.computeWorldMatrix(true);
  93598. node.getWorldMatrix().invertToRef(invParentMatrix);
  93599. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  93600. diffMatrix.decompose(scale, quatRotation, position);
  93601. }
  93602. if (this.rotationQuaternion) {
  93603. this.rotationQuaternion.copyFrom(quatRotation);
  93604. }
  93605. else {
  93606. quatRotation.toEulerAnglesToRef(this.rotation);
  93607. }
  93608. this.scaling.copyFrom(scale);
  93609. this.position.copyFrom(position);
  93610. this.parent = node;
  93611. return this;
  93612. };
  93613. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  93614. /**
  93615. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93616. */
  93617. get: function () {
  93618. return this._nonUniformScaling;
  93619. },
  93620. enumerable: true,
  93621. configurable: true
  93622. });
  93623. /** @hidden */
  93624. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  93625. if (this._nonUniformScaling === value) {
  93626. return false;
  93627. }
  93628. this._nonUniformScaling = value;
  93629. return true;
  93630. };
  93631. /**
  93632. * Attach the current TransformNode to another TransformNode associated with a bone
  93633. * @param bone Bone affecting the TransformNode
  93634. * @param affectedTransformNode TransformNode associated with the bone
  93635. * @returns this object
  93636. */
  93637. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  93638. this._transformToBoneReferal = affectedTransformNode;
  93639. this.parent = bone;
  93640. if (bone.getWorldMatrix().determinant() < 0) {
  93641. this.scalingDeterminant *= -1;
  93642. }
  93643. return this;
  93644. };
  93645. /**
  93646. * Detach the transform node if its associated with a bone
  93647. * @returns this object
  93648. */
  93649. TransformNode.prototype.detachFromBone = function () {
  93650. if (!this.parent) {
  93651. return this;
  93652. }
  93653. if (this.parent.getWorldMatrix().determinant() < 0) {
  93654. this.scalingDeterminant *= -1;
  93655. }
  93656. this._transformToBoneReferal = null;
  93657. this.parent = null;
  93658. return this;
  93659. };
  93660. /**
  93661. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93662. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93663. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93664. * The passed axis is also normalized.
  93665. * @param axis the axis to rotate around
  93666. * @param amount the amount to rotate in radians
  93667. * @param space Space to rotate in (Default: local)
  93668. * @returns the TransformNode.
  93669. */
  93670. TransformNode.prototype.rotate = function (axis, amount, space) {
  93671. axis.normalize();
  93672. if (!this.rotationQuaternion) {
  93673. this.rotationQuaternion = this.rotation.toQuaternion();
  93674. this.rotation.setAll(0);
  93675. }
  93676. var rotationQuaternion;
  93677. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  93678. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  93679. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  93680. }
  93681. else {
  93682. if (this.parent) {
  93683. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93684. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  93685. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  93686. }
  93687. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  93688. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  93689. }
  93690. return this;
  93691. };
  93692. /**
  93693. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93694. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93695. * The passed axis is also normalized. .
  93696. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93697. * @param point the point to rotate around
  93698. * @param axis the axis to rotate around
  93699. * @param amount the amount to rotate in radians
  93700. * @returns the TransformNode
  93701. */
  93702. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  93703. axis.normalize();
  93704. if (!this.rotationQuaternion) {
  93705. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  93706. this.rotation.setAll(0);
  93707. }
  93708. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  93709. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  93710. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  93711. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  93712. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  93713. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  93714. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  93715. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  93716. point.subtractToRef(this.position, tmpVector);
  93717. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  93718. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  93719. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  93720. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  93721. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  93722. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  93723. this.position.addInPlace(finalTranslation);
  93724. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  93725. return this;
  93726. };
  93727. /**
  93728. * Translates the mesh along the axis vector for the passed distance in the given space.
  93729. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93730. * @param axis the axis to translate in
  93731. * @param distance the distance to translate
  93732. * @param space Space to rotate in (Default: local)
  93733. * @returns the TransformNode.
  93734. */
  93735. TransformNode.prototype.translate = function (axis, distance, space) {
  93736. var displacementVector = axis.scale(distance);
  93737. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  93738. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  93739. this.setPositionWithLocalVector(tempV3);
  93740. }
  93741. else {
  93742. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  93743. }
  93744. return this;
  93745. };
  93746. /**
  93747. * Adds a rotation step to the mesh current rotation.
  93748. * x, y, z are Euler angles expressed in radians.
  93749. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93750. * This means this rotation is made in the mesh local space only.
  93751. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93752. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93753. * ```javascript
  93754. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93755. * ```
  93756. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93757. * 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.
  93758. * @param x Rotation to add
  93759. * @param y Rotation to add
  93760. * @param z Rotation to add
  93761. * @returns the TransformNode.
  93762. */
  93763. TransformNode.prototype.addRotation = function (x, y, z) {
  93764. var rotationQuaternion;
  93765. if (this.rotationQuaternion) {
  93766. rotationQuaternion = this.rotationQuaternion;
  93767. }
  93768. else {
  93769. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  93770. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  93771. }
  93772. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  93773. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  93774. rotationQuaternion.multiplyInPlace(accumulation);
  93775. if (!this.rotationQuaternion) {
  93776. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  93777. }
  93778. return this;
  93779. };
  93780. /**
  93781. * Computes the world matrix of the node
  93782. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93783. * @returns the world matrix
  93784. */
  93785. TransformNode.prototype.computeWorldMatrix = function (force) {
  93786. if (this._isWorldMatrixFrozen) {
  93787. return this._worldMatrix;
  93788. }
  93789. if (!force && this.isSynchronized()) {
  93790. this._currentRenderId = this.getScene().getRenderId();
  93791. return this._worldMatrix;
  93792. }
  93793. this._updateCache();
  93794. this._cache.position.copyFrom(this.position);
  93795. this._cache.scaling.copyFrom(this.scaling);
  93796. this._cache.pivotMatrixUpdated = false;
  93797. this._cache.billboardMode = this.billboardMode;
  93798. this._cache.infiniteDistance = this.infiniteDistance;
  93799. this._currentRenderId = this.getScene().getRenderId();
  93800. this._childRenderId = this.getScene().getRenderId();
  93801. this._isDirty = false;
  93802. // Scaling
  93803. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]);
  93804. // Rotation
  93805. //rotate, if quaternion is set and rotation was used
  93806. if (this.rotationQuaternion) {
  93807. var len = this.rotation.length();
  93808. if (len) {
  93809. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  93810. this.rotation.copyFromFloats(0, 0, 0);
  93811. }
  93812. }
  93813. if (this.rotationQuaternion) {
  93814. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93815. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  93816. }
  93817. else {
  93818. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93819. this._cache.rotation.copyFrom(this.rotation);
  93820. }
  93821. // Translation
  93822. var camera = this.getScene().activeCamera;
  93823. if (this.infiniteDistance && !this.parent && camera) {
  93824. var cameraWorldMatrix = camera.getWorldMatrix();
  93825. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  93826. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, this._tempMatrix2);
  93827. }
  93828. else {
  93829. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._tempMatrix2);
  93830. }
  93831. // Composing transformations
  93832. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  93833. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._tempMatrix);
  93834. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  93835. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  93836. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  93837. // Need to decompose each rotation here
  93838. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[3];
  93839. if (this.parent && this.parent.getWorldMatrix) {
  93840. if (this._transformToBoneReferal) {
  93841. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  93842. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6], currentPosition);
  93843. }
  93844. else {
  93845. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  93846. }
  93847. }
  93848. else {
  93849. currentPosition.copyFrom(this.position);
  93850. }
  93851. currentPosition.subtractInPlace(camera.globalPosition);
  93852. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  93853. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  93854. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  93855. }
  93856. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  93857. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  93858. }
  93859. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  93860. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  93861. }
  93862. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93863. }
  93864. else {
  93865. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  93866. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  93867. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93868. }
  93869. if (this._scene.useRightHandedSystem) {
  93870. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1, 1, -1, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]);
  93871. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93872. }
  93873. this._tempMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._tempMatrix);
  93874. }
  93875. // Post multiply inverse of pivotMatrix
  93876. if (this._postMultiplyPivotMatrix) {
  93877. this._tempMatrix.multiplyToRef(this._pivotMatrixInverse, this._tempMatrix);
  93878. }
  93879. // Local world
  93880. this._tempMatrix.multiplyToRef(this._tempMatrix2, this._localMatrix);
  93881. // Parent
  93882. if (this.parent && this.parent.getWorldMatrix) {
  93883. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  93884. if (this._transformToBoneReferal) {
  93885. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  93886. }
  93887. else {
  93888. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].copyFrom(this.parent.getWorldMatrix());
  93889. }
  93890. // Extract scaling and translation from parent
  93891. var translation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5];
  93892. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[6];
  93893. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].decompose(scale, undefined, translation);
  93894. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scale.x, scale.y, scale.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  93895. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].setTranslation(translation);
  93896. this._localMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7], this._worldMatrix);
  93897. }
  93898. else {
  93899. if (this._transformToBoneReferal) {
  93900. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  93901. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  93902. }
  93903. else {
  93904. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  93905. }
  93906. }
  93907. this._markSyncedWithParent();
  93908. }
  93909. else {
  93910. this._worldMatrix.copyFrom(this._localMatrix);
  93911. }
  93912. // Normal matrix
  93913. if (!this.ignoreNonUniformScaling) {
  93914. if (this.scaling.isNonUniform) {
  93915. this._updateNonUniformScalingState(true);
  93916. }
  93917. else if (this.parent && this.parent._nonUniformScaling) {
  93918. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  93919. }
  93920. else {
  93921. this._updateNonUniformScalingState(false);
  93922. }
  93923. }
  93924. else {
  93925. this._updateNonUniformScalingState(false);
  93926. }
  93927. this._afterComputeWorldMatrix();
  93928. // Absolute position
  93929. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  93930. // Callbacks
  93931. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  93932. if (!this._poseMatrix) {
  93933. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  93934. }
  93935. // Cache the determinant
  93936. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  93937. return this._worldMatrix;
  93938. };
  93939. TransformNode.prototype._afterComputeWorldMatrix = function () {
  93940. };
  93941. /**
  93942. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93943. * @param func callback function to add
  93944. *
  93945. * @returns the TransformNode.
  93946. */
  93947. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  93948. this.onAfterWorldMatrixUpdateObservable.add(func);
  93949. return this;
  93950. };
  93951. /**
  93952. * Removes a registered callback function.
  93953. * @param func callback function to remove
  93954. * @returns the TransformNode.
  93955. */
  93956. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  93957. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  93958. return this;
  93959. };
  93960. /**
  93961. * Gets the position of the current mesh in camera space
  93962. * @param camera defines the camera to use
  93963. * @returns a position
  93964. */
  93965. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  93966. if (camera === void 0) { camera = null; }
  93967. if (!camera) {
  93968. camera = this.getScene().activeCamera;
  93969. }
  93970. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  93971. };
  93972. /**
  93973. * Returns the distance from the mesh to the active camera
  93974. * @param camera defines the camera to use
  93975. * @returns the distance
  93976. */
  93977. TransformNode.prototype.getDistanceToCamera = function (camera) {
  93978. if (camera === void 0) { camera = null; }
  93979. if (!camera) {
  93980. camera = this.getScene().activeCamera;
  93981. }
  93982. return this.absolutePosition.subtract(camera.position).length();
  93983. };
  93984. /**
  93985. * Clone the current transform node
  93986. * @param name Name of the new clone
  93987. * @param newParent New parent for the clone
  93988. * @param doNotCloneChildren Do not clone children hierarchy
  93989. * @returns the new transform node
  93990. */
  93991. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  93992. var _this = this;
  93993. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  93994. result.name = name;
  93995. result.id = name;
  93996. if (newParent) {
  93997. result.parent = newParent;
  93998. }
  93999. if (!doNotCloneChildren) {
  94000. // Children
  94001. var directDescendants = this.getDescendants(true);
  94002. for (var index = 0; index < directDescendants.length; index++) {
  94003. var child = directDescendants[index];
  94004. if (child.clone) {
  94005. child.clone(name + "." + child.name, result);
  94006. }
  94007. }
  94008. }
  94009. return result;
  94010. };
  94011. /**
  94012. * Serializes the objects information.
  94013. * @param currentSerializationObject defines the object to serialize in
  94014. * @returns the serialized object
  94015. */
  94016. TransformNode.prototype.serialize = function (currentSerializationObject) {
  94017. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  94018. serializationObject.type = this.getClassName();
  94019. // Parent
  94020. if (this.parent) {
  94021. serializationObject.parentId = this.parent.id;
  94022. }
  94023. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  94024. serializationObject.isEnabled = this.isEnabled();
  94025. // Parent
  94026. if (this.parent) {
  94027. serializationObject.parentId = this.parent.id;
  94028. }
  94029. return serializationObject;
  94030. };
  94031. // Statics
  94032. /**
  94033. * Returns a new TransformNode object parsed from the source provided.
  94034. * @param parsedTransformNode is the source.
  94035. * @param scene the scne the object belongs to
  94036. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94037. * @returns a new TransformNode object parsed from the source provided.
  94038. */
  94039. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  94040. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  94041. if (parsedTransformNode.localMatrix) {
  94042. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  94043. }
  94044. else if (parsedTransformNode.pivotMatrix) {
  94045. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  94046. }
  94047. transformNode.setEnabled(parsedTransformNode.isEnabled);
  94048. // Parent
  94049. if (parsedTransformNode.parentId) {
  94050. transformNode._waitingParentId = parsedTransformNode.parentId;
  94051. }
  94052. return transformNode;
  94053. };
  94054. /**
  94055. * Get all child-transformNodes of this node
  94056. * @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
  94057. * @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
  94058. * @returns an array of TransformNode
  94059. */
  94060. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  94061. var results = [];
  94062. this._getDescendants(results, directDescendantsOnly, function (node) {
  94063. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  94064. });
  94065. return results;
  94066. };
  94067. /**
  94068. * Releases resources associated with this transform node.
  94069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94071. */
  94072. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  94073. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  94074. // Animations
  94075. this.getScene().stopAnimation(this);
  94076. // Remove from scene
  94077. this.getScene().removeTransformNode(this);
  94078. this.onAfterWorldMatrixUpdateObservable.clear();
  94079. if (doNotRecurse) {
  94080. var transformNodes = this.getChildTransformNodes(true);
  94081. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  94082. var transformNode = transformNodes_1[_i];
  94083. transformNode.parent = null;
  94084. transformNode.computeWorldMatrix(true);
  94085. }
  94086. }
  94087. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  94088. };
  94089. // Statics
  94090. /**
  94091. * Object will not rotate to face the camera
  94092. */
  94093. TransformNode.BILLBOARDMODE_NONE = 0;
  94094. /**
  94095. * Object will rotate to face the camera but only on the x axis
  94096. */
  94097. TransformNode.BILLBOARDMODE_X = 1;
  94098. /**
  94099. * Object will rotate to face the camera but only on the y axis
  94100. */
  94101. TransformNode.BILLBOARDMODE_Y = 2;
  94102. /**
  94103. * Object will rotate to face the camera but only on the z axis
  94104. */
  94105. TransformNode.BILLBOARDMODE_Z = 4;
  94106. /**
  94107. * Object will rotate to face the camera
  94108. */
  94109. TransformNode.BILLBOARDMODE_ALL = 7;
  94110. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  94111. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  94112. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  94114. ], TransformNode.prototype, "_position", void 0);
  94115. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  94117. ], TransformNode.prototype, "_rotation", void 0);
  94118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  94120. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  94121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  94123. ], TransformNode.prototype, "_scaling", void 0);
  94124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  94126. ], TransformNode.prototype, "billboardMode", void 0);
  94127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  94129. ], TransformNode.prototype, "scalingDeterminant", void 0);
  94130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  94132. ], TransformNode.prototype, "infiniteDistance", void 0);
  94133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  94135. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  94136. return TransformNode;
  94137. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  94138. /***/ }),
  94139. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  94140. /*!***************************************************************!*\
  94141. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  94142. \***************************************************************/
  94143. /*! exports provided: CubeMapToSphericalPolynomialTools */
  94144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94145. "use strict";
  94146. __webpack_require__.r(__webpack_exports__);
  94147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  94148. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  94149. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  94150. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  94151. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  94152. var FileFaceOrientation = /** @class */ (function () {
  94153. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  94154. this.name = name;
  94155. this.worldAxisForNormal = worldAxisForNormal;
  94156. this.worldAxisForFileX = worldAxisForFileX;
  94157. this.worldAxisForFileY = worldAxisForFileY;
  94158. }
  94159. return FileFaceOrientation;
  94160. }());
  94161. /**
  94162. * Helper class dealing with the extraction of spherical polynomial dataArray
  94163. * from a cube map.
  94164. */
  94165. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  94166. function CubeMapToSphericalPolynomialTools() {
  94167. }
  94168. /**
  94169. * Converts a texture to the according Spherical Polynomial data.
  94170. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94171. *
  94172. * @param texture The texture to extract the information from.
  94173. * @return The Spherical Polynomial data.
  94174. */
  94175. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  94176. if (!texture.isCube) {
  94177. // Only supports cube Textures currently.
  94178. return null;
  94179. }
  94180. var size = texture.getSize().width;
  94181. var right = texture.readPixels(0);
  94182. var left = texture.readPixels(1);
  94183. var up;
  94184. var down;
  94185. if (texture.isRenderTarget) {
  94186. up = texture.readPixels(3);
  94187. down = texture.readPixels(2);
  94188. }
  94189. else {
  94190. up = texture.readPixels(2);
  94191. down = texture.readPixels(3);
  94192. }
  94193. var front = texture.readPixels(4);
  94194. var back = texture.readPixels(5);
  94195. var gammaSpace = texture.gammaSpace;
  94196. // Always read as RGBA.
  94197. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  94198. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94199. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  94200. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  94201. }
  94202. var cubeInfo = {
  94203. size: size,
  94204. right: right,
  94205. left: left,
  94206. up: up,
  94207. down: down,
  94208. front: front,
  94209. back: back,
  94210. format: format,
  94211. type: type,
  94212. gammaSpace: gammaSpace,
  94213. };
  94214. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  94215. };
  94216. /**
  94217. * Converts a cubemap to the according Spherical Polynomial data.
  94218. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94219. *
  94220. * @param cubeInfo The Cube map to extract the information from.
  94221. * @return The Spherical Polynomial data.
  94222. */
  94223. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  94224. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  94225. var totalSolidAngle = 0.0;
  94226. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  94227. var du = 2.0 / cubeInfo.size;
  94228. var dv = du;
  94229. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  94230. var minUV = du * 0.5 - 1.0;
  94231. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  94232. var fileFace = this.FileFaces[faceIndex];
  94233. var dataArray = cubeInfo[fileFace.name];
  94234. var v = minUV;
  94235. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  94236. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  94237. // Because SP is still linear, so summation is fine in that basis.
  94238. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  94239. for (var y = 0; y < cubeInfo.size; y++) {
  94240. var u = minUV;
  94241. for (var x = 0; x < cubeInfo.size; x++) {
  94242. // World direction (not normalised)
  94243. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  94244. worldDirection.normalize();
  94245. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  94246. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  94247. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  94248. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  94249. // Handle Integer types.
  94250. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  94251. r /= 255;
  94252. g /= 255;
  94253. b /= 255;
  94254. }
  94255. // Handle Gamma space textures.
  94256. if (cubeInfo.gammaSpace) {
  94257. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  94258. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  94259. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  94260. }
  94261. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  94262. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  94263. totalSolidAngle += deltaSolidAngle;
  94264. u += du;
  94265. }
  94266. v += dv;
  94267. }
  94268. }
  94269. // Solid angle for entire sphere is 4*pi
  94270. var sphereSolidAngle = 4.0 * Math.PI;
  94271. // Adjust the solid angle to allow for how many faces we processed.
  94272. var facesProcessed = 6.0;
  94273. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  94274. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  94275. // This is needed because the numerical integration over the cube uses a
  94276. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  94277. // and also to compensate for accumulative error due to float precision in the summation.
  94278. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  94279. sphericalHarmonics.scale(correctionFactor);
  94280. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  94281. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  94282. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  94283. };
  94284. CubeMapToSphericalPolynomialTools.FileFaces = [
  94285. 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)),
  94286. 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)),
  94287. 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)),
  94288. 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)),
  94289. 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)),
  94290. 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
  94291. ];
  94292. return CubeMapToSphericalPolynomialTools;
  94293. }());
  94294. /***/ }),
  94295. /***/ "./Misc/HighDynamicRange/hdr.ts":
  94296. /*!**************************************!*\
  94297. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  94298. \**************************************/
  94299. /*! exports provided: HDRTools */
  94300. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94301. "use strict";
  94302. __webpack_require__.r(__webpack_exports__);
  94303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  94304. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  94305. /**
  94306. * This groups tools to convert HDR texture to native colors array.
  94307. */
  94308. var HDRTools = /** @class */ (function () {
  94309. function HDRTools() {
  94310. }
  94311. HDRTools.Ldexp = function (mantissa, exponent) {
  94312. if (exponent > 1023) {
  94313. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  94314. }
  94315. if (exponent < -1074) {
  94316. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  94317. }
  94318. return mantissa * Math.pow(2, exponent);
  94319. };
  94320. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  94321. if (exponent > 0) { /*nonzero pixel*/
  94322. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  94323. float32array[index + 0] = red * exponent;
  94324. float32array[index + 1] = green * exponent;
  94325. float32array[index + 2] = blue * exponent;
  94326. }
  94327. else {
  94328. float32array[index + 0] = 0;
  94329. float32array[index + 1] = 0;
  94330. float32array[index + 2] = 0;
  94331. }
  94332. };
  94333. HDRTools.readStringLine = function (uint8array, startIndex) {
  94334. var line = "";
  94335. var character = "";
  94336. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  94337. character = String.fromCharCode(uint8array[i]);
  94338. if (character == "\n") {
  94339. break;
  94340. }
  94341. line += character;
  94342. }
  94343. return line;
  94344. };
  94345. /**
  94346. * Reads header information from an RGBE texture stored in a native array.
  94347. * More information on this format are available here:
  94348. * https://en.wikipedia.org/wiki/RGBE_image_format
  94349. *
  94350. * @param uint8array The binary file stored in native array.
  94351. * @return The header information.
  94352. */
  94353. HDRTools.RGBE_ReadHeader = function (uint8array) {
  94354. var height = 0;
  94355. var width = 0;
  94356. var line = this.readStringLine(uint8array, 0);
  94357. if (line[0] != '#' || line[1] != '?') {
  94358. throw "Bad HDR Format.";
  94359. }
  94360. var endOfHeader = false;
  94361. var findFormat = false;
  94362. var lineIndex = 0;
  94363. do {
  94364. lineIndex += (line.length + 1);
  94365. line = this.readStringLine(uint8array, lineIndex);
  94366. if (line == "FORMAT=32-bit_rle_rgbe") {
  94367. findFormat = true;
  94368. }
  94369. else if (line.length == 0) {
  94370. endOfHeader = true;
  94371. }
  94372. } while (!endOfHeader);
  94373. if (!findFormat) {
  94374. throw "HDR Bad header format, unsupported FORMAT";
  94375. }
  94376. lineIndex += (line.length + 1);
  94377. line = this.readStringLine(uint8array, lineIndex);
  94378. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  94379. var match = sizeRegexp.exec(line);
  94380. // TODO. Support +Y and -X if needed.
  94381. if (!match || match.length < 3) {
  94382. throw "HDR Bad header format, no size";
  94383. }
  94384. width = parseInt(match[2]);
  94385. height = parseInt(match[1]);
  94386. if (width < 8 || width > 0x7fff) {
  94387. throw "HDR Bad header format, unsupported size";
  94388. }
  94389. lineIndex += (line.length + 1);
  94390. return {
  94391. height: height,
  94392. width: width,
  94393. dataPosition: lineIndex
  94394. };
  94395. };
  94396. /**
  94397. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  94398. * This RGBE texture needs to store the information as a panorama.
  94399. *
  94400. * More information on this format are available here:
  94401. * https://en.wikipedia.org/wiki/RGBE_image_format
  94402. *
  94403. * @param buffer The binary file stored in an array buffer.
  94404. * @param size The expected size of the extracted cubemap.
  94405. * @return The Cube Map information.
  94406. */
  94407. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  94408. var uint8array = new Uint8Array(buffer);
  94409. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  94410. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  94411. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  94412. return cubeMapData;
  94413. };
  94414. /**
  94415. * Returns the pixels data extracted from an RGBE texture.
  94416. * This pixels will be stored left to right up to down in the R G B order in one array.
  94417. *
  94418. * More information on this format are available here:
  94419. * https://en.wikipedia.org/wiki/RGBE_image_format
  94420. *
  94421. * @param uint8array The binary file stored in an array buffer.
  94422. * @param hdrInfo The header information of the file.
  94423. * @return The pixels data in RGB right to left up to down order.
  94424. */
  94425. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  94426. // Keep for multi format supports.
  94427. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  94428. };
  94429. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  94430. var num_scanlines = hdrInfo.height;
  94431. var scanline_width = hdrInfo.width;
  94432. var a, b, c, d, count;
  94433. var dataIndex = hdrInfo.dataPosition;
  94434. var index = 0, endIndex = 0, i = 0;
  94435. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  94436. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  94437. // 3 channels of 4 bytes per pixel in float.
  94438. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  94439. var resultArray = new Float32Array(resultBuffer);
  94440. // read in each successive scanline
  94441. while (num_scanlines > 0) {
  94442. a = uint8array[dataIndex++];
  94443. b = uint8array[dataIndex++];
  94444. c = uint8array[dataIndex++];
  94445. d = uint8array[dataIndex++];
  94446. if (a != 2 || b != 2 || (c & 0x80)) {
  94447. // this file is not run length encoded
  94448. throw "HDR Bad header format, not RLE";
  94449. }
  94450. if (((c << 8) | d) != scanline_width) {
  94451. throw "HDR Bad header format, wrong scan line width";
  94452. }
  94453. index = 0;
  94454. // read each of the four channels for the scanline into the buffer
  94455. for (i = 0; i < 4; i++) {
  94456. endIndex = (i + 1) * scanline_width;
  94457. while (index < endIndex) {
  94458. a = uint8array[dataIndex++];
  94459. b = uint8array[dataIndex++];
  94460. if (a > 128) {
  94461. // a run of the same value
  94462. count = a - 128;
  94463. if ((count == 0) || (count > endIndex - index)) {
  94464. throw "HDR Bad Format, bad scanline data (run)";
  94465. }
  94466. while (count-- > 0) {
  94467. scanLineArray[index++] = b;
  94468. }
  94469. }
  94470. else {
  94471. // a non-run
  94472. count = a;
  94473. if ((count == 0) || (count > endIndex - index)) {
  94474. throw "HDR Bad Format, bad scanline data (non-run)";
  94475. }
  94476. scanLineArray[index++] = b;
  94477. if (--count > 0) {
  94478. for (var j = 0; j < count; j++) {
  94479. scanLineArray[index++] = uint8array[dataIndex++];
  94480. }
  94481. }
  94482. }
  94483. }
  94484. }
  94485. // now convert data from buffer into floats
  94486. for (i = 0; i < scanline_width; i++) {
  94487. a = scanLineArray[i];
  94488. b = scanLineArray[i + scanline_width];
  94489. c = scanLineArray[i + 2 * scanline_width];
  94490. d = scanLineArray[i + 3 * scanline_width];
  94491. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  94492. }
  94493. num_scanlines--;
  94494. }
  94495. return resultArray;
  94496. };
  94497. return HDRTools;
  94498. }());
  94499. /***/ }),
  94500. /***/ "./Misc/HighDynamicRange/index.ts":
  94501. /*!****************************************!*\
  94502. !*** ./Misc/HighDynamicRange/index.ts ***!
  94503. \****************************************/
  94504. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  94505. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94506. "use strict";
  94507. __webpack_require__.r(__webpack_exports__);
  94508. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  94509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  94510. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  94511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  94512. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  94513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  94514. /***/ }),
  94515. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  94516. /*!****************************************************!*\
  94517. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  94518. \****************************************************/
  94519. /*! exports provided: PanoramaToCubeMapTools */
  94520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94521. "use strict";
  94522. __webpack_require__.r(__webpack_exports__);
  94523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  94524. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  94525. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  94526. /**
  94527. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94528. */
  94529. var PanoramaToCubeMapTools = /** @class */ (function () {
  94530. function PanoramaToCubeMapTools() {
  94531. }
  94532. /**
  94533. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94534. *
  94535. * @param float32Array The source data.
  94536. * @param inputWidth The width of the input panorama.
  94537. * @param inputHeight The height of the input panorama.
  94538. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94539. * @return The cubemap data
  94540. */
  94541. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  94542. if (!float32Array) {
  94543. throw "ConvertPanoramaToCubemap: input cannot be null";
  94544. }
  94545. if (float32Array.length != inputWidth * inputHeight * 3) {
  94546. throw "ConvertPanoramaToCubemap: input size is wrong";
  94547. }
  94548. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  94549. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  94550. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  94551. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  94552. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  94553. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  94554. return {
  94555. front: textureFront,
  94556. back: textureBack,
  94557. left: textureLeft,
  94558. right: textureRight,
  94559. up: textureUp,
  94560. down: textureDown,
  94561. size: size,
  94562. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  94563. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  94564. gammaSpace: false,
  94565. };
  94566. };
  94567. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  94568. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  94569. var textureArray = new Float32Array(buffer);
  94570. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  94571. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  94572. var dy = 1 / texSize;
  94573. var fy = 0;
  94574. for (var y = 0; y < texSize; y++) {
  94575. var xv1 = faceData[0];
  94576. var xv2 = faceData[2];
  94577. for (var x = 0; x < texSize; x++) {
  94578. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  94579. v.normalize();
  94580. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  94581. // 3 channels per pixels
  94582. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  94583. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  94584. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  94585. xv1 = xv1.add(rotDX1);
  94586. xv2 = xv2.add(rotDX2);
  94587. }
  94588. fy += dy;
  94589. }
  94590. return textureArray;
  94591. };
  94592. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  94593. var theta = Math.atan2(vDir.z, vDir.x);
  94594. var phi = Math.acos(vDir.y);
  94595. while (theta < -Math.PI) {
  94596. theta += 2 * Math.PI;
  94597. }
  94598. while (theta > Math.PI) {
  94599. theta -= 2 * Math.PI;
  94600. }
  94601. var dx = theta / Math.PI;
  94602. var dy = phi / Math.PI;
  94603. // recenter.
  94604. dx = dx * 0.5 + 0.5;
  94605. var px = Math.round(dx * inputWidth);
  94606. if (px < 0) {
  94607. px = 0;
  94608. }
  94609. else if (px >= inputWidth) {
  94610. px = inputWidth - 1;
  94611. }
  94612. var py = Math.round(dy * inputHeight);
  94613. if (py < 0) {
  94614. py = 0;
  94615. }
  94616. else if (py >= inputHeight) {
  94617. py = inputHeight - 1;
  94618. }
  94619. var inputY = (inputHeight - py - 1);
  94620. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  94621. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  94622. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  94623. return {
  94624. r: r,
  94625. g: g,
  94626. b: b
  94627. };
  94628. };
  94629. PanoramaToCubeMapTools.FACE_FRONT = [
  94630. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  94631. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  94632. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  94633. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  94634. ];
  94635. PanoramaToCubeMapTools.FACE_BACK = [
  94636. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  94637. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  94638. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  94639. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  94640. ];
  94641. PanoramaToCubeMapTools.FACE_RIGHT = [
  94642. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  94643. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  94644. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  94645. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  94646. ];
  94647. PanoramaToCubeMapTools.FACE_LEFT = [
  94648. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  94649. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  94650. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  94651. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  94652. ];
  94653. PanoramaToCubeMapTools.FACE_DOWN = [
  94654. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  94655. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  94656. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  94657. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  94658. ];
  94659. PanoramaToCubeMapTools.FACE_UP = [
  94660. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  94661. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  94662. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  94663. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  94664. ];
  94665. return PanoramaToCubeMapTools;
  94666. }());
  94667. /***/ }),
  94668. /***/ "./Misc/andOrNotEvaluator.ts":
  94669. /*!***********************************!*\
  94670. !*** ./Misc/andOrNotEvaluator.ts ***!
  94671. \***********************************/
  94672. /*! exports provided: AndOrNotEvaluator */
  94673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94674. "use strict";
  94675. __webpack_require__.r(__webpack_exports__);
  94676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  94677. /**
  94678. * Class used to evalaute queries containing `and` and `or` operators
  94679. */
  94680. var AndOrNotEvaluator = /** @class */ (function () {
  94681. function AndOrNotEvaluator() {
  94682. }
  94683. /**
  94684. * Evaluate a query
  94685. * @param query defines the query to evaluate
  94686. * @param evaluateCallback defines the callback used to filter result
  94687. * @returns true if the query matches
  94688. */
  94689. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  94690. if (!query.match(/\([^\(\)]*\)/g)) {
  94691. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  94692. }
  94693. else {
  94694. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  94695. // remove parenthesis
  94696. r = r.slice(1, r.length - 1);
  94697. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  94698. });
  94699. }
  94700. if (query === "true") {
  94701. return true;
  94702. }
  94703. if (query === "false") {
  94704. return false;
  94705. }
  94706. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  94707. };
  94708. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  94709. evaluateCallback = evaluateCallback || (function (r) {
  94710. return r === "true" ? true : false;
  94711. });
  94712. var result;
  94713. var or = parenthesisContent.split("||");
  94714. for (var i in or) {
  94715. if (or.hasOwnProperty(i)) {
  94716. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  94717. var and = ori.split("&&");
  94718. if (and.length > 1) {
  94719. for (var j = 0; j < and.length; ++j) {
  94720. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  94721. if (andj !== "true" && andj !== "false") {
  94722. if (andj[0] === "!") {
  94723. result = !evaluateCallback(andj.substring(1));
  94724. }
  94725. else {
  94726. result = evaluateCallback(andj);
  94727. }
  94728. }
  94729. else {
  94730. result = andj === "true" ? true : false;
  94731. }
  94732. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  94733. ori = "false";
  94734. break;
  94735. }
  94736. }
  94737. }
  94738. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  94739. result = true;
  94740. break;
  94741. }
  94742. // result equals false (or undefined)
  94743. if (ori !== "true" && ori !== "false") {
  94744. if (ori[0] === "!") {
  94745. result = !evaluateCallback(ori.substring(1));
  94746. }
  94747. else {
  94748. result = evaluateCallback(ori);
  94749. }
  94750. }
  94751. else {
  94752. result = ori === "true" ? true : false;
  94753. }
  94754. }
  94755. }
  94756. // the whole parenthesis scope is replaced by 'true' or 'false'
  94757. return result ? "true" : "false";
  94758. };
  94759. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  94760. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  94761. // remove whitespaces
  94762. r = r.replace(/[\s]/g, function () { return ""; });
  94763. return r.length % 2 ? "!" : "";
  94764. });
  94765. booleanString = booleanString.trim();
  94766. if (booleanString === "!true") {
  94767. booleanString = "false";
  94768. }
  94769. else if (booleanString === "!false") {
  94770. booleanString = "true";
  94771. }
  94772. return booleanString;
  94773. };
  94774. return AndOrNotEvaluator;
  94775. }());
  94776. /***/ }),
  94777. /***/ "./Misc/arrayTools.ts":
  94778. /*!****************************!*\
  94779. !*** ./Misc/arrayTools.ts ***!
  94780. \****************************/
  94781. /*! exports provided: ArrayTools */
  94782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94783. "use strict";
  94784. __webpack_require__.r(__webpack_exports__);
  94785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  94786. /**
  94787. * Class containing a set of static utilities functions for arrays.
  94788. */
  94789. var ArrayTools = /** @class */ (function () {
  94790. function ArrayTools() {
  94791. }
  94792. /**
  94793. * Returns an array of the given size filled with element built from the given constructor and the paramters
  94794. * @param size the number of element to construct and put in the array
  94795. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  94796. * @returns a new array filled with new objects
  94797. */
  94798. ArrayTools.BuildArray = function (size, itemBuilder) {
  94799. var a = [];
  94800. for (var i = 0; i < size; ++i) {
  94801. a.push(itemBuilder());
  94802. }
  94803. return a;
  94804. };
  94805. return ArrayTools;
  94806. }());
  94807. /***/ }),
  94808. /***/ "./Misc/assetsManager.ts":
  94809. /*!*******************************!*\
  94810. !*** ./Misc/assetsManager.ts ***!
  94811. \*******************************/
  94812. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  94813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94814. "use strict";
  94815. __webpack_require__.r(__webpack_exports__);
  94816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  94817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  94818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  94819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  94820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  94821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  94822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  94823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  94824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  94825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  94826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  94827. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  94828. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  94829. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94830. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  94831. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  94832. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  94833. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  94834. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94835. /**
  94836. * Defines the list of states available for a task inside a AssetsManager
  94837. */
  94838. var AssetTaskState;
  94839. (function (AssetTaskState) {
  94840. /**
  94841. * Initialization
  94842. */
  94843. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  94844. /**
  94845. * Running
  94846. */
  94847. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  94848. /**
  94849. * Done
  94850. */
  94851. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  94852. /**
  94853. * Error
  94854. */
  94855. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  94856. })(AssetTaskState || (AssetTaskState = {}));
  94857. /**
  94858. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  94859. */
  94860. var AbstractAssetTask = /** @class */ (function () {
  94861. /**
  94862. * Creates a new AssetsManager
  94863. * @param name defines the name of the task
  94864. */
  94865. function AbstractAssetTask(
  94866. /**
  94867. * Task name
  94868. */ name) {
  94869. this.name = name;
  94870. this._isCompleted = false;
  94871. this._taskState = AssetTaskState.INIT;
  94872. }
  94873. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  94874. /**
  94875. * Get if the task is completed
  94876. */
  94877. get: function () {
  94878. return this._isCompleted;
  94879. },
  94880. enumerable: true,
  94881. configurable: true
  94882. });
  94883. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  94884. /**
  94885. * Gets the current state of the task
  94886. */
  94887. get: function () {
  94888. return this._taskState;
  94889. },
  94890. enumerable: true,
  94891. configurable: true
  94892. });
  94893. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  94894. /**
  94895. * Gets the current error object (if task is in error)
  94896. */
  94897. get: function () {
  94898. return this._errorObject;
  94899. },
  94900. enumerable: true,
  94901. configurable: true
  94902. });
  94903. /**
  94904. * Internal only
  94905. * @hidden
  94906. */
  94907. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  94908. if (this._errorObject) {
  94909. return;
  94910. }
  94911. this._errorObject = {
  94912. message: message,
  94913. exception: exception
  94914. };
  94915. };
  94916. /**
  94917. * Execute the current task
  94918. * @param scene defines the scene where you want your assets to be loaded
  94919. * @param onSuccess is a callback called when the task is successfully executed
  94920. * @param onError is a callback called if an error occurs
  94921. */
  94922. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  94923. var _this = this;
  94924. this._taskState = AssetTaskState.RUNNING;
  94925. this.runTask(scene, function () {
  94926. _this.onDoneCallback(onSuccess, onError);
  94927. }, function (msg, exception) {
  94928. _this.onErrorCallback(onError, msg, exception);
  94929. });
  94930. };
  94931. /**
  94932. * Execute the current task
  94933. * @param scene defines the scene where you want your assets to be loaded
  94934. * @param onSuccess is a callback called when the task is successfully executed
  94935. * @param onError is a callback called if an error occurs
  94936. */
  94937. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94938. throw new Error("runTask is not implemented");
  94939. };
  94940. /**
  94941. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  94942. * This can be used with failed tasks that have the reason for failure fixed.
  94943. */
  94944. AbstractAssetTask.prototype.reset = function () {
  94945. this._taskState = AssetTaskState.INIT;
  94946. };
  94947. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  94948. this._taskState = AssetTaskState.ERROR;
  94949. this._errorObject = {
  94950. message: message,
  94951. exception: exception
  94952. };
  94953. if (this.onError) {
  94954. this.onError(this, message, exception);
  94955. }
  94956. onError();
  94957. };
  94958. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  94959. try {
  94960. this._taskState = AssetTaskState.DONE;
  94961. this._isCompleted = true;
  94962. if (this.onSuccess) {
  94963. this.onSuccess(this);
  94964. }
  94965. onSuccess();
  94966. }
  94967. catch (e) {
  94968. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  94969. }
  94970. };
  94971. return AbstractAssetTask;
  94972. }());
  94973. /**
  94974. * Class used to share progress information about assets loading
  94975. */
  94976. var AssetsProgressEvent = /** @class */ (function () {
  94977. /**
  94978. * Creates a AssetsProgressEvent
  94979. * @param remainingCount defines the number of remaining tasks to process
  94980. * @param totalCount defines the total number of tasks
  94981. * @param task defines the task that was just processed
  94982. */
  94983. function AssetsProgressEvent(remainingCount, totalCount, task) {
  94984. this.remainingCount = remainingCount;
  94985. this.totalCount = totalCount;
  94986. this.task = task;
  94987. }
  94988. return AssetsProgressEvent;
  94989. }());
  94990. /**
  94991. * Define a task used by AssetsManager to load meshes
  94992. */
  94993. var MeshAssetTask = /** @class */ (function (_super) {
  94994. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  94995. /**
  94996. * Creates a new MeshAssetTask
  94997. * @param name defines the name of the task
  94998. * @param meshesNames defines the list of mesh's names you want to load
  94999. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  95000. * @param sceneFilename defines the filename of the scene to load from
  95001. */
  95002. function MeshAssetTask(
  95003. /**
  95004. * Defines the name of the task
  95005. */
  95006. name,
  95007. /**
  95008. * Defines the list of mesh's names you want to load
  95009. */
  95010. meshesNames,
  95011. /**
  95012. * Defines the root url to use as a base to load your meshes and associated resources
  95013. */
  95014. rootUrl,
  95015. /**
  95016. * Defines the filename of the scene to load from
  95017. */
  95018. sceneFilename) {
  95019. var _this = _super.call(this, name) || this;
  95020. _this.name = name;
  95021. _this.meshesNames = meshesNames;
  95022. _this.rootUrl = rootUrl;
  95023. _this.sceneFilename = sceneFilename;
  95024. return _this;
  95025. }
  95026. /**
  95027. * Execute the current task
  95028. * @param scene defines the scene where you want your assets to be loaded
  95029. * @param onSuccess is a callback called when the task is successfully executed
  95030. * @param onError is a callback called if an error occurs
  95031. */
  95032. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95033. var _this = this;
  95034. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  95035. _this.loadedMeshes = meshes;
  95036. _this.loadedParticleSystems = particleSystems;
  95037. _this.loadedSkeletons = skeletons;
  95038. _this.loadedAnimationGroups = animationGroups;
  95039. onSuccess();
  95040. }, null, function (scene, message, exception) {
  95041. onError(message, exception);
  95042. });
  95043. };
  95044. return MeshAssetTask;
  95045. }(AbstractAssetTask));
  95046. /**
  95047. * Define a task used by AssetsManager to load text content
  95048. */
  95049. var TextFileAssetTask = /** @class */ (function (_super) {
  95050. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  95051. /**
  95052. * Creates a new TextFileAssetTask object
  95053. * @param name defines the name of the task
  95054. * @param url defines the location of the file to load
  95055. */
  95056. function TextFileAssetTask(
  95057. /**
  95058. * Defines the name of the task
  95059. */
  95060. name,
  95061. /**
  95062. * Defines the location of the file to load
  95063. */
  95064. url) {
  95065. var _this = _super.call(this, name) || this;
  95066. _this.name = name;
  95067. _this.url = url;
  95068. return _this;
  95069. }
  95070. /**
  95071. * Execute the current task
  95072. * @param scene defines the scene where you want your assets to be loaded
  95073. * @param onSuccess is a callback called when the task is successfully executed
  95074. * @param onError is a callback called if an error occurs
  95075. */
  95076. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95077. var _this = this;
  95078. scene._loadFile(this.url, function (data) {
  95079. _this.text = data;
  95080. onSuccess();
  95081. }, undefined, false, false, function (request, exception) {
  95082. if (request) {
  95083. onError(request.status + " " + request.statusText, exception);
  95084. }
  95085. });
  95086. };
  95087. return TextFileAssetTask;
  95088. }(AbstractAssetTask));
  95089. /**
  95090. * Define a task used by AssetsManager to load binary data
  95091. */
  95092. var BinaryFileAssetTask = /** @class */ (function (_super) {
  95093. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  95094. /**
  95095. * Creates a new BinaryFileAssetTask object
  95096. * @param name defines the name of the new task
  95097. * @param url defines the location of the file to load
  95098. */
  95099. function BinaryFileAssetTask(
  95100. /**
  95101. * Defines the name of the task
  95102. */
  95103. name,
  95104. /**
  95105. * Defines the location of the file to load
  95106. */
  95107. url) {
  95108. var _this = _super.call(this, name) || this;
  95109. _this.name = name;
  95110. _this.url = url;
  95111. return _this;
  95112. }
  95113. /**
  95114. * Execute the current task
  95115. * @param scene defines the scene where you want your assets to be loaded
  95116. * @param onSuccess is a callback called when the task is successfully executed
  95117. * @param onError is a callback called if an error occurs
  95118. */
  95119. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95120. var _this = this;
  95121. scene._loadFile(this.url, function (data) {
  95122. _this.data = data;
  95123. onSuccess();
  95124. }, undefined, true, true, function (request, exception) {
  95125. if (request) {
  95126. onError(request.status + " " + request.statusText, exception);
  95127. }
  95128. });
  95129. };
  95130. return BinaryFileAssetTask;
  95131. }(AbstractAssetTask));
  95132. /**
  95133. * Define a task used by AssetsManager to load images
  95134. */
  95135. var ImageAssetTask = /** @class */ (function (_super) {
  95136. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  95137. /**
  95138. * Creates a new ImageAssetTask
  95139. * @param name defines the name of the task
  95140. * @param url defines the location of the image to load
  95141. */
  95142. function ImageAssetTask(
  95143. /**
  95144. * Defines the name of the task
  95145. */
  95146. name,
  95147. /**
  95148. * Defines the location of the image to load
  95149. */
  95150. url) {
  95151. var _this = _super.call(this, name) || this;
  95152. _this.name = name;
  95153. _this.url = url;
  95154. return _this;
  95155. }
  95156. /**
  95157. * Execute the current task
  95158. * @param scene defines the scene where you want your assets to be loaded
  95159. * @param onSuccess is a callback called when the task is successfully executed
  95160. * @param onError is a callback called if an error occurs
  95161. */
  95162. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95163. var _this = this;
  95164. var img = new Image();
  95165. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  95166. img.onload = function () {
  95167. _this.image = img;
  95168. onSuccess();
  95169. };
  95170. img.onerror = function (err) {
  95171. onError("Error loading image", err);
  95172. };
  95173. img.src = this.url;
  95174. };
  95175. return ImageAssetTask;
  95176. }(AbstractAssetTask));
  95177. /**
  95178. * Define a task used by AssetsManager to load 2D textures
  95179. */
  95180. var TextureAssetTask = /** @class */ (function (_super) {
  95181. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  95182. /**
  95183. * Creates a new TextureAssetTask object
  95184. * @param name defines the name of the task
  95185. * @param url defines the location of the file to load
  95186. * @param noMipmap defines if mipmap should not be generated (default is false)
  95187. * @param invertY defines if texture must be inverted on Y axis (default is false)
  95188. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95189. */
  95190. function TextureAssetTask(
  95191. /**
  95192. * Defines the name of the task
  95193. */
  95194. name,
  95195. /**
  95196. * Defines the location of the file to load
  95197. */
  95198. url,
  95199. /**
  95200. * Defines if mipmap should not be generated (default is false)
  95201. */
  95202. noMipmap,
  95203. /**
  95204. * Defines if texture must be inverted on Y axis (default is false)
  95205. */
  95206. invertY,
  95207. /**
  95208. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95209. */
  95210. samplingMode) {
  95211. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  95212. var _this = _super.call(this, name) || this;
  95213. _this.name = name;
  95214. _this.url = url;
  95215. _this.noMipmap = noMipmap;
  95216. _this.invertY = invertY;
  95217. _this.samplingMode = samplingMode;
  95218. return _this;
  95219. }
  95220. /**
  95221. * Execute the current task
  95222. * @param scene defines the scene where you want your assets to be loaded
  95223. * @param onSuccess is a callback called when the task is successfully executed
  95224. * @param onError is a callback called if an error occurs
  95225. */
  95226. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95227. var onload = function () {
  95228. onSuccess();
  95229. };
  95230. var onerror = function (message, exception) {
  95231. onError(message, exception);
  95232. };
  95233. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  95234. };
  95235. return TextureAssetTask;
  95236. }(AbstractAssetTask));
  95237. /**
  95238. * Define a task used by AssetsManager to load cube textures
  95239. */
  95240. var CubeTextureAssetTask = /** @class */ (function (_super) {
  95241. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  95242. /**
  95243. * Creates a new CubeTextureAssetTask
  95244. * @param name defines the name of the task
  95245. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  95246. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  95247. * @param noMipmap defines if mipmaps should not be generated (default is false)
  95248. * @param files defines the explicit list of files (undefined by default)
  95249. */
  95250. function CubeTextureAssetTask(
  95251. /**
  95252. * Defines the name of the task
  95253. */
  95254. name,
  95255. /**
  95256. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  95257. */
  95258. url,
  95259. /**
  95260. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  95261. */
  95262. extensions,
  95263. /**
  95264. * Defines if mipmaps should not be generated (default is false)
  95265. */
  95266. noMipmap,
  95267. /**
  95268. * Defines the explicit list of files (undefined by default)
  95269. */
  95270. files) {
  95271. var _this = _super.call(this, name) || this;
  95272. _this.name = name;
  95273. _this.url = url;
  95274. _this.extensions = extensions;
  95275. _this.noMipmap = noMipmap;
  95276. _this.files = files;
  95277. return _this;
  95278. }
  95279. /**
  95280. * Execute the current task
  95281. * @param scene defines the scene where you want your assets to be loaded
  95282. * @param onSuccess is a callback called when the task is successfully executed
  95283. * @param onError is a callback called if an error occurs
  95284. */
  95285. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95286. var onload = function () {
  95287. onSuccess();
  95288. };
  95289. var onerror = function (message, exception) {
  95290. onError(message, exception);
  95291. };
  95292. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  95293. };
  95294. return CubeTextureAssetTask;
  95295. }(AbstractAssetTask));
  95296. /**
  95297. * Define a task used by AssetsManager to load HDR cube textures
  95298. */
  95299. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  95300. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  95301. /**
  95302. * Creates a new HDRCubeTextureAssetTask object
  95303. * @param name defines the name of the task
  95304. * @param url defines the location of the file to load
  95305. * @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.
  95306. * @param noMipmap defines if mipmaps should not be generated (default is false)
  95307. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  95308. * @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)
  95309. * @param reserved Internal use only
  95310. */
  95311. function HDRCubeTextureAssetTask(
  95312. /**
  95313. * Defines the name of the task
  95314. */
  95315. name,
  95316. /**
  95317. * Defines the location of the file to load
  95318. */
  95319. url,
  95320. /**
  95321. * Defines the desired size (the more it increases the longer the generation will be)
  95322. */
  95323. size,
  95324. /**
  95325. * Defines if mipmaps should not be generated (default is false)
  95326. */
  95327. noMipmap,
  95328. /**
  95329. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  95330. */
  95331. generateHarmonics,
  95332. /**
  95333. * 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)
  95334. */
  95335. gammaSpace,
  95336. /**
  95337. * Internal Use Only
  95338. */
  95339. reserved) {
  95340. if (noMipmap === void 0) { noMipmap = false; }
  95341. if (generateHarmonics === void 0) { generateHarmonics = true; }
  95342. if (gammaSpace === void 0) { gammaSpace = false; }
  95343. if (reserved === void 0) { reserved = false; }
  95344. var _this = _super.call(this, name) || this;
  95345. _this.name = name;
  95346. _this.url = url;
  95347. _this.size = size;
  95348. _this.noMipmap = noMipmap;
  95349. _this.generateHarmonics = generateHarmonics;
  95350. _this.gammaSpace = gammaSpace;
  95351. _this.reserved = reserved;
  95352. return _this;
  95353. }
  95354. /**
  95355. * Execute the current task
  95356. * @param scene defines the scene where you want your assets to be loaded
  95357. * @param onSuccess is a callback called when the task is successfully executed
  95358. * @param onError is a callback called if an error occurs
  95359. */
  95360. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  95361. var onload = function () {
  95362. onSuccess();
  95363. };
  95364. var onerror = function (message, exception) {
  95365. onError(message, exception);
  95366. };
  95367. 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);
  95368. };
  95369. return HDRCubeTextureAssetTask;
  95370. }(AbstractAssetTask));
  95371. /**
  95372. * This class can be used to easily import assets into a scene
  95373. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  95374. */
  95375. var AssetsManager = /** @class */ (function () {
  95376. /**
  95377. * Creates a new AssetsManager
  95378. * @param scene defines the scene to work on
  95379. */
  95380. function AssetsManager(scene) {
  95381. this._isLoading = false;
  95382. this._tasks = new Array();
  95383. this._waitingTasksCount = 0;
  95384. this._totalTasksCount = 0;
  95385. /**
  95386. * Observable called when all tasks are processed
  95387. */
  95388. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95389. /**
  95390. * Observable called when a task had an error
  95391. */
  95392. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95393. /**
  95394. * Observable called when all tasks were executed
  95395. */
  95396. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95397. /**
  95398. * Observable called when a task is done (whatever the result is)
  95399. */
  95400. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95401. /**
  95402. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  95403. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95404. */
  95405. this.useDefaultLoadingScreen = true;
  95406. this._scene = scene;
  95407. }
  95408. /**
  95409. * Add a MeshAssetTask to the list of active tasks
  95410. * @param taskName defines the name of the new task
  95411. * @param meshesNames defines the name of meshes to load
  95412. * @param rootUrl defines the root url to use to locate files
  95413. * @param sceneFilename defines the filename of the scene file
  95414. * @returns a new MeshAssetTask object
  95415. */
  95416. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  95417. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  95418. this._tasks.push(task);
  95419. return task;
  95420. };
  95421. /**
  95422. * Add a TextFileAssetTask to the list of active tasks
  95423. * @param taskName defines the name of the new task
  95424. * @param url defines the url of the file to load
  95425. * @returns a new TextFileAssetTask object
  95426. */
  95427. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  95428. var task = new TextFileAssetTask(taskName, url);
  95429. this._tasks.push(task);
  95430. return task;
  95431. };
  95432. /**
  95433. * Add a BinaryFileAssetTask to the list of active tasks
  95434. * @param taskName defines the name of the new task
  95435. * @param url defines the url of the file to load
  95436. * @returns a new BinaryFileAssetTask object
  95437. */
  95438. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  95439. var task = new BinaryFileAssetTask(taskName, url);
  95440. this._tasks.push(task);
  95441. return task;
  95442. };
  95443. /**
  95444. * Add a ImageAssetTask to the list of active tasks
  95445. * @param taskName defines the name of the new task
  95446. * @param url defines the url of the file to load
  95447. * @returns a new ImageAssetTask object
  95448. */
  95449. AssetsManager.prototype.addImageTask = function (taskName, url) {
  95450. var task = new ImageAssetTask(taskName, url);
  95451. this._tasks.push(task);
  95452. return task;
  95453. };
  95454. /**
  95455. * Add a TextureAssetTask to the list of active tasks
  95456. * @param taskName defines the name of the new task
  95457. * @param url defines the url of the file to load
  95458. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95459. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  95460. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  95461. * @returns a new TextureAssetTask object
  95462. */
  95463. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  95464. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  95465. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  95466. this._tasks.push(task);
  95467. return task;
  95468. };
  95469. /**
  95470. * Add a CubeTextureAssetTask to the list of active tasks
  95471. * @param taskName defines the name of the new task
  95472. * @param url defines the url of the file to load
  95473. * @param extensions defines the extension to use to load the cube map (can be null)
  95474. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95475. * @param files defines the list of files to load (can be null)
  95476. * @returns a new CubeTextureAssetTask object
  95477. */
  95478. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  95479. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  95480. this._tasks.push(task);
  95481. return task;
  95482. };
  95483. /**
  95484. *
  95485. * Add a HDRCubeTextureAssetTask to the list of active tasks
  95486. * @param taskName defines the name of the new task
  95487. * @param url defines the url of the file to load
  95488. * @param size defines the size you want for the cubemap (can be null)
  95489. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95490. * @param generateHarmonics defines if you want to automatically generate (true by default)
  95491. * @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)
  95492. * @param reserved Internal use only
  95493. * @returns a new HDRCubeTextureAssetTask object
  95494. */
  95495. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  95496. if (noMipmap === void 0) { noMipmap = false; }
  95497. if (generateHarmonics === void 0) { generateHarmonics = true; }
  95498. if (gammaSpace === void 0) { gammaSpace = false; }
  95499. if (reserved === void 0) { reserved = false; }
  95500. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  95501. this._tasks.push(task);
  95502. return task;
  95503. };
  95504. /**
  95505. * Remove a task from the assets manager.
  95506. * @param task the task to remove
  95507. */
  95508. AssetsManager.prototype.removeTask = function (task) {
  95509. var index = this._tasks.indexOf(task);
  95510. if (index > -1) {
  95511. this._tasks.splice(index, 1);
  95512. }
  95513. };
  95514. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  95515. this._waitingTasksCount--;
  95516. try {
  95517. if (this.onProgress) {
  95518. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  95519. }
  95520. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  95521. }
  95522. catch (e) {
  95523. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  95524. console.log(e);
  95525. }
  95526. if (this._waitingTasksCount === 0) {
  95527. try {
  95528. if (this.onFinish) {
  95529. this.onFinish(this._tasks);
  95530. }
  95531. // Let's remove successfull tasks
  95532. var currentTasks = this._tasks.slice();
  95533. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  95534. var task = currentTasks_1[_i];
  95535. if (task.taskState === AssetTaskState.DONE) {
  95536. var index = this._tasks.indexOf(task);
  95537. if (index > -1) {
  95538. this._tasks.splice(index, 1);
  95539. }
  95540. }
  95541. }
  95542. this.onTasksDoneObservable.notifyObservers(this._tasks);
  95543. }
  95544. catch (e) {
  95545. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  95546. console.log(e);
  95547. }
  95548. this._isLoading = false;
  95549. this._scene.getEngine().hideLoadingUI();
  95550. }
  95551. };
  95552. AssetsManager.prototype._runTask = function (task) {
  95553. var _this = this;
  95554. var done = function () {
  95555. try {
  95556. if (_this.onTaskSuccess) {
  95557. _this.onTaskSuccess(task);
  95558. }
  95559. _this.onTaskSuccessObservable.notifyObservers(task);
  95560. _this._decreaseWaitingTasksCount(task);
  95561. }
  95562. catch (e) {
  95563. error("Error executing task success callbacks", e);
  95564. }
  95565. };
  95566. var error = function (message, exception) {
  95567. task._setErrorObject(message, exception);
  95568. if (_this.onTaskError) {
  95569. _this.onTaskError(task);
  95570. }
  95571. _this.onTaskErrorObservable.notifyObservers(task);
  95572. _this._decreaseWaitingTasksCount(task);
  95573. };
  95574. task.run(this._scene, done, error);
  95575. };
  95576. /**
  95577. * Reset the AssetsManager and remove all tasks
  95578. * @return the current instance of the AssetsManager
  95579. */
  95580. AssetsManager.prototype.reset = function () {
  95581. this._isLoading = false;
  95582. this._tasks = new Array();
  95583. return this;
  95584. };
  95585. /**
  95586. * Start the loading process
  95587. * @return the current instance of the AssetsManager
  95588. */
  95589. AssetsManager.prototype.load = function () {
  95590. if (this._isLoading) {
  95591. return this;
  95592. }
  95593. this._isLoading = true;
  95594. this._waitingTasksCount = this._tasks.length;
  95595. this._totalTasksCount = this._tasks.length;
  95596. if (this._waitingTasksCount === 0) {
  95597. this._isLoading = false;
  95598. if (this.onFinish) {
  95599. this.onFinish(this._tasks);
  95600. }
  95601. this.onTasksDoneObservable.notifyObservers(this._tasks);
  95602. return this;
  95603. }
  95604. if (this.useDefaultLoadingScreen) {
  95605. this._scene.getEngine().displayLoadingUI();
  95606. }
  95607. for (var index = 0; index < this._tasks.length; index++) {
  95608. var task = this._tasks[index];
  95609. if (task.taskState === AssetTaskState.INIT) {
  95610. this._runTask(task);
  95611. }
  95612. }
  95613. return this;
  95614. };
  95615. /**
  95616. * Start the loading process as an async operation
  95617. * @return a promise returning the list of failed tasks
  95618. */
  95619. AssetsManager.prototype.loadAsync = function () {
  95620. var _this = this;
  95621. return new Promise(function (resolve, reject) {
  95622. _this.onTasksDoneObservable.addOnce(function (remainingTasks) {
  95623. if (remainingTasks && remainingTasks.length) {
  95624. reject(remainingTasks);
  95625. }
  95626. else {
  95627. resolve();
  95628. }
  95629. });
  95630. });
  95631. };
  95632. return AssetsManager;
  95633. }());
  95634. /***/ }),
  95635. /***/ "./Misc/brdfTextureTools.ts":
  95636. /*!**********************************!*\
  95637. !*** ./Misc/brdfTextureTools.ts ***!
  95638. \**********************************/
  95639. /*! exports provided: BRDFTextureTools */
  95640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95641. "use strict";
  95642. __webpack_require__.r(__webpack_exports__);
  95643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return BRDFTextureTools; });
  95644. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  95645. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95646. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  95647. /**
  95648. * Class used to host texture specific utilities
  95649. */
  95650. var BRDFTextureTools = /** @class */ (function () {
  95651. function BRDFTextureTools() {
  95652. }
  95653. /**
  95654. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  95655. * @param texture the texture to expand.
  95656. */
  95657. BRDFTextureTools._ExpandDefaultBRDFTexture = function (texture) {
  95658. // Gets everything ready.
  95659. var engine = texture.getEngine();
  95660. var caps = engine.getCaps();
  95661. var expandTexture = false;
  95662. // If half float available we can uncompress the texture
  95663. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  95664. expandTexture = true;
  95665. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_HALF_FLOAT;
  95666. }
  95667. // If full float available we can uncompress the texture
  95668. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  95669. expandTexture = true;
  95670. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT;
  95671. }
  95672. // Expand the texture if possible
  95673. if (expandTexture) {
  95674. // Do not use during decode.
  95675. texture.isReady = false;
  95676. // Simply run through the decode PP.
  95677. var rgbdPostProcess_1 = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]("rgbdDecode", "rgbdDecode", null, null, 1, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, engine, false, undefined, texture.type, undefined, null, false);
  95678. texture._isRGBD = false;
  95679. texture.invertY = false;
  95680. // Hold the output of the decoding.
  95681. var expandedTexture_1 = engine.createRenderTargetTexture(texture.width, {
  95682. generateDepthBuffer: false,
  95683. generateMipMaps: false,
  95684. generateStencilBuffer: false,
  95685. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  95686. type: texture.type,
  95687. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA
  95688. });
  95689. rgbdPostProcess_1.getEffect().executeWhenCompiled(function () {
  95690. // PP Render Pass
  95691. rgbdPostProcess_1.onApply = function (effect) {
  95692. effect._bindTexture("textureSampler", texture);
  95693. effect.setFloat2("scale", 1, 1);
  95694. };
  95695. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess_1], expandedTexture_1, true);
  95696. // Cleanup
  95697. engine.restoreDefaultFramebuffer();
  95698. engine._releaseTexture(texture);
  95699. engine._releaseFramebufferObjects(expandedTexture_1);
  95700. if (rgbdPostProcess_1) {
  95701. rgbdPostProcess_1.dispose();
  95702. }
  95703. // Internal Swap
  95704. expandedTexture_1._swapAndDie(texture);
  95705. // Ready to get rolling again.
  95706. texture.isReady = true;
  95707. });
  95708. }
  95709. };
  95710. /**
  95711. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  95712. * @param scene defines the hosting scene
  95713. * @returns the environment BRDF texture
  95714. */
  95715. BRDFTextureTools.GetEnvironmentBRDFTexture = function (scene) {
  95716. var _this = this;
  95717. if (!scene.environmentBRDFTexture) {
  95718. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, true, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  95719. texture._texture._isRGBD = true;
  95720. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  95721. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  95722. scene.environmentBRDFTexture = texture;
  95723. texture.onLoadObservable.addOnce(function () {
  95724. _this._ExpandDefaultBRDFTexture(texture._texture);
  95725. });
  95726. }
  95727. return scene.environmentBRDFTexture;
  95728. };
  95729. BRDFTextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xuy9Ccx261oW9q5v/r7/33ufgalSbWtiTJsmTZOmSdOkpVKsWhxAxIJFQaCKUkpFiiBFKjKPh3PO7hjb2LmNnYxtjbGtbY21rQGkgCgiIKPMM5x99ruatZ7puq/7up/nWd/3bzzABjb/9675Xeu5hnt41rv8s+evW9fz+ZT+W9N/63o6re3v+nlfvq2CbdZT2hbW7dukDbf/a/9uS3G7E69Ln9PifK50sHSMvD2ur3+XY/E2++dyPelDPoU7Jm9XTm2uab86vJ56gvSd80dzXflA+Zul74PHwGuGv/MXLv+kL4Lfp56r3DM8ef6utE10Xnu97fra7uWi2/etZ8BV/F3F+fdni/8Dn9O4KSvt/cxPMa+HY5Qx024OHF3cM7zHdcsy3uAeuu3wPve3S2OVthHH09v5e9BuCT0HHgPlHsjz+3uxNALYAJ9JgAigALyBmQGPQEcAxwRQgVhIogwcIoAG2HYsM1gR3IokEDD5biMBhMeSoLXkweCoAxsGcDoX3Xi3nkCFACnfiQaPARECgPaVAMZjEuAsNttAjIBZSY8HXHkuFctt4Npj2e8+B/ImFOnwEcg9SPEqcNdyDBSZemwipBkwmvMwocG9Gm6nCDUisHpb+iSRTp+2kQTQAJ9cACt8cwRN/Ss5IJBJ7a2qC0AHYK4gUkpuQE2uoTiJfMPw4epjeqdRXYE5Rhu0me7aGCwIKtfFD0sAmklCgWBmG3utbfCrfdtlBUpK6qUIpwCkkUYDIg4yp4QhAeW9GDBwLR6glgysC8PvZq6o2MJMT3jdhtKqI0WiMfeTCMhs54BqzwNPyLueclxzS/3+XQI0jtSSQrmly4ecv249Z+U/gQOoNj+HBKj+yhGEtn9/2C10qLaWLH5Tz6KykeI3FTb7wM0uRJMWlZtmQwgXFgAr23VwDGRjADoPOgMIQ1pigNdnCrbviaqvFMopuDpvHjB8/RXoeI8ydGp4RAM2x13NzQtr74BkQoFZlceBDQTugIlaixa7kbn5nl3wNgVNpxGKi2OvQxJmjOJ24riNB/sKX0VJPS/zjNfTTgAp9s95AIj9K9DPqPQc22+nS6C0eYAGZJMLyF+sPPwGVggXypcH8HggA5gwbCjHhy9v1Z7yDIY4Gie3nIMGrQHUUNVBVeq14rnyOeiBvWjVl8QgQoZ6NajErESk0n0wx4CLFLuXJ5gOE4J8gtV4cW2RlYbvrO5lVWMk10KU6lpwrHbBr8cHn8+EMdH5YPl2H4gANhCmPEABLTsBp/5k+Y1TwGReWlGTgqiy6WFrxXcEQQTilLw8mUP5AIh1pbJnTgUrOiYIVBZKMAXqW7GISigAyjbYgkWfyyqyTTI5ZckLokEehQNxAs8TYMHF8X3w+3kSrcc1qozPAsAUqbfLX8B5AKgyFGBidOcIiB8JAMdZWV4fGak/nU+Sd0BC266CANbTqdp+zPZHmX9Uf1Txju1HxS6DbeeAZtOtavtKAILAhw9B1aCNjhyJELDZrldlFwRB1YT2nJtUNnVTBPJ41Y+dAQwOE2eD6+EBWZ4FDDRUFmUn7ZiLzjkgGbgOTTTintG1y2QiuKh2ZSKrLoDDVt4RI90jc28CMunnC/AK27iBhEB+FHgme78rtk2w5b+vcguSAKLyH5YCfT6ghAgFeAh+H9PXBxcBPiKICjo4fnEE+ODLk1NJQ7M9PACXK2iqgTa1DTpPHo59FYGgNZuM9T1AoBphFMIPIhXPMzG1Q/jBVYceAobVqCElHYo+uzwBPKvGyXBuY1O9YjZBQzOP312TK4PAVjDw/Hn/p5CEJKI2puq15C/jXFz7kiZB2CPLckzzzIPjlMtbPuT89WtK/rUSoOkFMDV/KvflEp6pCnCtH614yRPU0AAScxjvlwGABFFGlgQ12MJD+QCt7HX88bEE2aRFFnhGOdBO5hWsLDOx/mzZT6meSgAa9cLrYnA6O0yqxSDpbG/uFRAXwDWPYUsG1s2Le91Yp8CJsK5VM6wYUJyMGLLqjESsCcykC80XsddknltlRSC/fL+GBFAdXXw97fDrafnnzl+fG4FyIrAAPggD9nsTNQIhsLfziwqAVX+r5IcqAQKMxZlYUBaSQVUog4jWgXJhCGKah1QlQIUDZlDSQCm804n1+6rfQOAqEALA0SCMcwdeqZyqONKIQBsAVoBWKlcvRKnq6YHSKmAa/LJKUZFBJMf3tEdeJvmGY05cIx1XkXIlH8re8/J0SeK6I3LMvQCSAHQYULL8OhfApT6X2BN2v4YSRxW/Hivf4ALcScuPAx9JxxIHwKY6AXiIfC5+mHBNj63rW2cAwyMiDiQnygJ3AQzEZ+6BG+iCGBQ4BqD1cTHlKFTJUA3kyi0RyHF8EAAVWOg+vBCSqLeMFFnct64jOXAcW6SM8wHbLcgEUNT/3BKA2BJsWnoFAahKgGv79V2Bs5WAWkbkHAAMirgnoA1ajN8REKHay/IesCzkDdrzfMR6/B5moHuLORMu1PtKipbG9wGldsSgQVSpqdkWECRtRcPyn1DQGTVvl+rPh7pYOA2tvKxE8DOBJJuq+4/i7rj0SKpN9zA9QpFQbV9EtBxbZ1uPUcYDuAlDAEn5z83i7yRgld91AXZiftMXkG9oAartCqQKQOgIhOKHMX8elsbWF8mgdRSnm0QfJry4SoCEhAwND9EMjFE+wCXXJlS/o7ZK9RXwDhNDl0jsgJ2r81cpz8a0MpfrkJNA53sQqWsHXI8mCXZdCDImRAHmuvljjiO+Z+0FUG5GCMLy6/YcAAB/B30igdOZ4/2dDRJBIKCNQyggxfheNfn4kh8qsSGKei6v5l7VDyQEcSBzWIEKgDeTtkubWQvKg5StfBsXI4DDd2ky2EBirkt3pw3BXbFnQdjGVqSoj9weBi3fB1QqHyaIe0FEZMmmnigfNqoYwDOge4zg1AovQhcCmflOgjgbX4jrCLavWzpCa8/EOQ5xXds2y687f0ObDchdgC4M2E4wqAQYYsiDcrcRDSjVRRiQlQds/5WzAE3mHSoJlJGfIoeW8jezBDON+R7/URIQE4IyJvcJQT5XSzqCLhHJtOFN9pBVh0iil5U+5BhUnM6qw3G2UOCo4w/hkNUGtDWIa3mOgVC8CsjhtVhSN/c7ALl0J0Aqs6BkUkASUWMFiapFKoLwRCgBBJCUf9wE1MCswoEKdOcSChlQf76y8PlOGkeAeYZCMkwg+SlJ4PfIQal9uQZULKW4sAxVi2N1rr2zMusyXx/cKtZXqtrtFJxQ5C4xKBWeARc7D6F2GlAQLu4j3zoRoEwXPqRTkKMBMJt9pWLWAZbX2mON8gDTyTl4Jgbc7lrFd8HxiPdH3N9tkSGAU24DtmU+7gYsTT8lHGjlPhPz13gZFV01BWUbpWr+tazYyMOoI8TkCKg4ISgUtRIQcDwk9xhQ0u4jIQHL6m0bqDn5xANopvZ/vMZfvpGoYbscRNWbLEITA55VGMhAkZMrsfYAqQa3JBsgBiKJUTKuOg9x3PBa8ZljsjCqZojlqPIy/CFCMg6pfEe6ZvNdA+JbPrSGAG0egO36C8p+KTtYe/ttGZBzBKz+uv5fzotMPQLz/r3YRbhqAYDOgdvnDDzJIPNb4BxK8kX5AnQghqk74cJAubXqB7aWBodSMnU8Qw8MdHPMdv/cwOUEnhvEvnLRxnusgD0n0AM5CgmCMp1T2epj9ffu8XuJQFLwEZH5Z9OIH11FJoACfnohSNDwo63/DBnkyyo5gTDbv329AtpokhAOKtq23shiD21ZxIUW9VBwHACYsdomk5+HEiiTGSQ4uCsggqYg/L547mJyMZ5mNqdKRc0Eq0HDAMNrZyJS5SfaXlpqvEfRwOXjRKrIcxoitWUSI8WcUth8TYY81LPoJQs75+2SSM9F0DUYcHfcRLvFgijzdyAC2DL/rQyIQEdXYGYE1jKgz/Tbkh/Z/5QsqH3jBpQqL4AM3Fmv3QOFEDgoe9l/tZ1RAuEsROLPKo6v0VpVoGx34bBDYBxUD14EMQwciGp+CgGggMeOgq45Lnd13MZR8gjAFfYNDBUcoYturN7MmtMwTolJOoN35Ca6oUS+1uVDz38tVQFKAhBagBvQC1gpHJDgB3vPiUAX00MG38TzXtGl1e/lDdJoM5l9vGH4EF03IA+UMkBRPY0TgAcrcgpISra7TOUDhKswpBN1zen9npIAVANdDjrOHQycROMOr0xy0KrjT4C5FwO3R6nU8RHJwgN5AKPgh8EN/iRKaIJDafeAvmf+uBNAUn07GagP/jLYIkIoNzB2BVb9i8x5R+DsugFj277adAYrzcjzFQIkCkhYssIpYKtOQUkedI4qUlXeoQFmPkloQhPhPIrtVVZQgpsHY5DQi4A1TRiVw/ygNMqnnErPDgsw9TLz7lwHbPhIofsE411geVYtgtDEhFUPXVZUY8o7jMQR62n556sDaM1AUSlw2ASkbH3JI1T1hwRhecBQMTAqraw+EYCNz2dife4baDfHJRyNks3affEAYGCyIk8lEVlRZdKunVcBVA1YNUiniIE7INmhUIwMmmVKcxFIFGGNMvDTYMZcSrnO7BbbRzxae+6ufViQUZR/wX2738WFVoIICgYKW8jvQd8Bt4Xx6Aggeh9AHPejamN23ycF7Qs/mouoFrmC264z+yEYOKPP5ABZ9y64VYJOOYfIFaBSSVeAmWKRA0DlEqpbH2XFePkjHqj9TH65v6gMKfw0lpHPpxS5objAaP5FmjOhQ5PEdnyRhFMEV3cdJe3w/uNZguVpk6AiIPMABGJ1X0ffyZDUCNwgavB9SviJbiMTQGkCyglA1QFI8bypBHAuAOcHRK6g2K1uHK8tvrTx0/kAn2TD47Ux7sOB+shrdn8yhqfKASufBbi2h2FPQX7WXdUPiCPt6hUujXs7aB9VGmTnMhrkADgmPaO+Qez72CafOfdQb6JO1Kl7xgpNhDIq5Y3W1+cXOJiZ9cuH7SEA9gCUeQC5538v2aVLUZWApt4JrOkhROqPDoG2LczZrQBwchCYeBjrk+pB0rFlrGEosLswrD/OFdT7AgqGg5oVy5NLRXZ+vAKoA5C6hBreI3YzNIja9Qg1AdVvY7oRRpQl1wAVDUk9hVXKq4gDvh9/g6LgziGMQExuxwBMuIUeifVast11dZJ9LCYu1IDxh8pf/l4+7PyNtQpgfxUoE0EH/GWAaTdQ1EWECFV1RO8ArwubeoISotjfgFGp8UDRe3G6BK4KKYq5xhgUH6wAJ6s6D6gQpBznsvLwgAqsOEK68YO3s5bMhD09AlACWQQi5VIM0COwiuWjmDx0FjzvgxW/13pcSnnm2dC9jZKl5WGIHhFNACqPkc7lCGCU/TcuwLmCMeiNQzDg7gPa234RHqBysJPAhxG6hbhfwKgpxfkxMAHCgmTUwJtOEiqVrC61/EFg7Ci3AppXF9Atdh+kuFUdFaCFojm3IgECEBeK60kKAHUoZhfuS4B7lAcwKh8kHHUmH0u9nhSqkjviFgRiXI1fXwmA3wWgG39aP0BR1aPqnwY9WGhX/89DsRsKiPZfyAHg4EOlaOAC8jDEAKZOuQJUdraYUtl9vkFZP6tmgyShUB0GD37PSLldTG8SgA0AQ3VXRAT3xrgIJiiy3CoB6UDEJNa+YIYoJeciRxERlrPMMCaCZKLKvxSQmu/vzhkkEtnBgeIj+PHK6nLcNpOkeYZ0rOXX1xCAXgZi2oCx3s+WPq8zbiBfmgE6lP/KhWGcXZfBvji4iBAkmA2ZEIvS8QuBpfthldqqIZUWYdA64OLgRIUS2fUjrgEJLSozuUQmgUu6jXAbqxSOLAJra++HJ1McpC9K8Q8fRyQ9DVgDZ6G+W+WKSgxarVWoJglCnHtEIJVTpkuB9hozAeQkYGc6sCkD7oABN5AHeHUDBVTlC5mWX6X+jRwQmCVcqOUpTtzV4zfrjsAyYQMCV8XonbLfbPa/PT/rYurDDkkBO8/INeQnzOpolZlUipXWKEE9IDQf2az/oQSgIRGtvt0KRUURfiMYpNWJtaGO5SyrblSVKcfu9SWMzl9DEQ3uci09lY2Sn4ZAQDzqZZdzd8qY+OQrwdKxdJiR7tXy68//X2sF3kCArwTLLiCe/PMY9S+jEx2BBYyr2e+DQOQITJ2/Dex54Jfz0r4DV8AAQXWwyq7sPHK6Tc6MrHy8Pg8DVhAR9w5bgyN1V+oULkOw4rXZ5bpa4O/ZSKGZeJ26qnzFvlGrKjk1N+sZZoqgAoLo5R4UuTNpmVKtPgcLVCWC/B2ciwDS3gmgtgLvBJB7Ajrgt/kBTPwBkKlvIJ0zWF8v6A1KBIaVgTYgfaNQ0C8gyMEMD6oy1DME+QPnGsiiIrnU8wDDj9aPzh+pUDsFERYMHv7eJjwZqa5UdgzbiEQiIA2TewFoRCIyJhrhToj8nMqO1rcHA+a9XKslGA9g+508AYr1GCLAd1/+BXAAGwjw58AR6M3ed6x/vhKb5KOcQQXQRE9A7ari+j8QyUR2P3QEMJhVlaGJQL6hLkywKoKgsU7AZs8ZXHbboHKgBgwmKqMBxZliBbyZBKDscAs64jjnkVlGWWG+T45EgOwiwmF9xiYmDUzqeETVVSVRhKgkDiCIgFh0olCQaxl0ZmwSGdbrKTgYrBfHLGQHBFC6AakBCJOBEPcnV065AEwEFqA/QvVVCIBKZ5xE/nLVHnNVARUbB7/L8nMeQrgDAQKfjGykYHQDHEAT+UIsvgUX93XlJgFqoxKiPDSTyFMJNbmfcikiuabAzddpwTtSvn4LrrpWbvIqAx+eLiwSSt9UwOZMRNLNPDNa71UaQatzJ6b7kUBfL1qRNwIer9q4knS1mQC2o9gZgbIfQCT+ynYtUUd5AdMViKQRdAIa1dfJQZkPeArw4cZgXBqWDYGd8VraYhjmLuGo1mUYmAdkE4M8gJAQq2ry/hTj2n3QlSAcGilFaqxUVS/zyuSB0FfPIYmMlLKj6JbwgHxgRgS3RHviCPaTBGG3rcajNolZUnDrAxvfnqQ6vsqptO2W33D+pjVNBW4EMAX+mpgTicCB+isAO1U3vf0+BHCKT0qPA8e4B8wH4OCJYvSIHBhcYP10M0+5IpX4U27DNiXVLfA8Nc4m5arPt8AyyI5z9yHeQ1CR2BmIwa9IyBCmrezX17mRarXsugaNTiBqUnMuw90fIiqZVwDiFm6nKLJ1AUF1xXzXvAfdt6b+9GzpXsq8C7uPzrGJAHJ8nysBhgjodeCqDFjdgAoFirJHGf2q4FAdEACtpcEg9m84toM/zgMwucBwCcOE3ja4DocenKehOQ8FAdD80FgBR+VAsz5oJXXVBGnpo9IgAaHIlEzqiZJm+cYAQgsee96oEUiXtqicWiV0UFkogIzICwEb5DdGuQv3Pei+heszmKOKST2MChGUWBA5VAIwrwI7l5Bgu6HnWoKzbcDQHASKb+P3fqJPdwQWRmTF7FQIuurPwLPHxRIK21NPGn3gcznGOQ8kNBp0DQ8+HuQEEqtMz3HUKzZOJjOQUsIjQBYOQg1Uc71MbF0CadfplLXadOuompaDc+BkKbkNXaf3eZlCVPIc7CzpHI0g8nUJVVbfsQ2T8n2UI6IxI1xCdOzlN9YQoDQDbe8FhERgbt1V4J9OBAbqb/IGBGIdJsCtL+xmQgUcMAeB784/ytzT8XF/UFRHMNW22wHGCSwNavH9m4fQvw6rADeZ9T+UAKyXpgajzrp3yWKkxhVHHhBIvDqRZgmQXZMBemCfdVYfBIJzAJnoXJs2EIUF6YjY7Pdmp9gNIeDaMgHAj4PWXoDtkEFFQM73L3YvhxGh5QeFB9uf8EPqn8MFta5lxicnBWFyUYAVb6AELSaTEECsmAQu88B761JbCoDY21a53rgKqy5tiMCzKYqr5hQAOcnYUtnfIAutEmxqkJprNM+lkV0BZEhITSYLzGCIE1BCQNP5Bq6Bk7+Pdwd4B5Q7EOsFuTwqRNheCZYcQHkbcHshSCnxuV4A/jFQfBlIeYBmYk405dfH+sZyF+UqD2yg9N7Kl+FGg79Ty4+B3x7MlKJTEonBgAPZgjpI/HUdxcgV4MAOSKVnXwXo+ZpN/MrJVACnsqHqWPCNAFeQ0wESa7dGOQEPKHUNVbfrIQJ1LeeVYZK4z4bQ8Vv5a023KfiO+R46sgzcZL09kBeI9l1+4/mbN/mHFuD9F0HbLwTz36jsuQ/AN/6gkkfvA9BqX8Dis/xC6UmJnYpPrEfTZh6A3Nc/JLTqbO8Q+EhubVwASdXxYZOX5vqGMwEVwPuuQCWfZJKQBvMoL1GPaxQX9pIJqpjMKvakSxGACpxJlFTUSTigC7heF88XkgOCiIiGn2fbFfco32eOiKYqAeIat0XLbzp/M5QBs33fQR8QAai8aQTC5aYKgKFBUThUf87Ccx8BgM6oNzkItPjFPTCrKhuP24ZhAgGfVLGr6KyIImRQg9JE0nCMxhNtkDThEoNoYj5AwyjqBAxCvG+gvjFRdNQuOpZQS6da/KzwWkid00ehqJ0SnwPtTBhQgEXuISYARYLBfYfvh3c0x4p57ey+QCYwnoAASuafp/4CKewAwex/+Zxv9nZgUb8vpbum7pFDyF8TcgNVI8sorevK47UEg8ozCgvatqzEVoWdsyiDC9RNq71NJFq34bPMdtAUxwN7KdVUdlTZ9oESm3MH/fXOxaCq9MDZBUd5fm2IF/AmTrAqaIBAoDeupJbP2pgyxz2YpHNkVMVCX3ev7DdFDkFZ77H78rMrrmEngPYyEHgNGAK9/G1e/rkdEsGnGoJoPbkESRZGhZV7sIBI4w4AjAPRxfvgNsR+mA02gEbwUJwW2XxUZSQQHhhORTtq37Xdw1jdKw8PJhfCCHWzRDGX3VfgmU3oKVDX6hESEDXq7gPckJIFKj7rxgXGdxmFtc8Qj6X2IfdBBBiSQyUtrdae/Cw5soBUA6Fe457PtfyL529JIUDOA4zj/5wfcFl+Uv8Cyv1fPyGIXUF9qJzsK/sX8kDgvmjg98Dds/ITNp8HHD4sV/Iz5ASDbdrOm6Nn4dMDdQR6c91RYxERhVbi6v1LvcNodK8jEMm0qLgnlQw643SM56rnLeQQqam7/nwyvhfhtcgkYQ+s+Iw1qfq8g3JGR4ljPVUCaD8NHrgAUv9qz8yEoPIQAPR1fRz/s5NA6yfXdeL9+sghVJBWf+QUCv8juGFwNUs1b/OtW4hLfiOVta7BJv6G+wK5WHgoK56PRqDqkZkFhQU9g3Zs7wfhwahsicXAA0k8b5c7RIJ0NqX0mpyNWpOzKeDvJSoRM7h9OW5EXjsB+IlA7QdCqyPA+B+TfEgARaWd+peBVKgUwoVyXKfwvvMvjUNyFEYto3xAuek+BEBr13IGloVtOFCecgA8zj47V4EwaPfD2Ds+hrBwOEhZyXqOYgz6QtRsOK26uHNWMIrvlwd0e35+WNZB28s/IDDEPZKKPKveKvSiONw5BnZ+AriRy9AvFBXkQLmK8TV4Z9AjjuXDawiQmoF8CHDOoZRN/tX+gEoMj1P/FB5YgnDhgWgSUvuZUEMQAzqBpwMfHoXLFtsEHrNzE1TKUsvqAgEK1NgMF1I4BttItbsJPpOMixVMkgJcL+totbXDRF/sBBQg8I4VUmA6a+cG+w0AlrkHcR+c46lSHt+n0T49wKLzZKW398ITgXcB62n58PNf33MAthcAMv9VcYNqAMf3rgowjv+bwgrVL4MDlLRsL/cbAL8OQgSb+duCMp4S3Oxtcw68Lw675j56au9jcmWjtV1HYnFgm+jbj52EGsyjBKBSsyISFnSPyhlIex+7D3zuSArOEWUAPzpJSC6l3aUeIPF+BC6g7k6iYVzH8XXLb84E0H4dWLgAsP9NnSnpp0KEieRf2P4ryn3KiiuAovo5q6wqA5k0pCsg++1i/4w6va+107gNDzzMitvtKHlH1rer3NyRWAZLHkyjBJ9TjKjSMJNxD5yLUUPlYtQAN66C7g8DePaYBrgBCB05WOAyAbfEnQd4RDwtQekJwycCJ4jDuBrafnspKBIA/zYAv/EnBH+YB4jVv5f1d4pq1L+M3sZ2lRhggCrga/UH1uxYcEM09T6O9oXH7MIEP3XVkQsA1g7J2BU4YglBP1JjbbuVMjoiyYRqwG2A7PMMChBMmH01zQ8lJJrYkdiyYgOJDgM8Idvv+QSlB7JSdj3zD7yuZMbmw/ehPMd2PysBpNh/awkusX6uBvCEIIj504AtMTyDfWYOACblbAKvHtuAAFwHVQKUDe8n7wLwhkk7aEWmiTvTIYBxGp4cTOynLLtLOlUpd4PCVhzsQEG3YYGn+9Hx+yE8HMA7A5hdzWOPo67XLVP19OmQge4VEddjkncezNS7wudQHYyQkORQbVglMC7VuoDlt+whQJkKfLZTgWuv/xYW4Cu8EPTb0Rns21dGQOdbMFEStIm8OKtvjm+ARUAVZTwXItD+VhGA2CoF21jLuwOKRTlMoHp6D2BmrgFl2lmhXJkRtscrMoAR12bXazvMdtcOSriyTqZ8hhQcUYgwpKfATHZRgo3vT7PiFjBehe36CJz6nQMqfKGxY8ihF5rkdRQelXujCHdbtvyW87fWRqBUDoQ3A7vaP0wSUrMAwzxAuTj8t5MczIBM/2SCQZCinQ5i+sO5ASQsJhS8HnYk+bNT3CrO5YECmeVR5MKUolz0EC1h0YCr46UMjo4rgO+hgBCGIK7WPUsKSk1F/wMMcme7a7QD95FaiUys3S3nIQzstT0pDDDXb7+fJwx1T+haypgSzkCRswW5vU/9dWsigNoHkJ1AfSFIN/lX7H++pAN5gJpbQIAXJar/ti/Ssv4wyFG5wFnIUh+WETlhxbF5RCiGBArIyAmoZBiHFHUbfJR9cjAPvVeSU/0DHdAjafE58D5GgxiJqausQGgqrjbLZB+AVso5dRfVisBFSKse2DVzzl4AACAASURBVHG+d6MEnXQYBuiW2I1iK0Ew5ABYKQ+Lehii/MnyW8EBtLn/KRdQau2+5l/WlWQOhwQ2XDBKzgB3YUG5VF8StOEBxFHkCOpgDpJ6VlExD5Fvu0wmwkDq5QmUWyDQtudJqk3TfavOItnhoAnsdQxs0Z+AjSZRqRAVbjAY0UVEg85+L0sdEZAs2RB5wqBHb5IuOyCPACh2//yJvvNjVT0kGHN85VK8Q5gjq57bSOsyAWwjPs8HKEm9Eg5so8kk+loizlcFOO4/lgdw6l3IAQEkljkrLVW8PMzYRbC9MrxqQMiKzQnC4hCs+sgYPSqtuapByaPoARIm9vi62T4LgLSchAKaB5QlHLG+5iLmgcv9ENahoJ62p1R4augyOknCI7F6pOrq/E28OkpPqv441+DJwpNqu2fLbzv/jTYZKHoHwP6EN4IojCqmBHPSrwzgEsO7z+WR6ux/U3FMILJCU4LOOAGt2D5WR863wI6Se2HWP6iHz+QHQhC5EKLdA1ZY7Rj89xvF/3PHVUQEy6AioJyAUbDJON8AonIsEYCZFdghiumuPrp/oduAc1EeIu1iw8WyLCI2v/1YzfWxjIzBhKi0tSGAWgoE1Vf2Pylu3/bXLH0lgDI4JjoDEUhVwRQ4SdXREncU+wiw02EC11CTdnST6/YKEDZDbodXGdWBiprvBI8bwMbWUFYReslGHqwB0PouwcfdTE5IHxYgvKaFaGqf4bJ8z4bbgfriMzEJRoyrxbOIvscbkx8YKD187/A7bCHA5gCO2H9j++nloHZdnAdwTUC9+QAVgOQEjM1v7GrUtpPg06oMLC3zAHo95ibMQOMchCGTHjkUYmvbGEUgxeyp6UhpjUaaQROAOMg7WPUZ9BNUC26/X8uPsmqp+yAciAG7B4iKm8NldC+G+QxwBvOqLr4D5mTYNXTufQG5cnfdEOAj9hAg9QHUMmD9bFXeuYFi+00F4EAeAKoAM6RQkpL1BiPAVL4AW5FZyWViDpR+Yj2/xBETYDiwHNnk5262EdeH3zO00ex08kB0eRFshJnpDyhOgJQECcMM9N51sLrOkoiK1UWi8gg4jboLp9ZTyylnYBwUEVxQTj0GWrzrjSgr/7hQIwoB0vLlI85/s00Gyom/NiMwzwswNf9W/quhANf/XYiQL9pYaVR0tPciJyCBPJcbSLiKLfzICYzW4/HNgxxVCgTAYtLQbsG4jV55sESgFb02HmV7bgc6JTLrSS1ZpgHIce6g6jAJ8BnlDsFJ8fiTEoSkzvI7B0QYq3AP0D4UHIUT2n3g3bGksRMAhgDoAvS7AEQzkLPwg/ZgtX1WwHT/tv9PBIFAzuvH4A6AT6HBKCfg1nPTkJswVAgPIZpvfJR1FwMndBRFUUXyDMHMoIjtfpBzEE7FDjD41MtDRLa23BKqWc8obTsdK5xV3dCxKEcULQuIs+cWIiDy9TyOGHx45kOAdqZuCPCR2QHYtwDTjEByAHPlP1b4WPGLylqlbtvXmwmq2pTZVwIsCJAELCF0bToBshET3PygycfyregzMGpNCpvPa9WlQyiVKAXZwAwBk8jMfvFQwrCQDhJ1B0QGxL1SY+Qc8jWq645UkJ1LlEnnigs7qX4Y0AOWIh+7vSK3uRDAHvuo0kf3YvnI87eBA8DXgQEJgKV3th/yAC1Gty/5aPsE6l5jefE+AFNa65TpyOa3LDUkCKW7gMfvYlNR31dKzfup5J9yDfXUbMkHbkGA0JCOs73aiaiBb1xCvV+s+0CkSCZAXmy1GZyj5GR8be4KTWkLcx+VQ5zDmAPxTOhhibq5EXP9ktRniGFG6Y8Qg72+7ejLbz9/m58LUMuA29uAfMlPZvupFdgTReshwISfU3eXzFOTe1T874EunYABq2jogUFfj+gAzgBosW7XVRS1M0DpE1C6nHiwzIQJrDASjILYlMpE5xsCNmp4AnAitJlyMCQsoBsRmAYnHnkMQnYysVvokcr4PHMu4MhxPNj5/hoCaLG/sv+cDMyXS9n/Rgz5JpdYvgwu+bkdS5MBHkttC+Ymyg2QYvrEnlBgAoTO5ItkWtj7H51DJdkEwVQ5E4m2TCyNu/z+zWx01nFSTrmdXpmKWpm9b2CFFAO6Q3YKJP2kHsIXzh02Hr1IZzCTwDsC6Mcovd3HEn/6tHwUOIBU5qMXgir7X4G8HSQnBct2FWylZbjTDgxlQB3Ti31Nwo2n6qJb8Ouq8whKfO0GCYeh9qm23qvKVOKwALdT17fEg/qjcwus2tH+JibsJRO5dZgSnu58QEbSQYD78XGpt7w8aNm9pPGHA13bZqV+0gkNrj9SanVd6vu/cUpPY8N8D036uwP4qPPfCsqA4oUgNXtvW4Fr8k4QQ+KDTBQYBxelFJbf7IMq1N22uANOqtGXl4lEdhHl0c2FCO1644TeODRo18/AwLgWB7LVNyYEPSA4e26uq7iMKF+BTiOy7k+y+qTYxoHEA1wp2ygHESYIu8DxRL8nDPND8TkD7QLU9U4Rw3LEMVi3FX3fnQBaGZDtP/1GQFX5pu7JNeiQwAI5f20OA5RzYLU1CT6I9SvzdyoBhoCorTdQ9XGIQMnMPGjS5YzDiTqMxACvgyNKJPYqCAjQUd4gg50n3dghawdRS6wqpY4HpwQjXB8Dpw/eHqg6KiiJyV6zVuzHO4oIdMr5jLdFlxMreuQ6zPJKJOtp+R3GAaSOQN//r5KBAejrHAFeT5+F/S9K1xKI+UsL1TbbFgBGlQDTSOStcwGu4feZikAH8F5ZAzdR4u4AEOraWC1kfgJLgNBTkXCvYN7Abs85r7zRfi/C6jfy4cGvVXnG8s9c1xGw9p3IWL29gwgch3mGkdLPEcbyO87fLhyABbyu+2+XyxOCbPkvxWfZ/le16+UEUMlVyY9cBAMQiUKBs4YiwgmYcmO+8dVhRCFCISgcJgAksX+6JxpUbTG4HLbdxjXgMB+dN1DtvJskrIgsHDnOgdCdI7gPeHcUYc0q9VyCsOcCYgDOHLvEBnPEgFsFzmuinDl2EvbYy0efv92XAXcwxMnAAuym1CUkwFJfIgi0xLpKgM6gAC8CehmtCBBSVswTqFhWEREO9GELbz43uo3qQPyA8fE7KRiTVs3Ee5JyuYEpG23bce0w44HmCW2kknZwl2epCO5Y2KBiYh8qtOsdXedTiOTFuwAdxmhio22X2JE1wvGuIDr2TgCuFbh2/gEJkNrLWYHG1mflr0osSAKteRjnA2CgYahl9J9QCSCCqjdJxd8E+C6wjzQCkT2PYvC+zS+E2bPr5BaEk+jF3gZ8naoFq3cIWraxg0qEGsCjXIHdp6fm1i4zqUWqOusCZo93hGimlR7ifeVElt95/tvZAbye1Vr9OCiEBJAI7CYATdyeyQAAzJWDxBOKNMpXpfCALD5P+EkPB50EaIpRXbtN3WoimVdvaAD4ELTC+hp7bNYLUKtrG9h1b/GDMCQ4t3MfnX6AFq8HjijJsZ48BOseA3qkOa16PSdCJJmvcfY4RwDs4/04BBgT0NGQoW2/E4CpAuyqHGT/tynDGaje/mPdv9lkkyfougEIHyIywAlBmYjaw+lVAgY9AZksfPbfDpbqRQSAo9h+FALIfgFM01EfvbTwISHo68d+CAXEkCx6lQkAyxGyGFn9XtmS3UYMlL7CKzDOqLZSVL1MWPLFZggeY9+Z7I4dI+29/EvVAWzgxrhf2P8cX2v7rxOAwzyAidPbMfybg0WugBN3w/gfwgl2EC4bD3kGpdiiStBczAzwMI8xEe/n62U1miOEQO2NwrVr6AHYW/o2uM2A7JBF7zv0VV+rJIO1d42KNOw5tTOZdQFHlH1MPLEjOS1t/BQSj1xVb/lOANUBqOTf5gagGzAp3a7rOWTAfxGkUAFQyj+qEDhiKI+gUx3gpCOBHFVa2fcSNijrrpQ68QKRipnGHAAvE4oE76hKcCRJCDZ96DQOlQbnrHLPjo+sepQLMUCs9/7pCu/A6ADmQ4exNdfPvwdI5SDG5xEhACQLe85g+Zjzd7QqQHUAnYYgWfrLj0V0AjbbvP0FLkFWCHzXYPry+SiDRKGN3wGYrEYMWpGJnwX8Uy3+FDCVA0Fwl7+HuYFAQaOQJo3UTqzuj+fUd7ZSAefqu4Dx9TzdRcw4DSb+Adi7gOzvq92HF57DDmA5nXYCaA4AgS+mA1eHYJXe/IhojadtHkD/GAiCFC23XV5vgEss+gSh3HbGCXB+IcjOK8ArN4Gs/dT1ZshHoUcGKg+WrkuZArdudWWlUlSggRgPdm/dZ7Z9MYQwQxqjfMVRZZ8KATJxvDBnAONk+z7LxxoHwAlAOx/A2X9WfBMWZO2umX3RMhx2A3oyqE4A1FxWDcqgrjb7gBMwHYNlSASdg9RjYBJnXcXWjUAu8abKjgKwsQPR4DFA7XUf1lCD7eX4uAYoHVeCR5oBYJ90WlChLLPdd4Y0bBCy33oRdytg6mX2Pka2fjaRWckmdBZz51s+9vyd5AC4AUi0BocdgPhCD8oTjHoEhpl/DAPIXRSTKpt4fDKvPSBRHTjiBMhZWBXsEAea6lDR2wMsOQl3/IgQzHX5we7IxoEdIPxIAGuw9q+FCSFORs5ZdAb905KDkeX2uQFzno6CI8WUOP1R8T6puiOg3AugHMfyu87f2c0BVNXfS4DzCcBi+f1rvrbLs0RhbXsf6N08Qh34Cjx4XPvQzDU6BwFOoAf4KBk4kdSbDhEq0R0H9egcfQWm+wUDzpNJxyG4ezRDCLGyx4Cm40oQziX1RiQyC1gFdgXI014enFPv2XPbJKA99k4AugrQeSNw+ZWgrhPIQDfKfqAbsJMwNO3FBPpWnYCBaAaeUn3RTVgGOTYvuWUCGIFi1oc6Wt/LPUwpfnM8DOoGpcE2gsx6dr3vTMYhA4PjxVl9/p7tWiwo1DXqMKEuHbTk4r2udp2UWpHuNKg7qq5CEH3c9bT8y+fvSg7gVH4XAC1/8HLQrhPI1p8sf3oUrPzCyqucgVHR3j75lu53oF2HOW/UHciE45pxvAXsWfOwioB2m65TWfM6kCYy/BKIw/2OuwlvzS2wuoSQv7MmJ22z6/GEkvcShzO5gHFYMFLjScU+oOwvxAHMlgE3AtgdwK7qBfD8MpBm/znj75qCMDnGrwwzai0ah0I1t2FBHTzRNGHOJ0jQvwAnAJY8Bi/1LYC9g+xEFiStzDJmh975vgIL4lIW3hHFEeWOlbYHMHvdcyRiieNpIURIENA/z85nTCqaxKaTe9NEcew88vxbGfDjzn9nXdfXoQsQSAAagJK17lQFVJJPqLl8O5DJvqsZhPnyzSD1cwNMVYCPWewzq65JwsFNxWoDgvZgrG9BHoPRgEEkBkcg1/uPY3dJLuh+ZhqERMUgAvc8ITQTPU4GWpWeCyHaPnb7QVKP7k2196S4fMxpa9+6XtKhg2rMvrySBX9/71qicGMnAOsAsAXYVgBUC3CLuVVnIAx/IAP3CrFu1x9CCDPr1hUkXEP4YVTfAs8RRd633SQMM1hl/Dq7BU1PxkYmQyT+4YYuokc6wSBRhFGXdXv6NTDGRBGTTQzgx+zDJHocsGsXrNbNzCt+7GAkiKeqAxFJ9Zbn6ycXExHQ8rt3B1DmARTAp/ZffEloiqMzwNjaiw7AekLeJytzywmg6or8QRAW2ONDzC+Sdq21FwnJ5gkSkellRsUphu9Zf3negf3WwA1A2SEGR0rFAUnCKHdT6fYkIYTXQgQqLG5MLo8JCxjAjyAIysKzo1CZ+lEu4VEO4JFz/1UOwTmAfOzl95y/ew8BUhIQGoHMxKDtkFQVoAqAcQIq2VcdACp1IZV8ea7VV6g8txCze5CEwQNcH7e4CHxYlZ6IHMw2eZ0CXSG6dJmsXrwEr0sfbRrYT1D5GUCOHUH8XTmujo41tv6xRXaADOfFjwlixgU4ktiGucsleGsu95stAwYTguqYA7IPHUAiAHQADejmrUDGAaj3A3AfP7kFGeejXe6QAWTo0xeh/Qag5/DAgpfCg8gJiAYhCUY1r8Ak/goBHggBqOtQEdQ0MZATcI6jEp0Gl3IoCKEeaKN99zM5gHLo5T/3VLdALYqhR4q9r+8o8Gh/vidOgctzmOzkm1J1fLaGfDwZ75turcAfnwmglQGTC6iWv1QGqvLie/62A9vP1tqryT+4T75NGLsPyoBVM9FRuBKeSBASaZjhxMcqzCnBbHMN0i1kQmrnsLbUOYHwtWBKRWlZ2FdQANyGzog4HgPePiHw9Vu1ndl3fE0BUb3QOH/gEiYz949S+x3IHNbosEyTXWfbrQrw8efvyUnA103M30ICSwiVGIAQWvJN5AlkC7BX/gqWiAxEac928E1UBSowvfXmbsCedW8kF6u4sbUHk3i2h2AybBhm4uPwgtWJPZFdfxzEw3DBNbXMnSO67qJuXcfB9viJhKEU3qh2kPQ7Tgo2jGCnosmi4wA+4fw9YQhQ+wJqQnCQCzCkUMy6qA5E3YFSyeHijVJSuZCy/nWvamnxOOVx4Y1R3YDAnmSNDYW4dWxXYeu8bWzZGX75GgYuYaTuQxC6DEVMPD3gKb8xVvH5c3VBX2Pip4UPXTAf6MCbAbez9t24vrk6RXJRuLNNYgpzAJ9w/t71lJOADfA0LbjE/y7bn3MBocqneF3P2ustB4CarP5M7I/QRNUj1Q9sf+gEoklCZM9kiZHUWZPH05W+VR20gipFPEIMx5yCDnscGUwm554aLjhQD6oRI3fRV/y8dqIUN0MS5p5VpxKruj9mxwH83vP3ZgeQQoAW/4uWYOMEMqtEbwdyuYF8U0yMj8oILFXDgLy+FxbMVAWiNl855RbPaZ1CfRCq34A7/Caz/u1h+fPGLsErXA1LkjSYVmh3joCQIqU+ThI+NHrDXAApJitqPwwQdhpCA7bw/tgH9q/PBFR8MnegyCapPeUGOu4kCg2WT8wEYJKAriRY1Do3Can4P4PCdvpZAO+fENxoz3v2fpjwIyu/37HkPurNU/0BJuPPoBFuwwCnM4GI7XTXvmulVKDzcw/I1bxgYB8H/ryVr8AkEPQBOyaWHtHUsTAZj7OSDj8P8gixawiIZPBK7xJkF8KPwwJ4LnSNyyeev0+GAKkJKMX87e8GYKwU+EpApPYtbq+KNZP1f0zsP1MqrByqwV5vm0ziKXIpw88CwcE0aj+WLbhIEMcBnzhWX8+U4otS2GOJ4UW6gIhARtb9kCMY1PGPOoK5F4qQqovkLgI+lU97TqStU6HB8knn7/NJwN0yY9//4M1ATtmz+hq1Dyz+TAmwC2YRJhR7hA6jTtxRIIqO0QBdgOQHEB0Pvo9KzDUo0oN5gkuQbkFYWQ3c46TSAxkfbRr0gdpFZOOPq92BudbBG30soD0QnQM4WDmIHUC79kQSFtBzZcAA6EAQ/P22sy6fdP7+9XTa4n+YDYghQAF3dgNzswHTl4gn/hQyUBN/qjewNh6dggTzZFVAhQczoQJGXEMFR0LxAxO+oZvsYQHUcxk4nOxgnTn+U6sGDpgi/ozU9oUtDxp1elZ9qNod2z0MASrpEhgPHLM91Y6quxBm7AAUqWxjYPnk8/evKf73SUAVAiRQ92YFauD73EAmAaPSqnEIVNhYWdq28KZL0EVNQX1rHVUDjJmOKglRLN5JHlpAWcvecxL9dX7t44DfdwlToUSQXIus/FNIYr7SMKHyT0gKqhg9VHdJEj37bis9NQwwLqdv/3cH8K+cf2BdswOwbwYSFYGw/790DuaLktYf8wc4wDtOga0/5wK4n0A1C0X9AWa5SACa1mW1HuJ9l/H3gGkDWoUM9vhzoD5u3Xvhi/ITI7II1x+w848G+uDlINFxu0nCAxOVlC1nh+AnDXnCGYcFOO0XQgVTATjoAOD57ASQFD2FAV718fXgOE9A2fx4WUsUZl505cB8+9jqT3xm2+w6BDOLy3f/qfxCmW9QQw3KBZgsv4rlrYK76wvj8w6ooYqhzb9ne76KEaD3sxOwFJBKiPFCcwFvVAhx4LjKfjvbf2B+gCYJAOuwGnHAAUw7CEsWy+/bHQC8DkyWAHkmIIQA5Aoa0OfzAL6lF4ZuryegJvvIUQRx/h50ZELBh52ikJZ84Ri6Hr3XN0CM3PbpuYf+ul5Y4GLwHikNuvz0sWJCiYDvyKKj0uqcDMDuNgccQFf1C8kPwehdmlTvQ5UDH+q5Y051HioHIJZRE9GeA/j9579rQ4BcAeg7Aazni94AbLwZhAP14ZQ+AtnYg8ookn0qNFDHiZKHUA7kWrtU7+h8WFY0bRo79bTMQGIcyBT01NsPEu8vZtSf9b/nUoTH6ChpA761uOxnekCsVzOR2IuIwR4frqXTazBFDsWxhSFCrNTOQeyBdxoPikCUa9DLIAQNqxHqusgBbATQQoBtZaoGtLf/2L/r6757zUCiLFicQVVXmdArrgHZlpN44rNRcCYLZd+jun9+KHxt9VEJ0AzJoJ8/iGCoHUqLAUOXguGFAe08OJ2Sc7uzGLz8PZxLCBU7JrhhiHHABWjSyOfuqLYEMJTp3PqDDoD3r9/5UMvvGOiqX2B3AJ9y/sHdAfifB8MfBcXpwZkkAOTqxaBx1r89cL2NTSTWrcNcAADMgTGoAIQVAyKLmbDgsd2BnGcQjiGO9ftgZtcynzOInYQ6Bja2PNUFOIBKx6GV9miooFV/cOzAiuO5p3II1QHokOKwA5CEY1U+Z912aSjOI/27npY/sBNASgKmdwPm7L/rAlRvBAp+LIR6AHqTgcaOIN8o19orYvZIuXuKHrUIy7BA6bW38i5s2HdToGWTzN+p7YUPUe1VHm60zoIkUF0oIb0hLiAP/n78r+lKuoEDJNENPzoW+pADECU4TRAFiHZMmLBgygEooLdjV8DLGYZp3+UPnH/INgLhLwQbMpidD7CRCCbV4B0BrjnIDng5j6Ao5UDd661UDUOmpIeDH+AyY/tFt54Dew0X5qx/ulXBNdVjxTbZAV5kg8FzmatTVQEFTk8GTEz5u3bOHdl5RTT7toNS4gyJtOPMhxn+OjPIDjmAGOD+haQ9EA+IImwDHjmAdj+WP3j+IWgEKra/JPbaewJNDJ+dgv35rwzmcFJQshz1xaIOlLYfwJEIk4or33FogXY+r3ONOwS8qtQRIGH50Dmo3EOfFLT25fsWEIsGsT3PU7fB109PkwHYTc5XcH2cfVUIQpVkPZwHiN1Pc1EFeOzcvGIbhyBbjS0YRyFDPeOjHYAHv52D0NZvfy2fev5hqgLYNwPX9wLugIO3BRd34EDdgF5sa6jspsSHlQXOAzCAEYg6FLCq9xSln1TnQ12BY+s/tvz+GG249gIBGADDmn/vHJ3wZHhcva+06cPZghPqPkhA9sIDQ0YvwOK/OAewnvhYUf4Ax0UNCzKZ7gRgGoGq7Uewi98KQOBXIENJ0PQHgBoai06qbxSYXhiSQwH3wg2p6jb558hgVum7jiGoLqjynzzfUYfQcw/FMj+OFHrE4VxJMP9ehw5WbRzQuk06KmeiQw/vKPx5oxCkqv5kv75VcOEIXD6h5wAemwPwpGfyB9V9ebLHJOB29uVfPf+IqQLYMiDW+LneL5KCWBmISoFH8gBBmNAHNKs9gsL+naKIYrE7tl/afQXIkbKP1h8lBTbP6vMBUiCFi47uQxW95f5tOuo7G07wL+DwN+om+ErJbmomoAIWkM6LcADbzTNk4y17uy+KyGgZ5QFm9y3favm0nQDKZCDMAcDfBbQy9uewAADlmntUeIBAGuUBuH5f8g4dIHeSe0mYRQjBpb0af+P5Rw5gBPbR+qNkwLAkUOaBwlBVYI63EWQCFt2u7ZAC5wcOuAq2s1WRBxUMFd8710L3aLSPstwjiz9yEOb7Bd2Jj7H6qPyFgHYH8K+df1TkAGhOAP5ISDf2D0IA5wx0SLDfnKDcZwYXtwebPEQv+RerfOsALAR2QOEflRCcU2sdzcPSOkh6bqC/rgv4YTw/mSeAee46XCiJt471f2ozEc21Vw7Egss7gmMAb2PRkQk9N2vN273g0GVs9ZWjwGXoIDIB2BxAifdLjd9WBvavxO8GkPmAuPwXNgkpyy9aev2LN9FZlPQZAdk5AU8GjYDIlaADwP6AunxEFu1c6i8cdHq9dwNHEn6szGbgB92CR1xAPR78WKUClwW+AFe2x37fY26iF++XkC/cRsy1j4iC3YghjwDghxwAjS8bOliSsMRgAd+u35LDVmpdPv38Y6IT0DcEpZ8N2y5fTAxSXYGz+YCw979Yc9X6q94F4MODBstCEPPADknmEWQQAXAW7EMXwAMF5xlMOoRpwB/OEwhFd2FDQAZB8xQm/ZSb6OcEWi/+GNiW2F8EwBmMGMIoQnn0snC+ATmAf30nAOwE5CnBQAZF6eGXg6re8otCgmSftfn562OugPfLjTKFueu/+/dIJNHWUQOSAWveKqoaCGDXoRs1F02Qgbm2eq2s+QhxpXad9UMF18dDBXQEFdp+TUXlORibK2PymXAhX+9khSAC8aiRSF4z9vhDHX5MFAiqosxEHvScXEhAY4mz9WX7/d/wtWFW+f05vDNY/tD5x3UOIMf6+AYg/LWgFAqU3wUAu29m/+WuwB4ZOMBj6BDlCvLNFcCMbTzo7UQ4gIFEGyyWsLQNVyDx4QYOQOkQRMzsyUSFHpPJQ2HXvQsYAD6o0fNeKsTZlw2nCw+s/zCxGTuL/c51ZuVZZ3EU4M2eI3mM8gt4TxrgrYNKxDBa5q0+EgqGCzsByBxAfUfAdjJ6EYgDvnhRiCgDGhWnacJ2HcfxPjlonQQO+uwIuiW+/FgmKwDWfSiAeYDPgfWY8ns4DNyCULH5sAM8wjCB1wFqdxrxhPXvZvdji74fWWT1LbDngNqO1aAXxdxo8SX4B2U7vD57Dhvz1+0ciVnws9Ph614+4/wTYQ7AvSLMvAtQ/UKwfVGInDrsGnrgVWFovdC3NQAAIABJREFUg6hL0PfLZyZUcwT2e1WCA8uYypLPVAD6Vt4CWYNsDuyHiaMb44/cCJCZs/1e9brkMcg1xI7HWloFUAUqY8uFks8ouNsmfBfBhAMopeNOjb88W7TzDHj8rvx2JhsWWELwQFfkBt8jX+fyh3cCiHIAXA4E218Ayu3BJiGYKwkl9pUvB6GfFVcEUSyPA3XQF2Be/MHA058r8Lp9AzNWHiEcgV4vlwAzCjhQfJmTIMfy1OMNEniWcqxVLZbbgJfeLYAgMccKCIZtdXzsvKY7yUgBXX2HA85BvjvAX8tY7fW1yVBB5i/QGbTvtHzm+SeDHIAvB6a4f9tZTw22IKIyYK8qwOsoL1CHPcT8ZnBQX0CDoH97kB+gDGrYQuQKZtR9ZptqsDMg+w5Dx/Xdfbox/gSRBDVz5SlcjD9dKfBHm5t41Ak5trF0sPvQqafLbcw5AKPeNKMR80W95Jw7Ro75K9DhuSL4IWDLc/7tuNbbrqflM88/lacD55eClqYfyAGU14DLEmB1AtvD3E4avCLsQCJwP46c/lvOYRU03B6z7oY8MHYcOAKjqvPq3gf0/HHYOjtyCRJhkRLr/ScThzzPYTLTzzC3CUALZksmcRjSTyKqY9Iy2X044QBA0fmXftC9qERduQ9R/oATk5Gtt8fx39WGCqD8IjxZ/o1KAPmHQcorwdyPg/jJQdIRmORf3BlomoGqsyBg8mzB3ChkFN6EFzYZaId1MLlIALylIL07aFfYW9cjGExwjhKKsK1U9FjJPQHpWFtup8qVYUJNeQK4rkBNmaBQwcw6SiLi4Ld/BwlBUX6ThITABqLjkptWaH9upcj7vodyBO1KpdUPypajbZGcls86/3ROAuZfB6r23v5SkP9BEJsErL8VOGgAqgMumApswM2JQEjuWZDmG6VyBKZzz27nCMLNAdDuwEN4e7TsSuygUI5AhgqPCAnmwD4Aarn+x+YIDs0JsAN7/9TtIhTb47sBDjQWuXCFzq3seQN9GzF+u7xO5hi0SuNxvdpbEk2qHtl6f13xtvYYyx/ZCcAmAfEnws1rwrD2X1/80V4Lli4jeGX4IAfgHIFqCFI9AwQ8m/2fcQR2GwtKtupe9RWIY/ud17iy2hPIQyokE1dAT1Phg3Apg8qDV3MinzC/EKh4cSQHKhVswRPJKMfUU+8gPAn6B0YWP3QPzl3pUKSRDth6SvwiUaQwCbfF4yZCWT77/DM5CUjvBDRvB6Y3BO1gFu8LKE0KNd6eJAOX9MuKCkk45Qw80LYlUeIvr4P+QYZFyTuYc3W2l0DPg1uqe6lw0ENjmnHXlRNKSsPlthMWfvpYj+w0LHaX70N0vSZJdtBNGMIJwZm2ksQgGmvapB/lPjRAu4oukneaECy4y9iQtv5Atr84gnYP0nmWzz7/rEgC4lTg9lqwBK4A+KU6UOP5BuI6wCNiMHkDNNg8PRiJQalzAnm6TlZ2pd5+mY3xWZmPOACtwkN3AKw9RQwO7L7DTp0Tj11BMdV9qFR0dE5rUc31TCYSnXUPKg1IJAhIBFJVahHuKOuMym7/bqQy8zNgY4dAyu5afi0Z9cMC3Na6ALyO5XMqAagkYPCWYJfph7IgkkSvG5BLejJ+F6XEzNYyZCCGN+8fhPjp8QrPoFYkhARm7bM6b8kke0CidjLxAE0FtrgSoZy9aH9vrn9uymUcDBsqICfKkpHzYeurANlddpAsyhN0cf6BygEnASX4yZ53HQT1Szirb5KYMF5cCGCJYfmj558TSUCcAGTfEdjyA9uBsB+gNf3YDsB8rB4ZhLE9tgDTkHY9ATzk2YE8zhFYCzsCPDsGBE9SSQW2OFygHEbef257OPfwvJ2E5aGkYL6yg2FDBZxI5ikVD5cF5zXhBWb4RagUtw9b58MkIc8RTCjy+/pj21BFhxyt38EqvM4VJDzwdS6fe/75gABK/I6/FORzAUgI6aJ7cb8nA6OKwgVYpR+FBwrkmRj2757+9hrdW0YgFDkB8x0qSMsxbVCBD79RFjuLNFEFlyovIY81BHtg4feA0PsGPoe24pFDUcSiJ+F4YvQxe70fopQ2dgV0vPDlIH2gN/LJZwzKergduwEFbusQkEhtWFDuk8wJkAuw14Ak0v5e/s1MAOmXgV8HAGNIQD8V7nIBfmbg3hDEyT2cvWfAXrZFsDRQ+r5+VnelzGUw8+C0/QAGvEafLQANcZgsOJ+bv0McBhglJ+Da6+qEFc6S41E7wBwmK01qLT3L6XkHcN7J8p4lu3zPBhWOUby/X8WwD2CsvvgWIAQgg1Y5ExdGoAp3SoazLoEVvYUG7Y7uy4KE4fJ55/dQFYCAL2cF0u8F1sQf/VIQlg1Vpr/zHgADOH6TMCq5nAw0o/QMlAjwipR6roBcSjVdcHwA7TTQcxlLw1t9FwDwNNgBho8oL9qfCnucK1AgMkQZWfhJV6DyDHWZKMfh9YS5AVVFKGosGqgUuPk8cQhgHcG+HVQ+GgG0MYpuwRLGelr+2Pm1DgFsyhxVARDsOgm4X4J7PwDYbfGKcGvRm9I3WMH+BVxhPkCoPyQK5bkUYE3YoMEWA7kX+3uQmOOYcCJyEiLEAPCqMEKGQMPQgex8x3koZWb7Hln+npXf1z3KFYAaDhwJ2/UplXe/GkzqS6Q1EwIY+y5fL6YtfSKAGPwYBu8GaSOA02nrAsS5ALYMmMKD7UthXmA7kX9V+P7Vq7IzMYAyY9mwlu7QtvO2AvjkBDxJsFLj8VmpESp4rp66otNottXuMSIMALBLYtlrUkqYQDEmB0MTQ7AL9Z7qUCQj3214UvmBfuhgyUHnF+oA707o8bZfHdsAlSoAPTfAAIxJJIOYqhQRgA0pgFCxwkfhA4N/I9Pl88/vDQhgAy+WAfnVYNgKjIk/9U4AahvmrsBKAOkNQumGlb+L0+iBOQM7mi1YuwMGJOLUvxBGENdXaz0CuSIX+2Meo1DAQKtj6ZXi8zTcQls4UIwiT4cMlniwb36k8Hy+rmsQquavNx3BWny/rLs+zBd4wrAq7hXXEYprUEIrj47BEtvI0itSSGFB++7FFShiWP6t8+umClB/GKTG/uwGUPlFGbBafpoIlPMB9SIGGX8LCN8PgOvd37IJiN2FJRSvtZG6M3zaoItBnNdU28xn64cCKvnmgQ5LgtKdIgef+e9dCwzOQV1fuRU7MIk8REnOkYhImvF3Qgtf9ne2vpMY9MqOVlsRir0nHmR9cmAiYRKT4B2QCcf56BAsYayn5Y+fz+t6em9S+1wFSMqP9f+SGMQXgkQdgfyeQHgpSK8TUCUJUbkVYbjYXABL7seKDkpvVD0CuwIwDtd8PIjduoClwV/6t9tVeXrCAKYpL1/D8fyAV+5jIYZRWFk1sN9FAXYfpJ3wQbsF4QA6hNGz8AiS9nf+ZoI8LIhRzUfOIYjXZduwdQwF1Og0PFn4fRoppnXLF+wEsM0DwNmAhQAoDDDvCtgOZasB+8FLrsDZ/M7U4GL53ew/tOyYW2jLGxCUDUcVF4ruQgPlCgSwndXMxxY9AOgKujB2MXYnrOjE4+4cE/kBp9aySuFjbkdqjwX8cD9l73W+QJGDXoZAtSodvSwUwWaBR/vn8dFAinbcEomy5Ug6PUfAxFMIAJ0PhhD1XECMy584r+f19PpiCWDrB8i1f3QD9V0BOCdgXA2oIIjmC8gkIDiJMEkYATYCfk/RRwQShAxVqSKiQK2GbUSc3XUJZOsjMkk2O6Ya4QlEA9BEGDBVafCk8fhSYb6mQSsyAkoBFsFhXx2OVn9k+2PyaCDT4YICJ8fxM9so4kiS3sY4g1/ts/yJ19fXT8v5YrP/rRFoAzV3APZyAWKSULX04tXh3B/QqQI4BZ0OBY6qP4OG3EfpAOzG8R0S6BIFhyTYCcjHZCLCh97bFvYbgBePUghFEgfUv5la9+0fWyoUPQ+spp4slUvIy4JJP9rqd5wBKPu+FZUklVprcCty0ATkVP0FzABsxLCeli987/ra6eJ8lQgArH8lgEIG21fmkIBfEhpXA8y8ARUedHIAxuYfJAAkEA+dNGw1bPLyUKnbnjYMgTMGDT9en7lXQJEROIlBqOHASvG0AzgBuZQVI5DNgj1MBO5ohqNMEoWO/W0o4B2AdzPKKhtnEHbrHXMJeL06Zrehw35doiQYqb1yCvacNgfACcDdMHzha+vPL5frjSWA11uNf/8VoOwGaguw7QfYL4SnCZMDaD39oiRYYFh+cciAUij5QRJAE+7BiiTAysvntkqtgRw5CR9CYHZfHgtn8k2GAEWZOKCx35vuyCDmd0RgkpvC5vecwcSsQEVQBkCdY5S7zKDh79CAkvc4UBnAc9i/PaDLeas7gFePK2CzYwitPhAoKroiHU94jRiWL3pt/dnl8nQXhwD4I6FRI5BtFEpfGpN+/ZJgfeBYJaAMPyp5IhxWb0EUJsmHgx72hay/BiEeNzqGWh6QhQkFPFlU4HZU296LfJ4hQcC5ujkChF/eZ6IvQIJ2IgE5VvV23RbcmnhGCT/1k2EIUvu3tuq9mD0RcGzxWbUdQWR3VAiPyUa5l0YAREC1XGhdEB57+aL3rD+zXJ5uT6fzhc4BQDtwdgL7acqvA2GzEMf26heEqtqXGDvIERgXIBKCQYnQEQUafFHi4+2tcto8gIGryQXwXmW/pi5IV96F8HbsFo7kCDyN7UcLymoRmcQxvz2+2W744lJBLtOhAA5ivD+WCKpiypZfJBN/jFllTyDXoLKAtoBk8HtwewehtsHviODXboHDFhsWLF/88+tP7QSwbHkATP6h9S+xP1t/3SKcvmjPAdCUYdoeByWCpS0fEAKAXhOCdwt+aCJkG4A81AnshZjIVkugCWDyddTPZkCX60fnQS7Eba8gnY9zcCZiUTml+jbufzpZRKDEI3PcHOUetDuIQeqBHpBNVW0kGPs3hhwFtF27P905yHG+/WxzD7xuPS1f/HPrT1xcnu5OF+t1IoDcD2BifwQ6hgSqHEgtwjXDD+8CiKoAveWDvMBxoEckAEBy4UEhBVboTAIuOeeBWgaVpY12XOMO4HgxQWEIwJG/3kt1/yngmr3B8cTuQJOMeuOvpYZ2N6zNJ5WddBgMMFRlQxwZuHPlQFTS46GBU+fJZh/lGiJX0F/uwb8nAb/kZ9cf23IAmwvoE4B/S1DL7HtnoJN+yu4zMRTQ0HITz5M6C3LoEcJwXQBkVvEGZrweUuLqCFROQOj9QOnrAB6UFflaG+iZJIJwYxgyRGD3pIODX7kGSShh6c6SwiG1f3Q5MFb2puLevvMbeXu5A23f50MCD352Bo20EkGmzxsB/OjFxel2J4AtD+DKfyUHoNqDtxsTOYIcBuwAoFmBJjwo4ImqA327PwRzQBxuP6P2EVjztXbtPWiMSPjxeROJ2EDHAqK5g1ZXLyTJZMPuJQC3y9Lba2AV5rDHWOlQlSeJ4EBFoecODBEEnYU6BEBw4/2aVPmOVUfAd+0+dZYiQNG9lOXaFSBZ2EQkfm889k4AX/oz6w8vmQBOy3rVCKCUAqEBKOoK7LUI5zcDmRZhsPoWEEwUTVkr0TwhFHDgo0SeU00gDwaf0O5UtAv6Bpx7cOdWpNPKkh5OjRjseZ8SBoz31ZOHYrC70GLY9gsEOjULUDuCbihB8+XZlVg1Va8wo9CkhBKgrAxcrf6oysJBwPFKWFPBDO28fWLga7XOYPnSn15/cFP/zQWcLk43iQD43QA5CVjfCcDNQUnl9y/NVYEM9qZNrPTqF4S1/U/H8I7giAuIgdzIxuhqlySyEstYnQBqEn6ODmzBslOaNPCgrsQ+gVmC8S4jDgX62+rjJlLyispgw+9jtyYioJh55jgFNBwmoN2uahoc36qnBWkP5Eftvtn+ES8Aad+JY31yBpCw3B3Al/3U+gN7DuDidLP9l9qCg1eEj+YFmJ8Vy+BAd1CHuQgJXFlvZP0tcXRJYAbEodozMDKwpxS87wgYzKGrCEuZjarkvmKCUWTn6/7d6oFXW3NekSj0oB7E8J1ZgAg4RRwS2CbcKe8I9C4D933q30wafLxCjk7VSfFnwoa++jdyZutfPi9f9pPr919cphzAaTldLxfrXg7slQTxp8NMIpAcQB0ctR8AlB1mDbZBpPIAbR8P8njdvm2YxS/k1FRfba90mo/J17Q/tEH1oIGtnZ8DAEM7gwlHFVKmz8H4GNNWZUAZtjrr/cu+KqnYA7sHbL5q0QYcJfZiJfeA9jP67BU0d9AUM4rZjy7HqscMGaht6n12Mwu9wiuCQcCzU0HiWb78J9fvLTmAZSOAy9NNIgDIAVA7cCOH7dBifgCrPr/+y7T8stJbd5AufqYikI/zQkEPRAFq6kGftwMw9bdhcBUiAAgFYHZK3w0DWO91so+JDn1FJaZwXgOqjCcNXMLvLVCKvV0xfke9DbgIasiJyGOcAHyEK4C23nLNM4AfhQcR+PvLNTGE5JCvffnyn1i/u1QBdgdwuecB9jAgqgi0Xwr2MwRdVYAbgvacQCYODAnQgqOTMNoVxP8VLOP8gFJfBdZk08gh1GuEYU3bKEcwk0C0DiQmCL6urnMwLshvKYFe7nenXdhCpUG2B3YNan+kLuCDSUMRkfDgZxcSxfdG8YO23h6IkQwUAI8RAFYjJtSfkoNa/dsxl6/48fW7qgNIeYDrrRqQXgQqZge6dmDbJFQV2839L+CkDsGa1Rd2viQUiQQ8CBCoPjdgQOlKc2jD899By7DR6Qm1t8BHZYPrFSVFVuR964HSGyhRHC38Bfy8Sd5zInwwAK/PLS8NHIJNINp7wKpsSILCnmMgt1Bnu+/UGsiOVXZs/9t32vNrcF/aeY9m+/0x05i3x9HHtyRhyYYJZD0tX/Fj63dsnYA1CXhxut5CgfV0XhoBbOFA6f/nBKHN/PccgF+XnIAdoD4k8KraTwByydADSIDeZekD9Q/JgYHQcQ9dEgJdFrG/vVcAmWEfA+q9CgVYjW34gNDVnYR6e00a9lx2+jGtOxASDElioj9gnPW3ScyR5WcF7ib2yOEUQomIZLScySxtjySyEcCPrt+OBJAcwO4CLuPJQQX0pUkoA7mqPvyEmKv50zpZ2hN5AQoRFMjtEM8kMcgJ7A9I2HjlGjwRAZEQAB1QJXEQKKmPIDofxuXKLfBRrWPiUEABl8gA4mxUaT43A1Bu24nZrW73iMCC0MT9gz4DBAWC07kCqB5YIHmV98dB2w6Ae0L7ryKOEcBH6r+tX77yR9ZvUw7gtBFB/akwGw7YFuCcKwCHYJt+GuDrgBBVAQ9oVnml+p0qwKLzARGwJdg6Sj1PHKiB1hXUc1KC0V9LftQy3yBIJHh7kTqu3TsPmW7VwRKItfgxcWgngL7iEYDvJgA7JCGsOpPPY5xAIVpU2VG8zw5BOQoP9IBgSN0j0ihOYDv38lU/vP7NrQRYQoDiAPaegNN5SS/+VAQArcG7jQdlr7G7bRNuIUB2DC7Dz4Duf5YuwIAkIIEXAmxQf3Yn3RxCDGZWzP0M7lpjQtmHhXM8HYIIE36iemBy883f1KM7MDKgvR9ojsF/c84P6LcEz4Mcz6Cs8zQBdBqGGKgj8CtgoxMp1xmRgl3uE4T6WG27RAA/tH7r3glY+wC2XoDTzZYH2MKARgDtRaGt9MevC6eqgJnm65OADcAIVJ0TaEMuIAUJOjrWKGO/r49Ljggu1i6/zqu9qga0HDps3ykBWhXXbzCSx4S2WksqilBilW+uxd4B5QTwWu36jvJT9cESQR/w6nyodhFAUYWTs5u3+W5fUOERATxV/XvEgOTKcX/5nAjgB9dvKY1Aex9AqQSUZOCu5vZ9gb72314ZZhuDIgeAICt/RySgbD4s25XHbtMGQl4+yOonYPpjaAUmYIsuQ+MNOuuNNlMYwNbcaG6Y14jcgW9OYo33kIQzdisEVun5E8fcRmnhO7cBq4mFj+M/434xgBuBWSVEUPDfqKSsqk8jAEzI+Wtm8mIgxxa/3QuzjygRLl/9d9dvIgewlwJrMnDrCajNPr5F2PYE0OvDTD2fHYACPMb5A1fgQC1IgBS9Den8Vz2GIJkDiUHW+hILCg9gGlPZrlt1h6vtkoinivr4O4lH3otTgz4zr4DerhipB49djytr+Lw/gsCebx7wvJ+ezIPgsX+jy5hxAkgkcWzOxPFC7b8oD6rz2dxEuu7lq39g/caeA7AzBEvWv8T8+bPp/MOkH/QI5Gx/+uJcCVCOIG3XBlNT83oMnD+ACm4GvlB2E1fT+l7VYBRCiOahmHSMT/BvQAxdS6TyrU4sCQnupAV/HoqdsMNqq/EiVMLlY+lQgtUeaSByAibTb0qDGYD1mUZOQIcPiljwGmb/ZkC/MPs/VfufcRI2R1Cub/ma71+/YZsMdLF1AEIIAMnA6z0ZmOcHsBtIIBVvDS6Ah4RgetAZcK4SoBW/kgCouSKAemwHUjhusG7fN1D8fbhLwtiuwocYVsUBao8gD2uGmTDaD4A4kjHEGDgE+dITdUYGMak2Ac9ruicMBh1q9pAcnpD5b6roXcIs0Mueve1n1D2NuQLco/a/PScbFlgHpdZte+L1LV/zfevX7WXAy5T44xzATgSnkgzcEoHcIQgNQjgvIFcGsCRokn6mHbjlAbziCxdQv4TNBcgGoO06egnCHjCDEKJCsRv/91qJUaPVnH/WcAA/5Qo0+AWQBVDtvspZcGDwxAai2iXHNCHUWTgSr9YM5PZZKTvaYiTqNyT+ly3Ex0KEXpIPv0sBtfoeaR06BHuvl6/53vWvKgJAB5A6A/07Asx8AaP4AGjpAJoLYMBXh5Dr+MY1uKYhC275rgA4ToORbhJCYGM1wKh6zykU5R0RA4UKXqM9QfS2kU5BTFe27iSdw0Pc1hCsMxq4AXFEa8j9Of1PhU2QAxFJFDYwIPDIrIT9UMCCZr8L+f72yKOAj8GKLiLaRrkIdc0N3EguviSIJIFOaHnH96z/TyOA9Xq5WNJ8gFwFyAnBm6012AJeJATxfQDmBSGo8JT1VwRByTmboYd8gVTofq5gH4JEChVcPcUfWXhJNKTkzol0YG3CDuUICPYyd2GPrz7xFfjXk0U+wZIH+gc8JlIGg50BydAfK769B6iYNmfwhPgfMucI3OhvBdzHEUD7bmzlX5T670nAd3z3+leGDmB/Uch6KRuCavyPCcLtEoPPoOLcB+A/l+NQmS50Bx7cJiyIAC6qAZYUCgjihKKCaB3QM65hMBeh6LKBozyu0vSivN4D9BTeazFexYQbCFqIFUEoAvkFIYAXUPNnRY8qDJFFb9vbZF4E9McTgM81LO/4O+tf3gjgYgP5xem6/Lsrf8oJ7HMDttxAi//FT4nnVuCk1qU6gPmBAmKO98v2ZZBah9BsPdp9BCLkCCJHEGX9DYB61YBRJUHAP0w4kuYOld67CO8bED6aioptxbVqL+cIZPXABx1zZUN/RqvaBUqWsHoWHyktdAA5b8IWeqToCLTob7w2/nvGDURxflTjj8iiHx5wBaB9Xr72u9a/BHMBahKQcwDpdWHr/ivCtTtwSv079r+ShVJ6ArkDNxCFiXftfrbWzknDomh+eRqC/RJhA5OuBoSuYNYRhDkFHTrIpeatu/aKPIytz2AvYeBLOQZj9aE4GIYDlC/QDkBbfHQmFXTTLwZhkrGqOAP6WTKICSBOBvaBHIcFinw4dFDbLF/7nev/ERFAcQAJ/LsL2H9FuE8ATdHrdOL6Ik9Ue5hEVIFW1JxcgJnYw+ssUFsSUQCYKgIG5NNuwB+3W0IEEFv4CVcB/fZ+DkBEJ6iW9h2EZQ9FDHHyr+3FYRAThgItghPV2cLOlqL4jKz4BvDGMSF454CtVP8poMd9+27A229FEB6ko7BgTCaVCMgJbedavvY71r9YQoCS8MNOwLpsOV3ltwa3ZCA6gPIGIQwBTIKPAa/ATstMYq2/rsJDkkUBBoOOqwgE7h4pyKaf4zkCA+uZ6gFPPKo9DAdcgcz9Z1BCmbEXDlhwT+QDqOKAgz8kAPEz6A0gDHhPAArYjyGAXlPPvBvQ6q2s/iH7P3iDcHIUMUks7/zb6/8qHUCO/wsBZAeQJgjV14VlN4C9AbXjrzQHgSMAckg3DtU8/b0vM3Zf5AyicEAtFwm+qvwZcNsZ0uOxVj4tP/tZAuEx81AOLX4jCFbXvr7TWvHrQWp/TwnGxCcq6VQm5ghABRK6QuDDBFgyOZvwRRHASPWjRF4vwddzAyrWRzJCoOo3/4zsv3UKJZTogX93AO/89vUvcBLQxP9pXsDWJHS1hwIXJ/sbgibbjwlAagl28T4qegGeDgssYCnGd2U9jOfFtqIMiMdvQIri/8i6Ry5DQPNoDuBQ30A6nwUvfDowr4CP4Qmhnam3LVIEvxgUr9UnBHX5Ds8aE4IlJs7Aa3eglXKGDBjgngwAoFK1VYgwsvfz66Nk4/LOv7X++cv2SrCWBPQOYCOAXA1YL+qPiJpWYCYA/FwUNi1riouKH+QAyBUY5zCt+lEVQZcOK2xB7SX0Z+r/IekMdN+p87xPaA6j5wPweD4rcIQAmHRGVQFDCrWxxzsUJgX7uZ8DiMhFHQNDkkYqHpRdMoDmoC4BQAjWFHqWALzSWycROwHlOJZ3fdv65zAEqGVAJID29+4AlvzSUFvrL2Cn9wcWglD2v4JHhQmZMIJwwE7hRetOScKOQ9hed+Iy/a6/P1D8EPht+/2vrtprl+EhOw/8/SHTLxVZmOtgQZ2T4Rg6AFHK9Ha/DD90KKzS3lFEBKBdANpkPp+10EwOCHrlDup1POItwUwuWo2Vxe+TQnM1CvRzRLG862+s/9PFVeoDSLX/9Xq5XMq8gNIDsPcD1HkC28tCytuC9vi/5QLs5KCi9hTrLz4hmIYFLBfk0GJ0BrlS97hvoIGylxT0wN+zARLQUbigCEYAMDzmNig6IUcx+wecQuQHpglgMmesYnE4AAAgAElEQVQwRwAWpPiJATln+z3oFbBRCc3flIfo2XpW03FuwAKSHUI7lwJuDPCx+isSgT6Ad33r+mcvLtfbi8tley1YIoDcDmyagbBJCN4WJMHP/QGo/jv4CzCa8pvmoR38CuQR8CfzAlRVaFBMwCbthnx7v1rQlH4EViCEx+QBwpIiqmrfLRwigHqNVqnLGXgpHntEAArQPZCzYs8RgnAE1a1YYHRVHyoY2xE1McTxeEwWihReBAHMHmM9Le/66+uf2QlgdwBpHkBxAzQfwDiAbTvzpqDa/beBYOsU3L52Dgd25aT8gKsAJJC1TkIgCRcGFMvfs/u0jux+ze2HDUY2NxCSwyAUMJTgQD9DGBluA8KYCRv0NgBjOsdcCIBQbOSjYnzW+xmV77kCre7t7Uc+ro9A384ykx/oOYPY7iuC6C/zrmAW2GW7cQixvPtb1v9+I4AN/DUMKOEAtgOXv9u04ev6Q6JV4fPPiYEDSGW9Bn6XACz7ZiA6AqgABUB3l5VBaEnCFvM64cHmPXq5garCojyo7Lo4loa9WDrhEmaAbxWbCUWrOypu8Rc6BzAmAKXe9vg4UNvVNoBb6vAzCDmXYOkHjzMCOKp1/Hds52fUXrXz+mVj8NpzWdAXp2IJyRPI8u5vXv/b/Y1AFycggBwG2EpAmhvQXhySkoEK/MYNMPjt5/1xZ4Iw4HdhgOoPiJzAWYCYty0Oo1j/mBQqNAfE0LaLlD1W/P45WFnb59m/+t2KaNijc4228etHLkCFDHWZKZURAcg2Yq3u7CBeDAG0GFo3CcXKrkAbAbmQ5B5zmIYe9Aap5Bttw26Ft13e/U3rn94IIKt/TQRe5ETgHgbYqcHmpSEpGQjKf4gQGvh9ApDyAFL1rc1vtr6fK0hrAYwm4QiEYGJuDgIYzDZP4M5hOvjw3D0IHwgRuEMwtPP6fAreKl8QuwDb/BMpPPoF+wvD3klYsKrmInYOXjWZAJSqI9D83/ExMQRRuQGlvscJwKv2TGhQCCFyFuV6l3d/4/m/urhachVgvb7Y8gDpZ8JdMrCSAYQI6dXhSAD5rUGm7JfAjDMFfViACg3g7zqBArPYCZSuQgvIsj26AASbdQMWhna7FC6U/43MPS2H3oKxgk+SwBNyBFEQoMIL3tYTAmcOyu8aiuVZ2SKyQACV+xSRAm87H/+3bzRyB0pNLaGo0MCqtyaA4yDv2/92TruddwrLu//a+b+4vFzqK8G2dwPCJKCwMajOF9hfGVbKgBH4ySGYnEAC4YnyBPsD5+2IDLTiN/W3sbxX/BbF23Ws9WnwAYW4xB/rvQBt3sevmQF4sM1EjsCCK1J/XK6A2tbzWukIRKvyk8IBRxRzdh89Ayu0KttFYNYlPkscTDhepZsXQbseATRW7nYmbf1VeKJDiG3p8u5vWP+z1AmY1Z8SgIUQQP3NlOE0UzD/glAmgqT0ojdAJAQl+I3dz25gL9OBM6jHauCs+Yi6La2LlrvEH1KAJ450VBECZCdg6KDjEDTRKJCiYxl7Bt5CKbmGvN1zJiyI3yCk5wNwoKCIQS+z3kOpdSM7TRDxPvM2PyIDDgdmE30vngAi9dcksLz69et/kjoBKwHUMqAMBUpOoBDFnhRMYUCz+Qr8eRlXBEKVL2AvNXr7uSUfM8irwjYHgI1DKgSwjT3gHNzEINybQgCO7QHwqk6gGnv0dthFOOMSZtQ9Jo/Y7mdYiW4/BFyz6DGJNJDoPe36ppga2Lx+liDG5IDqXc7tY2qr6PF2nlxG8bklBQ/c0frR8dGBLK9+3fqnLi72RqAtAdj6AEwFgPIB0BW4v0249ARI5Qcy6ILflwtLCNDgV7Ypys7uAJenEMLsWxXaVxQcQdTGICQUkSDM3YGxmjO8IzDn7WY6DTnh1/k8Un8J3ADsFnIN6HgOdg0YMtjt/NGOKP/j1R4beR4f/7Nys+L3qwOWYhCQNpR4DPjt9/Nhgj3m8upfXf+jWgW4PN1cqARg7hDMJGHbgrfGocvTzbqcL6z157jfuoINnL2koAO/yBskgJPi5/DBx/cFYAxo+kwVAWv3AeZBV6ElkkJICSx+XQZRt1fgMeqf9pkFf5l+yv4g2t9qrT9PHO8r5ecZf33lx7VouyNC6G2DYENA279bgg5B/kYRQE/de3mBBvRRjiDRTdl+efX/Xf9kKwO2MABDgpoUzGpvXhxSl209AQjyQgCvu0agdeklBZsTqIDhBKEBOQBYKv7WE2BB3iJ4sP3UbahDBp45iOqOHoBBaz+360HIaaCH4UFUVoTlEsBB4lCDXWUBFODt3pEjeIwbUMfywO2FAx7ACuwxAeikGlp+Bu0oHPAJwrm43RJAnNhr1xNvU0hgefX/Pv/7rQzY2oA30LuKABBA7RosyzYXANWA6gYMeBMZaOXHHEGGqKsMCHKAZCAnCS3wMRzIeiwSi2zlW55AATzODRjtF1UDooTAxIeewaQbWbmN+j+xUqCgzWTB23ir75U/dgneXzQV7wGdnUSc2GO3gMlBlSj0gG3XocD8YglgjhyKrvsQokMCy+m0vPpXzv9ucQCp+SfF+xd7nO9j/50URA4gdQjmHxItRLBQebACWiQEAewJdDm+r63C6XMDuX2PgLH8wgnU/VwlwBNDcx42AMAJSirmN2ptyn7aEcR5Axs6FID3t1dv91HUoJf17b7dB5XckE2d11+2ZzDrygD6DFb3Y5b/qBMYuQMGn46v58OBPph7Ci/tP/20GB7d5hUUCaRly6v/1/pvp8lAbS4AzAnYSWBvDirZ/0wAygGcLtar2hMgwc8JQV0ZSMoN/+XPFvwFpna7ppmFMJraNwIpwLahAfcVcB6B5xM4fa7EYwHM+1njr6x/FPfTGYOE4XTsPwoXur8cxKTAtNDWe4AzUBthxJY/VngmCaXidhvrDlCxEcz9+r93GLEbsADUYG5nbvE8hx8xkAvgyx7+GLhv+3t59S+v764OAN4JUBN+OSnYEoDrdf07kcHNcpneFbAnA43659LgDmAEf/D3pu8j8LNTyFl46w4A4KY8yKSRt4O+A4799ecGcBvPxyFBrN4zVQL9HoIoQHixBBA5hjjut/DGnAFSQVluXYIKDRjQ6Dp6YG+hgz1qAUc7zljpfQIwcAPwS0KKELxFt0e2yt1b58kgdhAa/NvS5dW/tL5zJ4C9AuDtfwoF0iSgPFW4/r0t253ARgCZDPYwIKu/dAMYBiDY8z7NqlsXwGEBbseVgLatbx6KQoFY7YMQARKLHtzHk4MGzBPtxZ2aAmX/Izfhge2Jw1t4a+61ytuwQIGeKUJVArzizwLfA5v1P123Vc1GSAxS5xDAelv73/a0JNOz/kgT7ZryxZlf8sVl/m/lIGLgl+++vPp/nr/m4nKbC9A6AQvoMRSA2H8H+77NBnpIAu4/MX5RqgE504+hADoB9/cGmrmQAMnAhAW7gyjqjPkCIAKT+LPgdklEU7yzvQOeMND2H3QCtaphgwMP0RjMeMbHOAALWntmdTwLa64MzIIeodqoJUr6WRhbEjnmBBqxWfi1n+zWBNEHOFt7ZfURphFJoAtQ21uXYH1Gs/498LdAYXn1f1+/quYA9nkA2eLnRqCNGPZXhOV6P/67EwEQQCGENDloy/hDEtAAXocACdi2X4BDAvyM4Hfb1ap7dhKUGEQAa/XHDsQcKphZhFHyEMID0y6MPkH/qnEvTNBGfFbd57bTxMFQL+rJVxSBXqm9Bz7uPU4Etq17wPdOIB95J1xW3raMrXtU/x8BXhOAsu4NkBy7z9j6mW20e9hCgL+4fgX3Aeygh0qAj/8TKezgL6HB1f5Ogevl6nS7TxHegZz/k+DH/oDXIfZvLsCqO24D6l6bgXxSUIcCZd8gPDBqTIlEMwcAzxeDviozzQDU8ftkPiDs/JsDuiYTVvG2lXYA3jNwVsAm9LzCe0VXZOHjdwZ2epOUpQ0mEQ9qH8PPxPkRGaDJ96FFpNL9GP9p6s8OQH3eCOB/W78M3gewzwPY7X1xAqD8Tf2zSygOIOUA9jzCXg68OF+mGLW4gALq2BE0sCdiMOBfXjefffxfgNryBiU5Z1wCTCay7oEVHtXdA72XKDRuIoOeHQaercGMHMJEo4+aV2DBfYwQeqGDygbw9r2wQCm8pRBUdeEQzAxDezSV7POE0LH9zg+o/MAR+++3xSVo0zHUYJWeVXZLFHPALyS1vPt/OX/xNh24qT5MCqLEX4n767/FATQiSI7gct3fF2hDAAX+5gJs/A+A38mghQUq/o9CgbIcY3u/bYGjrxD4/YrSi9wBdBIyQXjAxzmC5iXsX4oongL2tK8nCG34tTtoBKCThR706axuOU0fVvD2YcEoDChA8HYfQedDAQvex9l/RQCjZRa4x9X/GPAL2Szv/gvrF17CZKCdCPYuwNwMlBN+JdY3/17lHEAmghoSXJ5ubQiA4PdEwLH/Dvha+wfwQwXBgZtcA69vVty6iwb7AgZcj9N+W+iwLx20DmuXgKCL7T6v0Uofqfsx1edwIHIBfrmmCmPY3VuJmCjsMWLgM2mosEARgl5mCWAmFLB+Ymz3lVtggPJ5ewQQ7VtgjDmE3jJPEsu7//z6Ba0PwKp/6QYsOYC9VHjZ4n8AfM0HXGy5gDo5KLmApOAF1P7vZNcT0JEMjPLzNnVbtP8cKoC6S4LAPAABHCYZVUC6RGIDNNt8b/sR1n0HoEOEo44g2p4hbz/3CQDWyhmDDOhy7Dngo6NgW2913PoIb/e96nOGAD/j/seXj8jBry/2u8HWJwF76xrEHw/86gDe9efOn3+5vRIsx/yl9FfLgpdpTgDY/jRHAGx//Xy1L98JYLk4XzUXsCkmJgWbC2jgx9i/kIFalgEP1QKv9pwLaKpucwJo/znhV8godgE8qWhEAjo0YKBiLkCBWCn8jOrPbFMsOpCC+4XeiDBmw4CYDKyu+2DBx/rKCaiEIFPEnOr3E34I0ZYz8O7A0ouO/4+ovz4DHreAu/2riCKtXd71P58/73J/KWhpBU4u4GLv7kvJvp0M9lLgen1xlbL/hgQgFNjfMLy7gJwHgERgIgGbHEygKUAvJJHj/qra1h342L4pf10nOgY1UQgSEFOKo3wAgr6XHLTvEMJwowAKAWqP5EOAx5IAgpeOUe26tvYJjt498Na9vIC1+O2IHviPt/x4VKX63i2oJRFBIPgUAWi1j+J5u1wBm4GrfEEM7j4ppLXLu/7H9XN3AoAeAGgKSuqPLiCDvZIAgj/b/0ICpgpgQoEE9Jb4KwDOy43dj8BPicE9LodtYeKQJwx0BFllIUSwoFbOoCizTQaOHIGfhmxpwQLdhwwWfk/IATzyBaIzeQCv7wz04jKU4S8kY6nCAlkpvLf8SCHHQK9AjlBt59JW3G57xBH40KCdAVXdVwdY83ukYH3B8q4/u35OygFk5S9lwKL+l+ACWP0t+Hf7X3IAez/A8voFkkBK7rVQAO1/IQN0CW1ZcgnFLVhAc3/AHAlURYeXitjwgKsCCPbob9VbYG38TG4gQYRTgQz4SQKYnA7M2j6bC7Db+TDAq35s7RVoLbTVpxj8WtubXe9XAGwiz+v9yAEw9C0oj6u/phsL/TngY8CxvPPPnD+LQ4BL6PzbYv+LDejl31zm2x3A1ZLmEOTYH/7dw4DTcr5sgH8v5AFsTqARQ7b+Bey1/s/gz58hRHCkALMJnfWn2YWzwPdhAJOEzRdYGOO2ESnY5TpsUCFDXpbbnCPwegMfL5klABsa9JN9EfRV7O+tfE/TZ+J+b8+tlvdtf0QArMYM7Nj+27i/D28mD+8H2AOMPpcjLu/8H9bPvLg43V5yCACx/5b533MBu+LveYDkGK6WDegpJ1Dsf/p3dwKnPQ/w3toQ1KoBrTKArqApfKkeKOUvio9xP6u+cAHO4rcwAGcSHksS6lAgyhcoQvBaD8oeTC8uDkHBdzv3G0sAKhBQNIAQLleqrL2lhb7510D3ZNEDu03t4ZY6VEAnEG0dq72y62P119bfUsa82isyqATwtf/d+hnJAUAIsMX8HALkEmAigaT6xQHsFYGrbP+3f1siME0PXt4LpUAsCxIRbMqf4/9CFsb2jxxBjfuBHKifQCcCmQwKLLHEGKn9yAX08wSVANyPhRxPBJY9tiFbaOSxZKD3Q3g2+uGl4zxArPk+M9CjBIasNvX9UMCnCvswR+AhlL0XiAAbxfCj2N4Tx0jn9Xr8Bss7/pvzp5cQ4HJ/H8B6vYUALfGHmX/4+2qFECD9vdn+Av6Lq9P2YyO3G/j3+H2P/fPfORfQQN5yAwh8QwI1iVjCBPVvBjK0Dtc8Qg4JIgJQLqDvBmy8H6t+QAD0UlGGu53uOxf/c9YAHcJRIogIwGp9OsOYAHRtYOQHGhBHGt9zBlbB8XoTPBqsLJx1jM+WPqIDPnaDooLxGPqWTB4HfHWM5R1/ev20y4v2PgAs+212fyeDZv139b/cY/715rKEADvwKwnc5XBgCwPu1uX1BR3AeSOBnAisAOfPuXFoW28dAeUIcq5AJwuRIFDJRckwIAd8g5DKE+j16B7y37MvHDVvOEajPyIATx8cHjQIquRhZOv1UcbVAEsJI6BHQUDbr6fhDOkZiD8e9Ec0nwMDa+x7cb2H6tMMf6EjTxzLO/7r9VMvLtb9xR4p+ZdBn2v+W24gx/07Eeyfd/ufbX+J/3MIkEOBXf2Xq9Pd6SJVAgrw939LCXBXavhcS4MW+Coc8O4A8wUJ/E3to8qAXm7dgA0HEPS4XbXy+SfNMNvf4IlAbb0AZl/q0beq3q//67pAWzrnAlitPQkcI4Aj8Lehgf7kLbungFnTr91BPwRQsJ6L9DmbgHCc8wAvTvnLkZav+S/Pn9KqACkPsCl8TvLt4C8uYF9ecwA5BChEUJJ/16e7vay4hQA7AZwvE/ghD3BKFQEJfugXSCAuPQMF4HkZTBJqYA+qBSo34FRfkYFqFS75AiCGmdeO8ctF5LsF0jEb5BD+fRdg10Ylwm2YMaDVZ47ibTBxlADQwHPIwFDVbmDGAfSIIYb0nO3XoD9a2Ovp+kjhR+tH1BDtv3z1f77+vpYETC6gZP0vU8a/qn4lgBQS7HH/5fXe9ZeTgEuy/1en7d9CAFc1D1DUvuQFQP1LjgDzAiZHsIO45BIQ6Br0NvZ/ihtoJGDCAAd6jPXt31bhdTlwPgcQ6XwM+jgc6JOBNfJlW7XUqjwDPgK9zR54kI/MfboiG20rQLfjMJBx6yhXYHW6F/Nj1kDF20xD3gFoGL9R4N/OtnzVf3r+pEQAGfw1CZjBX23/9nmL/5dN3W8urlIOoGT/M/B35c9/329/ny7Peykwlfu2f4vlb9b/XAmhdQgmABfXkPoGPDnYnEADPcwlyOofE0LJDwzCAflGIeEGahMPWvxRJSBS+p4DsG5hZP81CYz9wBwJHCEAFRJo9e4X/Y7bfF8AHIGeCcLCegR4Xh+TQl+/31gC+I/Pv/fyMjf0bBOCNsXfSGDr+tvBX4Cfkn+76m9JQEEAF9e76hcSuN+cwOYOdiDvIE8EUMGdKwPJwvtcQMsbtLZhGxY0oCP4PRH08gN2XZuR2EqDXDmwLb24XQHlUx1Ag7PP7D/dATSFHnsDHQwwLfiynrbyVtNHdl85gEjxLVlYrWUHoFRc5/yZIHpuYBzRR0DuAfyp4I9Ip+YAvvJPrR+/JQG3EuBWAUhJv9P1BvIN/JUIdvXPyn+9EcZ6c7H925J/dxdX6+3+K0OJCHYHsFyttwncRf0TGaDCa1fQHEAUFiRwJHLAvxNAo3wAVwG4q3AEfKwolL8R+E35dSIQAwLc1iq6LQPyOv95PgAoxrln/1UiEN3CDAGMlT4igHnlV87BG+1jBBCB3roB9gIMVAXcX2gCmCGP5Sv+w/PHpclAadbfRgAb6Av4S9y/EwISwN4HcLq9vC5xfwZ/jv8vrncCuC8EUElAOQF0AJAsbG6hgJxDBFxeQI/235JAI4lMHKYleFwe1B2DnCjULsDG+FFI4ElgnNzz2YMetHFdL9VX0oVRTcBSgHIADYjNcVjAItARpEr5C+AiMB8BOULZO4ftGjlXUPIMRTd7ZMDbNmdwhBTamfrhQbR2Bvx7DuDL/+T5d+0hwNLAv2f+r5abqwb668vrZP1r7H992j43B7Bl/wH8ORG4EcBdCQHQCdi/W7cguoGm/MkxDBOEUDFQpcPUkMT9AQr4Nh+gm4RY9TG5x87gMZOEElRnQgCv/rxEx/rj6j9TBNKBdQRWzeesvncA5ZjewjNQLeCRWHhfD2ZPALHVH5OBBvws2EdAHa1XBHBkn+XL/oP1Yy63PoBN+bcQIMf/l9c5BNj+zUSwkcCeF7hOwK8EUMDf/t3Vf3MBy+V6l+L/13L8j7mAMkGo5AZagjAGfysncpkwrhog6DFv0EsANmIYKX+rDkRuICKApvhRvd8TwNPtf3MBbOWbVuttojDAK7tWfQVw3DKpr1LzPgE0SPvtFAGoMAGVWqXvijOYA/yLIIAjQPYZiDnnsHzpv3f+6MuLZZ8MtIcAxf5fn26utr8LAVyXrP96k4ng9iK5gBT7b+C/Xva4v9j/i+vTQ3UAmQBqInB5rWb5k9UvxIAJwaL8UDHA0iF2DKL6Q2ehs/01b9CSf3YbjPHjsKCpc8sZ+OQgAzyO+Y8RgCWB+fg/0nxebj83mjhKAB7wiVgKiNjs4/aWCGLrrxW/ncPb9t46G9vHoB/F/KP1Mxb/MQRwdJ/lS/6d9aNKErCAf7f+1zkEqARQlD8TwfVa4/8M+rvLFPdvBPCQHcBOAOdTAftrOQFYwL65ggL45gJ8GNBCAKwWmJDAgF41D2G2nxOEHBaozyr5p2y/Ajluh8ZeZfs56u/BexT/a+tfQOj13tt6Ze0biO0RME7n+N5+5vxAi7uTA4hCALVOEQC7CAYyGnuv6J4g4m0iIP+iIYAvevf5I65yGXC3/0X5r9brqwz+q5sU/yfrvzmAlvzblf/qtIF/+3e3/fm/jQQeLjIBbCTAoUAjBgR/yf7bngEuFba+gig3gD0CbPuf0jGYiMCHBQXYZT2/G8Am/ljxkQqa/VY5AFxb8gR+WbzEqz3rPdr/eQLwYUDLIKh1s2rP2x0DPOcKUOERpBb0niBOp6U6l55LmCWEN8oB8LWNAoHli951/q0XS+rxb4m/BP6dAKoD2EgAwL+TQLL/l2j9r9f7y+vlYXcBWwhweb47Lyn+T3mAkgsoroCVH/MBLQTA3gFdHeBEoSaA8mahca8AOgZfGozmBDRN7vUCMDkUILPa6wwAg3scAign0JbZTIB3AQ3IqPhWxVm5vUvA7Xt/s/Wfs/gYViiQz4JdbZeOt/8iaP2faLsIgLM5gegcIyDPEIo6xvKFX7v+5hQCbHMA1uvN/l9t9j+DP7mAFPdf7nmA0+3lzVb6yyHA9a7+95vSZ+BvDmAH/+X16dnp6nzbgJ8IIOUBGhFwdcDmBHjeAPcQ2H4BmwhMSi+TgyIXUPoHxlODZ8KBkQOwcbzX+pG9n1H/PvBbwo2Dgaa62u57RVexPapv/DeTwQwBRKFAs/ps41vmwW8zcgW/WAjgaPy/fa/lC776/JtSG/CW9MvgL/Z/cwGb/U9uYLf/V1vdP6t/tv07AewkkP7bgP9wcXN6dnF9erZcvn6TwF7Ab11AcwboBF6rk4dUglA3EcVlQqv2SAqqOjCr/Dr5Z5t/Wj4AI38Ldjb/nAPo2/tY/b3Vt0eyII9UfkwAfJwEMEUIzWm0mNoSg1d7tuYe2O1YDcgN7iqeP7rs7wUBHAXz0e2LG1j++Feuv2F3AJdb0q9Z/+QCNsCfbi5vltuNAPbYf6v97wnATfmXDfBIAA+XN7v6P9vU//Lm9Hy9eO9VUv1GApYQwA3UUMGGBVwh0L0Ctp247wSwAuDnDbQXkPas/wwBoMpzDmDkAFDhEeYW2J4A5lS/ALQHcAtka/85qacdwMjqK7W36t4HfLkmb81HRMFWvUcK7+sE8Fjw7w7g87/s/GEbAWwlv80BXN8k+7//d7PlAHbVT+Df/0vWPxHAupf+LnPcv4F/A/6m/pkAXlqX1y4S4N9TXYAjhL37D/MEcV7gMRWC+XbhXva/vIY8mB0oJgFZE68IwJKASgRqhW8gt+t7qu9j+z7AOd73YYEigQKsFl4UR6Cs/hjsvdg+AnkvBxDnAqyT8ATRcgCjDP9svN8D7hFQH9mW8wDLH/uS84duIcBOADvw1+vrDP5EAgn81QEU9b9Z7i+v1ruLm9P91fWSlX99uLxeduXP/72UgF/An/7d3cCu9vY/mxtIpNAmENFEIpxUVLsEsVyIvz3gW4b5NeN2tmBMBOplIT4hiIafy4I2GIh0vtj1eQKYAb8CcTPhSAjNIbBKN9XluB4BaR0Bxt3Wntt9RiGAjd/fJIB2P2aThI4APvcLX/+Qq8uL2633//pmcwA5D7D/u+4EgODfcgCXN9n236TYf4v5i/pf3qzPLm+WlzYCuLhen51PP5+Bnohg3YFv3UDLDxQnwF2D+DlZfTOrsJJBATo2DuH8gWL92farvoCS6OMfIFEOwHb6aa2PC389sM8RgFJ3tuz9zz4HgGRh1RvJoSm+B7aP72fcwBzIE1mp+F8ve1zcj6HF4x1ApNBHlyuQP0X99xDgj37B+Z/ZZgJuan+9xf03hQh24G9hADiA9XYD/9Vm+wv4N9t/c3q4SjF/Uv/b00YALy2Xr9/toN8AvxQnYN2ATw5ymbCBn+cP6O7BXi4gKbt6bwB3A7b2Xp8HKOt0yQ/7ARG+jyWAfkxvXwLOCh+BfmTnrcqzSs8TQM/2Ixn0/44s/S93Angq+HcC+OzPf/2fvry8uN0SgDebA7jNZLA5gE39b5r9v0rKf3dVwb/eX93sln8jgedXxfrfnl66uj29clpeuzovmwNA8AchgUsS2vkDLUegmoZ8+3CL++EVUykAAAroSURBVDkUwLIgZ/zbJKAxAWjVj+DPZT6l7PGyWOHbPrG954SftfqYsUfgq2y+dQUjy+/t/Tzoe0m8Iwm+IyQRJQY5CXg0B3BU6WeBPbtdLzxYPuvzzv/U5gA2639zs+z/7mHAzbolBHcCKMm/jQCutth/j/vX7d+HTADPrm63uH99fnW7vHx1e9r+eyXZ//KfJ4HdGVTg49++aUj1CpQ3BtlwoCi8bwyypBCVAIvi4zyAErdj/d/W+THhZ0OAluizfqAY//ZvWm8V3y+zQI8dgFZ5TQYc51vwzzkAb917BKCAGW3PDuCXAgG8LyQAdwfwhz/n9X/y+uridkv+3dxuJHC6ubrdqwHbsj0EuLpZNtW/u7peGwHs4F835X92dbs8v9pU/2ZX/pev7k6vXFy/nuN/JADrBhIBaBJoCcG4cxAJoLx5WLYM0wtD5roA2fpz7K8IwCb4uJVHE0ADvFfz7RxK/Ru4LUGwQnMI4IFdYmmO171LaLF128cvs1UAuz5ah8vV30cJAMH1S9kBsGN5TCJw+Yw/cv4ntiagHfy3y04A1zc78HfwX+/gT7H/dVb/6xL3327gT9b/6nZ96fpueWVT/qvb01tOl++5bur/cxnojQwa+I/mBLhV2L9dKH5vQNQEZBN+HOPrz9zO44t43MiLYFXlO2XnRxY/EUSk9t6y2+x+ZPObVe+B3TuDPiG8SQAWokdDgzckCfjpn/n6P745gOub8/XtXQoBbm4365/UPxHAHvfvsf/VzXp/fbs829Q/Kf/6/Pou2f7ru9MrV3ent17drq+cTxvoy38YCvx8Sgru/xVHgJWBLWmI5cFSDrTJQPdCkVwJ4NmC/sUgUcZ/3vIfaemJQK+s/XiZBWzbPlJ2julVjK/jcgR++ZsBrAhg1va/kSHALwYH8CJCgBeSA/i0P3T+x7YGoNu7083t7XJzfbvF/nseYI//r28T+K9vlx38V7fLw/Vu+9dn13fLS9cp4ffy9d36yvX98tbru9PblqvX7hL4fzaDfPt7A74lAp8cTETguwYxIahLghgCqAQgZvltzV/N+ceY36f1UNl1lb/E9Sd6y7+N8dneKzvvFR7t/yzwtaIzyBXAjzqAxxDAiAx+KYYA7zME8Ac/7fV/9Ob24vbm9ny9EcDN3XK7hQBIAJv1v7o93V/fnh6ub9eH6xTzP7++O710fXd6+ebu9Jbr7b/709uu79e3J+AXAkguYN0/RwRAvQKibbg1BJWOQZwp2HthCJf+et1+JRTAWL7pfQ/sNr7nuD599m5AJfSsbbcqbxXcO4A5oCt1j9T8TQIoYc2L7QN4nyGAT/nU8z+yxf27A7jL1YDbXflvr2+T/b/ewL9Z/7vl2fXt6dn13en5zQ7+9eWbu2UD/ltv7k9vu3k4vd9y9Z77jQDWnQTKfxgKIBFgGJAbhUTbsJowZDsES6mPXxdWynyo8tFbfjDJx8k8m85TyTyM1ft/FzKYA3oP5M0dPA34PYv/JgH8EieAT/797/21m/Lf3adE4O3mAG53F7Db/5vbZVP+++u79eHmdrHgv1/ecvNweuvt/entG/hv7s9vP59+5tT+804guQAmgVYitKVBnEWIU4jt68PGrw23qt+SegXY0b/JynNZT8X1aOf93x70bZsE3gjoPZC/SQD9rr+ogagk0zj0+IXsA3ifcQCf+MnnX3N3d0oEcJcSgDe7+q+3O/jvNuu/3t/cnZ7d3C278t/cry/fFvA/rG+/fVje/+756YNOFz97fT79NBHARgg2HIhDgdw1OJwjYF8eqgmgB3rM67eIXgO9WHf+19p6SwocpyfrjqBn8EZgfpMAPMij0l4P0DPrflkSwO/5hPf+6vv75ADu7vdqwM3N3cXdzd2m/uvdzd3ycLOp/93p+e39ksD/sLzl9uH0trtnp7ffPjt9wN2z0wdd3b7n5fPpp06JAJgEOBTQYUBT/1IaxAlBJfmH7xDEST6+xIdKz5F8qfKrd/O0WL84gAJg/JeXqdq8An16tdSbBKB7BHp9ALPAf7MKMN8RsHzc7z7/g/cPp5v73QGsexLw9m7J4D/d394vz27u1me3D8tLt/fry3cPy1vunu3gf7+75+sH3L+0/Irbh9c/4Hz6yVMigB4JRKXBEv+rSUL0GnE38Qd7+5Xql7l6GMe3Rt+WnPMKX1Q9+jft6y08gtv//SYBqJzDTKb/KAEcJYJflg7gYz72vb/y4dmm/psLWG5v7k63t3enu9u7Dfynh9v707O7DfwPp5fvHk5vuX++vu3++fL+98/XD3x4efngh5dPv+p8+vFTIgAmAZUP4N6AKP7HdwTYdwNibb/9BFjSdGXum9pbkFulb3G4BbwHuQJ4H/SFJLZ/33cJYFQJeKP6AGbLgL8YCEDF9rPLODcx0vEX0gfw0b/z/MHPn59ubvcQYFP/9fb2frm/vV/v7+5Pz+6fLS/dPZxevn92esv9S6e3Pzw/vf/Dy6e/79nLp7//+VtO/9B68RNXiQCYBEoYsP0bhQB2fkD78RCeAdisPv/mXwx6m7zzoG5ttiU2t/82m95UHoFs/36TAHRD0Wxr8C8VBzAL9veZJOBH/vb3ftBGAPfPLm/v7k63dw+nu7v70/3tw/pw/3B6fv/s9PLDS8tbH146vf3ZS+sHPH/L8sHPX1l/1ctvW37N6fLHb86nHz2dTz8mCGALBdABYGMQTxDCl4Xa2X42wccqz026kcK3hhwEeQTs2eUYy79JAG8SQNSbP0sKf08cwG/7iPMHJAew3jw8XNzd3Z/v7p8tD/fPTs8fXjq9/Oyl5a3PXz693/NX1g986a3Lr3zlbadf/cr7nf7h08WPXJ9PP3w6n34ECOAnIAwoyUDVC8CTgLi5BxW/NOew1iewl/9KLI9Kj0BWoJ4F+psOIIH7zRDAViQUYGfB/j7jAD78w197+7Pny83Ds+X2/tly9/Cw3j97aXn+7KXl5ecvn976/JX1/V552/IrXnnb+g+89f2XX/u2D/z/2zuXnYSBMAqf0YhAW1pKuQVUVDRqCG5MUBN0oRt3bnwMX8c38EmMD+DGxBgX3qKocUc0mk5NkQk/ZWw1bozMgnBpWJ5zvv8yrbfM0QLHIzieiAH4FED7ACL9xS4APQlI7wxM7+4jOvm9pKejObng+1H9K9ErA/jeslDYOrAygH9oADs7PK3piCU1b1wzWEI3mKYZnmFazDZt5KwMypkcqtki6pbzuuTiFhz34HgIGIBIf5r8YtxHEz+I+PLmXb/YP0VOXwK/xW/0e9Rn2XUZzkcRgioBoqlA9QB69ESben+GALa231O67sV0YyRupJA00yMpy2a27aDg5FHJl7xaucKaca1V4LiEi5uuAfgEQPGf1vy0xqcNPXnCy0QcJvZgyn8n9RUBKAKQbQaGj/56kqVPBgqKVzZujBL7nzGAZrOtpczYuGmxhGUzw8myTK6IUmkSi5Uqa05Mt7c4TsFxAY4ruLjr4r8vfj/1hfBF2gu8F3W8OIwzmOJRqR5mDIoABpeJxHz9N++qBKCiHwIDaKy+JWx7LO5kPb1QhDM1g9mFGttYWfP2OY7BcQKOc3Bcd7Df7XT9/VpfHPWlgo8WeVD0UUkvS3tFAIPjyN+Inv5XGcCQGUC9/hwrlQ1tbn602FjH5u7eywHHIVwcgeOsi/v+jN9v6vn1O+AG6vEwUf/kWjDVFQGEpzwdPSoD6J9UfIX2wWWiYS8BPgCAPOYxoDrtqQAAAABJRU5ErkJggg==";
  95730. return BRDFTextureTools;
  95731. }());
  95732. /***/ }),
  95733. /***/ "./Misc/dds.ts":
  95734. /*!*********************!*\
  95735. !*** ./Misc/dds.ts ***!
  95736. \*********************/
  95737. /*! exports provided: DDSTools */
  95738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95739. "use strict";
  95740. __webpack_require__.r(__webpack_exports__);
  95741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  95742. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  95743. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  95744. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95745. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  95746. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  95747. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  95748. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  95749. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  95750. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  95751. // All values and structures referenced from:
  95752. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  95753. var DDS_MAGIC = 0x20534444;
  95754. var
  95755. //DDSD_CAPS = 0x1,
  95756. //DDSD_HEIGHT = 0x2,
  95757. //DDSD_WIDTH = 0x4,
  95758. //DDSD_PITCH = 0x8,
  95759. //DDSD_PIXELFORMAT = 0x1000,
  95760. DDSD_MIPMAPCOUNT = 0x20000;
  95761. //DDSD_LINEARSIZE = 0x80000,
  95762. //DDSD_DEPTH = 0x800000;
  95763. // var DDSCAPS_COMPLEX = 0x8,
  95764. // DDSCAPS_MIPMAP = 0x400000,
  95765. // DDSCAPS_TEXTURE = 0x1000;
  95766. var DDSCAPS2_CUBEMAP = 0x200;
  95767. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  95768. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  95769. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  95770. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  95771. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  95772. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  95773. // DDSCAPS2_VOLUME = 0x200000;
  95774. var
  95775. //DDPF_ALPHAPIXELS = 0x1,
  95776. //DDPF_ALPHA = 0x2,
  95777. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  95778. //DDPF_YUV = 0x200,
  95779. DDPF_LUMINANCE = 0x20000;
  95780. function FourCCToInt32(value) {
  95781. return value.charCodeAt(0) +
  95782. (value.charCodeAt(1) << 8) +
  95783. (value.charCodeAt(2) << 16) +
  95784. (value.charCodeAt(3) << 24);
  95785. }
  95786. function Int32ToFourCC(value) {
  95787. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  95788. }
  95789. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  95790. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  95791. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  95792. var FOURCC_DX10 = FourCCToInt32("DX10");
  95793. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  95794. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  95795. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  95796. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  95797. var headerLengthInt = 31; // The header length in 32 bit ints
  95798. // Offsets into the header array
  95799. var off_magic = 0;
  95800. var off_size = 1;
  95801. var off_flags = 2;
  95802. var off_height = 3;
  95803. var off_width = 4;
  95804. var off_mipmapCount = 7;
  95805. var off_pfFlags = 20;
  95806. var off_pfFourCC = 21;
  95807. var off_RGBbpp = 22;
  95808. var off_RMask = 23;
  95809. var off_GMask = 24;
  95810. var off_BMask = 25;
  95811. var off_AMask = 26;
  95812. // var off_caps1 = 27;
  95813. var off_caps2 = 28;
  95814. // var off_caps3 = 29;
  95815. // var off_caps4 = 30;
  95816. var off_dxgiFormat = 32;
  95817. /**
  95818. * Class used to provide DDS decompression tools
  95819. */
  95820. var DDSTools = /** @class */ (function () {
  95821. function DDSTools() {
  95822. }
  95823. /**
  95824. * Gets DDS information from an array buffer
  95825. * @param arrayBuffer defines the array buffer to read data from
  95826. * @returns the DDS information
  95827. */
  95828. DDSTools.GetDDSInfo = function (arrayBuffer) {
  95829. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  95830. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  95831. var mipmapCount = 1;
  95832. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  95833. mipmapCount = Math.max(1, header[off_mipmapCount]);
  95834. }
  95835. var fourCC = header[off_pfFourCC];
  95836. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  95837. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95838. switch (fourCC) {
  95839. case FOURCC_D3DFMT_R16G16B16A16F:
  95840. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  95841. break;
  95842. case FOURCC_D3DFMT_R32G32B32A32F:
  95843. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  95844. break;
  95845. case FOURCC_DX10:
  95846. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  95847. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  95848. break;
  95849. }
  95850. }
  95851. return {
  95852. width: header[off_width],
  95853. height: header[off_height],
  95854. mipmapCount: mipmapCount,
  95855. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  95856. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  95857. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  95858. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  95859. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  95860. dxgiFormat: dxgiFormat,
  95861. textureType: textureType
  95862. };
  95863. };
  95864. DDSTools._ToHalfFloat = function (value) {
  95865. if (!DDSTools._FloatView) {
  95866. DDSTools._FloatView = new Float32Array(1);
  95867. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  95868. }
  95869. DDSTools._FloatView[0] = value;
  95870. var x = DDSTools._Int32View[0];
  95871. var bits = (x >> 16) & 0x8000; /* Get the sign */
  95872. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  95873. var e = (x >> 23) & 0xff; /* Using int is faster here */
  95874. /* If zero, or denormal, or exponent underflows too much for a denormal
  95875. * half, return signed zero. */
  95876. if (e < 103) {
  95877. return bits;
  95878. }
  95879. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  95880. if (e > 142) {
  95881. bits |= 0x7c00;
  95882. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  95883. * not Inf, so make sure we set one mantissa bit too. */
  95884. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  95885. return bits;
  95886. }
  95887. /* If exponent underflows but not too much, return a denormal */
  95888. if (e < 113) {
  95889. m |= 0x0800;
  95890. /* Extra rounding may overflow and set mantissa to 0 and exponent
  95891. * to 1, which is OK. */
  95892. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  95893. return bits;
  95894. }
  95895. bits |= ((e - 112) << 10) | (m >> 1);
  95896. bits += m & 1;
  95897. return bits;
  95898. };
  95899. DDSTools._FromHalfFloat = function (value) {
  95900. var s = (value & 0x8000) >> 15;
  95901. var e = (value & 0x7C00) >> 10;
  95902. var f = value & 0x03FF;
  95903. if (e === 0) {
  95904. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  95905. }
  95906. else if (e == 0x1F) {
  95907. return f ? NaN : ((s ? -1 : 1) * Infinity);
  95908. }
  95909. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  95910. };
  95911. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95912. var destArray = new Float32Array(dataLength);
  95913. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  95914. var index = 0;
  95915. for (var y = 0; y < height; y++) {
  95916. for (var x = 0; x < width; x++) {
  95917. var srcPos = (x + y * width) * 4;
  95918. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  95919. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  95920. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  95921. if (DDSTools.StoreLODInAlphaChannel) {
  95922. destArray[index + 3] = lod;
  95923. }
  95924. else {
  95925. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  95926. }
  95927. index += 4;
  95928. }
  95929. }
  95930. return destArray;
  95931. };
  95932. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95933. if (DDSTools.StoreLODInAlphaChannel) {
  95934. var destArray = new Uint16Array(dataLength);
  95935. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  95936. var index = 0;
  95937. for (var y = 0; y < height; y++) {
  95938. for (var x = 0; x < width; x++) {
  95939. var srcPos = (x + y * width) * 4;
  95940. destArray[index] = srcData[srcPos];
  95941. destArray[index + 1] = srcData[srcPos + 1];
  95942. destArray[index + 2] = srcData[srcPos + 2];
  95943. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  95944. index += 4;
  95945. }
  95946. }
  95947. return destArray;
  95948. }
  95949. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  95950. };
  95951. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95952. if (DDSTools.StoreLODInAlphaChannel) {
  95953. var destArray = new Float32Array(dataLength);
  95954. var srcData = new Float32Array(arrayBuffer, dataOffset);
  95955. var index = 0;
  95956. for (var y = 0; y < height; y++) {
  95957. for (var x = 0; x < width; x++) {
  95958. var srcPos = (x + y * width) * 4;
  95959. destArray[index] = srcData[srcPos];
  95960. destArray[index + 1] = srcData[srcPos + 1];
  95961. destArray[index + 2] = srcData[srcPos + 2];
  95962. destArray[index + 3] = lod;
  95963. index += 4;
  95964. }
  95965. }
  95966. return destArray;
  95967. }
  95968. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  95969. };
  95970. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95971. var destArray = new Uint8Array(dataLength);
  95972. var srcData = new Float32Array(arrayBuffer, dataOffset);
  95973. var index = 0;
  95974. for (var y = 0; y < height; y++) {
  95975. for (var x = 0; x < width; x++) {
  95976. var srcPos = (x + y * width) * 4;
  95977. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  95978. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  95979. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  95980. if (DDSTools.StoreLODInAlphaChannel) {
  95981. destArray[index + 3] = lod;
  95982. }
  95983. else {
  95984. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  95985. }
  95986. index += 4;
  95987. }
  95988. }
  95989. return destArray;
  95990. };
  95991. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95992. var destArray = new Uint8Array(dataLength);
  95993. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  95994. var index = 0;
  95995. for (var y = 0; y < height; y++) {
  95996. for (var x = 0; x < width; x++) {
  95997. var srcPos = (x + y * width) * 4;
  95998. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  95999. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  96000. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  96001. if (DDSTools.StoreLODInAlphaChannel) {
  96002. destArray[index + 3] = lod;
  96003. }
  96004. else {
  96005. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  96006. }
  96007. index += 4;
  96008. }
  96009. }
  96010. return destArray;
  96011. };
  96012. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  96013. var byteArray = new Uint8Array(dataLength);
  96014. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  96015. var index = 0;
  96016. for (var y = 0; y < height; y++) {
  96017. for (var x = 0; x < width; x++) {
  96018. var srcPos = (x + y * width) * 4;
  96019. byteArray[index] = srcData[srcPos + rOffset];
  96020. byteArray[index + 1] = srcData[srcPos + gOffset];
  96021. byteArray[index + 2] = srcData[srcPos + bOffset];
  96022. byteArray[index + 3] = srcData[srcPos + aOffset];
  96023. index += 4;
  96024. }
  96025. }
  96026. return byteArray;
  96027. };
  96028. DDSTools._ExtractLongWordOrder = function (value) {
  96029. if (value === 0 || value === 255 || value === -16777216) {
  96030. return 0;
  96031. }
  96032. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  96033. };
  96034. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  96035. var byteArray = new Uint8Array(dataLength);
  96036. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  96037. var index = 0;
  96038. for (var y = 0; y < height; y++) {
  96039. for (var x = 0; x < width; x++) {
  96040. var srcPos = (x + y * width) * 3;
  96041. byteArray[index] = srcData[srcPos + rOffset];
  96042. byteArray[index + 1] = srcData[srcPos + gOffset];
  96043. byteArray[index + 2] = srcData[srcPos + bOffset];
  96044. index += 3;
  96045. }
  96046. }
  96047. return byteArray;
  96048. };
  96049. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  96050. var byteArray = new Uint8Array(dataLength);
  96051. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  96052. var index = 0;
  96053. for (var y = 0; y < height; y++) {
  96054. for (var x = 0; x < width; x++) {
  96055. var srcPos = (x + y * width);
  96056. byteArray[index] = srcData[srcPos];
  96057. index++;
  96058. }
  96059. }
  96060. return byteArray;
  96061. };
  96062. /**
  96063. * Uploads DDS Levels to a Babylon Texture
  96064. * @hidden
  96065. */
  96066. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  96067. if (lodIndex === void 0) { lodIndex = -1; }
  96068. var sphericalPolynomialFaces = null;
  96069. if (info.sphericalPolynomial) {
  96070. sphericalPolynomialFaces = new Array();
  96071. }
  96072. var ext = engine.getCaps().s3tc;
  96073. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  96074. var fourCC, width, height, dataLength = 0, dataOffset;
  96075. var byteArray, mipmapCount, mip;
  96076. var internalCompressedFormat = 0;
  96077. var blockBytes = 1;
  96078. if (header[off_magic] !== DDS_MAGIC) {
  96079. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  96080. return;
  96081. }
  96082. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  96083. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  96084. return;
  96085. }
  96086. if (info.isCompressed && !ext) {
  96087. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  96088. return;
  96089. }
  96090. var bpp = header[off_RGBbpp];
  96091. dataOffset = header[off_size] + 4;
  96092. var computeFormats = false;
  96093. if (info.isFourCC) {
  96094. fourCC = header[off_pfFourCC];
  96095. switch (fourCC) {
  96096. case FOURCC_DXT1:
  96097. blockBytes = 8;
  96098. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  96099. break;
  96100. case FOURCC_DXT3:
  96101. blockBytes = 16;
  96102. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  96103. break;
  96104. case FOURCC_DXT5:
  96105. blockBytes = 16;
  96106. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  96107. break;
  96108. case FOURCC_D3DFMT_R16G16B16A16F:
  96109. computeFormats = true;
  96110. break;
  96111. case FOURCC_D3DFMT_R32G32B32A32F:
  96112. computeFormats = true;
  96113. break;
  96114. case FOURCC_DX10:
  96115. // There is an additionnal header so dataOffset need to be changed
  96116. dataOffset += 5 * 4; // 5 uints
  96117. var supported = false;
  96118. switch (info.dxgiFormat) {
  96119. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  96120. computeFormats = true;
  96121. supported = true;
  96122. break;
  96123. case DXGI_FORMAT_B8G8R8X8_UNORM:
  96124. info.isRGB = true;
  96125. info.isFourCC = false;
  96126. bpp = 32;
  96127. supported = true;
  96128. break;
  96129. }
  96130. if (supported) {
  96131. break;
  96132. }
  96133. default:
  96134. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  96135. return;
  96136. }
  96137. }
  96138. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  96139. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  96140. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  96141. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  96142. if (computeFormats) {
  96143. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  96144. }
  96145. mipmapCount = 1;
  96146. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  96147. mipmapCount = Math.max(1, header[off_mipmapCount]);
  96148. }
  96149. for (var face = 0; face < faces; face++) {
  96150. width = header[off_width];
  96151. height = header[off_height];
  96152. for (mip = 0; mip < mipmapCount; ++mip) {
  96153. if (lodIndex === -1 || lodIndex === mip) {
  96154. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  96155. var i = (lodIndex === -1) ? mip : 0;
  96156. if (!info.isCompressed && info.isFourCC) {
  96157. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  96158. dataLength = width * height * 4;
  96159. var floatArray = null;
  96160. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  96161. if (bpp === 128) {
  96162. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96163. if (sphericalPolynomialFaces && i == 0) {
  96164. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  96165. }
  96166. }
  96167. else if (bpp === 64) {
  96168. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96169. if (sphericalPolynomialFaces && i == 0) {
  96170. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  96171. }
  96172. }
  96173. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96174. }
  96175. else {
  96176. if (bpp === 128) {
  96177. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  96178. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96179. if (sphericalPolynomialFaces && i == 0) {
  96180. sphericalPolynomialFaces.push(floatArray);
  96181. }
  96182. }
  96183. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  96184. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  96185. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96186. if (sphericalPolynomialFaces && i == 0) {
  96187. sphericalPolynomialFaces.push(floatArray);
  96188. }
  96189. }
  96190. else { // 64
  96191. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96192. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96193. if (sphericalPolynomialFaces && i == 0) {
  96194. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  96195. }
  96196. }
  96197. }
  96198. if (floatArray) {
  96199. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  96200. }
  96201. }
  96202. else if (info.isRGB) {
  96203. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96204. if (bpp === 24) {
  96205. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  96206. dataLength = width * height * 3;
  96207. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  96208. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  96209. }
  96210. else { // 32
  96211. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  96212. dataLength = width * height * 4;
  96213. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  96214. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  96215. }
  96216. }
  96217. else if (info.isLuminance) {
  96218. var unpackAlignment = engine._getUnpackAlignement();
  96219. var unpaddedRowSize = width;
  96220. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  96221. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  96222. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  96223. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  96224. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96225. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  96226. }
  96227. else {
  96228. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  96229. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  96230. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96231. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  96232. }
  96233. }
  96234. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  96235. width *= 0.5;
  96236. height *= 0.5;
  96237. width = Math.max(1.0, width);
  96238. height = Math.max(1.0, height);
  96239. }
  96240. if (currentFace !== undefined) {
  96241. // Loading a single face
  96242. break;
  96243. }
  96244. }
  96245. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  96246. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  96247. size: header[off_width],
  96248. right: sphericalPolynomialFaces[0],
  96249. left: sphericalPolynomialFaces[1],
  96250. up: sphericalPolynomialFaces[2],
  96251. down: sphericalPolynomialFaces[3],
  96252. front: sphericalPolynomialFaces[4],
  96253. back: sphericalPolynomialFaces[5],
  96254. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  96255. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  96256. gammaSpace: false,
  96257. });
  96258. }
  96259. else {
  96260. info.sphericalPolynomial = undefined;
  96261. }
  96262. };
  96263. /**
  96264. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  96265. */
  96266. DDSTools.StoreLODInAlphaChannel = false;
  96267. return DDSTools;
  96268. }());
  96269. /**
  96270. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  96271. * @param rootUrl defines the url where the file to load is located
  96272. * @param scene defines the current scene
  96273. * @param lodScale defines scale to apply to the mip map selection
  96274. * @param lodOffset defines offset to apply to the mip map selection
  96275. * @param onLoad defines an optional callback raised when the texture is loaded
  96276. * @param onError defines an optional callback raised if there is an issue to load the texture
  96277. * @param format defines the format of the data
  96278. * @param forcedExtension defines the extension to use to pick the right loader
  96279. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  96280. * @returns the cube texture as an InternalTexture
  96281. */
  96282. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  96283. var _this = this;
  96284. if (onLoad === void 0) { onLoad = null; }
  96285. if (onError === void 0) { onError = null; }
  96286. if (forcedExtension === void 0) { forcedExtension = null; }
  96287. if (createPolynomials === void 0) { createPolynomials = true; }
  96288. var callback = function (loadData) {
  96289. if (!loadData) {
  96290. if (onLoad) {
  96291. onLoad(null);
  96292. }
  96293. return;
  96294. }
  96295. var texture = loadData.texture;
  96296. if (!createPolynomials) {
  96297. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  96298. }
  96299. else if (loadData.info.sphericalPolynomial) {
  96300. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  96301. }
  96302. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  96303. if (_this.getCaps().textureLOD) {
  96304. // Do not add extra process if texture lod is supported.
  96305. if (onLoad) {
  96306. onLoad(texture);
  96307. }
  96308. return;
  96309. }
  96310. var mipSlices = 3;
  96311. var gl = _this._gl;
  96312. var width = loadData.width;
  96313. if (!width) {
  96314. return;
  96315. }
  96316. var textures = [];
  96317. for (var i = 0; i < mipSlices; i++) {
  96318. //compute LOD from even spacing in smoothness (matching shader calculation)
  96319. var smoothness = i / (mipSlices - 1);
  96320. var roughness = 1 - smoothness;
  96321. var minLODIndex = lodOffset; // roughness = 0
  96322. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  96323. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  96324. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  96325. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  96326. glTextureFromLod.type = texture.type;
  96327. glTextureFromLod.format = texture.format;
  96328. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  96329. glTextureFromLod.height = glTextureFromLod.width;
  96330. glTextureFromLod.isCube = true;
  96331. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  96332. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  96333. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  96334. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  96335. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  96336. if (loadData.isDDS) {
  96337. var info = loadData.info;
  96338. var data = loadData.data;
  96339. _this._unpackFlipY(info.isCompressed);
  96340. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  96341. }
  96342. else {
  96343. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  96344. }
  96345. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  96346. // Wrap in a base texture for easy binding.
  96347. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  96348. lodTexture.isCube = true;
  96349. lodTexture._texture = glTextureFromLod;
  96350. glTextureFromLod.isReady = true;
  96351. textures.push(lodTexture);
  96352. }
  96353. texture._lodTextureHigh = textures[2];
  96354. texture._lodTextureMid = textures[1];
  96355. texture._lodTextureLow = textures[0];
  96356. if (onLoad) {
  96357. onLoad(texture);
  96358. }
  96359. };
  96360. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  96361. };
  96362. /***/ }),
  96363. /***/ "./Misc/decorators.ts":
  96364. /*!****************************!*\
  96365. !*** ./Misc/decorators.ts ***!
  96366. \****************************/
  96367. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper */
  96368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96369. "use strict";
  96370. __webpack_require__.r(__webpack_exports__);
  96371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  96372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  96373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  96374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  96375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  96376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  96377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  96378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  96379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  96380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  96381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  96382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  96383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return serializeAsMatrix; });
  96384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  96385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  96386. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  96387. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  96388. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  96389. var __decoratorInitialStore = {};
  96390. var __mergedStore = {};
  96391. var _copySource = function (creationFunction, source, instanciate) {
  96392. var destination = creationFunction();
  96393. // Tags
  96394. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  96395. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  96396. }
  96397. var classStore = getMergedStore(destination);
  96398. // Properties
  96399. for (var property in classStore) {
  96400. var propertyDescriptor = classStore[property];
  96401. var sourceProperty = source[property];
  96402. var propertyType = propertyDescriptor.type;
  96403. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  96404. switch (propertyType) {
  96405. case 0: // Value
  96406. case 6: // Mesh reference
  96407. case 11: // Camera reference
  96408. destination[property] = sourceProperty;
  96409. break;
  96410. case 1: // Texture
  96411. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  96412. break;
  96413. case 2: // Color3
  96414. case 3: // FresnelParameters
  96415. case 4: // Vector2
  96416. case 5: // Vector3
  96417. case 7: // Color Curves
  96418. case 10: // Quaternion
  96419. case 12: // Matrix
  96420. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  96421. break;
  96422. }
  96423. }
  96424. }
  96425. return destination;
  96426. };
  96427. function getDirectStore(target) {
  96428. var classKey = target.getClassName();
  96429. if (!__decoratorInitialStore[classKey]) {
  96430. __decoratorInitialStore[classKey] = {};
  96431. }
  96432. return __decoratorInitialStore[classKey];
  96433. }
  96434. /**
  96435. * Return the list of properties flagged as serializable
  96436. * @param target: host object
  96437. */
  96438. function getMergedStore(target) {
  96439. var classKey = target.getClassName();
  96440. if (__mergedStore[classKey]) {
  96441. return __mergedStore[classKey];
  96442. }
  96443. __mergedStore[classKey] = {};
  96444. var store = __mergedStore[classKey];
  96445. var currentTarget = target;
  96446. var currentKey = classKey;
  96447. while (currentKey) {
  96448. var initialStore = __decoratorInitialStore[currentKey];
  96449. for (var property in initialStore) {
  96450. store[property] = initialStore[property];
  96451. }
  96452. var parent_1 = void 0;
  96453. var done = false;
  96454. do {
  96455. parent_1 = Object.getPrototypeOf(currentTarget);
  96456. if (!parent_1.getClassName) {
  96457. done = true;
  96458. break;
  96459. }
  96460. if (parent_1.getClassName() !== currentKey) {
  96461. break;
  96462. }
  96463. currentTarget = parent_1;
  96464. } while (parent_1);
  96465. if (done) {
  96466. break;
  96467. }
  96468. currentKey = parent_1.getClassName();
  96469. currentTarget = parent_1;
  96470. }
  96471. return store;
  96472. }
  96473. function generateSerializableMember(type, sourceName) {
  96474. return function (target, propertyKey) {
  96475. var classStore = getDirectStore(target);
  96476. if (!classStore[propertyKey]) {
  96477. classStore[propertyKey] = { type: type, sourceName: sourceName };
  96478. }
  96479. };
  96480. }
  96481. function generateExpandMember(setCallback, targetKey) {
  96482. if (targetKey === void 0) { targetKey = null; }
  96483. return function (target, propertyKey) {
  96484. var key = targetKey || ("_" + propertyKey);
  96485. Object.defineProperty(target, propertyKey, {
  96486. get: function () {
  96487. return this[key];
  96488. },
  96489. set: function (value) {
  96490. if (this[key] === value) {
  96491. return;
  96492. }
  96493. this[key] = value;
  96494. target[setCallback].apply(this);
  96495. },
  96496. enumerable: true,
  96497. configurable: true
  96498. });
  96499. };
  96500. }
  96501. function expandToProperty(callback, targetKey) {
  96502. if (targetKey === void 0) { targetKey = null; }
  96503. return generateExpandMember(callback, targetKey);
  96504. }
  96505. function serialize(sourceName) {
  96506. return generateSerializableMember(0, sourceName); // value member
  96507. }
  96508. function serializeAsTexture(sourceName) {
  96509. return generateSerializableMember(1, sourceName); // texture member
  96510. }
  96511. function serializeAsColor3(sourceName) {
  96512. return generateSerializableMember(2, sourceName); // color3 member
  96513. }
  96514. function serializeAsFresnelParameters(sourceName) {
  96515. return generateSerializableMember(3, sourceName); // fresnel parameters member
  96516. }
  96517. function serializeAsVector2(sourceName) {
  96518. return generateSerializableMember(4, sourceName); // vector2 member
  96519. }
  96520. function serializeAsVector3(sourceName) {
  96521. return generateSerializableMember(5, sourceName); // vector3 member
  96522. }
  96523. function serializeAsMeshReference(sourceName) {
  96524. return generateSerializableMember(6, sourceName); // mesh reference member
  96525. }
  96526. function serializeAsColorCurves(sourceName) {
  96527. return generateSerializableMember(7, sourceName); // color curves
  96528. }
  96529. function serializeAsColor4(sourceName) {
  96530. return generateSerializableMember(8, sourceName); // color 4
  96531. }
  96532. function serializeAsImageProcessingConfiguration(sourceName) {
  96533. return generateSerializableMember(9, sourceName); // image processing
  96534. }
  96535. function serializeAsQuaternion(sourceName) {
  96536. return generateSerializableMember(10, sourceName); // quaternion member
  96537. }
  96538. function serializeAsMatrix(sourceName) {
  96539. return generateSerializableMember(12, sourceName); // matrix member
  96540. }
  96541. /**
  96542. * Decorator used to define property that can be serialized as reference to a camera
  96543. * @param sourceName defines the name of the property to decorate
  96544. */
  96545. function serializeAsCameraReference(sourceName) {
  96546. return generateSerializableMember(11, sourceName); // camera reference member
  96547. }
  96548. /**
  96549. * Class used to help serialization objects
  96550. */
  96551. var SerializationHelper = /** @class */ (function () {
  96552. function SerializationHelper() {
  96553. }
  96554. /**
  96555. * Appends the serialized animations from the source animations
  96556. * @param source Source containing the animations
  96557. * @param destination Target to store the animations
  96558. */
  96559. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  96560. if (source.animations) {
  96561. destination.animations = [];
  96562. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  96563. var animation = source.animations[animationIndex];
  96564. destination.animations.push(animation.serialize());
  96565. }
  96566. }
  96567. };
  96568. /**
  96569. * Static function used to serialized a specific entity
  96570. * @param entity defines the entity to serialize
  96571. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96572. * @returns a JSON compatible object representing the serialization of the entity
  96573. */
  96574. SerializationHelper.Serialize = function (entity, serializationObject) {
  96575. if (!serializationObject) {
  96576. serializationObject = {};
  96577. }
  96578. // Tags
  96579. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  96580. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  96581. }
  96582. var serializedProperties = getMergedStore(entity);
  96583. // Properties
  96584. for (var property in serializedProperties) {
  96585. var propertyDescriptor = serializedProperties[property];
  96586. var targetPropertyName = propertyDescriptor.sourceName || property;
  96587. var propertyType = propertyDescriptor.type;
  96588. var sourceProperty = entity[property];
  96589. if (sourceProperty !== undefined && sourceProperty !== null) {
  96590. switch (propertyType) {
  96591. case 0: // Value
  96592. serializationObject[targetPropertyName] = sourceProperty;
  96593. break;
  96594. case 1: // Texture
  96595. serializationObject[targetPropertyName] = sourceProperty.serialize();
  96596. break;
  96597. case 2: // Color3
  96598. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96599. break;
  96600. case 3: // FresnelParameters
  96601. serializationObject[targetPropertyName] = sourceProperty.serialize();
  96602. break;
  96603. case 4: // Vector2
  96604. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96605. break;
  96606. case 5: // Vector3
  96607. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96608. break;
  96609. case 6: // Mesh reference
  96610. serializationObject[targetPropertyName] = sourceProperty.id;
  96611. break;
  96612. case 7: // Color Curves
  96613. serializationObject[targetPropertyName] = sourceProperty.serialize();
  96614. break;
  96615. case 8: // Color 4
  96616. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96617. break;
  96618. case 9: // Image Processing
  96619. serializationObject[targetPropertyName] = sourceProperty.serialize();
  96620. break;
  96621. case 10: // Quaternion
  96622. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96623. break;
  96624. case 11: // Camera reference
  96625. serializationObject[targetPropertyName] = sourceProperty.id;
  96626. case 12: // Matrix
  96627. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96628. break;
  96629. }
  96630. }
  96631. }
  96632. return serializationObject;
  96633. };
  96634. /**
  96635. * Creates a new entity from a serialization data object
  96636. * @param creationFunction defines a function used to instanciated the new entity
  96637. * @param source defines the source serialization data
  96638. * @param scene defines the hosting scene
  96639. * @param rootUrl defines the root url for resources
  96640. * @returns a new entity
  96641. */
  96642. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  96643. if (rootUrl === void 0) { rootUrl = null; }
  96644. var destination = creationFunction();
  96645. if (!rootUrl) {
  96646. rootUrl = "";
  96647. }
  96648. // Tags
  96649. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  96650. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  96651. }
  96652. var classStore = getMergedStore(destination);
  96653. // Properties
  96654. for (var property in classStore) {
  96655. var propertyDescriptor = classStore[property];
  96656. var sourceProperty = source[propertyDescriptor.sourceName || property];
  96657. var propertyType = propertyDescriptor.type;
  96658. if (sourceProperty !== undefined && sourceProperty !== null) {
  96659. var dest = destination;
  96660. switch (propertyType) {
  96661. case 0: // Value
  96662. dest[property] = sourceProperty;
  96663. break;
  96664. case 1: // Texture
  96665. if (scene) {
  96666. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  96667. }
  96668. break;
  96669. case 2: // Color3
  96670. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  96671. break;
  96672. case 3: // FresnelParameters
  96673. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  96674. break;
  96675. case 4: // Vector2
  96676. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  96677. break;
  96678. case 5: // Vector3
  96679. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  96680. break;
  96681. case 6: // Mesh reference
  96682. if (scene) {
  96683. dest[property] = scene.getLastMeshByID(sourceProperty);
  96684. }
  96685. break;
  96686. case 7: // Color Curves
  96687. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  96688. break;
  96689. case 8: // Color 4
  96690. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  96691. break;
  96692. case 9: // Image Processing
  96693. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  96694. break;
  96695. case 10: // Quaternion
  96696. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  96697. break;
  96698. case 11: // Camera reference
  96699. if (scene) {
  96700. dest[property] = scene.getCameraByID(sourceProperty);
  96701. }
  96702. case 12: // Matrix
  96703. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(sourceProperty);
  96704. break;
  96705. }
  96706. }
  96707. }
  96708. return destination;
  96709. };
  96710. /**
  96711. * Clones an object
  96712. * @param creationFunction defines the function used to instanciate the new object
  96713. * @param source defines the source object
  96714. * @returns the cloned object
  96715. */
  96716. SerializationHelper.Clone = function (creationFunction, source) {
  96717. return _copySource(creationFunction, source, false);
  96718. };
  96719. /**
  96720. * Instanciates a new object based on a source one (some data will be shared between both object)
  96721. * @param creationFunction defines the function used to instanciate the new object
  96722. * @param source defines the source object
  96723. * @returns the new object
  96724. */
  96725. SerializationHelper.Instanciate = function (creationFunction, source) {
  96726. return _copySource(creationFunction, source, true);
  96727. };
  96728. /** hidden */
  96729. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  96730. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  96731. };
  96732. /** hidden */
  96733. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  96734. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  96735. };
  96736. /** hidden */
  96737. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  96738. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  96739. };
  96740. /** hidden */
  96741. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  96742. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  96743. };
  96744. return SerializationHelper;
  96745. }());
  96746. /***/ }),
  96747. /***/ "./Misc/deepCopier.ts":
  96748. /*!****************************!*\
  96749. !*** ./Misc/deepCopier.ts ***!
  96750. \****************************/
  96751. /*! exports provided: DeepCopier */
  96752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96753. "use strict";
  96754. __webpack_require__.r(__webpack_exports__);
  96755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  96756. var cloneValue = function (source, destinationObject) {
  96757. if (!source) {
  96758. return null;
  96759. }
  96760. if (source.getClassName && source.getClassName() === "Mesh") {
  96761. return null;
  96762. }
  96763. if (source.getClassName && source.getClassName() === "SubMesh") {
  96764. return source.clone(destinationObject);
  96765. }
  96766. else if (source.clone) {
  96767. return source.clone();
  96768. }
  96769. return null;
  96770. };
  96771. /**
  96772. * Class containing a set of static utilities functions for deep copy.
  96773. */
  96774. var DeepCopier = /** @class */ (function () {
  96775. function DeepCopier() {
  96776. }
  96777. /**
  96778. * Tries to copy an object by duplicating every property
  96779. * @param source defines the source object
  96780. * @param destination defines the target object
  96781. * @param doNotCopyList defines a list of properties to avoid
  96782. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96783. */
  96784. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  96785. for (var prop in source) {
  96786. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  96787. continue;
  96788. }
  96789. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  96790. continue;
  96791. }
  96792. var sourceValue = source[prop];
  96793. var typeOfSourceValue = typeof sourceValue;
  96794. if (typeOfSourceValue === "function") {
  96795. continue;
  96796. }
  96797. try {
  96798. if (typeOfSourceValue === "object") {
  96799. if (sourceValue instanceof Array) {
  96800. destination[prop] = [];
  96801. if (sourceValue.length > 0) {
  96802. if (typeof sourceValue[0] == "object") {
  96803. for (var index = 0; index < sourceValue.length; index++) {
  96804. var clonedValue = cloneValue(sourceValue[index], destination);
  96805. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  96806. destination[prop].push(clonedValue);
  96807. }
  96808. }
  96809. }
  96810. else {
  96811. destination[prop] = sourceValue.slice(0);
  96812. }
  96813. }
  96814. }
  96815. else {
  96816. destination[prop] = cloneValue(sourceValue, destination);
  96817. }
  96818. }
  96819. else {
  96820. destination[prop] = sourceValue;
  96821. }
  96822. }
  96823. catch (e) {
  96824. // Just ignore error (it could be because of a read-only property)
  96825. }
  96826. }
  96827. };
  96828. return DeepCopier;
  96829. }());
  96830. /***/ }),
  96831. /***/ "./Misc/deferred.ts":
  96832. /*!**************************!*\
  96833. !*** ./Misc/deferred.ts ***!
  96834. \**************************/
  96835. /*! exports provided: Deferred */
  96836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96837. "use strict";
  96838. __webpack_require__.r(__webpack_exports__);
  96839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  96840. /**
  96841. * Wrapper class for promise with external resolve and reject.
  96842. */
  96843. var Deferred = /** @class */ (function () {
  96844. /**
  96845. * Constructor for this deferred object.
  96846. */
  96847. function Deferred() {
  96848. var _this = this;
  96849. this.promise = new Promise(function (resolve, reject) {
  96850. _this._resolve = resolve;
  96851. _this._reject = reject;
  96852. });
  96853. }
  96854. Object.defineProperty(Deferred.prototype, "resolve", {
  96855. /**
  96856. * The resolve method of the promise associated with this deferred object.
  96857. */
  96858. get: function () {
  96859. return this._resolve;
  96860. },
  96861. enumerable: true,
  96862. configurable: true
  96863. });
  96864. Object.defineProperty(Deferred.prototype, "reject", {
  96865. /**
  96866. * The reject method of the promise associated with this deferred object.
  96867. */
  96868. get: function () {
  96869. return this._reject;
  96870. },
  96871. enumerable: true,
  96872. configurable: true
  96873. });
  96874. return Deferred;
  96875. }());
  96876. /***/ }),
  96877. /***/ "./Misc/devTools.ts":
  96878. /*!**************************!*\
  96879. !*** ./Misc/devTools.ts ***!
  96880. \**************************/
  96881. /*! exports provided: _DevTools */
  96882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96883. "use strict";
  96884. __webpack_require__.r(__webpack_exports__);
  96885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  96886. /** @hidden */
  96887. var _DevTools = /** @class */ (function () {
  96888. function _DevTools() {
  96889. }
  96890. _DevTools.WarnImport = function (name) {
  96891. return name + " needs to be imported before as it contains a side-effect required by your code.";
  96892. };
  96893. return _DevTools;
  96894. }());
  96895. /***/ }),
  96896. /***/ "./Misc/domManagement.ts":
  96897. /*!*******************************!*\
  96898. !*** ./Misc/domManagement.ts ***!
  96899. \*******************************/
  96900. /*! exports provided: DomManagement */
  96901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96902. "use strict";
  96903. __webpack_require__.r(__webpack_exports__);
  96904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  96905. /**
  96906. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  96907. * Babylon.js
  96908. */
  96909. var DomManagement = /** @class */ (function () {
  96910. function DomManagement() {
  96911. }
  96912. /**
  96913. * Checks if the window object exists
  96914. * @returns true if the window object exists
  96915. */
  96916. DomManagement.IsWindowObjectExist = function () {
  96917. return (typeof window) !== "undefined";
  96918. };
  96919. /**
  96920. * Extracts text content from a DOM element hierarchy
  96921. * @param element defines the root element
  96922. * @returns a string
  96923. */
  96924. DomManagement.GetDOMTextContent = function (element) {
  96925. var result = "";
  96926. var child = element.firstChild;
  96927. while (child) {
  96928. if (child.nodeType === 3) {
  96929. result += child.textContent;
  96930. }
  96931. child = (child.nextSibling);
  96932. }
  96933. return result;
  96934. };
  96935. return DomManagement;
  96936. }());
  96937. /***/ }),
  96938. /***/ "./Misc/environmentTextureTools.ts":
  96939. /*!*****************************************!*\
  96940. !*** ./Misc/environmentTextureTools.ts ***!
  96941. \*****************************************/
  96942. /*! exports provided: EnvironmentTextureTools */
  96943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96944. "use strict";
  96945. __webpack_require__.r(__webpack_exports__);
  96946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  96947. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96948. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  96949. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  96950. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  96951. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  96952. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  96953. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96954. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  96955. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  96956. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96957. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  96958. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  96959. /**
  96960. * Sets of helpers addressing the serialization and deserialization of environment texture
  96961. * stored in a BabylonJS env file.
  96962. * Those files are usually stored as .env files.
  96963. */
  96964. var EnvironmentTextureTools = /** @class */ (function () {
  96965. function EnvironmentTextureTools() {
  96966. }
  96967. /**
  96968. * Gets the environment info from an env file.
  96969. * @param data The array buffer containing the .env bytes.
  96970. * @returns the environment file info (the json header) if successfully parsed.
  96971. */
  96972. EnvironmentTextureTools.GetEnvInfo = function (data) {
  96973. var dataView = new DataView(data);
  96974. var pos = 0;
  96975. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  96976. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  96977. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  96978. return null;
  96979. }
  96980. }
  96981. // Read json manifest - collect characters up to null terminator
  96982. var manifestString = '';
  96983. var charCode = 0x00;
  96984. while ((charCode = dataView.getUint8(pos++))) {
  96985. manifestString += String.fromCharCode(charCode);
  96986. }
  96987. var manifest = JSON.parse(manifestString);
  96988. if (manifest.specular) {
  96989. // Extend the header with the position of the payload.
  96990. manifest.specular.specularDataPosition = pos;
  96991. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  96992. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  96993. }
  96994. return manifest;
  96995. };
  96996. /**
  96997. * Creates an environment texture from a loaded cube texture.
  96998. * @param texture defines the cube texture to convert in env file
  96999. * @return a promise containing the environment data if succesfull.
  97000. */
  97001. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  97002. var _this = this;
  97003. var internalTexture = texture.getInternalTexture();
  97004. if (!internalTexture) {
  97005. return Promise.reject("The cube texture is invalid.");
  97006. }
  97007. if (!texture._prefiltered) {
  97008. return Promise.reject("The cube texture is invalid (not prefiltered).");
  97009. }
  97010. var engine = internalTexture.getEngine();
  97011. if (engine && engine.premultipliedAlpha) {
  97012. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  97013. }
  97014. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  97015. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  97016. }
  97017. var canvas = engine.getRenderingCanvas();
  97018. if (!canvas) {
  97019. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  97020. }
  97021. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  97022. if (!engine.getCaps().textureFloatRender) {
  97023. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97024. if (!engine.getCaps().textureHalfFloatRender) {
  97025. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  97026. }
  97027. }
  97028. var cubeWidth = internalTexture.width;
  97029. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  97030. var specularTextures = {};
  97031. var promises = [];
  97032. // Read and collect all mipmaps data from the cube.
  97033. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  97034. mipmapsCount = Math.round(mipmapsCount);
  97035. var _loop_1 = function (i) {
  97036. var faceWidth = Math.pow(2, mipmapsCount - i);
  97037. var _loop_2 = function (face) {
  97038. var data = texture.readPixels(face, i);
  97039. // Creates a temp texture with the face data.
  97040. 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);
  97041. // And rgbdEncode them.
  97042. var promise = new Promise(function (resolve, reject) {
  97043. 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);
  97044. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  97045. rgbdPostProcess.onApply = function (effect) {
  97046. effect._bindTexture("textureSampler", tempTexture);
  97047. };
  97048. // As the process needs to happen on the main canvas, keep track of the current size
  97049. var currentW = engine.getRenderWidth();
  97050. var currentH = engine.getRenderHeight();
  97051. // Set the desired size for the texture
  97052. engine.setSize(faceWidth, faceWidth);
  97053. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  97054. // Reading datas from WebGL
  97055. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  97056. var fileReader = new FileReader();
  97057. fileReader.onload = function (event) {
  97058. var arrayBuffer = event.target.result;
  97059. specularTextures[i * 6 + face] = arrayBuffer;
  97060. resolve();
  97061. };
  97062. fileReader.readAsArrayBuffer(blob);
  97063. });
  97064. // Reapply the previous canvas size
  97065. engine.setSize(currentW, currentH);
  97066. });
  97067. });
  97068. promises.push(promise);
  97069. };
  97070. // All faces of the cube.
  97071. for (var face = 0; face < 6; face++) {
  97072. _loop_2(face);
  97073. }
  97074. };
  97075. for (var i = 0; i <= mipmapsCount; i++) {
  97076. _loop_1(i);
  97077. }
  97078. // Once all the textures haves been collected as RGBD stored in PNGs
  97079. return Promise.all(promises).then(function () {
  97080. // We can delete the hosting scene keeping track of all the creation objects
  97081. hostingScene.dispose();
  97082. // Creates the json header for the env texture
  97083. var info = {
  97084. version: 1,
  97085. width: cubeWidth,
  97086. irradiance: _this._CreateEnvTextureIrradiance(texture),
  97087. specular: {
  97088. mipmaps: [],
  97089. lodGenerationScale: texture.lodGenerationScale
  97090. }
  97091. };
  97092. // Sets the specular image data information
  97093. var position = 0;
  97094. for (var i = 0; i <= mipmapsCount; i++) {
  97095. for (var face = 0; face < 6; face++) {
  97096. var byteLength = specularTextures[i * 6 + face].byteLength;
  97097. info.specular.mipmaps.push({
  97098. length: byteLength,
  97099. position: position
  97100. });
  97101. position += byteLength;
  97102. }
  97103. }
  97104. // Encode the JSON as an array buffer
  97105. var infoString = JSON.stringify(info);
  97106. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  97107. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  97108. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  97109. infoView[i] = infoString.charCodeAt(i);
  97110. }
  97111. // Ends up with a null terminator for easier parsing
  97112. infoView[infoString.length] = 0x00;
  97113. // Computes the final required size and creates the storage
  97114. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  97115. var finalBuffer = new ArrayBuffer(totalSize);
  97116. var finalBufferView = new Uint8Array(finalBuffer);
  97117. var dataView = new DataView(finalBuffer);
  97118. // Copy the magic bytes identifying the file in
  97119. var pos = 0;
  97120. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  97121. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  97122. }
  97123. // Add the json info
  97124. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  97125. pos += infoBuffer.byteLength;
  97126. // Finally inserts the texture data
  97127. for (var i = 0; i <= mipmapsCount; i++) {
  97128. for (var face = 0; face < 6; face++) {
  97129. var dataBuffer = specularTextures[i * 6 + face];
  97130. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  97131. pos += dataBuffer.byteLength;
  97132. }
  97133. }
  97134. // Voila
  97135. return finalBuffer;
  97136. });
  97137. };
  97138. /**
  97139. * Creates a JSON representation of the spherical data.
  97140. * @param texture defines the texture containing the polynomials
  97141. * @return the JSON representation of the spherical info
  97142. */
  97143. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  97144. var polynmials = texture.sphericalPolynomial;
  97145. if (polynmials == null) {
  97146. return null;
  97147. }
  97148. return {
  97149. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  97150. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  97151. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  97152. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  97153. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  97154. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  97155. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  97156. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  97157. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  97158. };
  97159. };
  97160. /**
  97161. * Uploads the texture info contained in the env file to the GPU.
  97162. * @param texture defines the internal texture to upload to
  97163. * @param arrayBuffer defines the buffer cotaining the data to load
  97164. * @param info defines the texture info retrieved through the GetEnvInfo method
  97165. * @returns a promise
  97166. */
  97167. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  97168. if (info.version !== 1) {
  97169. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  97170. }
  97171. var specularInfo = info.specular;
  97172. if (!specularInfo) {
  97173. // Nothing else parsed so far
  97174. return Promise.resolve();
  97175. }
  97176. // Double checks the enclosed info
  97177. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  97178. mipmapsCount = Math.round(mipmapsCount) + 1;
  97179. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  97180. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  97181. }
  97182. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  97183. var imageData = new Array(mipmapsCount);
  97184. for (var i = 0; i < mipmapsCount; i++) {
  97185. imageData[i] = new Array(6);
  97186. for (var face = 0; face < 6; face++) {
  97187. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  97188. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  97189. }
  97190. }
  97191. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  97192. };
  97193. /**
  97194. * Uploads the levels of image data to the GPU.
  97195. * @param texture defines the internal texture to upload to
  97196. * @param imageData defines the array buffer views of image data [mipmap][face]
  97197. * @returns a promise
  97198. */
  97199. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  97200. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  97201. throw new Error("Texture size must be a power of two");
  97202. }
  97203. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  97204. // Gets everything ready.
  97205. var engine = texture.getEngine();
  97206. var expandTexture = false;
  97207. var generateNonLODTextures = false;
  97208. var rgbdPostProcess = null;
  97209. var cubeRtt = null;
  97210. var lodTextures = null;
  97211. var caps = engine.getCaps();
  97212. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  97213. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97214. texture.generateMipMaps = true;
  97215. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  97216. // Add extra process if texture lod is not supported
  97217. if (!caps.textureLOD) {
  97218. expandTexture = false;
  97219. generateNonLODTextures = true;
  97220. lodTextures = {};
  97221. }
  97222. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  97223. else if (engine.webGLVersion < 2) {
  97224. expandTexture = false;
  97225. }
  97226. // If half float available we can uncompress the texture
  97227. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  97228. expandTexture = true;
  97229. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97230. }
  97231. // If full float available we can uncompress the texture
  97232. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  97233. expandTexture = true;
  97234. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  97235. }
  97236. // Expand the texture if possible
  97237. if (expandTexture) {
  97238. // Simply run through the decode PP
  97239. 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);
  97240. texture._isRGBD = false;
  97241. texture.invertY = false;
  97242. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  97243. generateDepthBuffer: false,
  97244. generateMipMaps: true,
  97245. generateStencilBuffer: false,
  97246. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  97247. type: texture.type,
  97248. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  97249. });
  97250. }
  97251. else {
  97252. texture._isRGBD = true;
  97253. texture.invertY = true;
  97254. // In case of missing support, applies the same patch than DDS files.
  97255. if (generateNonLODTextures) {
  97256. var mipSlices = 3;
  97257. var scale = texture._lodGenerationScale;
  97258. var offset = texture._lodGenerationOffset;
  97259. for (var i = 0; i < mipSlices; i++) {
  97260. //compute LOD from even spacing in smoothness (matching shader calculation)
  97261. var smoothness = i / (mipSlices - 1);
  97262. var roughness = 1 - smoothness;
  97263. var minLODIndex = offset; // roughness = 0
  97264. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  97265. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  97266. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  97267. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  97268. glTextureFromLod.isCube = true;
  97269. glTextureFromLod.invertY = true;
  97270. glTextureFromLod.generateMipMaps = false;
  97271. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  97272. // Wrap in a base texture for easy binding.
  97273. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  97274. lodTexture.isCube = true;
  97275. lodTexture._texture = glTextureFromLod;
  97276. lodTextures[mipmapIndex] = lodTexture;
  97277. switch (i) {
  97278. case 0:
  97279. texture._lodTextureLow = lodTexture;
  97280. break;
  97281. case 1:
  97282. texture._lodTextureMid = lodTexture;
  97283. break;
  97284. case 2:
  97285. texture._lodTextureHigh = lodTexture;
  97286. break;
  97287. }
  97288. }
  97289. }
  97290. }
  97291. var promises = [];
  97292. var _loop_3 = function (i) {
  97293. var _loop_4 = function (face) {
  97294. // Constructs an image element from image data
  97295. var bytes = imageData[i][face];
  97296. var blob = new Blob([bytes], { type: 'image/png' });
  97297. var url = URL.createObjectURL(blob);
  97298. var image = new Image();
  97299. image.src = url;
  97300. // Enqueue promise to upload to the texture.
  97301. var promise = new Promise(function (resolve, reject) {
  97302. image.onload = function () {
  97303. if (expandTexture) {
  97304. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  97305. reject(message);
  97306. }, image);
  97307. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  97308. // Uncompress the data to a RTT
  97309. rgbdPostProcess.onApply = function (effect) {
  97310. effect._bindTexture("textureSampler", tempTexture_1);
  97311. effect.setFloat2("scale", 1, 1);
  97312. };
  97313. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  97314. // Cleanup
  97315. engine.restoreDefaultFramebuffer();
  97316. tempTexture_1.dispose();
  97317. window.URL.revokeObjectURL(url);
  97318. resolve();
  97319. });
  97320. }
  97321. else {
  97322. engine._uploadImageToTexture(texture, image, face, i);
  97323. // Upload the face to the non lod texture support
  97324. if (generateNonLODTextures) {
  97325. var lodTexture = lodTextures[i];
  97326. if (lodTexture) {
  97327. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  97328. }
  97329. }
  97330. resolve();
  97331. }
  97332. };
  97333. image.onerror = function (error) {
  97334. reject(error);
  97335. };
  97336. });
  97337. promises.push(promise);
  97338. };
  97339. // All faces
  97340. for (var face = 0; face < 6; face++) {
  97341. _loop_4(face);
  97342. }
  97343. };
  97344. // All mipmaps up to provided number of images
  97345. for (var i = 0; i < imageData.length; i++) {
  97346. _loop_3(i);
  97347. }
  97348. // Fill remaining mipmaps with black textures.
  97349. if (imageData.length < mipmapsCount) {
  97350. var data = void 0;
  97351. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  97352. var dataLength = size * size * 4;
  97353. switch (texture.type) {
  97354. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  97355. data = new Uint8Array(dataLength);
  97356. break;
  97357. }
  97358. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  97359. data = new Uint16Array(dataLength);
  97360. break;
  97361. }
  97362. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  97363. data = new Float32Array(dataLength);
  97364. break;
  97365. }
  97366. }
  97367. for (var i = imageData.length; i < mipmapsCount; i++) {
  97368. for (var face = 0; face < 6; face++) {
  97369. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  97370. }
  97371. }
  97372. }
  97373. // Once all done, finishes the cleanup and return
  97374. return Promise.all(promises).then(function () {
  97375. // Release temp RTT.
  97376. if (cubeRtt) {
  97377. engine._releaseFramebufferObjects(cubeRtt);
  97378. cubeRtt._swapAndDie(texture);
  97379. }
  97380. // Release temp Post Process.
  97381. if (rgbdPostProcess) {
  97382. rgbdPostProcess.dispose();
  97383. }
  97384. // Flag internal texture as ready in case they are in use.
  97385. if (generateNonLODTextures) {
  97386. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  97387. texture._lodTextureHigh._texture.isReady = true;
  97388. }
  97389. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  97390. texture._lodTextureMid._texture.isReady = true;
  97391. }
  97392. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  97393. texture._lodTextureLow._texture.isReady = true;
  97394. }
  97395. }
  97396. });
  97397. };
  97398. /**
  97399. * Uploads spherical polynomials information to the texture.
  97400. * @param texture defines the texture we are trying to upload the information to
  97401. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  97402. */
  97403. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  97404. if (info.version !== 1) {
  97405. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  97406. }
  97407. var irradianceInfo = info.irradiance;
  97408. if (!irradianceInfo) {
  97409. return;
  97410. }
  97411. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  97412. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  97413. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  97414. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  97415. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  97416. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  97417. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  97418. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  97419. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  97420. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  97421. texture._sphericalPolynomial = sp;
  97422. };
  97423. /** @hidden */
  97424. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  97425. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  97426. internalTexture._bufferViewArrayArray = data;
  97427. internalTexture._lodGenerationScale = lodScale;
  97428. internalTexture._lodGenerationOffset = lodOffset;
  97429. internalTexture._sphericalPolynomial = sphericalPolynomial;
  97430. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  97431. internalTexture.isReady = true;
  97432. });
  97433. };
  97434. /**
  97435. * Magic number identifying the env file.
  97436. */
  97437. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  97438. return EnvironmentTextureTools;
  97439. }());
  97440. // References the dependencies.
  97441. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  97442. /***/ }),
  97443. /***/ "./Misc/filesInput.ts":
  97444. /*!****************************!*\
  97445. !*** ./Misc/filesInput.ts ***!
  97446. \****************************/
  97447. /*! exports provided: FilesInput */
  97448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97449. "use strict";
  97450. __webpack_require__.r(__webpack_exports__);
  97451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  97452. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  97453. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97454. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  97455. /**
  97456. * Class used to help managing file picking and drag'n'drop
  97457. */
  97458. var FilesInput = /** @class */ (function () {
  97459. /**
  97460. * Creates a new FilesInput
  97461. * @param engine defines the rendering engine
  97462. * @param scene defines the hosting scene
  97463. * @param sceneLoadedCallback callback called when scene is loaded
  97464. * @param progressCallback callback called to track progress
  97465. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  97466. * @param textureLoadingCallback callback called when a texture is loading
  97467. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  97468. * @param onReloadCallback callback called when a reload is requested
  97469. * @param errorCallback callback call if an error occurs
  97470. */
  97471. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  97472. /**
  97473. * Callback called when a file is processed
  97474. */
  97475. this.onProcessFileCallback = function () { return true; };
  97476. this._engine = engine;
  97477. this._currentScene = scene;
  97478. this._sceneLoadedCallback = sceneLoadedCallback;
  97479. this._progressCallback = progressCallback;
  97480. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  97481. this._textureLoadingCallback = textureLoadingCallback;
  97482. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  97483. this._onReloadCallback = onReloadCallback;
  97484. this._errorCallback = errorCallback;
  97485. }
  97486. Object.defineProperty(FilesInput, "FilesToLoad", {
  97487. /**
  97488. * List of files ready to be loaded
  97489. */
  97490. get: function () {
  97491. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  97492. },
  97493. enumerable: true,
  97494. configurable: true
  97495. });
  97496. /**
  97497. * Calls this function to listen to drag'n'drop events on a specific DOM element
  97498. * @param elementToMonitor defines the DOM element to track
  97499. */
  97500. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  97501. var _this = this;
  97502. if (elementToMonitor) {
  97503. this._elementToMonitor = elementToMonitor;
  97504. this._dragEnterHandler = function (e) { _this.drag(e); };
  97505. this._dragOverHandler = function (e) { _this.drag(e); };
  97506. this._dropHandler = function (e) { _this.drop(e); };
  97507. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  97508. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  97509. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  97510. }
  97511. };
  97512. /**
  97513. * Release all associated resources
  97514. */
  97515. FilesInput.prototype.dispose = function () {
  97516. if (!this._elementToMonitor) {
  97517. return;
  97518. }
  97519. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  97520. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  97521. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  97522. };
  97523. FilesInput.prototype.renderFunction = function () {
  97524. if (this._additionalRenderLoopLogicCallback) {
  97525. this._additionalRenderLoopLogicCallback();
  97526. }
  97527. if (this._currentScene) {
  97528. if (this._textureLoadingCallback) {
  97529. var remaining = this._currentScene.getWaitingItemsCount();
  97530. if (remaining > 0) {
  97531. this._textureLoadingCallback(remaining);
  97532. }
  97533. }
  97534. this._currentScene.render();
  97535. }
  97536. };
  97537. FilesInput.prototype.drag = function (e) {
  97538. e.stopPropagation();
  97539. e.preventDefault();
  97540. };
  97541. FilesInput.prototype.drop = function (eventDrop) {
  97542. eventDrop.stopPropagation();
  97543. eventDrop.preventDefault();
  97544. this.loadFiles(eventDrop);
  97545. };
  97546. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  97547. var _this = this;
  97548. var reader = folder.createReader();
  97549. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  97550. reader.readEntries(function (entries) {
  97551. remaining.count += entries.length;
  97552. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  97553. var entry = entries_1[_i];
  97554. if (entry.isFile) {
  97555. entry.file(function (file) {
  97556. file.correctName = relativePath + file.name;
  97557. files.push(file);
  97558. if (--remaining.count === 0) {
  97559. callback();
  97560. }
  97561. });
  97562. }
  97563. else if (entry.isDirectory) {
  97564. _this._traverseFolder(entry, files, remaining, callback);
  97565. }
  97566. }
  97567. if (--remaining.count) {
  97568. callback();
  97569. }
  97570. });
  97571. };
  97572. FilesInput.prototype._processFiles = function (files) {
  97573. for (var i = 0; i < files.length; i++) {
  97574. var name = files[i].correctName.toLowerCase();
  97575. var extension = name.split('.').pop();
  97576. if (!this.onProcessFileCallback(files[i], name, extension)) {
  97577. continue;
  97578. }
  97579. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  97580. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  97581. this._sceneFileToLoad = files[i];
  97582. }
  97583. FilesInput.FilesToLoad[name] = files[i];
  97584. }
  97585. };
  97586. /**
  97587. * Load files from a drop event
  97588. * @param event defines the drop event to use as source
  97589. */
  97590. FilesInput.prototype.loadFiles = function (event) {
  97591. var _this = this;
  97592. // Handling data transfer via drag'n'drop
  97593. if (event && event.dataTransfer && event.dataTransfer.files) {
  97594. this._filesToLoad = event.dataTransfer.files;
  97595. }
  97596. // Handling files from input files
  97597. if (event && event.target && event.target.files) {
  97598. this._filesToLoad = event.target.files;
  97599. }
  97600. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  97601. return;
  97602. }
  97603. if (this._startingProcessingFilesCallback) {
  97604. this._startingProcessingFilesCallback(this._filesToLoad);
  97605. }
  97606. if (this._filesToLoad && this._filesToLoad.length > 0) {
  97607. var files_1 = new Array();
  97608. var folders = [];
  97609. var items = event.dataTransfer ? event.dataTransfer.items : null;
  97610. for (var i = 0; i < this._filesToLoad.length; i++) {
  97611. var fileToLoad = this._filesToLoad[i];
  97612. var name_1 = fileToLoad.name.toLowerCase();
  97613. var entry = void 0;
  97614. fileToLoad.correctName = name_1;
  97615. if (items) {
  97616. var item = items[i];
  97617. if (item.getAsEntry) {
  97618. entry = item.getAsEntry();
  97619. }
  97620. else if (item.webkitGetAsEntry) {
  97621. entry = item.webkitGetAsEntry();
  97622. }
  97623. }
  97624. if (!entry) {
  97625. files_1.push(fileToLoad);
  97626. }
  97627. else {
  97628. if (entry.isDirectory) {
  97629. folders.push(entry);
  97630. }
  97631. else {
  97632. files_1.push(fileToLoad);
  97633. }
  97634. }
  97635. }
  97636. if (folders.length === 0) {
  97637. this._processFiles(files_1);
  97638. this._processReload();
  97639. }
  97640. else {
  97641. var remaining = { count: folders.length };
  97642. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  97643. var folder = folders_1[_i];
  97644. this._traverseFolder(folder, files_1, remaining, function () {
  97645. _this._processFiles(files_1);
  97646. if (remaining.count === 0) {
  97647. _this._processReload();
  97648. }
  97649. });
  97650. }
  97651. }
  97652. }
  97653. };
  97654. FilesInput.prototype._processReload = function () {
  97655. if (this._onReloadCallback) {
  97656. this._onReloadCallback(this._sceneFileToLoad);
  97657. }
  97658. else {
  97659. this.reload();
  97660. }
  97661. };
  97662. /**
  97663. * Reload the current scene from the loaded files
  97664. */
  97665. FilesInput.prototype.reload = function () {
  97666. var _this = this;
  97667. // If a scene file has been provided
  97668. if (this._sceneFileToLoad) {
  97669. if (this._currentScene) {
  97670. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  97671. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  97672. }
  97673. this._engine.stopRenderLoop();
  97674. }
  97675. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  97676. if (_this._progressCallback) {
  97677. _this._progressCallback(progress);
  97678. }
  97679. }).then(function (scene) {
  97680. if (_this._currentScene) {
  97681. _this._currentScene.dispose();
  97682. }
  97683. _this._currentScene = scene;
  97684. if (_this._sceneLoadedCallback) {
  97685. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  97686. }
  97687. // Wait for textures and shaders to be ready
  97688. _this._currentScene.executeWhenReady(function () {
  97689. _this._engine.runRenderLoop(function () {
  97690. _this.renderFunction();
  97691. });
  97692. });
  97693. }).catch(function (error) {
  97694. if (_this._errorCallback) {
  97695. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  97696. }
  97697. });
  97698. }
  97699. else {
  97700. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  97701. }
  97702. };
  97703. return FilesInput;
  97704. }());
  97705. /***/ }),
  97706. /***/ "./Misc/filesInputStore.ts":
  97707. /*!*********************************!*\
  97708. !*** ./Misc/filesInputStore.ts ***!
  97709. \*********************************/
  97710. /*! exports provided: FilesInputStore */
  97711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97712. "use strict";
  97713. __webpack_require__.r(__webpack_exports__);
  97714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  97715. /**
  97716. * Class used to help managing file picking and drag'n'drop
  97717. * File Storage
  97718. */
  97719. var FilesInputStore = /** @class */ (function () {
  97720. function FilesInputStore() {
  97721. }
  97722. /**
  97723. * List of files ready to be loaded
  97724. */
  97725. FilesInputStore.FilesToLoad = {};
  97726. return FilesInputStore;
  97727. }());
  97728. /***/ }),
  97729. /***/ "./Misc/iInspectable.ts":
  97730. /*!******************************!*\
  97731. !*** ./Misc/iInspectable.ts ***!
  97732. \******************************/
  97733. /*! exports provided: InspectableType */
  97734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97735. "use strict";
  97736. __webpack_require__.r(__webpack_exports__);
  97737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return InspectableType; });
  97738. /**
  97739. * Enum that determines the text-wrapping mode to use.
  97740. */
  97741. var InspectableType;
  97742. (function (InspectableType) {
  97743. /**
  97744. * Checkbox for booleans
  97745. */
  97746. InspectableType[InspectableType["Checkbox"] = 0] = "Checkbox";
  97747. /**
  97748. * Sliders for numbers
  97749. */
  97750. InspectableType[InspectableType["Slider"] = 1] = "Slider";
  97751. /**
  97752. * Vector3
  97753. */
  97754. InspectableType[InspectableType["Vector3"] = 2] = "Vector3";
  97755. /**
  97756. * Quaternions
  97757. */
  97758. InspectableType[InspectableType["Quaternion"] = 3] = "Quaternion";
  97759. /**
  97760. * Color3
  97761. */
  97762. InspectableType[InspectableType["Color3"] = 4] = "Color3";
  97763. })(InspectableType || (InspectableType = {}));
  97764. /***/ }),
  97765. /***/ "./Misc/index.ts":
  97766. /*!***********************!*\
  97767. !*** ./Misc/index.ts ***!
  97768. \***********************/
  97769. /*! 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, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, CubeMapToSphericalPolynomialTools, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, HDRTools, PanoramaToCubeMapTools */
  97770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97771. "use strict";
  97772. __webpack_require__.r(__webpack_exports__);
  97773. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  97774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  97775. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  97776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  97777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  97778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  97779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  97780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  97781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  97782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  97783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  97784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  97785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  97786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  97787. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  97788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  97789. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  97790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  97791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  97792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  97793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  97794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  97795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  97796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  97797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  97798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  97799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  97800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  97801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  97802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMatrix"]; });
  97803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  97804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  97805. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  97806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  97807. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  97808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  97809. /* harmony import */ var _meshExploder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshExploder */ "./Misc/meshExploder.ts");
  97810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _meshExploder__WEBPACK_IMPORTED_MODULE_6__["MeshExploder"]; });
  97811. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  97812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_7__["FilesInput"]; });
  97813. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  97814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["CubeMapToSphericalPolynomialTools"]; });
  97815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["HDRTools"]; });
  97816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["PanoramaToCubeMapTools"]; });
  97817. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  97818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__["KhronosTextureContainer"]; });
  97819. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  97820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["EventState"]; });
  97821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observer"]; });
  97822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["MultiObserver"]; });
  97823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observable"]; });
  97824. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  97825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["PerformanceMonitor"]; });
  97826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["RollingAverage"]; });
  97827. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  97828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_12__["PromisePolyfill"]; });
  97829. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  97830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimization"]; });
  97831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["TextureOptimization"]; });
  97832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["HardwareScalingOptimization"]; });
  97833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ShadowsOptimization"]; });
  97834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["PostProcessesOptimization"]; });
  97835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["LensFlaresOptimization"]; });
  97836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["CustomOptimization"]; });
  97837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ParticlesOptimization"]; });
  97838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["RenderTargetsOptimization"]; });
  97839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["MergeMeshesOptimization"]; });
  97840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizerOptions"]; });
  97841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizer"]; });
  97842. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  97843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__["SceneSerializer"]; });
  97844. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  97845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArray"]; });
  97846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArrayNoDuplicate"]; });
  97847. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  97848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_16__["StringDictionary"]; });
  97849. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  97850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_17__["Tags"]; });
  97851. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  97852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_18__["TextureTools"]; });
  97853. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  97854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_19__["TGATools"]; });
  97855. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["ColorGradient"]; });
  97857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Color3Gradient"]; });
  97858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["FactorGradient"]; });
  97859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["LoadFileError"]; });
  97860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["RetryStrategy"]; });
  97861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Tools"]; });
  97862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["PerfCounter"]; });
  97863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["className"]; });
  97864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["AsyncLoop"]; });
  97865. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  97866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_21__["VideoRecorder"]; });
  97867. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  97868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["JoystickAxis"]; });
  97869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["VirtualJoystick"]; });
  97870. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  97871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_23__["WorkerPool"]; });
  97872. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_24__["Logger"]; });
  97874. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  97875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_25__["_TypeStore"]; });
  97876. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  97877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_26__["FilesInputStore"]; });
  97878. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  97879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_27__["DeepCopier"]; });
  97880. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  97881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_28__["PivotTools"]; });
  97882. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  97883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_29__["PrecisionDate"]; });
  97884. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  97885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_30__["ScreenshotTools"]; });
  97886. /* empty/unused harmony star reexport *//* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  97887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _webRequest__WEBPACK_IMPORTED_MODULE_31__["WebRequest"]; });
  97888. /* harmony import */ var _iInspectable__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./iInspectable */ "./Misc/iInspectable.ts");
  97889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _iInspectable__WEBPACK_IMPORTED_MODULE_32__["InspectableType"]; });
  97890. /***/ }),
  97891. /***/ "./Misc/khronosTextureContainer.ts":
  97892. /*!*****************************************!*\
  97893. !*** ./Misc/khronosTextureContainer.ts ***!
  97894. \*****************************************/
  97895. /*! exports provided: KhronosTextureContainer */
  97896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97897. "use strict";
  97898. __webpack_require__.r(__webpack_exports__);
  97899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  97900. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97901. /**
  97902. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97903. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97904. */
  97905. var KhronosTextureContainer = /** @class */ (function () {
  97906. /**
  97907. * Creates a new KhronosTextureContainer
  97908. * @param arrayBuffer contents of the KTX container file
  97909. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  97910. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  97911. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  97912. */
  97913. function KhronosTextureContainer(
  97914. /** contents of the KTX container file */
  97915. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  97916. this.arrayBuffer = arrayBuffer;
  97917. /**
  97918. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  97919. */
  97920. this.isInvalid = false;
  97921. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  97922. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  97923. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  97924. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  97925. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  97926. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  97927. this.isInvalid = true;
  97928. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  97929. return;
  97930. }
  97931. // load the reset of the header in native 32 bit uint
  97932. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  97933. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  97934. var endianness = headerDataView.getUint32(0, true);
  97935. var littleEndian = endianness === 0x04030201;
  97936. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  97937. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  97938. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  97939. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  97940. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  97941. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  97942. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  97943. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  97944. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  97945. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  97946. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  97947. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  97948. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  97949. if (this.glType !== 0) {
  97950. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  97951. return;
  97952. }
  97953. else {
  97954. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  97955. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  97956. }
  97957. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  97958. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  97959. return;
  97960. }
  97961. if (this.numberOfArrayElements !== 0) {
  97962. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  97963. return;
  97964. }
  97965. if (this.numberOfFaces !== facesExpected) {
  97966. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  97967. return;
  97968. }
  97969. // we now have a completely validated file, so could use existence of loadType as success
  97970. // would need to make this more elaborate & adjust checks above to support more than one load type
  97971. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  97972. }
  97973. /**
  97974. * Uploads KTX content to a Babylon Texture.
  97975. * It is assumed that the texture has already been created & is currently bound
  97976. * @hidden
  97977. */
  97978. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  97979. switch (this.loadType) {
  97980. case KhronosTextureContainer.COMPRESSED_2D:
  97981. this._upload2DCompressedLevels(texture, loadMipmaps);
  97982. break;
  97983. case KhronosTextureContainer.TEX_2D:
  97984. case KhronosTextureContainer.COMPRESSED_3D:
  97985. case KhronosTextureContainer.TEX_3D:
  97986. }
  97987. };
  97988. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  97989. // initialize width & height for level 1
  97990. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  97991. var width = this.pixelWidth;
  97992. var height = this.pixelHeight;
  97993. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  97994. for (var level = 0; level < mipmapCount; level++) {
  97995. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  97996. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  97997. for (var face = 0; face < this.numberOfFaces; face++) {
  97998. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  97999. var engine = texture.getEngine();
  98000. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  98001. dataOffset += imageSize; // add size of the image for the next face/mipmap
  98002. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  98003. }
  98004. width = Math.max(1.0, width * 0.5);
  98005. height = Math.max(1.0, height * 0.5);
  98006. }
  98007. };
  98008. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  98009. // load types
  98010. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  98011. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  98012. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  98013. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  98014. return KhronosTextureContainer;
  98015. }());
  98016. /***/ }),
  98017. /***/ "./Misc/logger.ts":
  98018. /*!************************!*\
  98019. !*** ./Misc/logger.ts ***!
  98020. \************************/
  98021. /*! exports provided: Logger */
  98022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98023. "use strict";
  98024. __webpack_require__.r(__webpack_exports__);
  98025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  98026. /**
  98027. * Logger used througouht the application to allow configuration of
  98028. * the log level required for the messages.
  98029. */
  98030. var Logger = /** @class */ (function () {
  98031. function Logger() {
  98032. }
  98033. Logger._AddLogEntry = function (entry) {
  98034. Logger._LogCache = entry + Logger._LogCache;
  98035. if (Logger.OnNewCacheEntry) {
  98036. Logger.OnNewCacheEntry(entry);
  98037. }
  98038. };
  98039. Logger._FormatMessage = function (message) {
  98040. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  98041. var date = new Date();
  98042. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  98043. };
  98044. Logger._LogDisabled = function (message) {
  98045. // nothing to do
  98046. };
  98047. Logger._LogEnabled = function (message) {
  98048. var formattedMessage = Logger._FormatMessage(message);
  98049. console.log("BJS - " + formattedMessage);
  98050. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  98051. Logger._AddLogEntry(entry);
  98052. };
  98053. Logger._WarnDisabled = function (message) {
  98054. // nothing to do
  98055. };
  98056. Logger._WarnEnabled = function (message) {
  98057. var formattedMessage = Logger._FormatMessage(message);
  98058. console.warn("BJS - " + formattedMessage);
  98059. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  98060. Logger._AddLogEntry(entry);
  98061. };
  98062. Logger._ErrorDisabled = function (message) {
  98063. // nothing to do
  98064. };
  98065. Logger._ErrorEnabled = function (message) {
  98066. Logger.errorsCount++;
  98067. var formattedMessage = Logger._FormatMessage(message);
  98068. console.error("BJS - " + formattedMessage);
  98069. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  98070. Logger._AddLogEntry(entry);
  98071. };
  98072. Object.defineProperty(Logger, "LogCache", {
  98073. /**
  98074. * Gets current log cache (list of logs)
  98075. */
  98076. get: function () {
  98077. return Logger._LogCache;
  98078. },
  98079. enumerable: true,
  98080. configurable: true
  98081. });
  98082. /**
  98083. * Clears the log cache
  98084. */
  98085. Logger.ClearLogCache = function () {
  98086. Logger._LogCache = "";
  98087. Logger.errorsCount = 0;
  98088. };
  98089. Object.defineProperty(Logger, "LogLevels", {
  98090. /**
  98091. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98092. */
  98093. set: function (level) {
  98094. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  98095. Logger.Log = Logger._LogEnabled;
  98096. }
  98097. else {
  98098. Logger.Log = Logger._LogDisabled;
  98099. }
  98100. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  98101. Logger.Warn = Logger._WarnEnabled;
  98102. }
  98103. else {
  98104. Logger.Warn = Logger._WarnDisabled;
  98105. }
  98106. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  98107. Logger.Error = Logger._ErrorEnabled;
  98108. }
  98109. else {
  98110. Logger.Error = Logger._ErrorDisabled;
  98111. }
  98112. },
  98113. enumerable: true,
  98114. configurable: true
  98115. });
  98116. /**
  98117. * No log
  98118. */
  98119. Logger.NoneLogLevel = 0;
  98120. /**
  98121. * Only message logs
  98122. */
  98123. Logger.MessageLogLevel = 1;
  98124. /**
  98125. * Only warning logs
  98126. */
  98127. Logger.WarningLogLevel = 2;
  98128. /**
  98129. * Only error logs
  98130. */
  98131. Logger.ErrorLogLevel = 4;
  98132. /**
  98133. * All logs
  98134. */
  98135. Logger.AllLogLevel = 7;
  98136. Logger._LogCache = "";
  98137. /**
  98138. * Gets a value indicating the number of loading errors
  98139. * @ignorenaming
  98140. */
  98141. Logger.errorsCount = 0;
  98142. /**
  98143. * Log a message to the console
  98144. */
  98145. Logger.Log = Logger._LogEnabled;
  98146. /**
  98147. * Write a warning message to the console
  98148. */
  98149. Logger.Warn = Logger._WarnEnabled;
  98150. /**
  98151. * Write an error message to the console
  98152. */
  98153. Logger.Error = Logger._ErrorEnabled;
  98154. return Logger;
  98155. }());
  98156. /***/ }),
  98157. /***/ "./Misc/meshExploder.ts":
  98158. /*!******************************!*\
  98159. !*** ./Misc/meshExploder.ts ***!
  98160. \******************************/
  98161. /*! exports provided: MeshExploder */
  98162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98163. "use strict";
  98164. __webpack_require__.r(__webpack_exports__);
  98165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return MeshExploder; });
  98166. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98167. /**
  98168. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  98169. */
  98170. var MeshExploder = /** @class */ (function () {
  98171. /**
  98172. * Explodes meshes from a center mesh.
  98173. * @param meshes The meshes to explode.
  98174. * @param centerMesh The mesh to be center of explosion.
  98175. */
  98176. function MeshExploder(meshes, centerMesh) {
  98177. this._meshesOrigins = [];
  98178. this._toCenterVectors = [];
  98179. this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98180. this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98181. this._centerPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98182. this._meshes = meshes.slice();
  98183. if (centerMesh) {
  98184. this._centerMesh = centerMesh;
  98185. }
  98186. else {
  98187. this._setCenterMesh();
  98188. }
  98189. var centerMeshIndex = this._meshes.indexOf(this._centerMesh);
  98190. if (centerMeshIndex >= 0) {
  98191. this._meshes.splice(centerMeshIndex, 1);
  98192. }
  98193. this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
  98194. for (var index = 0; index < this._meshes.length; index++) {
  98195. if (this._meshes[index]) {
  98196. var mesh = this._meshes[index];
  98197. this._meshesOrigins[index] = mesh.getAbsolutePosition().clone();
  98198. this._toCenterVectors[index] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98199. if (mesh._boundingInfo && this._centerMesh._boundingInfo) {
  98200. mesh._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld, this._toCenterVectors[index]);
  98201. }
  98202. }
  98203. }
  98204. }
  98205. MeshExploder.prototype._setCenterMesh = function () {
  98206. var averageCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98207. var totalCenters = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98208. var shortestToCenter = Number.MAX_VALUE;
  98209. for (var index = 0; index < this._meshes.length; index++) {
  98210. if (this._meshes[index]) {
  98211. var mesh = this._meshes[index];
  98212. var boundingInfo = mesh.getBoundingInfo();
  98213. if (boundingInfo) {
  98214. totalCenters.addInPlace(boundingInfo.boundingBox.centerWorld);
  98215. }
  98216. }
  98217. }
  98218. averageCenter = totalCenters.scale(1 / this._meshes.length);
  98219. for (var index = 0; index < this._meshes.length; index++) {
  98220. if (this._meshes[index]) {
  98221. var mesh = this._meshes[index];
  98222. var boundingInfo = mesh.getBoundingInfo();
  98223. if (boundingInfo) {
  98224. var distanceToCenter = boundingInfo.boundingBox.centerWorld.subtract(averageCenter).lengthSquared();
  98225. if (distanceToCenter < shortestToCenter) {
  98226. this._centerMesh = mesh;
  98227. shortestToCenter = distanceToCenter;
  98228. }
  98229. }
  98230. }
  98231. }
  98232. };
  98233. /**
  98234. * Get class name
  98235. * @returns "MeshExploder"
  98236. */
  98237. MeshExploder.prototype.getClassName = function () {
  98238. return "MeshExploder";
  98239. };
  98240. /**
  98241. * "Exploded meshes"
  98242. * @returns Array of meshes with the centerMesh at index 0.
  98243. */
  98244. MeshExploder.prototype.getMeshes = function () {
  98245. var meshArray = this._meshes.slice();
  98246. meshArray.unshift(this._centerMesh);
  98247. return meshArray;
  98248. };
  98249. /**
  98250. * Explodes meshes giving a specific direction
  98251. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  98252. */
  98253. MeshExploder.prototype.explode = function (direction) {
  98254. if (direction === void 0) { direction = 1.0; }
  98255. for (var index = 0; index < this._meshes.length; index++) {
  98256. if (this._meshes[index] && this._meshesOrigins[index] && this._toCenterVectors[index]) {
  98257. this._toCenterVectors[index].scaleToRef(direction, this._scaledDirection);
  98258. this._meshesOrigins[index].addToRef(this._scaledDirection, this._newPosition);
  98259. this._meshes[index].setAbsolutePosition(this._newPosition);
  98260. }
  98261. }
  98262. this._centerMesh.setAbsolutePosition(this._centerPosition);
  98263. };
  98264. return MeshExploder;
  98265. }());
  98266. /***/ }),
  98267. /***/ "./Misc/observable.ts":
  98268. /*!****************************!*\
  98269. !*** ./Misc/observable.ts ***!
  98270. \****************************/
  98271. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  98272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98273. "use strict";
  98274. __webpack_require__.r(__webpack_exports__);
  98275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  98276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  98277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  98278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  98279. /**
  98280. * A class serves as a medium between the observable and its observers
  98281. */
  98282. var EventState = /** @class */ (function () {
  98283. /**
  98284. * Create a new EventState
  98285. * @param mask defines the mask associated with this state
  98286. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  98287. * @param target defines the original target of the state
  98288. * @param currentTarget defines the current target of the state
  98289. */
  98290. function EventState(mask, skipNextObservers, target, currentTarget) {
  98291. if (skipNextObservers === void 0) { skipNextObservers = false; }
  98292. this.initalize(mask, skipNextObservers, target, currentTarget);
  98293. }
  98294. /**
  98295. * Initialize the current event state
  98296. * @param mask defines the mask associated with this state
  98297. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  98298. * @param target defines the original target of the state
  98299. * @param currentTarget defines the current target of the state
  98300. * @returns the current event state
  98301. */
  98302. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  98303. if (skipNextObservers === void 0) { skipNextObservers = false; }
  98304. this.mask = mask;
  98305. this.skipNextObservers = skipNextObservers;
  98306. this.target = target;
  98307. this.currentTarget = currentTarget;
  98308. return this;
  98309. };
  98310. return EventState;
  98311. }());
  98312. /**
  98313. * Represent an Observer registered to a given Observable object.
  98314. */
  98315. var Observer = /** @class */ (function () {
  98316. /**
  98317. * Creates a new observer
  98318. * @param callback defines the callback to call when the observer is notified
  98319. * @param mask defines the mask of the observer (used to filter notifications)
  98320. * @param scope defines the current scope used to restore the JS context
  98321. */
  98322. function Observer(
  98323. /**
  98324. * Defines the callback to call when the observer is notified
  98325. */
  98326. callback,
  98327. /**
  98328. * Defines the mask of the observer (used to filter notifications)
  98329. */
  98330. mask,
  98331. /**
  98332. * Defines the current scope used to restore the JS context
  98333. */
  98334. scope) {
  98335. if (scope === void 0) { scope = null; }
  98336. this.callback = callback;
  98337. this.mask = mask;
  98338. this.scope = scope;
  98339. /** @hidden */
  98340. this._willBeUnregistered = false;
  98341. /**
  98342. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  98343. */
  98344. this.unregisterOnNextCall = false;
  98345. }
  98346. return Observer;
  98347. }());
  98348. /**
  98349. * Represent a list of observers registered to multiple Observables object.
  98350. */
  98351. var MultiObserver = /** @class */ (function () {
  98352. function MultiObserver() {
  98353. }
  98354. /**
  98355. * Release associated resources
  98356. */
  98357. MultiObserver.prototype.dispose = function () {
  98358. if (this._observers && this._observables) {
  98359. for (var index = 0; index < this._observers.length; index++) {
  98360. this._observables[index].remove(this._observers[index]);
  98361. }
  98362. }
  98363. this._observers = null;
  98364. this._observables = null;
  98365. };
  98366. /**
  98367. * Raise a callback when one of the observable will notify
  98368. * @param observables defines a list of observables to watch
  98369. * @param callback defines the callback to call on notification
  98370. * @param mask defines the mask used to filter notifications
  98371. * @param scope defines the current scope used to restore the JS context
  98372. * @returns the new MultiObserver
  98373. */
  98374. MultiObserver.Watch = function (observables, callback, mask, scope) {
  98375. if (mask === void 0) { mask = -1; }
  98376. if (scope === void 0) { scope = null; }
  98377. var result = new MultiObserver();
  98378. result._observers = new Array();
  98379. result._observables = observables;
  98380. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  98381. var observable = observables_1[_i];
  98382. var observer = observable.add(callback, mask, false, scope);
  98383. if (observer) {
  98384. result._observers.push(observer);
  98385. }
  98386. }
  98387. return result;
  98388. };
  98389. return MultiObserver;
  98390. }());
  98391. /**
  98392. * The Observable class is a simple implementation of the Observable pattern.
  98393. *
  98394. * 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.
  98395. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  98396. * 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).
  98397. * 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.
  98398. */
  98399. var Observable = /** @class */ (function () {
  98400. /**
  98401. * Creates a new observable
  98402. * @param onObserverAdded defines a callback to call when a new observer is added
  98403. */
  98404. function Observable(onObserverAdded) {
  98405. this._observers = new Array();
  98406. this._eventState = new EventState(0);
  98407. if (onObserverAdded) {
  98408. this._onObserverAdded = onObserverAdded;
  98409. }
  98410. }
  98411. /**
  98412. * Create a new Observer with the specified callback
  98413. * @param callback the callback that will be executed for that Observer
  98414. * @param mask the mask used to filter observers
  98415. * @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.
  98416. * @param scope optional scope for the callback to be called from
  98417. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  98418. * @returns the new observer created for the callback
  98419. */
  98420. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  98421. if (mask === void 0) { mask = -1; }
  98422. if (insertFirst === void 0) { insertFirst = false; }
  98423. if (scope === void 0) { scope = null; }
  98424. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  98425. if (!callback) {
  98426. return null;
  98427. }
  98428. var observer = new Observer(callback, mask, scope);
  98429. observer.unregisterOnNextCall = unregisterOnFirstCall;
  98430. if (insertFirst) {
  98431. this._observers.unshift(observer);
  98432. }
  98433. else {
  98434. this._observers.push(observer);
  98435. }
  98436. if (this._onObserverAdded) {
  98437. this._onObserverAdded(observer);
  98438. }
  98439. return observer;
  98440. };
  98441. /**
  98442. * Create a new Observer with the specified callback and unregisters after the next notification
  98443. * @param callback the callback that will be executed for that Observer
  98444. * @returns the new observer created for the callback
  98445. */
  98446. Observable.prototype.addOnce = function (callback) {
  98447. return this.add(callback, undefined, undefined, undefined, true);
  98448. };
  98449. /**
  98450. * Remove an Observer from the Observable object
  98451. * @param observer the instance of the Observer to remove
  98452. * @returns false if it doesn't belong to this Observable
  98453. */
  98454. Observable.prototype.remove = function (observer) {
  98455. if (!observer) {
  98456. return false;
  98457. }
  98458. var index = this._observers.indexOf(observer);
  98459. if (index !== -1) {
  98460. this._deferUnregister(observer);
  98461. return true;
  98462. }
  98463. return false;
  98464. };
  98465. /**
  98466. * Remove a callback from the Observable object
  98467. * @param callback the callback to remove
  98468. * @param scope optional scope. If used only the callbacks with this scope will be removed
  98469. * @returns false if it doesn't belong to this Observable
  98470. */
  98471. Observable.prototype.removeCallback = function (callback, scope) {
  98472. for (var index = 0; index < this._observers.length; index++) {
  98473. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  98474. this._deferUnregister(this._observers[index]);
  98475. return true;
  98476. }
  98477. }
  98478. return false;
  98479. };
  98480. Observable.prototype._deferUnregister = function (observer) {
  98481. var _this = this;
  98482. observer.unregisterOnNextCall = false;
  98483. observer._willBeUnregistered = true;
  98484. setTimeout(function () {
  98485. _this._remove(observer);
  98486. }, 0);
  98487. };
  98488. // This should only be called when not iterating over _observers to avoid callback skipping.
  98489. // Removes an observer from the _observer Array.
  98490. Observable.prototype._remove = function (observer) {
  98491. if (!observer) {
  98492. return false;
  98493. }
  98494. var index = this._observers.indexOf(observer);
  98495. if (index !== -1) {
  98496. this._observers.splice(index, 1);
  98497. return true;
  98498. }
  98499. return false;
  98500. };
  98501. /**
  98502. * Moves the observable to the top of the observer list making it get called first when notified
  98503. * @param observer the observer to move
  98504. */
  98505. Observable.prototype.makeObserverTopPriority = function (observer) {
  98506. this._remove(observer);
  98507. this._observers.unshift(observer);
  98508. };
  98509. /**
  98510. * Moves the observable to the bottom of the observer list making it get called last when notified
  98511. * @param observer the observer to move
  98512. */
  98513. Observable.prototype.makeObserverBottomPriority = function (observer) {
  98514. this._remove(observer);
  98515. this._observers.push(observer);
  98516. };
  98517. /**
  98518. * Notify all Observers by calling their respective callback with the given data
  98519. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  98520. * @param eventData defines the data to send to all observers
  98521. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  98522. * @param target defines the original target of the state
  98523. * @param currentTarget defines the current target of the state
  98524. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  98525. */
  98526. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  98527. if (mask === void 0) { mask = -1; }
  98528. if (!this._observers.length) {
  98529. return true;
  98530. }
  98531. var state = this._eventState;
  98532. state.mask = mask;
  98533. state.target = target;
  98534. state.currentTarget = currentTarget;
  98535. state.skipNextObservers = false;
  98536. state.lastReturnValue = eventData;
  98537. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  98538. var obs = _a[_i];
  98539. if (obs._willBeUnregistered) {
  98540. continue;
  98541. }
  98542. if (obs.mask & mask) {
  98543. if (obs.scope) {
  98544. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  98545. }
  98546. else {
  98547. state.lastReturnValue = obs.callback(eventData, state);
  98548. }
  98549. if (obs.unregisterOnNextCall) {
  98550. this._deferUnregister(obs);
  98551. }
  98552. }
  98553. if (state.skipNextObservers) {
  98554. return false;
  98555. }
  98556. }
  98557. return true;
  98558. };
  98559. /**
  98560. * Calling this will execute each callback, expecting it to be a promise or return a value.
  98561. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  98562. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  98563. * and it is crucial that all callbacks will be executed.
  98564. * The order of the callbacks is kept, callbacks are not executed parallel.
  98565. *
  98566. * @param eventData The data to be sent to each callback
  98567. * @param mask is used to filter observers defaults to -1
  98568. * @param target defines the callback target (see EventState)
  98569. * @param currentTarget defines he current object in the bubbling phase
  98570. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  98571. */
  98572. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  98573. var _this = this;
  98574. if (mask === void 0) { mask = -1; }
  98575. // create an empty promise
  98576. var p = Promise.resolve(eventData);
  98577. // no observers? return this promise.
  98578. if (!this._observers.length) {
  98579. return p;
  98580. }
  98581. var state = this._eventState;
  98582. state.mask = mask;
  98583. state.target = target;
  98584. state.currentTarget = currentTarget;
  98585. state.skipNextObservers = false;
  98586. // execute one callback after another (not using Promise.all, the order is important)
  98587. this._observers.forEach(function (obs) {
  98588. if (state.skipNextObservers) {
  98589. return;
  98590. }
  98591. if (obs._willBeUnregistered) {
  98592. return;
  98593. }
  98594. if (obs.mask & mask) {
  98595. if (obs.scope) {
  98596. p = p.then(function (lastReturnedValue) {
  98597. state.lastReturnValue = lastReturnedValue;
  98598. return obs.callback.apply(obs.scope, [eventData, state]);
  98599. });
  98600. }
  98601. else {
  98602. p = p.then(function (lastReturnedValue) {
  98603. state.lastReturnValue = lastReturnedValue;
  98604. return obs.callback(eventData, state);
  98605. });
  98606. }
  98607. if (obs.unregisterOnNextCall) {
  98608. _this._deferUnregister(obs);
  98609. }
  98610. }
  98611. });
  98612. // return the eventData
  98613. return p.then(function () { return eventData; });
  98614. };
  98615. /**
  98616. * Notify a specific observer
  98617. * @param observer defines the observer to notify
  98618. * @param eventData defines the data to be sent to each callback
  98619. * @param mask is used to filter observers defaults to -1
  98620. */
  98621. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  98622. if (mask === void 0) { mask = -1; }
  98623. var state = this._eventState;
  98624. state.mask = mask;
  98625. state.skipNextObservers = false;
  98626. observer.callback(eventData, state);
  98627. };
  98628. /**
  98629. * Gets a boolean indicating if the observable has at least one observer
  98630. * @returns true is the Observable has at least one Observer registered
  98631. */
  98632. Observable.prototype.hasObservers = function () {
  98633. return this._observers.length > 0;
  98634. };
  98635. /**
  98636. * Clear the list of observers
  98637. */
  98638. Observable.prototype.clear = function () {
  98639. this._observers = new Array();
  98640. this._onObserverAdded = null;
  98641. };
  98642. /**
  98643. * Clone the current observable
  98644. * @returns a new observable
  98645. */
  98646. Observable.prototype.clone = function () {
  98647. var result = new Observable();
  98648. result._observers = this._observers.slice(0);
  98649. return result;
  98650. };
  98651. /**
  98652. * Does this observable handles observer registered with a given mask
  98653. * @param mask defines the mask to be tested
  98654. * @return whether or not one observer registered with the given mask is handeled
  98655. **/
  98656. Observable.prototype.hasSpecificMask = function (mask) {
  98657. if (mask === void 0) { mask = -1; }
  98658. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  98659. var obs = _a[_i];
  98660. if (obs.mask & mask || obs.mask === mask) {
  98661. return true;
  98662. }
  98663. }
  98664. return false;
  98665. };
  98666. return Observable;
  98667. }());
  98668. /***/ }),
  98669. /***/ "./Misc/performanceMonitor.ts":
  98670. /*!************************************!*\
  98671. !*** ./Misc/performanceMonitor.ts ***!
  98672. \************************************/
  98673. /*! exports provided: PerformanceMonitor, RollingAverage */
  98674. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98675. "use strict";
  98676. __webpack_require__.r(__webpack_exports__);
  98677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  98678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  98679. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  98680. /**
  98681. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98682. */
  98683. var PerformanceMonitor = /** @class */ (function () {
  98684. /**
  98685. * constructor
  98686. * @param frameSampleSize The number of samples required to saturate the sliding window
  98687. */
  98688. function PerformanceMonitor(frameSampleSize) {
  98689. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  98690. this._enabled = true;
  98691. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  98692. }
  98693. /**
  98694. * Samples current frame
  98695. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98696. */
  98697. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  98698. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  98699. if (!this._enabled) {
  98700. return;
  98701. }
  98702. if (this._lastFrameTimeMs != null) {
  98703. var dt = timeMs - this._lastFrameTimeMs;
  98704. this._rollingFrameTime.add(dt);
  98705. }
  98706. this._lastFrameTimeMs = timeMs;
  98707. };
  98708. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  98709. /**
  98710. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98711. */
  98712. get: function () {
  98713. return this._rollingFrameTime.average;
  98714. },
  98715. enumerable: true,
  98716. configurable: true
  98717. });
  98718. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  98719. /**
  98720. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98721. */
  98722. get: function () {
  98723. return this._rollingFrameTime.variance;
  98724. },
  98725. enumerable: true,
  98726. configurable: true
  98727. });
  98728. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  98729. /**
  98730. * Returns the frame time of the most recent frame
  98731. */
  98732. get: function () {
  98733. return this._rollingFrameTime.history(0);
  98734. },
  98735. enumerable: true,
  98736. configurable: true
  98737. });
  98738. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  98739. /**
  98740. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98741. */
  98742. get: function () {
  98743. return 1000.0 / this._rollingFrameTime.average;
  98744. },
  98745. enumerable: true,
  98746. configurable: true
  98747. });
  98748. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  98749. /**
  98750. * Returns the average framerate in frames per second using the most recent frame time
  98751. */
  98752. get: function () {
  98753. var history = this._rollingFrameTime.history(0);
  98754. if (history === 0) {
  98755. return 0;
  98756. }
  98757. return 1000.0 / history;
  98758. },
  98759. enumerable: true,
  98760. configurable: true
  98761. });
  98762. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  98763. /**
  98764. * Returns true if enough samples have been taken to completely fill the sliding window
  98765. */
  98766. get: function () {
  98767. return this._rollingFrameTime.isSaturated();
  98768. },
  98769. enumerable: true,
  98770. configurable: true
  98771. });
  98772. /**
  98773. * Enables contributions to the sliding window sample set
  98774. */
  98775. PerformanceMonitor.prototype.enable = function () {
  98776. this._enabled = true;
  98777. };
  98778. /**
  98779. * Disables contributions to the sliding window sample set
  98780. * Samples will not be interpolated over the disabled period
  98781. */
  98782. PerformanceMonitor.prototype.disable = function () {
  98783. this._enabled = false;
  98784. //clear last sample to avoid interpolating over the disabled period when next enabled
  98785. this._lastFrameTimeMs = null;
  98786. };
  98787. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  98788. /**
  98789. * Returns true if sampling is enabled
  98790. */
  98791. get: function () {
  98792. return this._enabled;
  98793. },
  98794. enumerable: true,
  98795. configurable: true
  98796. });
  98797. /**
  98798. * Resets performance monitor
  98799. */
  98800. PerformanceMonitor.prototype.reset = function () {
  98801. //clear last sample to avoid interpolating over the disabled period when next enabled
  98802. this._lastFrameTimeMs = null;
  98803. //wipe record
  98804. this._rollingFrameTime.reset();
  98805. };
  98806. return PerformanceMonitor;
  98807. }());
  98808. /**
  98809. * RollingAverage
  98810. *
  98811. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98812. */
  98813. var RollingAverage = /** @class */ (function () {
  98814. /**
  98815. * constructor
  98816. * @param length The number of samples required to saturate the sliding window
  98817. */
  98818. function RollingAverage(length) {
  98819. this._samples = new Array(length);
  98820. this.reset();
  98821. }
  98822. /**
  98823. * Adds a sample to the sample set
  98824. * @param v The sample value
  98825. */
  98826. RollingAverage.prototype.add = function (v) {
  98827. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  98828. var delta;
  98829. //we need to check if we've already wrapped round
  98830. if (this.isSaturated()) {
  98831. //remove bottom of stack from mean
  98832. var bottomValue = this._samples[this._pos];
  98833. delta = bottomValue - this.average;
  98834. this.average -= delta / (this._sampleCount - 1);
  98835. this._m2 -= delta * (bottomValue - this.average);
  98836. }
  98837. else {
  98838. this._sampleCount++;
  98839. }
  98840. //add new value to mean
  98841. delta = v - this.average;
  98842. this.average += delta / (this._sampleCount);
  98843. this._m2 += delta * (v - this.average);
  98844. //set the new variance
  98845. this.variance = this._m2 / (this._sampleCount - 1);
  98846. this._samples[this._pos] = v;
  98847. this._pos++;
  98848. this._pos %= this._samples.length; //positive wrap around
  98849. };
  98850. /**
  98851. * Returns previously added values or null if outside of history or outside the sliding window domain
  98852. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98853. * @return Value previously recorded with add() or null if outside of range
  98854. */
  98855. RollingAverage.prototype.history = function (i) {
  98856. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  98857. return 0;
  98858. }
  98859. var i0 = this._wrapPosition(this._pos - 1.0);
  98860. return this._samples[this._wrapPosition(i0 - i)];
  98861. };
  98862. /**
  98863. * Returns true if enough samples have been taken to completely fill the sliding window
  98864. * @return true if sample-set saturated
  98865. */
  98866. RollingAverage.prototype.isSaturated = function () {
  98867. return this._sampleCount >= this._samples.length;
  98868. };
  98869. /**
  98870. * Resets the rolling average (equivalent to 0 samples taken so far)
  98871. */
  98872. RollingAverage.prototype.reset = function () {
  98873. this.average = 0;
  98874. this.variance = 0;
  98875. this._sampleCount = 0;
  98876. this._pos = 0;
  98877. this._m2 = 0;
  98878. };
  98879. /**
  98880. * Wraps a value around the sample range boundaries
  98881. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98882. * @return Wrapped position in sample range
  98883. */
  98884. RollingAverage.prototype._wrapPosition = function (i) {
  98885. var max = this._samples.length;
  98886. return ((i % max) + max) % max;
  98887. };
  98888. return RollingAverage;
  98889. }());
  98890. /***/ }),
  98891. /***/ "./Misc/pivotTools.ts":
  98892. /*!****************************!*\
  98893. !*** ./Misc/pivotTools.ts ***!
  98894. \****************************/
  98895. /*! exports provided: PivotTools */
  98896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98897. "use strict";
  98898. __webpack_require__.r(__webpack_exports__);
  98899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  98900. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98901. /**
  98902. * Class containing a set of static utilities functions for managing Pivots
  98903. * @hidden
  98904. */
  98905. var PivotTools = /** @class */ (function () {
  98906. function PivotTools() {
  98907. }
  98908. /** @hidden */
  98909. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  98910. if (mesh && PivotTools._PivotCached === 0) {
  98911. // Save old pivot and set pivot to 0,0,0
  98912. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  98913. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  98914. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  98915. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  98916. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  98917. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  98918. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  98919. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  98920. }
  98921. }
  98922. PivotTools._PivotCached++;
  98923. };
  98924. /** @hidden */
  98925. PivotTools._RestorePivotPoint = function (mesh) {
  98926. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  98927. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  98928. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  98929. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  98930. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  98931. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  98932. }
  98933. this._PivotCached--;
  98934. };
  98935. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  98936. // store/remove pivot point should only be applied during their outermost calls
  98937. PivotTools._PivotCached = 0;
  98938. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  98939. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  98940. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  98941. return PivotTools;
  98942. }());
  98943. /***/ }),
  98944. /***/ "./Misc/precisionDate.ts":
  98945. /*!*******************************!*\
  98946. !*** ./Misc/precisionDate.ts ***!
  98947. \*******************************/
  98948. /*! exports provided: PrecisionDate */
  98949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98950. "use strict";
  98951. __webpack_require__.r(__webpack_exports__);
  98952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  98953. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  98954. /**
  98955. * Class containing a set of static utilities functions for precision date
  98956. */
  98957. var PrecisionDate = /** @class */ (function () {
  98958. function PrecisionDate() {
  98959. }
  98960. Object.defineProperty(PrecisionDate, "Now", {
  98961. /**
  98962. * Gets either window.performance.now() if supported or Date.now() else
  98963. */
  98964. get: function () {
  98965. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  98966. return window.performance.now();
  98967. }
  98968. return Date.now();
  98969. },
  98970. enumerable: true,
  98971. configurable: true
  98972. });
  98973. return PrecisionDate;
  98974. }());
  98975. /***/ }),
  98976. /***/ "./Misc/promise.ts":
  98977. /*!*************************!*\
  98978. !*** ./Misc/promise.ts ***!
  98979. \*************************/
  98980. /*! exports provided: PromisePolyfill */
  98981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98982. "use strict";
  98983. __webpack_require__.r(__webpack_exports__);
  98984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  98985. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98986. var PromiseStates;
  98987. (function (PromiseStates) {
  98988. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  98989. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  98990. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  98991. })(PromiseStates || (PromiseStates = {}));
  98992. var FulFillmentAgregator = /** @class */ (function () {
  98993. function FulFillmentAgregator() {
  98994. this.count = 0;
  98995. this.target = 0;
  98996. this.results = [];
  98997. }
  98998. return FulFillmentAgregator;
  98999. }());
  99000. var InternalPromise = /** @class */ (function () {
  99001. function InternalPromise(resolver) {
  99002. var _this = this;
  99003. this._state = PromiseStates.Pending;
  99004. this._children = new Array();
  99005. this._rejectWasConsumed = false;
  99006. if (!resolver) {
  99007. return;
  99008. }
  99009. try {
  99010. resolver(function (value) {
  99011. _this._resolve(value);
  99012. }, function (reason) {
  99013. _this._reject(reason);
  99014. });
  99015. }
  99016. catch (e) {
  99017. this._reject(e);
  99018. }
  99019. }
  99020. Object.defineProperty(InternalPromise.prototype, "_result", {
  99021. get: function () {
  99022. return this._resultValue;
  99023. },
  99024. set: function (value) {
  99025. this._resultValue = value;
  99026. if (this._parent && this._parent._result === undefined) {
  99027. this._parent._result = value;
  99028. }
  99029. },
  99030. enumerable: true,
  99031. configurable: true
  99032. });
  99033. InternalPromise.prototype.catch = function (onRejected) {
  99034. return this.then(undefined, onRejected);
  99035. };
  99036. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  99037. var _this = this;
  99038. var newPromise = new InternalPromise();
  99039. newPromise._onFulfilled = onFulfilled;
  99040. newPromise._onRejected = onRejected;
  99041. // Composition
  99042. this._children.push(newPromise);
  99043. newPromise._parent = this;
  99044. if (this._state !== PromiseStates.Pending) {
  99045. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  99046. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  99047. var returnedValue = newPromise._resolve(_this._result);
  99048. if (returnedValue !== undefined && returnedValue !== null) {
  99049. if (returnedValue._state !== undefined) {
  99050. var returnedPromise = returnedValue;
  99051. newPromise._children.push(returnedPromise);
  99052. returnedPromise._parent = newPromise;
  99053. newPromise = returnedPromise;
  99054. }
  99055. else {
  99056. newPromise._result = returnedValue;
  99057. }
  99058. }
  99059. }
  99060. else {
  99061. newPromise._reject(_this._reason);
  99062. }
  99063. });
  99064. }
  99065. return newPromise;
  99066. };
  99067. InternalPromise.prototype._moveChildren = function (children) {
  99068. var _this = this;
  99069. var _a;
  99070. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  99071. this._children.forEach(function (child) {
  99072. child._parent = _this;
  99073. });
  99074. if (this._state === PromiseStates.Fulfilled) {
  99075. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  99076. var child = _b[_i];
  99077. child._resolve(this._result);
  99078. }
  99079. }
  99080. else if (this._state === PromiseStates.Rejected) {
  99081. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  99082. var child = _d[_c];
  99083. child._reject(this._reason);
  99084. }
  99085. }
  99086. };
  99087. InternalPromise.prototype._resolve = function (value) {
  99088. try {
  99089. this._state = PromiseStates.Fulfilled;
  99090. var returnedValue = null;
  99091. if (this._onFulfilled) {
  99092. returnedValue = this._onFulfilled(value);
  99093. }
  99094. if (returnedValue !== undefined && returnedValue !== null) {
  99095. if (returnedValue._state !== undefined) {
  99096. // Transmit children
  99097. var returnedPromise = returnedValue;
  99098. returnedPromise._parent = this;
  99099. returnedPromise._moveChildren(this._children);
  99100. value = returnedPromise._result;
  99101. }
  99102. else {
  99103. value = returnedValue;
  99104. }
  99105. }
  99106. this._result = value;
  99107. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  99108. var child = _a[_i];
  99109. child._resolve(value);
  99110. }
  99111. this._children.length = 0;
  99112. delete this._onFulfilled;
  99113. delete this._onRejected;
  99114. }
  99115. catch (e) {
  99116. this._reject(e, true);
  99117. }
  99118. };
  99119. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  99120. if (onLocalThrow === void 0) { onLocalThrow = false; }
  99121. this._state = PromiseStates.Rejected;
  99122. this._reason = reason;
  99123. if (this._onRejected && !onLocalThrow) {
  99124. try {
  99125. this._onRejected(reason);
  99126. this._rejectWasConsumed = true;
  99127. }
  99128. catch (e) {
  99129. reason = e;
  99130. }
  99131. }
  99132. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  99133. var child = _a[_i];
  99134. if (this._rejectWasConsumed) {
  99135. child._resolve(null);
  99136. }
  99137. else {
  99138. child._reject(reason);
  99139. }
  99140. }
  99141. this._children.length = 0;
  99142. delete this._onFulfilled;
  99143. delete this._onRejected;
  99144. };
  99145. InternalPromise.resolve = function (value) {
  99146. var newPromise = new InternalPromise();
  99147. newPromise._resolve(value);
  99148. return newPromise;
  99149. };
  99150. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  99151. promise.then(function (value) {
  99152. agregator.results[index] = value;
  99153. agregator.count++;
  99154. if (agregator.count === agregator.target) {
  99155. agregator.rootPromise._resolve(agregator.results);
  99156. }
  99157. return null;
  99158. }, function (reason) {
  99159. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  99160. agregator.rootPromise._reject(reason);
  99161. }
  99162. });
  99163. };
  99164. InternalPromise.all = function (promises) {
  99165. var newPromise = new InternalPromise();
  99166. var agregator = new FulFillmentAgregator();
  99167. agregator.target = promises.length;
  99168. agregator.rootPromise = newPromise;
  99169. if (promises.length) {
  99170. for (var index = 0; index < promises.length; index++) {
  99171. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  99172. }
  99173. }
  99174. else {
  99175. newPromise._resolve([]);
  99176. }
  99177. return newPromise;
  99178. };
  99179. InternalPromise.race = function (promises) {
  99180. var newPromise = new InternalPromise();
  99181. if (promises.length) {
  99182. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  99183. var promise = promises_1[_i];
  99184. promise.then(function (value) {
  99185. if (newPromise) {
  99186. newPromise._resolve(value);
  99187. newPromise = null;
  99188. }
  99189. return null;
  99190. }, function (reason) {
  99191. if (newPromise) {
  99192. newPromise._reject(reason);
  99193. newPromise = null;
  99194. }
  99195. });
  99196. }
  99197. }
  99198. return newPromise;
  99199. };
  99200. return InternalPromise;
  99201. }());
  99202. /**
  99203. * Helper class that provides a small promise polyfill
  99204. */
  99205. var PromisePolyfill = /** @class */ (function () {
  99206. function PromisePolyfill() {
  99207. }
  99208. /**
  99209. * Static function used to check if the polyfill is required
  99210. * If this is the case then the function will inject the polyfill to window.Promise
  99211. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99212. */
  99213. PromisePolyfill.Apply = function (force) {
  99214. if (force === void 0) { force = false; }
  99215. if (force || typeof Promise === 'undefined') {
  99216. var root = window;
  99217. root.Promise = InternalPromise;
  99218. }
  99219. };
  99220. return PromisePolyfill;
  99221. }());
  99222. /***/ }),
  99223. /***/ "./Misc/sceneOptimizer.ts":
  99224. /*!********************************!*\
  99225. !*** ./Misc/sceneOptimizer.ts ***!
  99226. \********************************/
  99227. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  99228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99229. "use strict";
  99230. __webpack_require__.r(__webpack_exports__);
  99231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  99232. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  99233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  99234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  99235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  99236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  99237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  99238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  99239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  99240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  99241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  99242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  99243. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99244. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  99245. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  99246. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  99247. /**
  99248. * Defines the root class used to create scene optimization to use with SceneOptimizer
  99249. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99250. */
  99251. var SceneOptimization = /** @class */ (function () {
  99252. /**
  99253. * Creates the SceneOptimization object
  99254. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  99255. * @param desc defines the description associated with the optimization
  99256. */
  99257. function SceneOptimization(
  99258. /**
  99259. * Defines the priority of this optimization (0 by default which means first in the list)
  99260. */
  99261. priority) {
  99262. if (priority === void 0) { priority = 0; }
  99263. this.priority = priority;
  99264. }
  99265. /**
  99266. * Gets a string describing the action executed by the current optimization
  99267. * @returns description string
  99268. */
  99269. SceneOptimization.prototype.getDescription = function () {
  99270. return "";
  99271. };
  99272. /**
  99273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99274. * @param scene defines the current scene where to apply this optimization
  99275. * @param optimizer defines the current optimizer
  99276. * @returns true if everything that can be done was applied
  99277. */
  99278. SceneOptimization.prototype.apply = function (scene, optimizer) {
  99279. return true;
  99280. };
  99281. return SceneOptimization;
  99282. }());
  99283. /**
  99284. * Defines an optimization used to reduce the size of render target textures
  99285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99286. */
  99287. var TextureOptimization = /** @class */ (function (_super) {
  99288. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  99289. /**
  99290. * Creates the TextureOptimization object
  99291. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  99292. * @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
  99293. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  99294. */
  99295. function TextureOptimization(
  99296. /**
  99297. * Defines the priority of this optimization (0 by default which means first in the list)
  99298. */
  99299. priority,
  99300. /**
  99301. * 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
  99302. */
  99303. maximumSize,
  99304. /**
  99305. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  99306. */
  99307. step) {
  99308. if (priority === void 0) { priority = 0; }
  99309. if (maximumSize === void 0) { maximumSize = 1024; }
  99310. if (step === void 0) { step = 0.5; }
  99311. var _this = _super.call(this, priority) || this;
  99312. _this.priority = priority;
  99313. _this.maximumSize = maximumSize;
  99314. _this.step = step;
  99315. return _this;
  99316. }
  99317. /**
  99318. * Gets a string describing the action executed by the current optimization
  99319. * @returns description string
  99320. */
  99321. TextureOptimization.prototype.getDescription = function () {
  99322. return "Reducing render target texture size to " + this.maximumSize;
  99323. };
  99324. /**
  99325. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99326. * @param scene defines the current scene where to apply this optimization
  99327. * @param optimizer defines the current optimizer
  99328. * @returns true if everything that can be done was applied
  99329. */
  99330. TextureOptimization.prototype.apply = function (scene, optimizer) {
  99331. var allDone = true;
  99332. for (var index = 0; index < scene.textures.length; index++) {
  99333. var texture = scene.textures[index];
  99334. if (!texture.canRescale || texture.getContext) {
  99335. continue;
  99336. }
  99337. var currentSize = texture.getSize();
  99338. var maxDimension = Math.max(currentSize.width, currentSize.height);
  99339. if (maxDimension > this.maximumSize) {
  99340. texture.scale(this.step);
  99341. allDone = false;
  99342. }
  99343. }
  99344. return allDone;
  99345. };
  99346. return TextureOptimization;
  99347. }(SceneOptimization));
  99348. /**
  99349. * Defines an optimization used to increase or decrease the rendering resolution
  99350. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99351. */
  99352. var HardwareScalingOptimization = /** @class */ (function (_super) {
  99353. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  99354. /**
  99355. * Creates the HardwareScalingOptimization object
  99356. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  99357. * @param maximumScale defines the maximum scale to use (2 by default)
  99358. * @param step defines the step to use between two passes (0.5 by default)
  99359. */
  99360. function HardwareScalingOptimization(
  99361. /**
  99362. * Defines the priority of this optimization (0 by default which means first in the list)
  99363. */
  99364. priority,
  99365. /**
  99366. * Defines the maximum scale to use (2 by default)
  99367. */
  99368. maximumScale,
  99369. /**
  99370. * Defines the step to use between two passes (0.5 by default)
  99371. */
  99372. step) {
  99373. if (priority === void 0) { priority = 0; }
  99374. if (maximumScale === void 0) { maximumScale = 2; }
  99375. if (step === void 0) { step = 0.25; }
  99376. var _this = _super.call(this, priority) || this;
  99377. _this.priority = priority;
  99378. _this.maximumScale = maximumScale;
  99379. _this.step = step;
  99380. _this._currentScale = -1;
  99381. _this._directionOffset = 1;
  99382. return _this;
  99383. }
  99384. /**
  99385. * Gets a string describing the action executed by the current optimization
  99386. * @return description string
  99387. */
  99388. HardwareScalingOptimization.prototype.getDescription = function () {
  99389. return "Setting hardware scaling level to " + this._currentScale;
  99390. };
  99391. /**
  99392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99393. * @param scene defines the current scene where to apply this optimization
  99394. * @param optimizer defines the current optimizer
  99395. * @returns true if everything that can be done was applied
  99396. */
  99397. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  99398. if (this._currentScale === -1) {
  99399. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  99400. if (this._currentScale > this.maximumScale) {
  99401. this._directionOffset = -1;
  99402. }
  99403. }
  99404. this._currentScale += this._directionOffset * this.step;
  99405. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  99406. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  99407. };
  99408. return HardwareScalingOptimization;
  99409. }(SceneOptimization));
  99410. /**
  99411. * Defines an optimization used to remove shadows
  99412. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99413. */
  99414. var ShadowsOptimization = /** @class */ (function (_super) {
  99415. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  99416. function ShadowsOptimization() {
  99417. return _super !== null && _super.apply(this, arguments) || this;
  99418. }
  99419. /**
  99420. * Gets a string describing the action executed by the current optimization
  99421. * @return description string
  99422. */
  99423. ShadowsOptimization.prototype.getDescription = function () {
  99424. return "Turning shadows on/off";
  99425. };
  99426. /**
  99427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99428. * @param scene defines the current scene where to apply this optimization
  99429. * @param optimizer defines the current optimizer
  99430. * @returns true if everything that can be done was applied
  99431. */
  99432. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  99433. scene.shadowsEnabled = optimizer.isInImprovementMode;
  99434. return true;
  99435. };
  99436. return ShadowsOptimization;
  99437. }(SceneOptimization));
  99438. /**
  99439. * Defines an optimization used to turn post-processes off
  99440. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99441. */
  99442. var PostProcessesOptimization = /** @class */ (function (_super) {
  99443. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  99444. function PostProcessesOptimization() {
  99445. return _super !== null && _super.apply(this, arguments) || this;
  99446. }
  99447. /**
  99448. * Gets a string describing the action executed by the current optimization
  99449. * @return description string
  99450. */
  99451. PostProcessesOptimization.prototype.getDescription = function () {
  99452. return "Turning post-processes on/off";
  99453. };
  99454. /**
  99455. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99456. * @param scene defines the current scene where to apply this optimization
  99457. * @param optimizer defines the current optimizer
  99458. * @returns true if everything that can be done was applied
  99459. */
  99460. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  99461. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  99462. return true;
  99463. };
  99464. return PostProcessesOptimization;
  99465. }(SceneOptimization));
  99466. /**
  99467. * Defines an optimization used to turn lens flares off
  99468. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99469. */
  99470. var LensFlaresOptimization = /** @class */ (function (_super) {
  99471. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  99472. function LensFlaresOptimization() {
  99473. return _super !== null && _super.apply(this, arguments) || this;
  99474. }
  99475. /**
  99476. * Gets a string describing the action executed by the current optimization
  99477. * @return description string
  99478. */
  99479. LensFlaresOptimization.prototype.getDescription = function () {
  99480. return "Turning lens flares on/off";
  99481. };
  99482. /**
  99483. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99484. * @param scene defines the current scene where to apply this optimization
  99485. * @param optimizer defines the current optimizer
  99486. * @returns true if everything that can be done was applied
  99487. */
  99488. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  99489. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  99490. return true;
  99491. };
  99492. return LensFlaresOptimization;
  99493. }(SceneOptimization));
  99494. /**
  99495. * Defines an optimization based on user defined callback.
  99496. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99497. */
  99498. var CustomOptimization = /** @class */ (function (_super) {
  99499. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  99500. function CustomOptimization() {
  99501. return _super !== null && _super.apply(this, arguments) || this;
  99502. }
  99503. /**
  99504. * Gets a string describing the action executed by the current optimization
  99505. * @returns description string
  99506. */
  99507. CustomOptimization.prototype.getDescription = function () {
  99508. if (this.onGetDescription) {
  99509. return this.onGetDescription();
  99510. }
  99511. return "Running user defined callback";
  99512. };
  99513. /**
  99514. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99515. * @param scene defines the current scene where to apply this optimization
  99516. * @param optimizer defines the current optimizer
  99517. * @returns true if everything that can be done was applied
  99518. */
  99519. CustomOptimization.prototype.apply = function (scene, optimizer) {
  99520. if (this.onApply) {
  99521. return this.onApply(scene, optimizer);
  99522. }
  99523. return true;
  99524. };
  99525. return CustomOptimization;
  99526. }(SceneOptimization));
  99527. /**
  99528. * Defines an optimization used to turn particles off
  99529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99530. */
  99531. var ParticlesOptimization = /** @class */ (function (_super) {
  99532. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  99533. function ParticlesOptimization() {
  99534. return _super !== null && _super.apply(this, arguments) || this;
  99535. }
  99536. /**
  99537. * Gets a string describing the action executed by the current optimization
  99538. * @return description string
  99539. */
  99540. ParticlesOptimization.prototype.getDescription = function () {
  99541. return "Turning particles on/off";
  99542. };
  99543. /**
  99544. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99545. * @param scene defines the current scene where to apply this optimization
  99546. * @param optimizer defines the current optimizer
  99547. * @returns true if everything that can be done was applied
  99548. */
  99549. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  99550. scene.particlesEnabled = optimizer.isInImprovementMode;
  99551. return true;
  99552. };
  99553. return ParticlesOptimization;
  99554. }(SceneOptimization));
  99555. /**
  99556. * Defines an optimization used to turn render targets off
  99557. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99558. */
  99559. var RenderTargetsOptimization = /** @class */ (function (_super) {
  99560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  99561. function RenderTargetsOptimization() {
  99562. return _super !== null && _super.apply(this, arguments) || this;
  99563. }
  99564. /**
  99565. * Gets a string describing the action executed by the current optimization
  99566. * @return description string
  99567. */
  99568. RenderTargetsOptimization.prototype.getDescription = function () {
  99569. return "Turning render targets off";
  99570. };
  99571. /**
  99572. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99573. * @param scene defines the current scene where to apply this optimization
  99574. * @param optimizer defines the current optimizer
  99575. * @returns true if everything that can be done was applied
  99576. */
  99577. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  99578. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  99579. return true;
  99580. };
  99581. return RenderTargetsOptimization;
  99582. }(SceneOptimization));
  99583. /**
  99584. * Defines an optimization used to merge meshes with compatible materials
  99585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99586. */
  99587. var MergeMeshesOptimization = /** @class */ (function (_super) {
  99588. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  99589. function MergeMeshesOptimization() {
  99590. var _this = _super !== null && _super.apply(this, arguments) || this;
  99591. _this._canBeMerged = function (abstractMesh) {
  99592. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  99593. return false;
  99594. }
  99595. var mesh = abstractMesh;
  99596. if (mesh.isDisposed()) {
  99597. return false;
  99598. }
  99599. if (!mesh.isVisible || !mesh.isEnabled()) {
  99600. return false;
  99601. }
  99602. if (mesh.instances.length > 0) {
  99603. return false;
  99604. }
  99605. if (mesh.skeleton || mesh.hasLODLevels) {
  99606. return false;
  99607. }
  99608. return true;
  99609. };
  99610. return _this;
  99611. }
  99612. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  99613. /**
  99614. * Gets or sets a boolean which defines if optimization octree has to be updated
  99615. */
  99616. get: function () {
  99617. return MergeMeshesOptimization._UpdateSelectionTree;
  99618. },
  99619. /**
  99620. * Gets or sets a boolean which defines if optimization octree has to be updated
  99621. */
  99622. set: function (value) {
  99623. MergeMeshesOptimization._UpdateSelectionTree = value;
  99624. },
  99625. enumerable: true,
  99626. configurable: true
  99627. });
  99628. /**
  99629. * Gets a string describing the action executed by the current optimization
  99630. * @return description string
  99631. */
  99632. MergeMeshesOptimization.prototype.getDescription = function () {
  99633. return "Merging similar meshes together";
  99634. };
  99635. /**
  99636. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99637. * @param scene defines the current scene where to apply this optimization
  99638. * @param optimizer defines the current optimizer
  99639. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  99640. * @returns true if everything that can be done was applied
  99641. */
  99642. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  99643. var globalPool = scene.meshes.slice(0);
  99644. var globalLength = globalPool.length;
  99645. for (var index = 0; index < globalLength; index++) {
  99646. var currentPool = new Array();
  99647. var current = globalPool[index];
  99648. // Checks
  99649. if (!this._canBeMerged(current)) {
  99650. continue;
  99651. }
  99652. currentPool.push(current);
  99653. // Find compatible meshes
  99654. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  99655. var otherMesh = globalPool[subIndex];
  99656. if (!this._canBeMerged(otherMesh)) {
  99657. continue;
  99658. }
  99659. if (otherMesh.material !== current.material) {
  99660. continue;
  99661. }
  99662. if (otherMesh.checkCollisions !== current.checkCollisions) {
  99663. continue;
  99664. }
  99665. currentPool.push(otherMesh);
  99666. globalLength--;
  99667. globalPool.splice(subIndex, 1);
  99668. subIndex--;
  99669. }
  99670. if (currentPool.length < 2) {
  99671. continue;
  99672. }
  99673. // Merge meshes
  99674. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  99675. }
  99676. // Call the octree system optimization if it is defined.
  99677. var sceneAsAny = scene;
  99678. if (sceneAsAny.createOrUpdateSelectionOctree) {
  99679. if (updateSelectionTree != undefined) {
  99680. if (updateSelectionTree) {
  99681. sceneAsAny.createOrUpdateSelectionOctree();
  99682. }
  99683. }
  99684. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  99685. sceneAsAny.createOrUpdateSelectionOctree();
  99686. }
  99687. }
  99688. return true;
  99689. };
  99690. MergeMeshesOptimization._UpdateSelectionTree = false;
  99691. return MergeMeshesOptimization;
  99692. }(SceneOptimization));
  99693. /**
  99694. * Defines a list of options used by SceneOptimizer
  99695. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99696. */
  99697. var SceneOptimizerOptions = /** @class */ (function () {
  99698. /**
  99699. * Creates a new list of options used by SceneOptimizer
  99700. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  99701. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  99702. */
  99703. function SceneOptimizerOptions(
  99704. /**
  99705. * Defines the target frame rate to reach (60 by default)
  99706. */
  99707. targetFrameRate,
  99708. /**
  99709. * Defines the interval between two checkes (2000ms by default)
  99710. */
  99711. trackerDuration) {
  99712. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  99713. if (trackerDuration === void 0) { trackerDuration = 2000; }
  99714. this.targetFrameRate = targetFrameRate;
  99715. this.trackerDuration = trackerDuration;
  99716. /**
  99717. * Gets the list of optimizations to apply
  99718. */
  99719. this.optimizations = new Array();
  99720. }
  99721. /**
  99722. * Add a new optimization
  99723. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  99724. * @returns the current SceneOptimizerOptions
  99725. */
  99726. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  99727. this.optimizations.push(optimization);
  99728. return this;
  99729. };
  99730. /**
  99731. * Add a new custom optimization
  99732. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  99733. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  99734. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  99735. * @returns the current SceneOptimizerOptions
  99736. */
  99737. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  99738. if (priority === void 0) { priority = 0; }
  99739. var optimization = new CustomOptimization(priority);
  99740. optimization.onApply = onApply;
  99741. optimization.onGetDescription = onGetDescription;
  99742. this.optimizations.push(optimization);
  99743. return this;
  99744. };
  99745. /**
  99746. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  99747. * @param targetFrameRate defines the target frame rate (60 by default)
  99748. * @returns a SceneOptimizerOptions object
  99749. */
  99750. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  99751. var result = new SceneOptimizerOptions(targetFrameRate);
  99752. var priority = 0;
  99753. result.addOptimization(new MergeMeshesOptimization(priority));
  99754. result.addOptimization(new ShadowsOptimization(priority));
  99755. result.addOptimization(new LensFlaresOptimization(priority));
  99756. // Next priority
  99757. priority++;
  99758. result.addOptimization(new PostProcessesOptimization(priority));
  99759. result.addOptimization(new ParticlesOptimization(priority));
  99760. // Next priority
  99761. priority++;
  99762. result.addOptimization(new TextureOptimization(priority, 1024));
  99763. return result;
  99764. };
  99765. /**
  99766. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  99767. * @param targetFrameRate defines the target frame rate (60 by default)
  99768. * @returns a SceneOptimizerOptions object
  99769. */
  99770. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  99771. var result = new SceneOptimizerOptions(targetFrameRate);
  99772. var priority = 0;
  99773. result.addOptimization(new MergeMeshesOptimization(priority));
  99774. result.addOptimization(new ShadowsOptimization(priority));
  99775. result.addOptimization(new LensFlaresOptimization(priority));
  99776. // Next priority
  99777. priority++;
  99778. result.addOptimization(new PostProcessesOptimization(priority));
  99779. result.addOptimization(new ParticlesOptimization(priority));
  99780. // Next priority
  99781. priority++;
  99782. result.addOptimization(new TextureOptimization(priority, 512));
  99783. // Next priority
  99784. priority++;
  99785. result.addOptimization(new RenderTargetsOptimization(priority));
  99786. // Next priority
  99787. priority++;
  99788. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  99789. return result;
  99790. };
  99791. /**
  99792. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  99793. * @param targetFrameRate defines the target frame rate (60 by default)
  99794. * @returns a SceneOptimizerOptions object
  99795. */
  99796. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  99797. var result = new SceneOptimizerOptions(targetFrameRate);
  99798. var priority = 0;
  99799. result.addOptimization(new MergeMeshesOptimization(priority));
  99800. result.addOptimization(new ShadowsOptimization(priority));
  99801. result.addOptimization(new LensFlaresOptimization(priority));
  99802. // Next priority
  99803. priority++;
  99804. result.addOptimization(new PostProcessesOptimization(priority));
  99805. result.addOptimization(new ParticlesOptimization(priority));
  99806. // Next priority
  99807. priority++;
  99808. result.addOptimization(new TextureOptimization(priority, 256));
  99809. // Next priority
  99810. priority++;
  99811. result.addOptimization(new RenderTargetsOptimization(priority));
  99812. // Next priority
  99813. priority++;
  99814. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  99815. return result;
  99816. };
  99817. return SceneOptimizerOptions;
  99818. }());
  99819. /**
  99820. * Class used to run optimizations in order to reach a target frame rate
  99821. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99822. */
  99823. var SceneOptimizer = /** @class */ (function () {
  99824. /**
  99825. * Creates a new SceneOptimizer
  99826. * @param scene defines the scene to work on
  99827. * @param options defines the options to use with the SceneOptimizer
  99828. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  99829. * @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)
  99830. */
  99831. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  99832. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  99833. if (improvementMode === void 0) { improvementMode = false; }
  99834. var _this = this;
  99835. this._isRunning = false;
  99836. this._currentPriorityLevel = 0;
  99837. this._targetFrameRate = 60;
  99838. this._trackerDuration = 2000;
  99839. this._currentFrameRate = 0;
  99840. this._improvementMode = false;
  99841. /**
  99842. * Defines an observable called when the optimizer reaches the target frame rate
  99843. */
  99844. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  99845. /**
  99846. * Defines an observable called when the optimizer enables an optimization
  99847. */
  99848. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  99849. /**
  99850. * Defines an observable called when the optimizer is not able to reach the target frame rate
  99851. */
  99852. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  99853. if (!options) {
  99854. this._options = new SceneOptimizerOptions();
  99855. }
  99856. else {
  99857. this._options = options;
  99858. }
  99859. if (this._options.targetFrameRate) {
  99860. this._targetFrameRate = this._options.targetFrameRate;
  99861. }
  99862. if (this._options.trackerDuration) {
  99863. this._trackerDuration = this._options.trackerDuration;
  99864. }
  99865. if (autoGeneratePriorities) {
  99866. var priority = 0;
  99867. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  99868. var optim = _a[_i];
  99869. optim.priority = priority++;
  99870. }
  99871. }
  99872. this._improvementMode = improvementMode;
  99873. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  99874. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  99875. _this._sceneDisposeObserver = null;
  99876. _this.dispose();
  99877. });
  99878. }
  99879. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  99880. /**
  99881. * Gets a boolean indicating if the optimizer is in improvement mode
  99882. */
  99883. get: function () {
  99884. return this._improvementMode;
  99885. },
  99886. enumerable: true,
  99887. configurable: true
  99888. });
  99889. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  99890. /**
  99891. * Gets the current priority level (0 at start)
  99892. */
  99893. get: function () {
  99894. return this._currentPriorityLevel;
  99895. },
  99896. enumerable: true,
  99897. configurable: true
  99898. });
  99899. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  99900. /**
  99901. * Gets the current frame rate checked by the SceneOptimizer
  99902. */
  99903. get: function () {
  99904. return this._currentFrameRate;
  99905. },
  99906. enumerable: true,
  99907. configurable: true
  99908. });
  99909. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  99910. /**
  99911. * Gets or sets the current target frame rate (60 by default)
  99912. */
  99913. get: function () {
  99914. return this._targetFrameRate;
  99915. },
  99916. /**
  99917. * Gets or sets the current target frame rate (60 by default)
  99918. */
  99919. set: function (value) {
  99920. this._targetFrameRate = value;
  99921. },
  99922. enumerable: true,
  99923. configurable: true
  99924. });
  99925. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  99926. /**
  99927. * Gets or sets the current interval between two checks (every 2000ms by default)
  99928. */
  99929. get: function () {
  99930. return this._trackerDuration;
  99931. },
  99932. /**
  99933. * Gets or sets the current interval between two checks (every 2000ms by default)
  99934. */
  99935. set: function (value) {
  99936. this._trackerDuration = value;
  99937. },
  99938. enumerable: true,
  99939. configurable: true
  99940. });
  99941. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  99942. /**
  99943. * Gets the list of active optimizations
  99944. */
  99945. get: function () {
  99946. return this._options.optimizations;
  99947. },
  99948. enumerable: true,
  99949. configurable: true
  99950. });
  99951. /**
  99952. * Stops the current optimizer
  99953. */
  99954. SceneOptimizer.prototype.stop = function () {
  99955. this._isRunning = false;
  99956. };
  99957. /**
  99958. * Reset the optimizer to initial step (current priority level = 0)
  99959. */
  99960. SceneOptimizer.prototype.reset = function () {
  99961. this._currentPriorityLevel = 0;
  99962. };
  99963. /**
  99964. * Start the optimizer. By default it will try to reach a specific framerate
  99965. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  99966. */
  99967. SceneOptimizer.prototype.start = function () {
  99968. var _this = this;
  99969. if (this._isRunning) {
  99970. return;
  99971. }
  99972. this._isRunning = true;
  99973. // Let's wait for the scene to be ready before running our check
  99974. this._scene.executeWhenReady(function () {
  99975. setTimeout(function () {
  99976. _this._checkCurrentState();
  99977. }, _this._trackerDuration);
  99978. });
  99979. };
  99980. SceneOptimizer.prototype._checkCurrentState = function () {
  99981. var _this = this;
  99982. if (!this._isRunning) {
  99983. return;
  99984. }
  99985. var scene = this._scene;
  99986. var options = this._options;
  99987. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  99988. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  99989. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  99990. this._isRunning = false;
  99991. this.onSuccessObservable.notifyObservers(this);
  99992. return;
  99993. }
  99994. // Apply current level of optimizations
  99995. var allDone = true;
  99996. var noOptimizationApplied = true;
  99997. for (var index = 0; index < options.optimizations.length; index++) {
  99998. var optimization = options.optimizations[index];
  99999. if (optimization.priority === this._currentPriorityLevel) {
  100000. noOptimizationApplied = false;
  100001. allDone = allDone && optimization.apply(scene, this);
  100002. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  100003. }
  100004. }
  100005. // If no optimization was applied, this is a failure :(
  100006. if (noOptimizationApplied) {
  100007. this._isRunning = false;
  100008. this.onFailureObservable.notifyObservers(this);
  100009. return;
  100010. }
  100011. // If all optimizations were done, move to next level
  100012. if (allDone) {
  100013. this._currentPriorityLevel++;
  100014. }
  100015. // Let's the system running for a specific amount of time before checking FPS
  100016. scene.executeWhenReady(function () {
  100017. setTimeout(function () {
  100018. _this._checkCurrentState();
  100019. }, _this._trackerDuration);
  100020. });
  100021. };
  100022. /**
  100023. * Release all resources
  100024. */
  100025. SceneOptimizer.prototype.dispose = function () {
  100026. this.stop();
  100027. this.onSuccessObservable.clear();
  100028. this.onFailureObservable.clear();
  100029. this.onNewOptimizationAppliedObservable.clear();
  100030. if (this._sceneDisposeObserver) {
  100031. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  100032. }
  100033. };
  100034. /**
  100035. * Helper function to create a SceneOptimizer with one single line of code
  100036. * @param scene defines the scene to work on
  100037. * @param options defines the options to use with the SceneOptimizer
  100038. * @param onSuccess defines a callback to call on success
  100039. * @param onFailure defines a callback to call on failure
  100040. * @returns the new SceneOptimizer object
  100041. */
  100042. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  100043. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  100044. if (onSuccess) {
  100045. optimizer.onSuccessObservable.add(function () {
  100046. onSuccess();
  100047. });
  100048. }
  100049. if (onFailure) {
  100050. optimizer.onFailureObservable.add(function () {
  100051. onFailure();
  100052. });
  100053. }
  100054. optimizer.start();
  100055. return optimizer;
  100056. };
  100057. return SceneOptimizer;
  100058. }());
  100059. /***/ }),
  100060. /***/ "./Misc/sceneSerializer.ts":
  100061. /*!*********************************!*\
  100062. !*** ./Misc/sceneSerializer.ts ***!
  100063. \*********************************/
  100064. /*! exports provided: SceneSerializer */
  100065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100066. "use strict";
  100067. __webpack_require__.r(__webpack_exports__);
  100068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  100069. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  100070. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  100071. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  100072. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  100073. var serializedGeometries = [];
  100074. var serializeGeometry = function (geometry, serializationGeometries) {
  100075. if (serializedGeometries[geometry.id]) {
  100076. return;
  100077. }
  100078. if (geometry.doNotSerialize) {
  100079. return;
  100080. }
  100081. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  100082. serializedGeometries[geometry.id] = true;
  100083. };
  100084. var serializeMesh = function (mesh, serializationScene) {
  100085. var serializationObject = {};
  100086. // Geometry
  100087. var geometry = mesh._geometry;
  100088. if (geometry) {
  100089. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  100090. // 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
  100091. serializeGeometry(geometry, serializationScene.geometries);
  100092. }
  100093. }
  100094. // Custom
  100095. if (mesh.serialize) {
  100096. mesh.serialize(serializationObject);
  100097. }
  100098. return serializationObject;
  100099. };
  100100. var finalizeSingleMesh = function (mesh, serializationObject) {
  100101. //only works if the mesh is already loaded
  100102. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  100103. //serialize material
  100104. if (mesh.material) {
  100105. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  100106. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  100107. serializationObject.materials = serializationObject.materials || [];
  100108. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  100109. serializationObject.multiMaterials.push(mesh.material.serialize());
  100110. var _loop_1 = function (submaterial) {
  100111. if (submaterial) {
  100112. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  100113. serializationObject.materials.push(submaterial.serialize());
  100114. }
  100115. }
  100116. };
  100117. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  100118. var submaterial = _a[_i];
  100119. _loop_1(submaterial);
  100120. }
  100121. }
  100122. }
  100123. else {
  100124. serializationObject.materials = serializationObject.materials || [];
  100125. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  100126. serializationObject.materials.push(mesh.material.serialize());
  100127. }
  100128. }
  100129. }
  100130. //serialize geometry
  100131. var geometry = mesh._geometry;
  100132. if (geometry) {
  100133. if (!serializationObject.geometries) {
  100134. serializationObject.geometries = {};
  100135. serializationObject.geometries.boxes = [];
  100136. serializationObject.geometries.spheres = [];
  100137. serializationObject.geometries.cylinders = [];
  100138. serializationObject.geometries.toruses = [];
  100139. serializationObject.geometries.grounds = [];
  100140. serializationObject.geometries.planes = [];
  100141. serializationObject.geometries.torusKnots = [];
  100142. serializationObject.geometries.vertexData = [];
  100143. }
  100144. serializeGeometry(geometry, serializationObject.geometries);
  100145. }
  100146. // Skeletons
  100147. if (mesh.skeleton) {
  100148. serializationObject.skeletons = serializationObject.skeletons || [];
  100149. serializationObject.skeletons.push(mesh.skeleton.serialize());
  100150. }
  100151. //serialize the actual mesh
  100152. serializationObject.meshes = serializationObject.meshes || [];
  100153. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  100154. }
  100155. };
  100156. /**
  100157. * Class used to serialize a scene into a string
  100158. */
  100159. var SceneSerializer = /** @class */ (function () {
  100160. function SceneSerializer() {
  100161. }
  100162. /**
  100163. * Clear cache used by a previous serialization
  100164. */
  100165. SceneSerializer.ClearCache = function () {
  100166. serializedGeometries = [];
  100167. };
  100168. /**
  100169. * Serialize a scene into a JSON compatible object
  100170. * @param scene defines the scene to serialize
  100171. * @returns a JSON compatible object
  100172. */
  100173. SceneSerializer.Serialize = function (scene) {
  100174. var serializationObject = {};
  100175. SceneSerializer.ClearCache();
  100176. // Scene
  100177. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  100178. serializationObject.autoClear = scene.autoClear;
  100179. serializationObject.clearColor = scene.clearColor.asArray();
  100180. serializationObject.ambientColor = scene.ambientColor.asArray();
  100181. serializationObject.gravity = scene.gravity.asArray();
  100182. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  100183. // Fog
  100184. if (scene.fogMode && scene.fogMode !== 0) {
  100185. serializationObject.fogMode = scene.fogMode;
  100186. serializationObject.fogColor = scene.fogColor.asArray();
  100187. serializationObject.fogStart = scene.fogStart;
  100188. serializationObject.fogEnd = scene.fogEnd;
  100189. serializationObject.fogDensity = scene.fogDensity;
  100190. }
  100191. //Physics
  100192. if (scene.isPhysicsEnabled()) {
  100193. var physicEngine = scene.getPhysicsEngine();
  100194. if (physicEngine) {
  100195. serializationObject.physicsEnabled = true;
  100196. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  100197. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  100198. }
  100199. }
  100200. // Metadata
  100201. if (scene.metadata) {
  100202. serializationObject.metadata = scene.metadata;
  100203. }
  100204. // Morph targets
  100205. serializationObject.morphTargetManagers = [];
  100206. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  100207. var abstractMesh = _a[_i];
  100208. var manager = abstractMesh.morphTargetManager;
  100209. if (manager) {
  100210. serializationObject.morphTargetManagers.push(manager.serialize());
  100211. }
  100212. }
  100213. // Lights
  100214. serializationObject.lights = [];
  100215. var index;
  100216. var light;
  100217. for (index = 0; index < scene.lights.length; index++) {
  100218. light = scene.lights[index];
  100219. if (!light.doNotSerialize) {
  100220. serializationObject.lights.push(light.serialize());
  100221. }
  100222. }
  100223. // Cameras
  100224. serializationObject.cameras = [];
  100225. for (index = 0; index < scene.cameras.length; index++) {
  100226. var camera = scene.cameras[index];
  100227. if (!camera.doNotSerialize) {
  100228. serializationObject.cameras.push(camera.serialize());
  100229. }
  100230. }
  100231. if (scene.activeCamera) {
  100232. serializationObject.activeCameraID = scene.activeCamera.id;
  100233. }
  100234. // Animations
  100235. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  100236. // Reflection probes
  100237. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  100238. serializationObject.reflectionProbes = [];
  100239. for (index = 0; index < scene.reflectionProbes.length; index++) {
  100240. var reflectionProbe = scene.reflectionProbes[index];
  100241. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  100242. }
  100243. }
  100244. // Materials
  100245. serializationObject.materials = [];
  100246. serializationObject.multiMaterials = [];
  100247. var material;
  100248. for (index = 0; index < scene.materials.length; index++) {
  100249. material = scene.materials[index];
  100250. if (!material.doNotSerialize) {
  100251. serializationObject.materials.push(material.serialize());
  100252. }
  100253. }
  100254. // MultiMaterials
  100255. serializationObject.multiMaterials = [];
  100256. for (index = 0; index < scene.multiMaterials.length; index++) {
  100257. var multiMaterial = scene.multiMaterials[index];
  100258. serializationObject.multiMaterials.push(multiMaterial.serialize());
  100259. }
  100260. // Environment texture
  100261. if (scene.environmentTexture) {
  100262. serializationObject.environmentTexture = scene.environmentTexture.name;
  100263. }
  100264. // Skeletons
  100265. serializationObject.skeletons = [];
  100266. for (index = 0; index < scene.skeletons.length; index++) {
  100267. var skeleton = scene.skeletons[index];
  100268. if (!skeleton.doNotSerialize) {
  100269. serializationObject.skeletons.push(skeleton.serialize());
  100270. }
  100271. }
  100272. // Transform nodes
  100273. serializationObject.transformNodes = [];
  100274. for (index = 0; index < scene.transformNodes.length; index++) {
  100275. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  100276. }
  100277. // Geometries
  100278. serializationObject.geometries = {};
  100279. serializationObject.geometries.boxes = [];
  100280. serializationObject.geometries.spheres = [];
  100281. serializationObject.geometries.cylinders = [];
  100282. serializationObject.geometries.toruses = [];
  100283. serializationObject.geometries.grounds = [];
  100284. serializationObject.geometries.planes = [];
  100285. serializationObject.geometries.torusKnots = [];
  100286. serializationObject.geometries.vertexData = [];
  100287. serializedGeometries = [];
  100288. var geometries = scene.getGeometries();
  100289. for (index = 0; index < geometries.length; index++) {
  100290. var geometry = geometries[index];
  100291. if (geometry.isReady()) {
  100292. serializeGeometry(geometry, serializationObject.geometries);
  100293. }
  100294. }
  100295. // Meshes
  100296. serializationObject.meshes = [];
  100297. for (index = 0; index < scene.meshes.length; index++) {
  100298. var abstractMesh = scene.meshes[index];
  100299. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  100300. var mesh = abstractMesh;
  100301. if (!mesh.doNotSerialize) {
  100302. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  100303. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  100304. }
  100305. }
  100306. }
  100307. }
  100308. // Particles Systems
  100309. serializationObject.particleSystems = [];
  100310. for (index = 0; index < scene.particleSystems.length; index++) {
  100311. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  100312. }
  100313. // Action Manager
  100314. if (scene.actionManager) {
  100315. serializationObject.actions = scene.actionManager.serialize("scene");
  100316. }
  100317. // Components
  100318. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  100319. var component = _c[_b];
  100320. component.serialize(serializationObject);
  100321. }
  100322. return serializationObject;
  100323. };
  100324. /**
  100325. * Serialize a mesh into a JSON compatible object
  100326. * @param toSerialize defines the mesh to serialize
  100327. * @param withParents defines if parents must be serialized as well
  100328. * @param withChildren defines if children must be serialized as well
  100329. * @returns a JSON compatible object
  100330. */
  100331. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  100332. if (withParents === void 0) { withParents = false; }
  100333. if (withChildren === void 0) { withChildren = false; }
  100334. var serializationObject = {};
  100335. SceneSerializer.ClearCache();
  100336. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  100337. if (withParents || withChildren) {
  100338. //deliberate for loop! not for each, appended should be processed as well.
  100339. for (var i = 0; i < toSerialize.length; ++i) {
  100340. if (withChildren) {
  100341. toSerialize[i].getDescendants().forEach(function (node) {
  100342. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  100343. toSerialize.push(node);
  100344. }
  100345. });
  100346. }
  100347. //make sure the array doesn't contain the object already
  100348. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  100349. toSerialize.push(toSerialize[i].parent);
  100350. }
  100351. }
  100352. }
  100353. toSerialize.forEach(function (mesh) {
  100354. finalizeSingleMesh(mesh, serializationObject);
  100355. });
  100356. return serializationObject;
  100357. };
  100358. return SceneSerializer;
  100359. }());
  100360. /***/ }),
  100361. /***/ "./Misc/screenshotTools.ts":
  100362. /*!*********************************!*\
  100363. !*** ./Misc/screenshotTools.ts ***!
  100364. \*********************************/
  100365. /*! exports provided: ScreenshotTools */
  100366. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100367. "use strict";
  100368. __webpack_require__.r(__webpack_exports__);
  100369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  100370. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  100371. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  100372. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  100373. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  100374. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  100375. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100376. /**
  100377. * Class containing a set of static utilities functions for screenshots
  100378. */
  100379. var ScreenshotTools = /** @class */ (function () {
  100380. function ScreenshotTools() {
  100381. }
  100382. /**
  100383. * Captures a screenshot of the current rendering
  100384. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100385. * @param engine defines the rendering engine
  100386. * @param camera defines the source camera
  100387. * @param size This parameter can be set to a single number or to an object with the
  100388. * following (optional) properties: precision, width, height. If a single number is passed,
  100389. * it will be used for both width and height. If an object is passed, the screenshot size
  100390. * will be derived from the parameters. The precision property is a multiplier allowing
  100391. * rendering at a higher or lower resolution
  100392. * @param successCallback defines the callback receives a single parameter which contains the
  100393. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100394. * src parameter of an <img> to display it
  100395. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100396. * Check your browser for supported MIME types
  100397. */
  100398. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  100399. if (mimeType === void 0) { mimeType = "image/png"; }
  100400. var width;
  100401. var height;
  100402. // If a precision value is specified
  100403. if (size.precision) {
  100404. width = Math.round(engine.getRenderWidth() * size.precision);
  100405. height = Math.round(width / engine.getAspectRatio(camera));
  100406. }
  100407. else if (size.width && size.height) {
  100408. width = size.width;
  100409. height = size.height;
  100410. }
  100411. //If passing only width, computing height to keep display canvas ratio.
  100412. else if (size.width && !size.height) {
  100413. width = size.width;
  100414. height = Math.round(width / engine.getAspectRatio(camera));
  100415. }
  100416. //If passing only height, computing width to keep display canvas ratio.
  100417. else if (size.height && !size.width) {
  100418. height = size.height;
  100419. width = Math.round(height * engine.getAspectRatio(camera));
  100420. }
  100421. //Assuming here that "size" parameter is a number
  100422. else if (!isNaN(size)) {
  100423. height = size;
  100424. width = size;
  100425. }
  100426. else {
  100427. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  100428. return;
  100429. }
  100430. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  100431. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  100432. }
  100433. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  100434. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  100435. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  100436. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  100437. var newWidth = width;
  100438. var newHeight = newWidth / ratio;
  100439. if (newHeight > height) {
  100440. newHeight = height;
  100441. newWidth = newHeight * ratio;
  100442. }
  100443. var offsetX = Math.max(0, width - newWidth) / 2;
  100444. var offsetY = Math.max(0, height - newHeight) / 2;
  100445. var renderingCanvas = engine.getRenderingCanvas();
  100446. if (renderContext && renderingCanvas) {
  100447. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  100448. }
  100449. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  100450. };
  100451. /**
  100452. * Generates an image screenshot from the specified camera.
  100453. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100454. * @param engine The engine to use for rendering
  100455. * @param camera The camera to use for rendering
  100456. * @param size This parameter can be set to a single number or to an object with the
  100457. * following (optional) properties: precision, width, height. If a single number is passed,
  100458. * it will be used for both width and height. If an object is passed, the screenshot size
  100459. * will be derived from the parameters. The precision property is a multiplier allowing
  100460. * rendering at a higher or lower resolution
  100461. * @param successCallback The callback receives a single parameter which contains the
  100462. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100463. * src parameter of an <img> to display it
  100464. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100465. * Check your browser for supported MIME types
  100466. * @param samples Texture samples (default: 1)
  100467. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100468. * @param fileName A name for for the downloaded file.
  100469. */
  100470. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  100471. if (mimeType === void 0) { mimeType = "image/png"; }
  100472. if (samples === void 0) { samples = 1; }
  100473. if (antialiasing === void 0) { antialiasing = false; }
  100474. var width;
  100475. var height;
  100476. //If a precision value is specified
  100477. if (size.precision) {
  100478. width = Math.round(engine.getRenderWidth() * size.precision);
  100479. height = Math.round(width / engine.getAspectRatio(camera));
  100480. size = { width: width, height: height };
  100481. }
  100482. else if (size.width && size.height) {
  100483. width = size.width;
  100484. height = size.height;
  100485. }
  100486. //If passing only width, computing height to keep display canvas ratio.
  100487. else if (size.width && !size.height) {
  100488. width = size.width;
  100489. height = Math.round(width / engine.getAspectRatio(camera));
  100490. size = { width: width, height: height };
  100491. }
  100492. //If passing only height, computing width to keep display canvas ratio.
  100493. else if (size.height && !size.width) {
  100494. height = size.height;
  100495. width = Math.round(height * engine.getAspectRatio(camera));
  100496. size = { width: width, height: height };
  100497. }
  100498. //Assuming here that "size" parameter is a number
  100499. else if (!isNaN(size)) {
  100500. height = size;
  100501. width = size;
  100502. }
  100503. else {
  100504. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  100505. return;
  100506. }
  100507. var scene = camera.getScene();
  100508. var previousCamera = null;
  100509. if (scene.activeCamera !== camera) {
  100510. previousCamera = scene.activeCamera;
  100511. scene.activeCamera = camera;
  100512. }
  100513. var renderCanvas = engine.getRenderingCanvas();
  100514. if (!renderCanvas) {
  100515. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  100516. return;
  100517. }
  100518. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  100519. engine.setSize(width, height);
  100520. scene.render();
  100521. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  100522. 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);
  100523. texture.renderList = null;
  100524. texture.samples = samples;
  100525. if (antialiasing) {
  100526. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  100527. }
  100528. texture.onAfterRenderObservable.add(function () {
  100529. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  100530. });
  100531. scene.incrementRenderId();
  100532. scene.resetCachedMaterial();
  100533. texture.render(true);
  100534. texture.dispose();
  100535. if (previousCamera) {
  100536. scene.activeCamera = previousCamera;
  100537. }
  100538. engine.setSize(originalSize.width, originalSize.height);
  100539. camera.getProjectionMatrix(true); // Force cache refresh;
  100540. };
  100541. return ScreenshotTools;
  100542. }());
  100543. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  100544. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  100545. /***/ }),
  100546. /***/ "./Misc/smartArray.ts":
  100547. /*!****************************!*\
  100548. !*** ./Misc/smartArray.ts ***!
  100549. \****************************/
  100550. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  100551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100552. "use strict";
  100553. __webpack_require__.r(__webpack_exports__);
  100554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  100555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  100556. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100557. /**
  100558. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  100559. */
  100560. var SmartArray = /** @class */ (function () {
  100561. /**
  100562. * Instantiates a Smart Array.
  100563. * @param capacity defines the default capacity of the array.
  100564. */
  100565. function SmartArray(capacity) {
  100566. /**
  100567. * The active length of the array.
  100568. */
  100569. this.length = 0;
  100570. this.data = new Array(capacity);
  100571. this._id = SmartArray._GlobalId++;
  100572. }
  100573. /**
  100574. * Pushes a value at the end of the active data.
  100575. * @param value defines the object to push in the array.
  100576. */
  100577. SmartArray.prototype.push = function (value) {
  100578. this.data[this.length++] = value;
  100579. if (this.length > this.data.length) {
  100580. this.data.length *= 2;
  100581. }
  100582. };
  100583. /**
  100584. * Iterates over the active data and apply the lambda to them.
  100585. * @param func defines the action to apply on each value.
  100586. */
  100587. SmartArray.prototype.forEach = function (func) {
  100588. for (var index = 0; index < this.length; index++) {
  100589. func(this.data[index]);
  100590. }
  100591. };
  100592. /**
  100593. * Sorts the full sets of data.
  100594. * @param compareFn defines the comparison function to apply.
  100595. */
  100596. SmartArray.prototype.sort = function (compareFn) {
  100597. this.data.sort(compareFn);
  100598. };
  100599. /**
  100600. * Resets the active data to an empty array.
  100601. */
  100602. SmartArray.prototype.reset = function () {
  100603. this.length = 0;
  100604. };
  100605. /**
  100606. * Releases all the data from the array as well as the array.
  100607. */
  100608. SmartArray.prototype.dispose = function () {
  100609. this.reset();
  100610. if (this.data) {
  100611. this.data.length = 0;
  100612. this.data = [];
  100613. }
  100614. };
  100615. /**
  100616. * Concats the active data with a given array.
  100617. * @param array defines the data to concatenate with.
  100618. */
  100619. SmartArray.prototype.concat = function (array) {
  100620. if (array.length === 0) {
  100621. return;
  100622. }
  100623. if (this.length + array.length > this.data.length) {
  100624. this.data.length = (this.length + array.length) * 2;
  100625. }
  100626. for (var index = 0; index < array.length; index++) {
  100627. this.data[this.length++] = (array.data || array)[index];
  100628. }
  100629. };
  100630. /**
  100631. * Returns the position of a value in the active data.
  100632. * @param value defines the value to find the index for
  100633. * @returns the index if found in the active data otherwise -1
  100634. */
  100635. SmartArray.prototype.indexOf = function (value) {
  100636. var position = this.data.indexOf(value);
  100637. if (position >= this.length) {
  100638. return -1;
  100639. }
  100640. return position;
  100641. };
  100642. /**
  100643. * Returns whether an element is part of the active data.
  100644. * @param value defines the value to look for
  100645. * @returns true if found in the active data otherwise false
  100646. */
  100647. SmartArray.prototype.contains = function (value) {
  100648. return this.indexOf(value) !== -1;
  100649. };
  100650. // Statics
  100651. SmartArray._GlobalId = 0;
  100652. return SmartArray;
  100653. }());
  100654. /**
  100655. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  100656. * The data in this array can only be present once
  100657. */
  100658. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  100659. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  100660. function SmartArrayNoDuplicate() {
  100661. var _this = _super !== null && _super.apply(this, arguments) || this;
  100662. _this._duplicateId = 0;
  100663. return _this;
  100664. }
  100665. /**
  100666. * Pushes a value at the end of the active data.
  100667. * THIS DOES NOT PREVENT DUPPLICATE DATA
  100668. * @param value defines the object to push in the array.
  100669. */
  100670. SmartArrayNoDuplicate.prototype.push = function (value) {
  100671. _super.prototype.push.call(this, value);
  100672. if (!value.__smartArrayFlags) {
  100673. value.__smartArrayFlags = {};
  100674. }
  100675. value.__smartArrayFlags[this._id] = this._duplicateId;
  100676. };
  100677. /**
  100678. * Pushes a value at the end of the active data.
  100679. * If the data is already present, it won t be added again
  100680. * @param value defines the object to push in the array.
  100681. * @returns true if added false if it was already present
  100682. */
  100683. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  100684. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  100685. return false;
  100686. }
  100687. this.push(value);
  100688. return true;
  100689. };
  100690. /**
  100691. * Resets the active data to an empty array.
  100692. */
  100693. SmartArrayNoDuplicate.prototype.reset = function () {
  100694. _super.prototype.reset.call(this);
  100695. this._duplicateId++;
  100696. };
  100697. /**
  100698. * Concats the active data with a given array.
  100699. * This ensures no dupplicate will be present in the result.
  100700. * @param array defines the data to concatenate with.
  100701. */
  100702. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  100703. if (array.length === 0) {
  100704. return;
  100705. }
  100706. if (this.length + array.length > this.data.length) {
  100707. this.data.length = (this.length + array.length) * 2;
  100708. }
  100709. for (var index = 0; index < array.length; index++) {
  100710. var item = (array.data || array)[index];
  100711. this.pushNoDuplicate(item);
  100712. }
  100713. };
  100714. return SmartArrayNoDuplicate;
  100715. }(SmartArray));
  100716. /***/ }),
  100717. /***/ "./Misc/stringDictionary.ts":
  100718. /*!**********************************!*\
  100719. !*** ./Misc/stringDictionary.ts ***!
  100720. \**********************************/
  100721. /*! exports provided: StringDictionary */
  100722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100723. "use strict";
  100724. __webpack_require__.r(__webpack_exports__);
  100725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  100726. /**
  100727. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100728. * The underlying implementation relies on an associative array to ensure the best performances.
  100729. * The value can be anything including 'null' but except 'undefined'
  100730. */
  100731. var StringDictionary = /** @class */ (function () {
  100732. function StringDictionary() {
  100733. this._count = 0;
  100734. this._data = {};
  100735. }
  100736. /**
  100737. * This will clear this dictionary and copy the content from the 'source' one.
  100738. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100739. * @param source the dictionary to take the content from and copy to this dictionary
  100740. */
  100741. StringDictionary.prototype.copyFrom = function (source) {
  100742. var _this = this;
  100743. this.clear();
  100744. source.forEach(function (t, v) { return _this.add(t, v); });
  100745. };
  100746. /**
  100747. * Get a value based from its key
  100748. * @param key the given key to get the matching value from
  100749. * @return the value if found, otherwise undefined is returned
  100750. */
  100751. StringDictionary.prototype.get = function (key) {
  100752. var val = this._data[key];
  100753. if (val !== undefined) {
  100754. return val;
  100755. }
  100756. return undefined;
  100757. };
  100758. /**
  100759. * Get a value from its key or add it if it doesn't exist.
  100760. * This method will ensure you that a given key/data will be present in the dictionary.
  100761. * @param key the given key to get the matching value from
  100762. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100763. * The factory will only be invoked if there's no data for the given key.
  100764. * @return the value corresponding to the key.
  100765. */
  100766. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  100767. var val = this.get(key);
  100768. if (val !== undefined) {
  100769. return val;
  100770. }
  100771. val = factory(key);
  100772. if (val) {
  100773. this.add(key, val);
  100774. }
  100775. return val;
  100776. };
  100777. /**
  100778. * Get a value from its key if present in the dictionary otherwise add it
  100779. * @param key the key to get the value from
  100780. * @param val if there's no such key/value pair in the dictionary add it with this value
  100781. * @return the value corresponding to the key
  100782. */
  100783. StringDictionary.prototype.getOrAdd = function (key, val) {
  100784. var curVal = this.get(key);
  100785. if (curVal !== undefined) {
  100786. return curVal;
  100787. }
  100788. this.add(key, val);
  100789. return val;
  100790. };
  100791. /**
  100792. * Check if there's a given key in the dictionary
  100793. * @param key the key to check for
  100794. * @return true if the key is present, false otherwise
  100795. */
  100796. StringDictionary.prototype.contains = function (key) {
  100797. return this._data[key] !== undefined;
  100798. };
  100799. /**
  100800. * Add a new key and its corresponding value
  100801. * @param key the key to add
  100802. * @param value the value corresponding to the key
  100803. * @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
  100804. */
  100805. StringDictionary.prototype.add = function (key, value) {
  100806. if (this._data[key] !== undefined) {
  100807. return false;
  100808. }
  100809. this._data[key] = value;
  100810. ++this._count;
  100811. return true;
  100812. };
  100813. /**
  100814. * Update a specific value associated to a key
  100815. * @param key defines the key to use
  100816. * @param value defines the value to store
  100817. * @returns true if the value was updated (or false if the key was not found)
  100818. */
  100819. StringDictionary.prototype.set = function (key, value) {
  100820. if (this._data[key] === undefined) {
  100821. return false;
  100822. }
  100823. this._data[key] = value;
  100824. return true;
  100825. };
  100826. /**
  100827. * Get the element of the given key and remove it from the dictionary
  100828. * @param key defines the key to search
  100829. * @returns the value associated with the key or null if not found
  100830. */
  100831. StringDictionary.prototype.getAndRemove = function (key) {
  100832. var val = this.get(key);
  100833. if (val !== undefined) {
  100834. delete this._data[key];
  100835. --this._count;
  100836. return val;
  100837. }
  100838. return null;
  100839. };
  100840. /**
  100841. * Remove a key/value from the dictionary.
  100842. * @param key the key to remove
  100843. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100844. */
  100845. StringDictionary.prototype.remove = function (key) {
  100846. if (this.contains(key)) {
  100847. delete this._data[key];
  100848. --this._count;
  100849. return true;
  100850. }
  100851. return false;
  100852. };
  100853. /**
  100854. * Clear the whole content of the dictionary
  100855. */
  100856. StringDictionary.prototype.clear = function () {
  100857. this._data = {};
  100858. this._count = 0;
  100859. };
  100860. Object.defineProperty(StringDictionary.prototype, "count", {
  100861. /**
  100862. * Gets the current count
  100863. */
  100864. get: function () {
  100865. return this._count;
  100866. },
  100867. enumerable: true,
  100868. configurable: true
  100869. });
  100870. /**
  100871. * Execute a callback on each key/val of the dictionary.
  100872. * Note that you can remove any element in this dictionary in the callback implementation
  100873. * @param callback the callback to execute on a given key/value pair
  100874. */
  100875. StringDictionary.prototype.forEach = function (callback) {
  100876. for (var cur in this._data) {
  100877. var val = this._data[cur];
  100878. callback(cur, val);
  100879. }
  100880. };
  100881. /**
  100882. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100883. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100884. * Note that you can remove any element in this dictionary in the callback implementation
  100885. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100886. * @returns the first item
  100887. */
  100888. StringDictionary.prototype.first = function (callback) {
  100889. for (var cur in this._data) {
  100890. var val = this._data[cur];
  100891. var res = callback(cur, val);
  100892. if (res) {
  100893. return res;
  100894. }
  100895. }
  100896. return null;
  100897. };
  100898. return StringDictionary;
  100899. }());
  100900. /***/ }),
  100901. /***/ "./Misc/tags.ts":
  100902. /*!**********************!*\
  100903. !*** ./Misc/tags.ts ***!
  100904. \**********************/
  100905. /*! exports provided: Tags */
  100906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100907. "use strict";
  100908. __webpack_require__.r(__webpack_exports__);
  100909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  100910. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100911. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  100912. /**
  100913. * Class used to store custom tags
  100914. */
  100915. var Tags = /** @class */ (function () {
  100916. function Tags() {
  100917. }
  100918. /**
  100919. * Adds support for tags on the given object
  100920. * @param obj defines the object to use
  100921. */
  100922. Tags.EnableFor = function (obj) {
  100923. obj._tags = obj._tags || {};
  100924. obj.hasTags = function () {
  100925. return Tags.HasTags(obj);
  100926. };
  100927. obj.addTags = function (tagsString) {
  100928. return Tags.AddTagsTo(obj, tagsString);
  100929. };
  100930. obj.removeTags = function (tagsString) {
  100931. return Tags.RemoveTagsFrom(obj, tagsString);
  100932. };
  100933. obj.matchesTagsQuery = function (tagsQuery) {
  100934. return Tags.MatchesQuery(obj, tagsQuery);
  100935. };
  100936. };
  100937. /**
  100938. * Removes tags support
  100939. * @param obj defines the object to use
  100940. */
  100941. Tags.DisableFor = function (obj) {
  100942. delete obj._tags;
  100943. delete obj.hasTags;
  100944. delete obj.addTags;
  100945. delete obj.removeTags;
  100946. delete obj.matchesTagsQuery;
  100947. };
  100948. /**
  100949. * Gets a boolean indicating if the given object has tags
  100950. * @param obj defines the object to use
  100951. * @returns a boolean
  100952. */
  100953. Tags.HasTags = function (obj) {
  100954. if (!obj._tags) {
  100955. return false;
  100956. }
  100957. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  100958. };
  100959. /**
  100960. * Gets the tags available on a given object
  100961. * @param obj defines the object to use
  100962. * @param asString defines if the tags must be returned as a string instead of an array of strings
  100963. * @returns the tags
  100964. */
  100965. Tags.GetTags = function (obj, asString) {
  100966. if (asString === void 0) { asString = true; }
  100967. if (!obj._tags) {
  100968. return null;
  100969. }
  100970. if (asString) {
  100971. var tagsArray = [];
  100972. for (var tag in obj._tags) {
  100973. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  100974. tagsArray.push(tag);
  100975. }
  100976. }
  100977. return tagsArray.join(" ");
  100978. }
  100979. else {
  100980. return obj._tags;
  100981. }
  100982. };
  100983. /**
  100984. * Adds tags to an object
  100985. * @param obj defines the object to use
  100986. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  100987. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  100988. */
  100989. Tags.AddTagsTo = function (obj, tagsString) {
  100990. if (!tagsString) {
  100991. return;
  100992. }
  100993. if (typeof tagsString !== "string") {
  100994. return;
  100995. }
  100996. var tags = tagsString.split(" ");
  100997. tags.forEach(function (tag, index, array) {
  100998. Tags._AddTagTo(obj, tag);
  100999. });
  101000. };
  101001. /**
  101002. * @hidden
  101003. */
  101004. Tags._AddTagTo = function (obj, tag) {
  101005. tag = tag.trim();
  101006. if (tag === "" || tag === "true" || tag === "false") {
  101007. return;
  101008. }
  101009. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  101010. return;
  101011. }
  101012. Tags.EnableFor(obj);
  101013. obj._tags[tag] = true;
  101014. };
  101015. /**
  101016. * Removes specific tags from a specific object
  101017. * @param obj defines the object to use
  101018. * @param tagsString defines the tags to remove
  101019. */
  101020. Tags.RemoveTagsFrom = function (obj, tagsString) {
  101021. if (!Tags.HasTags(obj)) {
  101022. return;
  101023. }
  101024. var tags = tagsString.split(" ");
  101025. for (var t in tags) {
  101026. Tags._RemoveTagFrom(obj, tags[t]);
  101027. }
  101028. };
  101029. /**
  101030. * @hidden
  101031. */
  101032. Tags._RemoveTagFrom = function (obj, tag) {
  101033. delete obj._tags[tag];
  101034. };
  101035. /**
  101036. * Defines if tags hosted on an object match a given query
  101037. * @param obj defines the object to use
  101038. * @param tagsQuery defines the tag query
  101039. * @returns a boolean
  101040. */
  101041. Tags.MatchesQuery = function (obj, tagsQuery) {
  101042. if (tagsQuery === undefined) {
  101043. return true;
  101044. }
  101045. if (tagsQuery === "") {
  101046. return Tags.HasTags(obj);
  101047. }
  101048. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  101049. };
  101050. return Tags;
  101051. }());
  101052. /***/ }),
  101053. /***/ "./Misc/textureTools.ts":
  101054. /*!******************************!*\
  101055. !*** ./Misc/textureTools.ts ***!
  101056. \******************************/
  101057. /*! exports provided: TextureTools */
  101058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101059. "use strict";
  101060. __webpack_require__.r(__webpack_exports__);
  101061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  101062. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  101063. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  101064. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  101065. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101066. /**
  101067. * Class used to host texture specific utilities
  101068. */
  101069. var TextureTools = /** @class */ (function () {
  101070. function TextureTools() {
  101071. }
  101072. /**
  101073. * Uses the GPU to create a copy texture rescaled at a given size
  101074. * @param texture Texture to copy from
  101075. * @param width defines the desired width
  101076. * @param height defines the desired height
  101077. * @param useBilinearMode defines if bilinear mode has to be used
  101078. * @return the generated texture
  101079. */
  101080. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  101081. if (useBilinearMode === void 0) { useBilinearMode = true; }
  101082. var scene = texture.getScene();
  101083. var engine = scene.getEngine();
  101084. 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);
  101085. rtt.wrapU = texture.wrapU;
  101086. rtt.wrapV = texture.wrapV;
  101087. rtt.uOffset = texture.uOffset;
  101088. rtt.vOffset = texture.vOffset;
  101089. rtt.uScale = texture.uScale;
  101090. rtt.vScale = texture.vScale;
  101091. rtt.uAng = texture.uAng;
  101092. rtt.vAng = texture.vAng;
  101093. rtt.wAng = texture.wAng;
  101094. rtt.coordinatesIndex = texture.coordinatesIndex;
  101095. rtt.level = texture.level;
  101096. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  101097. rtt._texture.isReady = false;
  101098. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  101099. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  101100. 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);
  101101. passPostProcess.getEffect().executeWhenCompiled(function () {
  101102. passPostProcess.onApply = function (effect) {
  101103. effect.setTexture("textureSampler", texture);
  101104. };
  101105. var internalTexture = rtt.getInternalTexture();
  101106. if (internalTexture) {
  101107. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  101108. engine.unBindFramebuffer(internalTexture);
  101109. rtt.disposeFramebufferObjects();
  101110. passPostProcess.dispose();
  101111. internalTexture.isReady = true;
  101112. }
  101113. });
  101114. return rtt;
  101115. };
  101116. return TextureTools;
  101117. }());
  101118. /***/ }),
  101119. /***/ "./Misc/tga.ts":
  101120. /*!*********************!*\
  101121. !*** ./Misc/tga.ts ***!
  101122. \*********************/
  101123. /*! exports provided: TGATools */
  101124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101125. "use strict";
  101126. __webpack_require__.r(__webpack_exports__);
  101127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  101128. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  101129. /**
  101130. * Based on jsTGALoader - Javascript loader for TGA file
  101131. * By Vincent Thibault
  101132. * @see http://blog.robrowser.com/javascript-tga-loader.html
  101133. */
  101134. var TGATools = /** @class */ (function () {
  101135. function TGATools() {
  101136. }
  101137. /**
  101138. * Gets the header of a TGA file
  101139. * @param data defines the TGA data
  101140. * @returns the header
  101141. */
  101142. TGATools.GetTGAHeader = function (data) {
  101143. var offset = 0;
  101144. var header = {
  101145. id_length: data[offset++],
  101146. colormap_type: data[offset++],
  101147. image_type: data[offset++],
  101148. colormap_index: data[offset++] | data[offset++] << 8,
  101149. colormap_length: data[offset++] | data[offset++] << 8,
  101150. colormap_size: data[offset++],
  101151. origin: [
  101152. data[offset++] | data[offset++] << 8,
  101153. data[offset++] | data[offset++] << 8
  101154. ],
  101155. width: data[offset++] | data[offset++] << 8,
  101156. height: data[offset++] | data[offset++] << 8,
  101157. pixel_size: data[offset++],
  101158. flags: data[offset++]
  101159. };
  101160. return header;
  101161. };
  101162. /**
  101163. * Uploads TGA content to a Babylon Texture
  101164. * @hidden
  101165. */
  101166. TGATools.UploadContent = function (texture, data) {
  101167. // Not enough data to contain header ?
  101168. if (data.length < 19) {
  101169. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  101170. return;
  101171. }
  101172. // Read Header
  101173. var offset = 18;
  101174. var header = TGATools.GetTGAHeader(data);
  101175. // Assume it's a valid Targa file.
  101176. if (header.id_length + offset > data.length) {
  101177. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  101178. return;
  101179. }
  101180. // Skip not needed data
  101181. offset += header.id_length;
  101182. var use_rle = false;
  101183. var use_pal = false;
  101184. var use_grey = false;
  101185. // Get some informations.
  101186. switch (header.image_type) {
  101187. case TGATools._TYPE_RLE_INDEXED:
  101188. use_rle = true;
  101189. case TGATools._TYPE_INDEXED:
  101190. use_pal = true;
  101191. break;
  101192. case TGATools._TYPE_RLE_RGB:
  101193. use_rle = true;
  101194. case TGATools._TYPE_RGB:
  101195. // use_rgb = true;
  101196. break;
  101197. case TGATools._TYPE_RLE_GREY:
  101198. use_rle = true;
  101199. case TGATools._TYPE_GREY:
  101200. use_grey = true;
  101201. break;
  101202. }
  101203. var pixel_data;
  101204. // var numAlphaBits = header.flags & 0xf;
  101205. var pixel_size = header.pixel_size >> 3;
  101206. var pixel_total = header.width * header.height * pixel_size;
  101207. // Read palettes
  101208. var palettes;
  101209. if (use_pal) {
  101210. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  101211. }
  101212. // Read LRE
  101213. if (use_rle) {
  101214. pixel_data = new Uint8Array(pixel_total);
  101215. var c, count, i;
  101216. var localOffset = 0;
  101217. var pixels = new Uint8Array(pixel_size);
  101218. while (offset < pixel_total && localOffset < pixel_total) {
  101219. c = data[offset++];
  101220. count = (c & 0x7f) + 1;
  101221. // RLE pixels
  101222. if (c & 0x80) {
  101223. // Bind pixel tmp array
  101224. for (i = 0; i < pixel_size; ++i) {
  101225. pixels[i] = data[offset++];
  101226. }
  101227. // Copy pixel array
  101228. for (i = 0; i < count; ++i) {
  101229. pixel_data.set(pixels, localOffset + i * pixel_size);
  101230. }
  101231. localOffset += pixel_size * count;
  101232. }
  101233. // Raw pixels
  101234. else {
  101235. count *= pixel_size;
  101236. for (i = 0; i < count; ++i) {
  101237. pixel_data[localOffset + i] = data[offset++];
  101238. }
  101239. localOffset += count;
  101240. }
  101241. }
  101242. }
  101243. // RAW Pixels
  101244. else {
  101245. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  101246. }
  101247. // Load to texture
  101248. var x_start, y_start, x_step, y_step, y_end, x_end;
  101249. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  101250. default:
  101251. case TGATools._ORIGIN_UL:
  101252. x_start = 0;
  101253. x_step = 1;
  101254. x_end = header.width;
  101255. y_start = 0;
  101256. y_step = 1;
  101257. y_end = header.height;
  101258. break;
  101259. case TGATools._ORIGIN_BL:
  101260. x_start = 0;
  101261. x_step = 1;
  101262. x_end = header.width;
  101263. y_start = header.height - 1;
  101264. y_step = -1;
  101265. y_end = -1;
  101266. break;
  101267. case TGATools._ORIGIN_UR:
  101268. x_start = header.width - 1;
  101269. x_step = -1;
  101270. x_end = -1;
  101271. y_start = 0;
  101272. y_step = 1;
  101273. y_end = header.height;
  101274. break;
  101275. case TGATools._ORIGIN_BR:
  101276. x_start = header.width - 1;
  101277. x_step = -1;
  101278. x_end = -1;
  101279. y_start = header.height - 1;
  101280. y_step = -1;
  101281. y_end = -1;
  101282. break;
  101283. }
  101284. // Load the specify method
  101285. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  101286. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  101287. var engine = texture.getEngine();
  101288. engine._uploadDataToTextureDirectly(texture, imageData);
  101289. };
  101290. /** @hidden */
  101291. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101292. var image = pixel_data, colormap = palettes;
  101293. var width = header.width, height = header.height;
  101294. var color, i = 0, x, y;
  101295. var imageData = new Uint8Array(width * height * 4);
  101296. for (y = y_start; y !== y_end; y += y_step) {
  101297. for (x = x_start; x !== x_end; x += x_step, i++) {
  101298. color = image[i];
  101299. imageData[(x + width * y) * 4 + 3] = 255;
  101300. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  101301. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  101302. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  101303. }
  101304. }
  101305. return imageData;
  101306. };
  101307. /** @hidden */
  101308. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101309. var image = pixel_data;
  101310. var width = header.width, height = header.height;
  101311. var color, i = 0, x, y;
  101312. var imageData = new Uint8Array(width * height * 4);
  101313. for (y = y_start; y !== y_end; y += y_step) {
  101314. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  101315. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  101316. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  101317. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  101318. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  101319. imageData[(x + width * y) * 4 + 0] = r;
  101320. imageData[(x + width * y) * 4 + 1] = g;
  101321. imageData[(x + width * y) * 4 + 2] = b;
  101322. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  101323. }
  101324. }
  101325. return imageData;
  101326. };
  101327. /** @hidden */
  101328. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101329. var image = pixel_data;
  101330. var width = header.width, height = header.height;
  101331. var i = 0, x, y;
  101332. var imageData = new Uint8Array(width * height * 4);
  101333. for (y = y_start; y !== y_end; y += y_step) {
  101334. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  101335. imageData[(x + width * y) * 4 + 3] = 255;
  101336. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  101337. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  101338. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  101339. }
  101340. }
  101341. return imageData;
  101342. };
  101343. /** @hidden */
  101344. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101345. var image = pixel_data;
  101346. var width = header.width, height = header.height;
  101347. var i = 0, x, y;
  101348. var imageData = new Uint8Array(width * height * 4);
  101349. for (y = y_start; y !== y_end; y += y_step) {
  101350. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  101351. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  101352. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  101353. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  101354. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  101355. }
  101356. }
  101357. return imageData;
  101358. };
  101359. /** @hidden */
  101360. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101361. var image = pixel_data;
  101362. var width = header.width, height = header.height;
  101363. var color, i = 0, x, y;
  101364. var imageData = new Uint8Array(width * height * 4);
  101365. for (y = y_start; y !== y_end; y += y_step) {
  101366. for (x = x_start; x !== x_end; x += x_step, i++) {
  101367. color = image[i];
  101368. imageData[(x + width * y) * 4 + 0] = color;
  101369. imageData[(x + width * y) * 4 + 1] = color;
  101370. imageData[(x + width * y) * 4 + 2] = color;
  101371. imageData[(x + width * y) * 4 + 3] = 255;
  101372. }
  101373. }
  101374. return imageData;
  101375. };
  101376. /** @hidden */
  101377. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101378. var image = pixel_data;
  101379. var width = header.width, height = header.height;
  101380. var i = 0, x, y;
  101381. var imageData = new Uint8Array(width * height * 4);
  101382. for (y = y_start; y !== y_end; y += y_step) {
  101383. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  101384. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  101385. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  101386. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  101387. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  101388. }
  101389. }
  101390. return imageData;
  101391. };
  101392. //private static _TYPE_NO_DATA = 0;
  101393. TGATools._TYPE_INDEXED = 1;
  101394. TGATools._TYPE_RGB = 2;
  101395. TGATools._TYPE_GREY = 3;
  101396. TGATools._TYPE_RLE_INDEXED = 9;
  101397. TGATools._TYPE_RLE_RGB = 10;
  101398. TGATools._TYPE_RLE_GREY = 11;
  101399. TGATools._ORIGIN_MASK = 0x30;
  101400. TGATools._ORIGIN_SHIFT = 0x04;
  101401. TGATools._ORIGIN_BL = 0x00;
  101402. TGATools._ORIGIN_BR = 0x01;
  101403. TGATools._ORIGIN_UL = 0x02;
  101404. TGATools._ORIGIN_UR = 0x03;
  101405. return TGATools;
  101406. }());
  101407. /***/ }),
  101408. /***/ "./Misc/tools.ts":
  101409. /*!***********************!*\
  101410. !*** ./Misc/tools.ts ***!
  101411. \***********************/
  101412. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  101413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101414. "use strict";
  101415. __webpack_require__.r(__webpack_exports__);
  101416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  101417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  101418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  101419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  101420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  101421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  101422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  101423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  101424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  101425. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101426. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  101427. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101428. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  101429. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  101430. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101431. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  101432. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  101433. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  101434. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  101435. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  101436. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  101437. /* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  101438. /** Class used to store color4 gradient */
  101439. var ColorGradient = /** @class */ (function () {
  101440. function ColorGradient() {
  101441. }
  101442. /**
  101443. * Will get a color picked randomly between color1 and color2.
  101444. * If color2 is undefined then color1 will be used
  101445. * @param result defines the target Color4 to store the result in
  101446. */
  101447. ColorGradient.prototype.getColorToRef = function (result) {
  101448. if (!this.color2) {
  101449. result.copyFrom(this.color1);
  101450. return;
  101451. }
  101452. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  101453. };
  101454. return ColorGradient;
  101455. }());
  101456. /** Class used to store color 3 gradient */
  101457. var Color3Gradient = /** @class */ (function () {
  101458. function Color3Gradient() {
  101459. }
  101460. return Color3Gradient;
  101461. }());
  101462. /** Class used to store factor gradient */
  101463. var FactorGradient = /** @class */ (function () {
  101464. function FactorGradient() {
  101465. }
  101466. /**
  101467. * Will get a number picked randomly between factor1 and factor2.
  101468. * If factor2 is undefined then factor1 will be used
  101469. * @returns the picked number
  101470. */
  101471. FactorGradient.prototype.getFactor = function () {
  101472. if (this.factor2 === undefined) {
  101473. return this.factor1;
  101474. }
  101475. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  101476. };
  101477. return FactorGradient;
  101478. }());
  101479. /**
  101480. * @ignore
  101481. * Application error to support additional information when loading a file
  101482. */
  101483. var LoadFileError = /** @class */ (function (_super) {
  101484. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  101485. /**
  101486. * Creates a new LoadFileError
  101487. * @param message defines the message of the error
  101488. * @param request defines the optional web request
  101489. */
  101490. function LoadFileError(message,
  101491. /** defines the optional web request */
  101492. request) {
  101493. var _this = _super.call(this, message) || this;
  101494. _this.request = request;
  101495. _this.name = "LoadFileError";
  101496. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  101497. return _this;
  101498. }
  101499. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  101500. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  101501. // Polyfill for Object.setPrototypeOf if necessary.
  101502. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  101503. return LoadFileError;
  101504. }(Error));
  101505. /**
  101506. * Class used to define a retry strategy when error happens while loading assets
  101507. */
  101508. var RetryStrategy = /** @class */ (function () {
  101509. function RetryStrategy() {
  101510. }
  101511. /**
  101512. * Function used to defines an exponential back off strategy
  101513. * @param maxRetries defines the maximum number of retries (3 by default)
  101514. * @param baseInterval defines the interval between retries
  101515. * @returns the strategy function to use
  101516. */
  101517. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  101518. if (maxRetries === void 0) { maxRetries = 3; }
  101519. if (baseInterval === void 0) { baseInterval = 500; }
  101520. return function (url, request, retryIndex) {
  101521. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  101522. return -1;
  101523. }
  101524. return Math.pow(2, retryIndex) * baseInterval;
  101525. };
  101526. };
  101527. return RetryStrategy;
  101528. }());
  101529. /**
  101530. * Class containing a set of static utilities functions
  101531. */
  101532. var Tools = /** @class */ (function () {
  101533. function Tools() {
  101534. }
  101535. /**
  101536. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  101537. * @param u defines the coordinate on X axis
  101538. * @param v defines the coordinate on Y axis
  101539. * @param width defines the width of the source data
  101540. * @param height defines the height of the source data
  101541. * @param pixels defines the source byte array
  101542. * @param color defines the output color
  101543. */
  101544. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  101545. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  101546. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  101547. var position = (wrappedU + wrappedV * width) * 4;
  101548. color.r = pixels[position] / 255;
  101549. color.g = pixels[position + 1] / 255;
  101550. color.b = pixels[position + 2] / 255;
  101551. color.a = pixels[position + 3] / 255;
  101552. };
  101553. /**
  101554. * Interpolates between a and b via alpha
  101555. * @param a The lower value (returned when alpha = 0)
  101556. * @param b The upper value (returned when alpha = 1)
  101557. * @param alpha The interpolation-factor
  101558. * @return The mixed value
  101559. */
  101560. Tools.Mix = function (a, b, alpha) {
  101561. return a * (1 - alpha) + b * alpha;
  101562. };
  101563. /**
  101564. * Tries to instantiate a new object from a given class name
  101565. * @param className defines the class name to instantiate
  101566. * @returns the new object or null if the system was not able to do the instantiation
  101567. */
  101568. Tools.Instantiate = function (className) {
  101569. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  101570. return Tools.RegisteredExternalClasses[className];
  101571. }
  101572. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  101573. if (internalClass) {
  101574. return internalClass;
  101575. }
  101576. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  101577. var arr = className.split(".");
  101578. var fn = (window || this);
  101579. for (var i = 0, len = arr.length; i < len; i++) {
  101580. fn = fn[arr[i]];
  101581. }
  101582. if (typeof fn !== "function") {
  101583. return null;
  101584. }
  101585. return fn;
  101586. };
  101587. /**
  101588. * Provides a slice function that will work even on IE
  101589. * @param data defines the array to slice
  101590. * @param start defines the start of the data (optional)
  101591. * @param end defines the end of the data (optional)
  101592. * @returns the new sliced array
  101593. */
  101594. Tools.Slice = function (data, start, end) {
  101595. if (data.slice) {
  101596. return data.slice(start, end);
  101597. }
  101598. return Array.prototype.slice.call(data, start, end);
  101599. };
  101600. /**
  101601. * Polyfill for setImmediate
  101602. * @param action defines the action to execute after the current execution block
  101603. */
  101604. Tools.SetImmediate = function (action) {
  101605. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  101606. window.setImmediate(action);
  101607. }
  101608. else {
  101609. setTimeout(action, 1);
  101610. }
  101611. };
  101612. /**
  101613. * Function indicating if a number is an exponent of 2
  101614. * @param value defines the value to test
  101615. * @returns true if the value is an exponent of 2
  101616. */
  101617. Tools.IsExponentOfTwo = function (value) {
  101618. var count = 1;
  101619. do {
  101620. count *= 2;
  101621. } while (count < value);
  101622. return count === value;
  101623. };
  101624. /**
  101625. * Returns the nearest 32-bit single precision float representation of a Number
  101626. * @param value A Number. If the parameter is of a different type, it will get converted
  101627. * to a number or to NaN if it cannot be converted
  101628. * @returns number
  101629. */
  101630. Tools.FloatRound = function (value) {
  101631. if (Math.fround) {
  101632. return Math.fround(value);
  101633. }
  101634. return (Tools._tmpFloatArray[0] = value);
  101635. };
  101636. /**
  101637. * Find the next highest power of two.
  101638. * @param x Number to start search from.
  101639. * @return Next highest power of two.
  101640. */
  101641. Tools.CeilingPOT = function (x) {
  101642. x--;
  101643. x |= x >> 1;
  101644. x |= x >> 2;
  101645. x |= x >> 4;
  101646. x |= x >> 8;
  101647. x |= x >> 16;
  101648. x++;
  101649. return x;
  101650. };
  101651. /**
  101652. * Find the next lowest power of two.
  101653. * @param x Number to start search from.
  101654. * @return Next lowest power of two.
  101655. */
  101656. Tools.FloorPOT = function (x) {
  101657. x = x | (x >> 1);
  101658. x = x | (x >> 2);
  101659. x = x | (x >> 4);
  101660. x = x | (x >> 8);
  101661. x = x | (x >> 16);
  101662. return x - (x >> 1);
  101663. };
  101664. /**
  101665. * Find the nearest power of two.
  101666. * @param x Number to start search from.
  101667. * @return Next nearest power of two.
  101668. */
  101669. Tools.NearestPOT = function (x) {
  101670. var c = Tools.CeilingPOT(x);
  101671. var f = Tools.FloorPOT(x);
  101672. return (c - x) > (x - f) ? f : c;
  101673. };
  101674. /**
  101675. * Get the closest exponent of two
  101676. * @param value defines the value to approximate
  101677. * @param max defines the maximum value to return
  101678. * @param mode defines how to define the closest value
  101679. * @returns closest exponent of two of the given value
  101680. */
  101681. Tools.GetExponentOfTwo = function (value, max, mode) {
  101682. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  101683. var pot;
  101684. switch (mode) {
  101685. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  101686. pot = Tools.FloorPOT(value);
  101687. break;
  101688. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  101689. pot = Tools.NearestPOT(value);
  101690. break;
  101691. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  101692. default:
  101693. pot = Tools.CeilingPOT(value);
  101694. break;
  101695. }
  101696. return Math.min(pot, max);
  101697. };
  101698. /**
  101699. * Extracts the filename from a path
  101700. * @param path defines the path to use
  101701. * @returns the filename
  101702. */
  101703. Tools.GetFilename = function (path) {
  101704. var index = path.lastIndexOf("/");
  101705. if (index < 0) {
  101706. return path;
  101707. }
  101708. return path.substring(index + 1);
  101709. };
  101710. /**
  101711. * Extracts the "folder" part of a path (everything before the filename).
  101712. * @param uri The URI to extract the info from
  101713. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  101714. * @returns The "folder" part of the path
  101715. */
  101716. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  101717. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  101718. var index = uri.lastIndexOf("/");
  101719. if (index < 0) {
  101720. if (returnUnchangedIfNoSlash) {
  101721. return uri;
  101722. }
  101723. return "";
  101724. }
  101725. return uri.substring(0, index + 1);
  101726. };
  101727. /**
  101728. * Convert an angle in radians to degrees
  101729. * @param angle defines the angle to convert
  101730. * @returns the angle in degrees
  101731. */
  101732. Tools.ToDegrees = function (angle) {
  101733. return angle * 180 / Math.PI;
  101734. };
  101735. /**
  101736. * Convert an angle in degrees to radians
  101737. * @param angle defines the angle to convert
  101738. * @returns the angle in radians
  101739. */
  101740. Tools.ToRadians = function (angle) {
  101741. return angle * Math.PI / 180;
  101742. };
  101743. /**
  101744. * Encode a buffer to a base64 string
  101745. * @param buffer defines the buffer to encode
  101746. * @returns the encoded string
  101747. */
  101748. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  101749. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  101750. var output = "";
  101751. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  101752. var i = 0;
  101753. var bytes = new Uint8Array(buffer);
  101754. while (i < bytes.length) {
  101755. chr1 = bytes[i++];
  101756. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  101757. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  101758. enc1 = chr1 >> 2;
  101759. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  101760. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  101761. enc4 = chr3 & 63;
  101762. if (isNaN(chr2)) {
  101763. enc3 = enc4 = 64;
  101764. }
  101765. else if (isNaN(chr3)) {
  101766. enc4 = 64;
  101767. }
  101768. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  101769. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  101770. }
  101771. return "data:image/png;base64," + output;
  101772. };
  101773. /**
  101774. * Extracts minimum and maximum values from a list of indexed positions
  101775. * @param positions defines the positions to use
  101776. * @param indices defines the indices to the positions
  101777. * @param indexStart defines the start index
  101778. * @param indexCount defines the end index
  101779. * @param bias defines bias value to add to the result
  101780. * @return minimum and maximum values
  101781. */
  101782. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  101783. if (bias === void 0) { bias = null; }
  101784. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  101785. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  101786. for (var index = indexStart; index < indexStart + indexCount; index++) {
  101787. var offset = indices[index] * 3;
  101788. var x = positions[offset];
  101789. var y = positions[offset + 1];
  101790. var z = positions[offset + 2];
  101791. minimum.minimizeInPlaceFromFloats(x, y, z);
  101792. maximum.maximizeInPlaceFromFloats(x, y, z);
  101793. }
  101794. if (bias) {
  101795. minimum.x -= minimum.x * bias.x + bias.y;
  101796. minimum.y -= minimum.y * bias.x + bias.y;
  101797. minimum.z -= minimum.z * bias.x + bias.y;
  101798. maximum.x += maximum.x * bias.x + bias.y;
  101799. maximum.y += maximum.y * bias.x + bias.y;
  101800. maximum.z += maximum.z * bias.x + bias.y;
  101801. }
  101802. return {
  101803. minimum: minimum,
  101804. maximum: maximum
  101805. };
  101806. };
  101807. /**
  101808. * Extracts minimum and maximum values from a list of positions
  101809. * @param positions defines the positions to use
  101810. * @param start defines the start index in the positions array
  101811. * @param count defines the number of positions to handle
  101812. * @param bias defines bias value to add to the result
  101813. * @param stride defines the stride size to use (distance between two positions in the positions array)
  101814. * @return minimum and maximum values
  101815. */
  101816. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  101817. if (bias === void 0) { bias = null; }
  101818. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  101819. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  101820. if (!stride) {
  101821. stride = 3;
  101822. }
  101823. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  101824. var x = positions[offset];
  101825. var y = positions[offset + 1];
  101826. var z = positions[offset + 2];
  101827. minimum.minimizeInPlaceFromFloats(x, y, z);
  101828. maximum.maximizeInPlaceFromFloats(x, y, z);
  101829. }
  101830. if (bias) {
  101831. minimum.x -= minimum.x * bias.x + bias.y;
  101832. minimum.y -= minimum.y * bias.x + bias.y;
  101833. minimum.z -= minimum.z * bias.x + bias.y;
  101834. maximum.x += maximum.x * bias.x + bias.y;
  101835. maximum.y += maximum.y * bias.x + bias.y;
  101836. maximum.z += maximum.z * bias.x + bias.y;
  101837. }
  101838. return {
  101839. minimum: minimum,
  101840. maximum: maximum
  101841. };
  101842. };
  101843. /**
  101844. * Returns an array if obj is not an array
  101845. * @param obj defines the object to evaluate as an array
  101846. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  101847. * @returns either obj directly if obj is an array or a new array containing obj
  101848. */
  101849. Tools.MakeArray = function (obj, allowsNullUndefined) {
  101850. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  101851. return null;
  101852. }
  101853. return Array.isArray(obj) ? obj : [obj];
  101854. };
  101855. /**
  101856. * Gets the pointer prefix to use
  101857. * @returns "pointer" if touch is enabled. Else returns "mouse"
  101858. */
  101859. Tools.GetPointerPrefix = function () {
  101860. var eventPrefix = "pointer";
  101861. // Check if pointer events are supported
  101862. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  101863. eventPrefix = "mouse";
  101864. }
  101865. return eventPrefix;
  101866. };
  101867. /**
  101868. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  101869. * @param func - the function to be called
  101870. * @param requester - the object that will request the next frame. Falls back to window.
  101871. * @returns frame number
  101872. */
  101873. Tools.QueueNewFrame = function (func, requester) {
  101874. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  101875. return setTimeout(func, 16);
  101876. }
  101877. if (!requester) {
  101878. requester = window;
  101879. }
  101880. if (requester.requestAnimationFrame) {
  101881. return requester.requestAnimationFrame(func);
  101882. }
  101883. else if (requester.msRequestAnimationFrame) {
  101884. return requester.msRequestAnimationFrame(func);
  101885. }
  101886. else if (requester.webkitRequestAnimationFrame) {
  101887. return requester.webkitRequestAnimationFrame(func);
  101888. }
  101889. else if (requester.mozRequestAnimationFrame) {
  101890. return requester.mozRequestAnimationFrame(func);
  101891. }
  101892. else if (requester.oRequestAnimationFrame) {
  101893. return requester.oRequestAnimationFrame(func);
  101894. }
  101895. else {
  101896. return window.setTimeout(func, 16);
  101897. }
  101898. };
  101899. /**
  101900. * Ask the browser to promote the current element to fullscreen rendering mode
  101901. * @param element defines the DOM element to promote
  101902. */
  101903. Tools.RequestFullscreen = function (element) {
  101904. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  101905. if (!requestFunction) {
  101906. return;
  101907. }
  101908. requestFunction.call(element);
  101909. };
  101910. /**
  101911. * Asks the browser to exit fullscreen mode
  101912. */
  101913. Tools.ExitFullscreen = function () {
  101914. var anyDoc = document;
  101915. if (document.exitFullscreen) {
  101916. document.exitFullscreen();
  101917. }
  101918. else if (anyDoc.mozCancelFullScreen) {
  101919. anyDoc.mozCancelFullScreen();
  101920. }
  101921. else if (anyDoc.webkitCancelFullScreen) {
  101922. anyDoc.webkitCancelFullScreen();
  101923. }
  101924. else if (anyDoc.msCancelFullScreen) {
  101925. anyDoc.msCancelFullScreen();
  101926. }
  101927. };
  101928. /**
  101929. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  101930. * @param url define the url we are trying
  101931. * @param element define the dom element where to configure the cors policy
  101932. */
  101933. Tools.SetCorsBehavior = function (url, element) {
  101934. if (url && url.indexOf("data:") === 0) {
  101935. return;
  101936. }
  101937. if (Tools.CorsBehavior) {
  101938. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  101939. element.crossOrigin = Tools.CorsBehavior;
  101940. }
  101941. else {
  101942. var result = Tools.CorsBehavior(url);
  101943. if (result) {
  101944. element.crossOrigin = result;
  101945. }
  101946. }
  101947. }
  101948. };
  101949. // External files
  101950. /**
  101951. * Removes unwanted characters from an url
  101952. * @param url defines the url to clean
  101953. * @returns the cleaned url
  101954. */
  101955. Tools.CleanUrl = function (url) {
  101956. url = url.replace(/#/mg, "%23");
  101957. return url;
  101958. };
  101959. /**
  101960. * Loads an image as an HTMLImageElement.
  101961. * @param input url string, ArrayBuffer, or Blob to load
  101962. * @param onLoad callback called when the image successfully loads
  101963. * @param onError callback called when the image fails to load
  101964. * @param offlineProvider offline provider for caching
  101965. * @returns the HTMLImageElement of the loaded image
  101966. */
  101967. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  101968. var url;
  101969. var usingObjectURL = false;
  101970. if (input instanceof ArrayBuffer) {
  101971. url = URL.createObjectURL(new Blob([input]));
  101972. usingObjectURL = true;
  101973. }
  101974. else if (input instanceof Blob) {
  101975. url = URL.createObjectURL(input);
  101976. usingObjectURL = true;
  101977. }
  101978. else {
  101979. url = Tools.CleanUrl(input);
  101980. url = Tools.PreprocessUrl(input);
  101981. }
  101982. var img = new Image();
  101983. Tools.SetCorsBehavior(url, img);
  101984. var loadHandler = function () {
  101985. img.removeEventListener("load", loadHandler);
  101986. img.removeEventListener("error", errorHandler);
  101987. onLoad(img);
  101988. // Must revoke the URL after calling onLoad to avoid security exceptions in
  101989. // certain scenarios (e.g. when hosted in vscode).
  101990. if (usingObjectURL && img.src) {
  101991. URL.revokeObjectURL(img.src);
  101992. }
  101993. };
  101994. var errorHandler = function (err) {
  101995. img.removeEventListener("load", loadHandler);
  101996. img.removeEventListener("error", errorHandler);
  101997. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  101998. if (onError) {
  101999. onError("Error while trying to load image: " + input, err);
  102000. }
  102001. if (usingObjectURL && img.src) {
  102002. URL.revokeObjectURL(img.src);
  102003. }
  102004. };
  102005. img.addEventListener("load", loadHandler);
  102006. img.addEventListener("error", errorHandler);
  102007. var noOfflineSupport = function () {
  102008. img.src = url;
  102009. };
  102010. var loadFromOfflineSupport = function () {
  102011. if (offlineProvider) {
  102012. offlineProvider.loadImage(url, img);
  102013. }
  102014. };
  102015. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  102016. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  102017. }
  102018. else {
  102019. if (url.indexOf("file:") !== -1) {
  102020. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  102021. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  102022. try {
  102023. var blobURL;
  102024. try {
  102025. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  102026. }
  102027. catch (ex) {
  102028. // Chrome doesn't support oneTimeOnly parameter
  102029. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  102030. }
  102031. img.src = blobURL;
  102032. usingObjectURL = true;
  102033. }
  102034. catch (e) {
  102035. img.src = "";
  102036. }
  102037. return img;
  102038. }
  102039. }
  102040. noOfflineSupport();
  102041. }
  102042. return img;
  102043. };
  102044. /**
  102045. * Loads a file
  102046. * @param url url string, ArrayBuffer, or Blob to load
  102047. * @param onSuccess callback called when the file successfully loads
  102048. * @param onProgress callback called while file is loading (if the server supports this mode)
  102049. * @param offlineProvider defines the offline provider for caching
  102050. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102051. * @param onError callback called when the file fails to load
  102052. * @returns a file request object
  102053. */
  102054. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  102055. url = Tools.CleanUrl(url);
  102056. url = Tools.PreprocessUrl(url);
  102057. // If file and file input are set
  102058. if (url.indexOf("file:") !== -1) {
  102059. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  102060. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  102061. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  102062. }
  102063. }
  102064. var loadUrl = Tools.BaseUrl + url;
  102065. var aborted = false;
  102066. var fileRequest = {
  102067. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  102068. abort: function () { return aborted = true; },
  102069. };
  102070. var requestFile = function () {
  102071. var request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  102072. var retryHandle = null;
  102073. fileRequest.abort = function () {
  102074. aborted = true;
  102075. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  102076. request.abort();
  102077. }
  102078. if (retryHandle !== null) {
  102079. clearTimeout(retryHandle);
  102080. retryHandle = null;
  102081. }
  102082. };
  102083. var retryLoop = function (retryIndex) {
  102084. request.open('GET', loadUrl);
  102085. if (useArrayBuffer) {
  102086. request.responseType = "arraybuffer";
  102087. }
  102088. if (onProgress) {
  102089. request.addEventListener("progress", onProgress);
  102090. }
  102091. var onLoadEnd = function () {
  102092. request.removeEventListener("loadend", onLoadEnd);
  102093. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  102094. fileRequest.onCompleteObservable.clear();
  102095. };
  102096. request.addEventListener("loadend", onLoadEnd);
  102097. var onReadyStateChange = function () {
  102098. if (aborted) {
  102099. return;
  102100. }
  102101. // In case of undefined state in some browsers.
  102102. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  102103. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  102104. request.removeEventListener("readystatechange", onReadyStateChange);
  102105. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  102106. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  102107. return;
  102108. }
  102109. var retryStrategy = Tools.DefaultRetryStrategy;
  102110. if (retryStrategy) {
  102111. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  102112. if (waitTime !== -1) {
  102113. // Prevent the request from completing for retry.
  102114. request.removeEventListener("loadend", onLoadEnd);
  102115. request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  102116. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  102117. return;
  102118. }
  102119. }
  102120. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  102121. if (onError) {
  102122. onError(request, e);
  102123. }
  102124. else {
  102125. throw e;
  102126. }
  102127. }
  102128. };
  102129. request.addEventListener("readystatechange", onReadyStateChange);
  102130. request.send();
  102131. };
  102132. retryLoop(0);
  102133. };
  102134. // Caching all files
  102135. if (offlineProvider && offlineProvider.enableSceneOffline) {
  102136. var noOfflineSupport_1 = function (request) {
  102137. if (request && request.status > 400) {
  102138. if (onError) {
  102139. onError(request);
  102140. }
  102141. }
  102142. else {
  102143. if (!aborted) {
  102144. requestFile();
  102145. }
  102146. }
  102147. };
  102148. var loadFromOfflineSupport = function () {
  102149. // TODO: database needs to support aborting and should return a IFileRequest
  102150. if (aborted) {
  102151. return;
  102152. }
  102153. if (offlineProvider) {
  102154. offlineProvider.loadFile(url, function (data) {
  102155. if (!aborted) {
  102156. onSuccess(data);
  102157. }
  102158. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  102159. }, onProgress ? function (event) {
  102160. if (!aborted) {
  102161. onProgress(event);
  102162. }
  102163. } : undefined, noOfflineSupport_1, useArrayBuffer);
  102164. }
  102165. };
  102166. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  102167. }
  102168. else {
  102169. requestFile();
  102170. }
  102171. return fileRequest;
  102172. };
  102173. /**
  102174. * Load a script (identified by an url). When the url returns, the
  102175. * content of this file is added into a new script element, attached to the DOM (body element)
  102176. * @param scriptUrl defines the url of the script to laod
  102177. * @param onSuccess defines the callback called when the script is loaded
  102178. * @param onError defines the callback to call if an error occurs
  102179. */
  102180. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  102181. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  102182. return;
  102183. }
  102184. var head = document.getElementsByTagName('head')[0];
  102185. var script = document.createElement('script');
  102186. script.type = 'text/javascript';
  102187. script.src = scriptUrl;
  102188. script.onload = function () {
  102189. if (onSuccess) {
  102190. onSuccess();
  102191. }
  102192. };
  102193. script.onerror = function (e) {
  102194. if (onError) {
  102195. onError("Unable to load script '" + scriptUrl + "'", e);
  102196. }
  102197. };
  102198. head.appendChild(script);
  102199. };
  102200. /**
  102201. * Loads a file from a blob
  102202. * @param fileToLoad defines the blob to use
  102203. * @param callback defines the callback to call when data is loaded
  102204. * @param progressCallback defines the callback to call during loading process
  102205. * @returns a file request object
  102206. */
  102207. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  102208. var reader = new FileReader();
  102209. var request = {
  102210. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  102211. abort: function () { return reader.abort(); },
  102212. };
  102213. reader.onloadend = function (e) {
  102214. request.onCompleteObservable.notifyObservers(request);
  102215. };
  102216. reader.onload = function (e) {
  102217. //target doesn't have result from ts 1.3
  102218. callback(e.target['result']);
  102219. };
  102220. reader.onprogress = progressCallback;
  102221. reader.readAsDataURL(fileToLoad);
  102222. return request;
  102223. };
  102224. /**
  102225. * Loads a file
  102226. * @param fileToLoad defines the file to load
  102227. * @param callback defines the callback to call when data is loaded
  102228. * @param progressCallBack defines the callback to call during loading process
  102229. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  102230. * @returns a file request object
  102231. */
  102232. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  102233. var reader = new FileReader();
  102234. var request = {
  102235. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  102236. abort: function () { return reader.abort(); },
  102237. };
  102238. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  102239. reader.onerror = function (e) {
  102240. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  102241. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  102242. };
  102243. reader.onload = function (e) {
  102244. //target doesn't have result from ts 1.3
  102245. callback(e.target['result']);
  102246. };
  102247. if (progressCallBack) {
  102248. reader.onprogress = progressCallBack;
  102249. }
  102250. if (!useArrayBuffer) {
  102251. // Asynchronous read
  102252. reader.readAsText(fileToLoad);
  102253. }
  102254. else {
  102255. reader.readAsArrayBuffer(fileToLoad);
  102256. }
  102257. return request;
  102258. };
  102259. /**
  102260. * Creates a data url from a given string content
  102261. * @param content defines the content to convert
  102262. * @returns the new data url link
  102263. */
  102264. Tools.FileAsURL = function (content) {
  102265. var fileBlob = new Blob([content]);
  102266. var url = window.URL || window.webkitURL;
  102267. var link = url.createObjectURL(fileBlob);
  102268. return link;
  102269. };
  102270. /**
  102271. * Format the given number to a specific decimal format
  102272. * @param value defines the number to format
  102273. * @param decimals defines the number of decimals to use
  102274. * @returns the formatted string
  102275. */
  102276. Tools.Format = function (value, decimals) {
  102277. if (decimals === void 0) { decimals = 2; }
  102278. return value.toFixed(decimals);
  102279. };
  102280. /**
  102281. * Checks if a given vector is inside a specific range
  102282. * @param v defines the vector to test
  102283. * @param min defines the minimum range
  102284. * @param max defines the maximum range
  102285. */
  102286. Tools.CheckExtends = function (v, min, max) {
  102287. min.minimizeInPlace(v);
  102288. max.maximizeInPlace(v);
  102289. };
  102290. /**
  102291. * Tries to copy an object by duplicating every property
  102292. * @param source defines the source object
  102293. * @param destination defines the target object
  102294. * @param doNotCopyList defines a list of properties to avoid
  102295. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  102296. */
  102297. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  102298. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  102299. };
  102300. /**
  102301. * Gets a boolean indicating if the given object has no own property
  102302. * @param obj defines the object to test
  102303. * @returns true if object has no own property
  102304. */
  102305. Tools.IsEmpty = function (obj) {
  102306. for (var i in obj) {
  102307. if (obj.hasOwnProperty(i)) {
  102308. return false;
  102309. }
  102310. }
  102311. return true;
  102312. };
  102313. /**
  102314. * Function used to register events at window level
  102315. * @param events defines the events to register
  102316. */
  102317. Tools.RegisterTopRootEvents = function (events) {
  102318. for (var index = 0; index < events.length; index++) {
  102319. var event = events[index];
  102320. window.addEventListener(event.name, event.handler, false);
  102321. try {
  102322. if (window.parent) {
  102323. window.parent.addEventListener(event.name, event.handler, false);
  102324. }
  102325. }
  102326. catch (e) {
  102327. // Silently fails...
  102328. }
  102329. }
  102330. };
  102331. /**
  102332. * Function used to unregister events from window level
  102333. * @param events defines the events to unregister
  102334. */
  102335. Tools.UnregisterTopRootEvents = function (events) {
  102336. for (var index = 0; index < events.length; index++) {
  102337. var event = events[index];
  102338. window.removeEventListener(event.name, event.handler);
  102339. try {
  102340. if (window.parent) {
  102341. window.parent.removeEventListener(event.name, event.handler);
  102342. }
  102343. }
  102344. catch (e) {
  102345. // Silently fails...
  102346. }
  102347. }
  102348. };
  102349. /**
  102350. * Dumps the current bound framebuffer
  102351. * @param width defines the rendering width
  102352. * @param height defines the rendering height
  102353. * @param engine defines the hosting engine
  102354. * @param successCallback defines the callback triggered once the data are available
  102355. * @param mimeType defines the mime type of the result
  102356. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  102357. */
  102358. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  102359. if (mimeType === void 0) { mimeType = "image/png"; }
  102360. // Read the contents of the framebuffer
  102361. var numberOfChannelsByLine = width * 4;
  102362. var halfHeight = height / 2;
  102363. //Reading datas from WebGL
  102364. var data = engine.readPixels(0, 0, width, height);
  102365. //To flip image on Y axis.
  102366. for (var i = 0; i < halfHeight; i++) {
  102367. for (var j = 0; j < numberOfChannelsByLine; j++) {
  102368. var currentCell = j + i * numberOfChannelsByLine;
  102369. var targetLine = height - i - 1;
  102370. var targetCell = j + targetLine * numberOfChannelsByLine;
  102371. var temp = data[currentCell];
  102372. data[currentCell] = data[targetCell];
  102373. data[targetCell] = temp;
  102374. }
  102375. }
  102376. // Create a 2D canvas to store the result
  102377. if (!Tools._ScreenshotCanvas) {
  102378. Tools._ScreenshotCanvas = document.createElement('canvas');
  102379. }
  102380. Tools._ScreenshotCanvas.width = width;
  102381. Tools._ScreenshotCanvas.height = height;
  102382. var context = Tools._ScreenshotCanvas.getContext('2d');
  102383. if (context) {
  102384. // Copy the pixels to a 2D canvas
  102385. var imageData = context.createImageData(width, height);
  102386. var castData = (imageData.data);
  102387. castData.set(data);
  102388. context.putImageData(imageData, 0, 0);
  102389. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  102390. }
  102391. };
  102392. /**
  102393. * Converts the canvas data to blob.
  102394. * This acts as a polyfill for browsers not supporting the to blob function.
  102395. * @param canvas Defines the canvas to extract the data from
  102396. * @param successCallback Defines the callback triggered once the data are available
  102397. * @param mimeType Defines the mime type of the result
  102398. */
  102399. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  102400. if (mimeType === void 0) { mimeType = "image/png"; }
  102401. // We need HTMLCanvasElement.toBlob for HD screenshots
  102402. if (!canvas.toBlob) {
  102403. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  102404. canvas.toBlob = function (callback, type, quality) {
  102405. var _this = this;
  102406. setTimeout(function () {
  102407. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  102408. for (var i = 0; i < len; i++) {
  102409. arr[i] = binStr.charCodeAt(i);
  102410. }
  102411. callback(new Blob([arr]));
  102412. });
  102413. };
  102414. }
  102415. canvas.toBlob(function (blob) {
  102416. successCallback(blob);
  102417. }, mimeType);
  102418. };
  102419. /**
  102420. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  102421. * @param successCallback defines the callback triggered once the data are available
  102422. * @param mimeType defines the mime type of the result
  102423. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  102424. */
  102425. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  102426. if (mimeType === void 0) { mimeType = "image/png"; }
  102427. if (successCallback) {
  102428. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  102429. successCallback(base64Image);
  102430. }
  102431. else {
  102432. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  102433. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  102434. if (("download" in document.createElement("a"))) {
  102435. if (!fileName) {
  102436. var date = new Date();
  102437. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  102438. fileName = "screenshot_" + stringDate + ".png";
  102439. }
  102440. Tools.Download(blob, fileName);
  102441. }
  102442. else {
  102443. var url = URL.createObjectURL(blob);
  102444. var newWindow = window.open("");
  102445. if (!newWindow) {
  102446. return;
  102447. }
  102448. var img = newWindow.document.createElement("img");
  102449. img.onload = function () {
  102450. // no longer need to read the blob so it's revoked
  102451. URL.revokeObjectURL(url);
  102452. };
  102453. img.src = url;
  102454. newWindow.document.body.appendChild(img);
  102455. }
  102456. }, mimeType);
  102457. }
  102458. };
  102459. /**
  102460. * Downloads a blob in the browser
  102461. * @param blob defines the blob to download
  102462. * @param fileName defines the name of the downloaded file
  102463. */
  102464. Tools.Download = function (blob, fileName) {
  102465. if (navigator && navigator.msSaveBlob) {
  102466. navigator.msSaveBlob(blob, fileName);
  102467. return;
  102468. }
  102469. var url = window.URL.createObjectURL(blob);
  102470. var a = document.createElement("a");
  102471. document.body.appendChild(a);
  102472. a.style.display = "none";
  102473. a.href = url;
  102474. a.download = fileName;
  102475. a.addEventListener("click", function () {
  102476. if (a.parentElement) {
  102477. a.parentElement.removeChild(a);
  102478. }
  102479. });
  102480. a.click();
  102481. window.URL.revokeObjectURL(url);
  102482. };
  102483. /**
  102484. * Captures a screenshot of the current rendering
  102485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102486. * @param engine defines the rendering engine
  102487. * @param camera defines the source camera
  102488. * @param size This parameter can be set to a single number or to an object with the
  102489. * following (optional) properties: precision, width, height. If a single number is passed,
  102490. * it will be used for both width and height. If an object is passed, the screenshot size
  102491. * will be derived from the parameters. The precision property is a multiplier allowing
  102492. * rendering at a higher or lower resolution
  102493. * @param successCallback defines the callback receives a single parameter which contains the
  102494. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102495. * src parameter of an <img> to display it
  102496. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102497. * Check your browser for supported MIME types
  102498. */
  102499. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  102500. if (mimeType === void 0) { mimeType = "image/png"; }
  102501. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  102502. };
  102503. /**
  102504. * Generates an image screenshot from the specified camera.
  102505. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102506. * @param engine The engine to use for rendering
  102507. * @param camera The camera to use for rendering
  102508. * @param size This parameter can be set to a single number or to an object with the
  102509. * following (optional) properties: precision, width, height. If a single number is passed,
  102510. * it will be used for both width and height. If an object is passed, the screenshot size
  102511. * will be derived from the parameters. The precision property is a multiplier allowing
  102512. * rendering at a higher or lower resolution
  102513. * @param successCallback The callback receives a single parameter which contains the
  102514. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102515. * src parameter of an <img> to display it
  102516. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102517. * Check your browser for supported MIME types
  102518. * @param samples Texture samples (default: 1)
  102519. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102520. * @param fileName A name for for the downloaded file.
  102521. */
  102522. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  102523. if (mimeType === void 0) { mimeType = "image/png"; }
  102524. if (samples === void 0) { samples = 1; }
  102525. if (antialiasing === void 0) { antialiasing = false; }
  102526. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  102527. };
  102528. /**
  102529. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102530. * Be aware Math.random() could cause collisions, but:
  102531. * "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"
  102532. * @returns a pseudo random id
  102533. */
  102534. Tools.RandomId = function () {
  102535. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  102536. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  102537. return v.toString(16);
  102538. });
  102539. };
  102540. /**
  102541. * Test if the given uri is a base64 string
  102542. * @param uri The uri to test
  102543. * @return True if the uri is a base64 string or false otherwise
  102544. */
  102545. Tools.IsBase64 = function (uri) {
  102546. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  102547. };
  102548. /**
  102549. * Decode the given base64 uri.
  102550. * @param uri The uri to decode
  102551. * @return The decoded base64 data.
  102552. */
  102553. Tools.DecodeBase64 = function (uri) {
  102554. var decodedString = atob(uri.split(",")[1]);
  102555. var bufferLength = decodedString.length;
  102556. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  102557. for (var i = 0; i < bufferLength; i++) {
  102558. bufferView[i] = decodedString.charCodeAt(i);
  102559. }
  102560. return bufferView.buffer;
  102561. };
  102562. Object.defineProperty(Tools, "errorsCount", {
  102563. /**
  102564. * Gets a value indicating the number of loading errors
  102565. * @ignorenaming
  102566. */
  102567. get: function () {
  102568. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  102569. },
  102570. enumerable: true,
  102571. configurable: true
  102572. });
  102573. /**
  102574. * Log a message to the console
  102575. * @param message defines the message to log
  102576. */
  102577. Tools.Log = function (message) {
  102578. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  102579. };
  102580. /**
  102581. * Write a warning message to the console
  102582. * @param message defines the message to log
  102583. */
  102584. Tools.Warn = function (message) {
  102585. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  102586. };
  102587. /**
  102588. * Write an error message to the console
  102589. * @param message defines the message to log
  102590. */
  102591. Tools.Error = function (message) {
  102592. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  102593. };
  102594. Object.defineProperty(Tools, "LogCache", {
  102595. /**
  102596. * Gets current log cache (list of logs)
  102597. */
  102598. get: function () {
  102599. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  102600. },
  102601. enumerable: true,
  102602. configurable: true
  102603. });
  102604. /**
  102605. * Clears the log cache
  102606. */
  102607. Tools.ClearLogCache = function () {
  102608. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  102609. };
  102610. Object.defineProperty(Tools, "LogLevels", {
  102611. /**
  102612. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  102613. */
  102614. set: function (level) {
  102615. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  102616. },
  102617. enumerable: true,
  102618. configurable: true
  102619. });
  102620. /**
  102621. * Checks if the loaded document was accessed via `file:`-Protocol.
  102622. * @returns boolean
  102623. */
  102624. Tools.IsFileURL = function () {
  102625. return location.protocol === "file:";
  102626. };
  102627. Object.defineProperty(Tools, "PerformanceLogLevel", {
  102628. /**
  102629. * Sets the current performance log level
  102630. */
  102631. set: function (level) {
  102632. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  102633. Tools.StartPerformanceCounter = Tools._StartUserMark;
  102634. Tools.EndPerformanceCounter = Tools._EndUserMark;
  102635. return;
  102636. }
  102637. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  102638. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  102639. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  102640. return;
  102641. }
  102642. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  102643. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  102644. },
  102645. enumerable: true,
  102646. configurable: true
  102647. });
  102648. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  102649. };
  102650. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  102651. };
  102652. Tools._StartUserMark = function (counterName, condition) {
  102653. if (condition === void 0) { condition = true; }
  102654. if (!Tools._performance) {
  102655. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  102656. return;
  102657. }
  102658. Tools._performance = window.performance;
  102659. }
  102660. if (!condition || !Tools._performance.mark) {
  102661. return;
  102662. }
  102663. Tools._performance.mark(counterName + "-Begin");
  102664. };
  102665. Tools._EndUserMark = function (counterName, condition) {
  102666. if (condition === void 0) { condition = true; }
  102667. if (!condition || !Tools._performance.mark) {
  102668. return;
  102669. }
  102670. Tools._performance.mark(counterName + "-End");
  102671. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  102672. };
  102673. Tools._StartPerformanceConsole = function (counterName, condition) {
  102674. if (condition === void 0) { condition = true; }
  102675. if (!condition) {
  102676. return;
  102677. }
  102678. Tools._StartUserMark(counterName, condition);
  102679. if (console.time) {
  102680. console.time(counterName);
  102681. }
  102682. };
  102683. Tools._EndPerformanceConsole = function (counterName, condition) {
  102684. if (condition === void 0) { condition = true; }
  102685. if (!condition) {
  102686. return;
  102687. }
  102688. Tools._EndUserMark(counterName, condition);
  102689. if (console.time) {
  102690. console.timeEnd(counterName);
  102691. }
  102692. };
  102693. Object.defineProperty(Tools, "Now", {
  102694. /**
  102695. * Gets either window.performance.now() if supported or Date.now() else
  102696. */
  102697. get: function () {
  102698. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  102699. },
  102700. enumerable: true,
  102701. configurable: true
  102702. });
  102703. /**
  102704. * This method will return the name of the class used to create the instance of the given object.
  102705. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  102706. * @param object the object to get the class name from
  102707. * @param isType defines if the object is actually a type
  102708. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  102709. */
  102710. Tools.GetClassName = function (object, isType) {
  102711. if (isType === void 0) { isType = false; }
  102712. var name = null;
  102713. if (!isType && object.getClassName) {
  102714. name = object.getClassName();
  102715. }
  102716. else {
  102717. if (object instanceof Object) {
  102718. var classObj = isType ? object : Object.getPrototypeOf(object);
  102719. name = classObj.constructor["__bjsclassName__"];
  102720. }
  102721. if (!name) {
  102722. name = typeof object;
  102723. }
  102724. }
  102725. return name;
  102726. };
  102727. /**
  102728. * Gets the first element of an array satisfying a given predicate
  102729. * @param array defines the array to browse
  102730. * @param predicate defines the predicate to use
  102731. * @returns null if not found or the element
  102732. */
  102733. Tools.First = function (array, predicate) {
  102734. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  102735. var el = array_1[_i];
  102736. if (predicate(el)) {
  102737. return el;
  102738. }
  102739. }
  102740. return null;
  102741. };
  102742. /**
  102743. * This method will return the name of the full name of the class, including its owning module (if any).
  102744. * 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).
  102745. * @param object the object to get the class name from
  102746. * @param isType defines if the object is actually a type
  102747. * @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.
  102748. * @ignorenaming
  102749. */
  102750. Tools.getFullClassName = function (object, isType) {
  102751. if (isType === void 0) { isType = false; }
  102752. var className = null;
  102753. var moduleName = null;
  102754. if (!isType && object.getClassName) {
  102755. className = object.getClassName();
  102756. }
  102757. else {
  102758. if (object instanceof Object) {
  102759. var classObj = isType ? object : Object.getPrototypeOf(object);
  102760. className = classObj.constructor["__bjsclassName__"];
  102761. moduleName = classObj.constructor["__bjsmoduleName__"];
  102762. }
  102763. if (!className) {
  102764. className = typeof object;
  102765. }
  102766. }
  102767. if (!className) {
  102768. return null;
  102769. }
  102770. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  102771. };
  102772. /**
  102773. * Returns a promise that resolves after the given amount of time.
  102774. * @param delay Number of milliseconds to delay
  102775. * @returns Promise that resolves after the given amount of time
  102776. */
  102777. Tools.DelayAsync = function (delay) {
  102778. return new Promise(function (resolve) {
  102779. setTimeout(function () {
  102780. resolve();
  102781. }, delay);
  102782. });
  102783. };
  102784. /**
  102785. * Gets the current gradient from an array of IValueGradient
  102786. * @param ratio defines the current ratio to get
  102787. * @param gradients defines the array of IValueGradient
  102788. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  102789. */
  102790. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  102791. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  102792. var currentGradient = gradients[gradientIndex];
  102793. var nextGradient = gradients[gradientIndex + 1];
  102794. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  102795. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  102796. updateFunc(currentGradient, nextGradient, scale);
  102797. return;
  102798. }
  102799. }
  102800. // Use last index if over
  102801. var lastIndex = gradients.length - 1;
  102802. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  102803. };
  102804. /**
  102805. * Gets or sets the base URL to use to load assets
  102806. */
  102807. Tools.BaseUrl = "";
  102808. /**
  102809. * Enable/Disable Custom HTTP Request Headers globally.
  102810. * default = false
  102811. * @see CustomRequestHeaders
  102812. */
  102813. Tools.UseCustomRequestHeaders = false;
  102814. /**
  102815. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102816. * i.e. when loading files, where the server/service expects an Authorization header
  102817. */
  102818. Tools.CustomRequestHeaders = _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"].CustomRequestHeaders;
  102819. /**
  102820. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102821. */
  102822. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  102823. /**
  102824. * Default behaviour for cors in the application.
  102825. * It can be a string if the expected behavior is identical in the entire app.
  102826. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102827. */
  102828. Tools.CorsBehavior = "anonymous";
  102829. /**
  102830. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102831. * @ignorenaming
  102832. */
  102833. Tools.UseFallbackTexture = true;
  102834. /**
  102835. * Use this object to register external classes like custom textures or material
  102836. * to allow the laoders to instantiate them
  102837. */
  102838. Tools.RegisteredExternalClasses = {};
  102839. /**
  102840. * Texture content used if a texture cannot loaded
  102841. * @ignorenaming
  102842. */
  102843. 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";
  102844. Tools._tmpFloatArray = new Float32Array(1);
  102845. /**
  102846. * Extracts text content from a DOM element hierarchy
  102847. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102848. */
  102849. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  102850. /**
  102851. * Gets or sets a function used to pre-process url before using them to load assets
  102852. */
  102853. Tools.PreprocessUrl = function (url) {
  102854. return url;
  102855. };
  102856. // Logs
  102857. /**
  102858. * No log
  102859. */
  102860. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  102861. /**
  102862. * Only message logs
  102863. */
  102864. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  102865. /**
  102866. * Only warning logs
  102867. */
  102868. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  102869. /**
  102870. * Only error logs
  102871. */
  102872. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  102873. /**
  102874. * All logs
  102875. */
  102876. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  102877. /**
  102878. * Checks if the window object exists
  102879. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  102880. */
  102881. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  102882. // Performances
  102883. /**
  102884. * No performance log
  102885. */
  102886. Tools.PerformanceNoneLogLevel = 0;
  102887. /**
  102888. * Use user marks to log performance
  102889. */
  102890. Tools.PerformanceUserMarkLogLevel = 1;
  102891. /**
  102892. * Log performance to the console
  102893. */
  102894. Tools.PerformanceConsoleLogLevel = 2;
  102895. /**
  102896. * Starts a performance counter
  102897. */
  102898. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  102899. /**
  102900. * Ends a specific performance coutner
  102901. */
  102902. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  102903. return Tools;
  102904. }());
  102905. /**
  102906. * This class is used to track a performance counter which is number based.
  102907. * The user has access to many properties which give statistics of different nature.
  102908. *
  102909. * The implementer can track two kinds of Performance Counter: time and count.
  102910. * 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.
  102911. * 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.
  102912. */
  102913. var PerfCounter = /** @class */ (function () {
  102914. /**
  102915. * Creates a new counter
  102916. */
  102917. function PerfCounter() {
  102918. this._startMonitoringTime = 0;
  102919. this._min = 0;
  102920. this._max = 0;
  102921. this._average = 0;
  102922. this._lastSecAverage = 0;
  102923. this._current = 0;
  102924. this._totalValueCount = 0;
  102925. this._totalAccumulated = 0;
  102926. this._lastSecAccumulated = 0;
  102927. this._lastSecTime = 0;
  102928. this._lastSecValueCount = 0;
  102929. }
  102930. Object.defineProperty(PerfCounter.prototype, "min", {
  102931. /**
  102932. * Returns the smallest value ever
  102933. */
  102934. get: function () {
  102935. return this._min;
  102936. },
  102937. enumerable: true,
  102938. configurable: true
  102939. });
  102940. Object.defineProperty(PerfCounter.prototype, "max", {
  102941. /**
  102942. * Returns the biggest value ever
  102943. */
  102944. get: function () {
  102945. return this._max;
  102946. },
  102947. enumerable: true,
  102948. configurable: true
  102949. });
  102950. Object.defineProperty(PerfCounter.prototype, "average", {
  102951. /**
  102952. * Returns the average value since the performance counter is running
  102953. */
  102954. get: function () {
  102955. return this._average;
  102956. },
  102957. enumerable: true,
  102958. configurable: true
  102959. });
  102960. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  102961. /**
  102962. * Returns the average value of the last second the counter was monitored
  102963. */
  102964. get: function () {
  102965. return this._lastSecAverage;
  102966. },
  102967. enumerable: true,
  102968. configurable: true
  102969. });
  102970. Object.defineProperty(PerfCounter.prototype, "current", {
  102971. /**
  102972. * Returns the current value
  102973. */
  102974. get: function () {
  102975. return this._current;
  102976. },
  102977. enumerable: true,
  102978. configurable: true
  102979. });
  102980. Object.defineProperty(PerfCounter.prototype, "total", {
  102981. /**
  102982. * Gets the accumulated total
  102983. */
  102984. get: function () {
  102985. return this._totalAccumulated;
  102986. },
  102987. enumerable: true,
  102988. configurable: true
  102989. });
  102990. Object.defineProperty(PerfCounter.prototype, "count", {
  102991. /**
  102992. * Gets the total value count
  102993. */
  102994. get: function () {
  102995. return this._totalValueCount;
  102996. },
  102997. enumerable: true,
  102998. configurable: true
  102999. });
  103000. /**
  103001. * Call this method to start monitoring a new frame.
  103002. * 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.
  103003. */
  103004. PerfCounter.prototype.fetchNewFrame = function () {
  103005. this._totalValueCount++;
  103006. this._current = 0;
  103007. this._lastSecValueCount++;
  103008. };
  103009. /**
  103010. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103011. * @param newCount the count value to add to the monitored count
  103012. * @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.
  103013. */
  103014. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  103015. if (!PerfCounter.Enabled) {
  103016. return;
  103017. }
  103018. this._current += newCount;
  103019. if (fetchResult) {
  103020. this._fetchResult();
  103021. }
  103022. };
  103023. /**
  103024. * Start monitoring this performance counter
  103025. */
  103026. PerfCounter.prototype.beginMonitoring = function () {
  103027. if (!PerfCounter.Enabled) {
  103028. return;
  103029. }
  103030. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  103031. };
  103032. /**
  103033. * Compute the time lapsed since the previous beginMonitoring() call.
  103034. * @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
  103035. */
  103036. PerfCounter.prototype.endMonitoring = function (newFrame) {
  103037. if (newFrame === void 0) { newFrame = true; }
  103038. if (!PerfCounter.Enabled) {
  103039. return;
  103040. }
  103041. if (newFrame) {
  103042. this.fetchNewFrame();
  103043. }
  103044. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  103045. this._current = currentTime - this._startMonitoringTime;
  103046. if (newFrame) {
  103047. this._fetchResult();
  103048. }
  103049. };
  103050. PerfCounter.prototype._fetchResult = function () {
  103051. this._totalAccumulated += this._current;
  103052. this._lastSecAccumulated += this._current;
  103053. // Min/Max update
  103054. this._min = Math.min(this._min, this._current);
  103055. this._max = Math.max(this._max, this._current);
  103056. this._average = this._totalAccumulated / this._totalValueCount;
  103057. // Reset last sec?
  103058. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  103059. if ((now - this._lastSecTime) > 1000) {
  103060. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  103061. this._lastSecTime = now;
  103062. this._lastSecAccumulated = 0;
  103063. this._lastSecValueCount = 0;
  103064. }
  103065. };
  103066. /**
  103067. * Gets or sets a global boolean to turn on and off all the counters
  103068. */
  103069. PerfCounter.Enabled = true;
  103070. return PerfCounter;
  103071. }());
  103072. /**
  103073. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  103074. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  103075. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  103076. * @param name The name of the class, case should be preserved
  103077. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  103078. */
  103079. function className(name, module) {
  103080. return function (target) {
  103081. target["__bjsclassName__"] = name;
  103082. target["__bjsmoduleName__"] = (module != null) ? module : null;
  103083. };
  103084. }
  103085. /**
  103086. * An implementation of a loop for asynchronous functions.
  103087. */
  103088. var AsyncLoop = /** @class */ (function () {
  103089. /**
  103090. * Constructor.
  103091. * @param iterations the number of iterations.
  103092. * @param func the function to run each iteration
  103093. * @param successCallback the callback that will be called upon succesful execution
  103094. * @param offset starting offset.
  103095. */
  103096. function AsyncLoop(
  103097. /**
  103098. * Defines the number of iterations for the loop
  103099. */
  103100. iterations, func, successCallback, offset) {
  103101. if (offset === void 0) { offset = 0; }
  103102. this.iterations = iterations;
  103103. this.index = offset - 1;
  103104. this._done = false;
  103105. this._fn = func;
  103106. this._successCallback = successCallback;
  103107. }
  103108. /**
  103109. * Execute the next iteration. Must be called after the last iteration was finished.
  103110. */
  103111. AsyncLoop.prototype.executeNext = function () {
  103112. if (!this._done) {
  103113. if (this.index + 1 < this.iterations) {
  103114. ++this.index;
  103115. this._fn(this);
  103116. }
  103117. else {
  103118. this.breakLoop();
  103119. }
  103120. }
  103121. };
  103122. /**
  103123. * Break the loop and run the success callback.
  103124. */
  103125. AsyncLoop.prototype.breakLoop = function () {
  103126. this._done = true;
  103127. this._successCallback();
  103128. };
  103129. /**
  103130. * Create and run an async loop.
  103131. * @param iterations the number of iterations.
  103132. * @param fn the function to run each iteration
  103133. * @param successCallback the callback that will be called upon succesful execution
  103134. * @param offset starting offset.
  103135. * @returns the created async loop object
  103136. */
  103137. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  103138. if (offset === void 0) { offset = 0; }
  103139. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  103140. loop.executeNext();
  103141. return loop;
  103142. };
  103143. /**
  103144. * A for-loop that will run a given number of iterations synchronous and the rest async.
  103145. * @param iterations total number of iterations
  103146. * @param syncedIterations number of synchronous iterations in each async iteration.
  103147. * @param fn the function to call each iteration.
  103148. * @param callback a success call back that will be called when iterating stops.
  103149. * @param breakFunction a break condition (optional)
  103150. * @param timeout timeout settings for the setTimeout function. default - 0.
  103151. * @returns the created async loop object
  103152. */
  103153. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  103154. if (timeout === void 0) { timeout = 0; }
  103155. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  103156. if (breakFunction && breakFunction()) {
  103157. loop.breakLoop();
  103158. }
  103159. else {
  103160. setTimeout(function () {
  103161. for (var i = 0; i < syncedIterations; ++i) {
  103162. var iteration = (loop.index * syncedIterations) + i;
  103163. if (iteration >= iterations) {
  103164. break;
  103165. }
  103166. fn(iteration);
  103167. if (breakFunction && breakFunction()) {
  103168. loop.breakLoop();
  103169. break;
  103170. }
  103171. }
  103172. loop.executeNext();
  103173. }, timeout);
  103174. }
  103175. }, callback);
  103176. };
  103177. return AsyncLoop;
  103178. }());
  103179. /***/ }),
  103180. /***/ "./Misc/typeStore.ts":
  103181. /*!***************************!*\
  103182. !*** ./Misc/typeStore.ts ***!
  103183. \***************************/
  103184. /*! exports provided: _TypeStore */
  103185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103186. "use strict";
  103187. __webpack_require__.r(__webpack_exports__);
  103188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  103189. /** @hidden */
  103190. var _TypeStore = /** @class */ (function () {
  103191. function _TypeStore() {
  103192. }
  103193. /** @hidden */
  103194. _TypeStore.GetClass = function (fqdn) {
  103195. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  103196. return this.RegisteredTypes[fqdn];
  103197. }
  103198. return null;
  103199. };
  103200. /** @hidden */
  103201. _TypeStore.RegisteredTypes = {};
  103202. return _TypeStore;
  103203. }());
  103204. /***/ }),
  103205. /***/ "./Misc/videoRecorder.ts":
  103206. /*!*******************************!*\
  103207. !*** ./Misc/videoRecorder.ts ***!
  103208. \*******************************/
  103209. /*! exports provided: VideoRecorder */
  103210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103211. "use strict";
  103212. __webpack_require__.r(__webpack_exports__);
  103213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  103214. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103215. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  103216. /**
  103217. * This can helps recording videos from BabylonJS.
  103218. * This is based on the available WebRTC functionalities of the browser.
  103219. *
  103220. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  103221. */
  103222. var VideoRecorder = /** @class */ (function () {
  103223. /**
  103224. * Create a new VideoCapture object which can help converting what you see in Babylon to
  103225. * a video file.
  103226. * @param engine Defines the BabylonJS Engine you wish to record
  103227. * @param options Defines options that can be used to customized the capture
  103228. */
  103229. function VideoRecorder(engine, options) {
  103230. if (options === void 0) { options = null; }
  103231. if (!VideoRecorder.IsSupported(engine)) {
  103232. throw "Your browser does not support recording so far.";
  103233. }
  103234. var canvas = engine.getRenderingCanvas();
  103235. if (!canvas) {
  103236. throw "The babylon engine must have a canvas to be recorded";
  103237. }
  103238. this._canvas = canvas;
  103239. this._canvas.isRecording = false;
  103240. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  103241. var stream = this._canvas.captureStream(this._options.fps);
  103242. if (this._options.audioTracks) {
  103243. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  103244. var track = _a[_i];
  103245. stream.addTrack(track);
  103246. }
  103247. }
  103248. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  103249. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  103250. this._mediaRecorder.onerror = this._handleError.bind(this);
  103251. this._mediaRecorder.onstop = this._handleStop.bind(this);
  103252. }
  103253. /**
  103254. * Returns wehther or not the VideoRecorder is available in your browser.
  103255. * @param engine Defines the Babylon Engine to check the support for
  103256. * @returns true if supported otherwise false
  103257. */
  103258. VideoRecorder.IsSupported = function (engine) {
  103259. var canvas = engine.getRenderingCanvas();
  103260. return (!!canvas && typeof canvas.captureStream === "function");
  103261. };
  103262. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  103263. /**
  103264. * True wether a recording is already in progress.
  103265. */
  103266. get: function () {
  103267. return !!this._canvas && this._canvas.isRecording;
  103268. },
  103269. enumerable: true,
  103270. configurable: true
  103271. });
  103272. /**
  103273. * Stops the current recording before the default capture timeout passed in the startRecording
  103274. * functions.
  103275. */
  103276. VideoRecorder.prototype.stopRecording = function () {
  103277. if (!this._canvas || !this._mediaRecorder) {
  103278. return;
  103279. }
  103280. if (!this.isRecording) {
  103281. return;
  103282. }
  103283. this._canvas.isRecording = false;
  103284. this._mediaRecorder.stop();
  103285. };
  103286. /**
  103287. * Starts recording the canvas for a max duration specified in parameters.
  103288. * @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.
  103289. * @param maxDuration Defines the maximum recording time in seconds.
  103290. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  103291. * @return a promise callback at the end of the recording with the video data in Blob.
  103292. */
  103293. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  103294. var _this = this;
  103295. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  103296. if (maxDuration === void 0) { maxDuration = 7; }
  103297. if (!this._canvas || !this._mediaRecorder) {
  103298. throw "Recorder has already been disposed";
  103299. }
  103300. if (this.isRecording) {
  103301. throw "Recording already in progress";
  103302. }
  103303. if (maxDuration > 0) {
  103304. setTimeout(function () {
  103305. _this.stopRecording();
  103306. }, maxDuration * 1000);
  103307. }
  103308. this._fileName = fileName;
  103309. this._recordedChunks = [];
  103310. this._resolve = null;
  103311. this._reject = null;
  103312. this._canvas.isRecording = true;
  103313. this._mediaRecorder.start(this._options.recordChunckSize);
  103314. return new Promise(function (resolve, reject) {
  103315. _this._resolve = resolve;
  103316. _this._reject = reject;
  103317. });
  103318. };
  103319. /**
  103320. * Releases internal resources used during the recording.
  103321. */
  103322. VideoRecorder.prototype.dispose = function () {
  103323. this._canvas = null;
  103324. this._mediaRecorder = null;
  103325. this._recordedChunks = [];
  103326. this._fileName = null;
  103327. this._resolve = null;
  103328. this._reject = null;
  103329. };
  103330. VideoRecorder.prototype._handleDataAvailable = function (event) {
  103331. if (event.data.size > 0) {
  103332. this._recordedChunks.push(event.data);
  103333. }
  103334. };
  103335. VideoRecorder.prototype._handleError = function (event) {
  103336. this.stopRecording();
  103337. if (this._reject) {
  103338. this._reject(event.error);
  103339. }
  103340. else {
  103341. throw new event.error();
  103342. }
  103343. };
  103344. VideoRecorder.prototype._handleStop = function () {
  103345. this.stopRecording();
  103346. var superBuffer = new Blob(this._recordedChunks);
  103347. if (this._resolve) {
  103348. this._resolve(superBuffer);
  103349. }
  103350. window.URL.createObjectURL(superBuffer);
  103351. if (this._fileName) {
  103352. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  103353. }
  103354. };
  103355. VideoRecorder._defaultOptions = {
  103356. mimeType: "video/webm",
  103357. fps: 25,
  103358. recordChunckSize: 3000
  103359. };
  103360. return VideoRecorder;
  103361. }());
  103362. /***/ }),
  103363. /***/ "./Misc/virtualJoystick.ts":
  103364. /*!*********************************!*\
  103365. !*** ./Misc/virtualJoystick.ts ***!
  103366. \*********************************/
  103367. /*! exports provided: JoystickAxis, VirtualJoystick */
  103368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103369. "use strict";
  103370. __webpack_require__.r(__webpack_exports__);
  103371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  103372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  103373. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103374. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  103375. // Mainly based on these 2 articles :
  103376. // 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
  103377. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  103378. /**
  103379. * Defines the potential axis of a Joystick
  103380. */
  103381. var JoystickAxis;
  103382. (function (JoystickAxis) {
  103383. /** X axis */
  103384. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  103385. /** Y axis */
  103386. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  103387. /** Z axis */
  103388. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  103389. })(JoystickAxis || (JoystickAxis = {}));
  103390. /**
  103391. * Class used to define virtual joystick (used in touch mode)
  103392. */
  103393. var VirtualJoystick = /** @class */ (function () {
  103394. /**
  103395. * Creates a new virtual joystick
  103396. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103397. */
  103398. function VirtualJoystick(leftJoystick) {
  103399. var _this = this;
  103400. if (leftJoystick) {
  103401. this._leftJoystick = true;
  103402. }
  103403. else {
  103404. this._leftJoystick = false;
  103405. }
  103406. VirtualJoystick._globalJoystickIndex++;
  103407. // By default left & right arrow keys are moving the X
  103408. // and up & down keys are moving the Y
  103409. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  103410. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  103411. this.reverseLeftRight = false;
  103412. this.reverseUpDown = false;
  103413. // collections of pointers
  103414. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  103415. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103416. this._joystickSensibility = 25;
  103417. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  103418. this._onResize = function (evt) {
  103419. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  103420. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  103421. if (VirtualJoystick.Canvas) {
  103422. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  103423. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  103424. }
  103425. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  103426. };
  103427. // injecting a canvas element on top of the canvas 3D game
  103428. if (!VirtualJoystick.Canvas) {
  103429. window.addEventListener("resize", this._onResize, false);
  103430. VirtualJoystick.Canvas = document.createElement("canvas");
  103431. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  103432. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  103433. VirtualJoystick.Canvas.width = window.innerWidth;
  103434. VirtualJoystick.Canvas.height = window.innerHeight;
  103435. VirtualJoystick.Canvas.style.width = "100%";
  103436. VirtualJoystick.Canvas.style.height = "100%";
  103437. VirtualJoystick.Canvas.style.position = "absolute";
  103438. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  103439. VirtualJoystick.Canvas.style.top = "0px";
  103440. VirtualJoystick.Canvas.style.left = "0px";
  103441. VirtualJoystick.Canvas.style.zIndex = "5";
  103442. VirtualJoystick.Canvas.style.msTouchAction = "none";
  103443. // Support for jQuery PEP polyfill
  103444. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  103445. var context = VirtualJoystick.Canvas.getContext('2d');
  103446. if (!context) {
  103447. throw new Error("Unable to create canvas for virtual joystick");
  103448. }
  103449. VirtualJoystick.vjCanvasContext = context;
  103450. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  103451. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  103452. document.body.appendChild(VirtualJoystick.Canvas);
  103453. }
  103454. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  103455. this.pressed = false;
  103456. // default joystick color
  103457. this._joystickColor = "cyan";
  103458. this._joystickPointerID = -1;
  103459. // current joystick position
  103460. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103461. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103462. // origin joystick position
  103463. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103464. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103465. this._onPointerDownHandlerRef = function (evt) {
  103466. _this._onPointerDown(evt);
  103467. };
  103468. this._onPointerMoveHandlerRef = function (evt) {
  103469. _this._onPointerMove(evt);
  103470. };
  103471. this._onPointerUpHandlerRef = function (evt) {
  103472. _this._onPointerUp(evt);
  103473. };
  103474. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  103475. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  103476. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  103477. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  103478. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  103479. evt.preventDefault(); // Disables system menu
  103480. }, false);
  103481. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  103482. }
  103483. /**
  103484. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  103485. * @param newJoystickSensibility defines the new sensibility
  103486. */
  103487. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  103488. this._joystickSensibility = newJoystickSensibility;
  103489. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  103490. };
  103491. VirtualJoystick.prototype._onPointerDown = function (e) {
  103492. var positionOnScreenCondition;
  103493. e.preventDefault();
  103494. if (this._leftJoystick === true) {
  103495. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  103496. }
  103497. else {
  103498. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  103499. }
  103500. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  103501. // First contact will be dedicated to the virtual joystick
  103502. this._joystickPointerID = e.pointerId;
  103503. this._joystickPointerStartPos.x = e.clientX;
  103504. this._joystickPointerStartPos.y = e.clientY;
  103505. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  103506. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  103507. this._deltaJoystickVector.x = 0;
  103508. this._deltaJoystickVector.y = 0;
  103509. this.pressed = true;
  103510. this._touches.add(e.pointerId.toString(), e);
  103511. }
  103512. else {
  103513. // You can only trigger the action buttons with a joystick declared
  103514. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  103515. this._action();
  103516. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  103517. }
  103518. }
  103519. };
  103520. VirtualJoystick.prototype._onPointerMove = function (e) {
  103521. // If the current pointer is the one associated to the joystick (first touch contact)
  103522. if (this._joystickPointerID == e.pointerId) {
  103523. this._joystickPointerPos.x = e.clientX;
  103524. this._joystickPointerPos.y = e.clientY;
  103525. this._deltaJoystickVector = this._joystickPointerPos.clone();
  103526. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  103527. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  103528. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  103529. switch (this._axisTargetedByLeftAndRight) {
  103530. case JoystickAxis.X:
  103531. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  103532. break;
  103533. case JoystickAxis.Y:
  103534. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  103535. break;
  103536. case JoystickAxis.Z:
  103537. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  103538. break;
  103539. }
  103540. var directionUpDown = this.reverseUpDown ? 1 : -1;
  103541. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  103542. switch (this._axisTargetedByUpAndDown) {
  103543. case JoystickAxis.X:
  103544. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  103545. break;
  103546. case JoystickAxis.Y:
  103547. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  103548. break;
  103549. case JoystickAxis.Z:
  103550. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  103551. break;
  103552. }
  103553. }
  103554. else {
  103555. var data = this._touches.get(e.pointerId.toString());
  103556. if (data) {
  103557. data.x = e.clientX;
  103558. data.y = e.clientY;
  103559. }
  103560. }
  103561. };
  103562. VirtualJoystick.prototype._onPointerUp = function (e) {
  103563. if (this._joystickPointerID == e.pointerId) {
  103564. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  103565. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  103566. this._joystickPointerID = -1;
  103567. this.pressed = false;
  103568. }
  103569. else {
  103570. var touch = this._touches.get(e.pointerId.toString());
  103571. if (touch) {
  103572. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  103573. }
  103574. }
  103575. this._deltaJoystickVector.x = 0;
  103576. this._deltaJoystickVector.y = 0;
  103577. this._touches.remove(e.pointerId.toString());
  103578. };
  103579. /**
  103580. * Change the color of the virtual joystick
  103581. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  103582. */
  103583. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  103584. this._joystickColor = newColor;
  103585. };
  103586. /**
  103587. * Defines a callback to call when the joystick is touched
  103588. * @param action defines the callback
  103589. */
  103590. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  103591. this._action = action;
  103592. };
  103593. /**
  103594. * Defines which axis you'd like to control for left & right
  103595. * @param axis defines the axis to use
  103596. */
  103597. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  103598. switch (axis) {
  103599. case JoystickAxis.X:
  103600. case JoystickAxis.Y:
  103601. case JoystickAxis.Z:
  103602. this._axisTargetedByLeftAndRight = axis;
  103603. break;
  103604. default:
  103605. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  103606. break;
  103607. }
  103608. };
  103609. /**
  103610. * Defines which axis you'd like to control for up & down
  103611. * @param axis defines the axis to use
  103612. */
  103613. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  103614. switch (axis) {
  103615. case JoystickAxis.X:
  103616. case JoystickAxis.Y:
  103617. case JoystickAxis.Z:
  103618. this._axisTargetedByUpAndDown = axis;
  103619. break;
  103620. default:
  103621. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  103622. break;
  103623. }
  103624. };
  103625. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  103626. var _this = this;
  103627. if (this.pressed) {
  103628. this._touches.forEach(function (key, touch) {
  103629. if (touch.pointerId === _this._joystickPointerID) {
  103630. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  103631. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  103632. VirtualJoystick.vjCanvasContext.beginPath();
  103633. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  103634. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  103635. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  103636. VirtualJoystick.vjCanvasContext.stroke();
  103637. VirtualJoystick.vjCanvasContext.closePath();
  103638. VirtualJoystick.vjCanvasContext.beginPath();
  103639. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  103640. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  103641. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  103642. VirtualJoystick.vjCanvasContext.stroke();
  103643. VirtualJoystick.vjCanvasContext.closePath();
  103644. VirtualJoystick.vjCanvasContext.beginPath();
  103645. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  103646. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  103647. VirtualJoystick.vjCanvasContext.stroke();
  103648. VirtualJoystick.vjCanvasContext.closePath();
  103649. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  103650. }
  103651. else {
  103652. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  103653. VirtualJoystick.vjCanvasContext.beginPath();
  103654. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  103655. VirtualJoystick.vjCanvasContext.beginPath();
  103656. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  103657. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  103658. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  103659. VirtualJoystick.vjCanvasContext.stroke();
  103660. VirtualJoystick.vjCanvasContext.closePath();
  103661. touch.prevX = touch.x;
  103662. touch.prevY = touch.y;
  103663. }
  103664. });
  103665. }
  103666. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  103667. };
  103668. /**
  103669. * Release internal HTML canvas
  103670. */
  103671. VirtualJoystick.prototype.releaseCanvas = function () {
  103672. if (VirtualJoystick.Canvas) {
  103673. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  103674. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  103675. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  103676. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  103677. window.removeEventListener("resize", this._onResize);
  103678. document.body.removeChild(VirtualJoystick.Canvas);
  103679. VirtualJoystick.Canvas = null;
  103680. }
  103681. };
  103682. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  103683. VirtualJoystick._globalJoystickIndex = 0;
  103684. return VirtualJoystick;
  103685. }());
  103686. /***/ }),
  103687. /***/ "./Misc/webRequest.ts":
  103688. /*!****************************!*\
  103689. !*** ./Misc/webRequest.ts ***!
  103690. \****************************/
  103691. /*! exports provided: WebRequest */
  103692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103693. "use strict";
  103694. __webpack_require__.r(__webpack_exports__);
  103695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return WebRequest; });
  103696. /**
  103697. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  103698. */
  103699. var WebRequest = /** @class */ (function () {
  103700. function WebRequest() {
  103701. this._xhr = new XMLHttpRequest();
  103702. }
  103703. WebRequest.prototype._injectCustomRequestHeaders = function () {
  103704. for (var key in WebRequest.CustomRequestHeaders) {
  103705. var val = WebRequest.CustomRequestHeaders[key];
  103706. if (val) {
  103707. this._xhr.setRequestHeader(key, val);
  103708. }
  103709. }
  103710. };
  103711. Object.defineProperty(WebRequest.prototype, "onprogress", {
  103712. /**
  103713. * Gets or sets a function to be called when loading progress changes
  103714. */
  103715. get: function () {
  103716. return this._xhr.onprogress;
  103717. },
  103718. set: function (value) {
  103719. this._xhr.onprogress = value;
  103720. },
  103721. enumerable: true,
  103722. configurable: true
  103723. });
  103724. Object.defineProperty(WebRequest.prototype, "readyState", {
  103725. /**
  103726. * Returns client's state
  103727. */
  103728. get: function () {
  103729. return this._xhr.readyState;
  103730. },
  103731. enumerable: true,
  103732. configurable: true
  103733. });
  103734. Object.defineProperty(WebRequest.prototype, "status", {
  103735. /**
  103736. * Returns client's status
  103737. */
  103738. get: function () {
  103739. return this._xhr.status;
  103740. },
  103741. enumerable: true,
  103742. configurable: true
  103743. });
  103744. Object.defineProperty(WebRequest.prototype, "statusText", {
  103745. /**
  103746. * Returns client's status as a text
  103747. */
  103748. get: function () {
  103749. return this._xhr.statusText;
  103750. },
  103751. enumerable: true,
  103752. configurable: true
  103753. });
  103754. Object.defineProperty(WebRequest.prototype, "response", {
  103755. /**
  103756. * Returns client's response
  103757. */
  103758. get: function () {
  103759. return this._xhr.response;
  103760. },
  103761. enumerable: true,
  103762. configurable: true
  103763. });
  103764. Object.defineProperty(WebRequest.prototype, "responseURL", {
  103765. /**
  103766. * Returns client's response url
  103767. */
  103768. get: function () {
  103769. return this._xhr.responseURL;
  103770. },
  103771. enumerable: true,
  103772. configurable: true
  103773. });
  103774. Object.defineProperty(WebRequest.prototype, "responseText", {
  103775. /**
  103776. * Returns client's response as text
  103777. */
  103778. get: function () {
  103779. return this._xhr.responseText;
  103780. },
  103781. enumerable: true,
  103782. configurable: true
  103783. });
  103784. Object.defineProperty(WebRequest.prototype, "responseType", {
  103785. /**
  103786. * Gets or sets the expected response type
  103787. */
  103788. get: function () {
  103789. return this._xhr.responseType;
  103790. },
  103791. set: function (value) {
  103792. this._xhr.responseType = value;
  103793. },
  103794. enumerable: true,
  103795. configurable: true
  103796. });
  103797. WebRequest.prototype.addEventListener = function (type, listener, options) {
  103798. this._xhr.addEventListener(type, listener, options);
  103799. };
  103800. WebRequest.prototype.removeEventListener = function (type, listener, options) {
  103801. this._xhr.removeEventListener(type, listener, options);
  103802. };
  103803. /**
  103804. * Cancels any network activity
  103805. */
  103806. WebRequest.prototype.abort = function () {
  103807. this._xhr.abort();
  103808. };
  103809. /**
  103810. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  103811. * @param body defines an optional request body
  103812. */
  103813. WebRequest.prototype.send = function (body) {
  103814. this._xhr.send(body);
  103815. };
  103816. /**
  103817. * Sets the request method, request URL
  103818. * @param method defines the method to use (GET, POST, etc..)
  103819. * @param url defines the url to connect with
  103820. */
  103821. WebRequest.prototype.open = function (method, url) {
  103822. if (WebRequest.CustomRequestHeaders) {
  103823. this._injectCustomRequestHeaders();
  103824. }
  103825. for (var _i = 0, _a = WebRequest.CustomRequestModifiers; _i < _a.length; _i++) {
  103826. var update = _a[_i];
  103827. update(this._xhr);
  103828. }
  103829. return this._xhr.open(method, url, true);
  103830. };
  103831. /**
  103832. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  103833. * i.e. when loading files, where the server/service expects an Authorization header
  103834. */
  103835. WebRequest.CustomRequestHeaders = {};
  103836. /**
  103837. * Add callback functions in this array to update all the requests before they get sent to the network
  103838. */
  103839. WebRequest.CustomRequestModifiers = new Array();
  103840. return WebRequest;
  103841. }());
  103842. /***/ }),
  103843. /***/ "./Misc/workerPool.ts":
  103844. /*!****************************!*\
  103845. !*** ./Misc/workerPool.ts ***!
  103846. \****************************/
  103847. /*! exports provided: WorkerPool */
  103848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103849. "use strict";
  103850. __webpack_require__.r(__webpack_exports__);
  103851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  103852. /**
  103853. * Helper class to push actions to a pool of workers.
  103854. */
  103855. var WorkerPool = /** @class */ (function () {
  103856. /**
  103857. * Constructor
  103858. * @param workers Array of workers to use for actions
  103859. */
  103860. function WorkerPool(workers) {
  103861. this._pendingActions = new Array();
  103862. this._workerInfos = workers.map(function (worker) { return ({
  103863. worker: worker,
  103864. active: false
  103865. }); });
  103866. }
  103867. /**
  103868. * Terminates all workers and clears any pending actions.
  103869. */
  103870. WorkerPool.prototype.dispose = function () {
  103871. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  103872. var workerInfo = _a[_i];
  103873. workerInfo.worker.terminate();
  103874. }
  103875. delete this._workerInfos;
  103876. delete this._pendingActions;
  103877. };
  103878. /**
  103879. * Pushes an action to the worker pool. If all the workers are active, the action will be
  103880. * pended until a worker has completed its action.
  103881. * @param action The action to perform. Call onComplete when the action is complete.
  103882. */
  103883. WorkerPool.prototype.push = function (action) {
  103884. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  103885. var workerInfo = _a[_i];
  103886. if (!workerInfo.active) {
  103887. this._execute(workerInfo, action);
  103888. return;
  103889. }
  103890. }
  103891. this._pendingActions.push(action);
  103892. };
  103893. WorkerPool.prototype._execute = function (workerInfo, action) {
  103894. var _this = this;
  103895. workerInfo.active = true;
  103896. action(workerInfo.worker, function () {
  103897. workerInfo.active = false;
  103898. var nextAction = _this._pendingActions.shift();
  103899. if (nextAction) {
  103900. _this._execute(workerInfo, nextAction);
  103901. }
  103902. });
  103903. };
  103904. return WorkerPool;
  103905. }());
  103906. /***/ }),
  103907. /***/ "./Morph/index.ts":
  103908. /*!************************!*\
  103909. !*** ./Morph/index.ts ***!
  103910. \************************/
  103911. /*! exports provided: MorphTarget, MorphTargetManager */
  103912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103913. "use strict";
  103914. __webpack_require__.r(__webpack_exports__);
  103915. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  103916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  103917. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  103918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  103919. /***/ }),
  103920. /***/ "./Morph/morphTarget.ts":
  103921. /*!******************************!*\
  103922. !*** ./Morph/morphTarget.ts ***!
  103923. \******************************/
  103924. /*! exports provided: MorphTarget */
  103925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103926. "use strict";
  103927. __webpack_require__.r(__webpack_exports__);
  103928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  103929. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103930. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  103931. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103932. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  103933. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  103934. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  103935. /**
  103936. * Defines a target to use with MorphTargetManager
  103937. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103938. */
  103939. var MorphTarget = /** @class */ (function () {
  103940. /**
  103941. * Creates a new MorphTarget
  103942. * @param name defines the name of the target
  103943. * @param influence defines the influence to use
  103944. * @param scene defines the scene the morphtarget belongs to
  103945. */
  103946. function MorphTarget(
  103947. /** defines the name of the target */
  103948. name, influence, scene) {
  103949. if (influence === void 0) { influence = 0; }
  103950. if (scene === void 0) { scene = null; }
  103951. this.name = name;
  103952. /**
  103953. * Gets or sets the list of animations
  103954. */
  103955. this.animations = new Array();
  103956. this._positions = null;
  103957. this._normals = null;
  103958. this._tangents = null;
  103959. /**
  103960. * Observable raised when the influence changes
  103961. */
  103962. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  103963. /** @hidden */
  103964. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  103965. this._animationPropertiesOverride = null;
  103966. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  103967. this.influence = influence;
  103968. }
  103969. Object.defineProperty(MorphTarget.prototype, "influence", {
  103970. /**
  103971. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103972. */
  103973. get: function () {
  103974. return this._influence;
  103975. },
  103976. set: function (influence) {
  103977. if (this._influence === influence) {
  103978. return;
  103979. }
  103980. var previous = this._influence;
  103981. this._influence = influence;
  103982. if (this.onInfluenceChanged.hasObservers) {
  103983. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  103984. }
  103985. },
  103986. enumerable: true,
  103987. configurable: true
  103988. });
  103989. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  103990. /**
  103991. * Gets or sets the animation properties override
  103992. */
  103993. get: function () {
  103994. if (!this._animationPropertiesOverride && this._scene) {
  103995. return this._scene.animationPropertiesOverride;
  103996. }
  103997. return this._animationPropertiesOverride;
  103998. },
  103999. set: function (value) {
  104000. this._animationPropertiesOverride = value;
  104001. },
  104002. enumerable: true,
  104003. configurable: true
  104004. });
  104005. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  104006. /**
  104007. * Gets a boolean defining if the target contains position data
  104008. */
  104009. get: function () {
  104010. return !!this._positions;
  104011. },
  104012. enumerable: true,
  104013. configurable: true
  104014. });
  104015. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  104016. /**
  104017. * Gets a boolean defining if the target contains normal data
  104018. */
  104019. get: function () {
  104020. return !!this._normals;
  104021. },
  104022. enumerable: true,
  104023. configurable: true
  104024. });
  104025. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  104026. /**
  104027. * Gets a boolean defining if the target contains tangent data
  104028. */
  104029. get: function () {
  104030. return !!this._tangents;
  104031. },
  104032. enumerable: true,
  104033. configurable: true
  104034. });
  104035. /**
  104036. * Affects position data to this target
  104037. * @param data defines the position data to use
  104038. */
  104039. MorphTarget.prototype.setPositions = function (data) {
  104040. var hadPositions = this.hasPositions;
  104041. this._positions = data;
  104042. if (hadPositions !== this.hasPositions) {
  104043. this._onDataLayoutChanged.notifyObservers(undefined);
  104044. }
  104045. };
  104046. /**
  104047. * Gets the position data stored in this target
  104048. * @returns a FloatArray containing the position data (or null if not present)
  104049. */
  104050. MorphTarget.prototype.getPositions = function () {
  104051. return this._positions;
  104052. };
  104053. /**
  104054. * Affects normal data to this target
  104055. * @param data defines the normal data to use
  104056. */
  104057. MorphTarget.prototype.setNormals = function (data) {
  104058. var hadNormals = this.hasNormals;
  104059. this._normals = data;
  104060. if (hadNormals !== this.hasNormals) {
  104061. this._onDataLayoutChanged.notifyObservers(undefined);
  104062. }
  104063. };
  104064. /**
  104065. * Gets the normal data stored in this target
  104066. * @returns a FloatArray containing the normal data (or null if not present)
  104067. */
  104068. MorphTarget.prototype.getNormals = function () {
  104069. return this._normals;
  104070. };
  104071. /**
  104072. * Affects tangent data to this target
  104073. * @param data defines the tangent data to use
  104074. */
  104075. MorphTarget.prototype.setTangents = function (data) {
  104076. var hadTangents = this.hasTangents;
  104077. this._tangents = data;
  104078. if (hadTangents !== this.hasTangents) {
  104079. this._onDataLayoutChanged.notifyObservers(undefined);
  104080. }
  104081. };
  104082. /**
  104083. * Gets the tangent data stored in this target
  104084. * @returns a FloatArray containing the tangent data (or null if not present)
  104085. */
  104086. MorphTarget.prototype.getTangents = function () {
  104087. return this._tangents;
  104088. };
  104089. /**
  104090. * Serializes the current target into a Serialization object
  104091. * @returns the serialized object
  104092. */
  104093. MorphTarget.prototype.serialize = function () {
  104094. var serializationObject = {};
  104095. serializationObject.name = this.name;
  104096. serializationObject.influence = this.influence;
  104097. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  104098. if (this.id != null) {
  104099. serializationObject.id = this.id;
  104100. }
  104101. if (this.hasNormals) {
  104102. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  104103. }
  104104. if (this.hasTangents) {
  104105. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  104106. }
  104107. // Animations
  104108. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  104109. return serializationObject;
  104110. };
  104111. /**
  104112. * Returns the string "MorphTarget"
  104113. * @returns "MorphTarget"
  104114. */
  104115. MorphTarget.prototype.getClassName = function () {
  104116. return "MorphTarget";
  104117. };
  104118. // Statics
  104119. /**
  104120. * Creates a new target from serialized data
  104121. * @param serializationObject defines the serialized data to use
  104122. * @returns a new MorphTarget
  104123. */
  104124. MorphTarget.Parse = function (serializationObject) {
  104125. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  104126. result.setPositions(serializationObject.positions);
  104127. if (serializationObject.id != null) {
  104128. result.id = serializationObject.id;
  104129. }
  104130. if (serializationObject.normals) {
  104131. result.setNormals(serializationObject.normals);
  104132. }
  104133. if (serializationObject.tangents) {
  104134. result.setTangents(serializationObject.tangents);
  104135. }
  104136. // Animations
  104137. if (serializationObject.animations) {
  104138. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  104139. var parsedAnimation = serializationObject.animations[animationIndex];
  104140. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  104141. if (internalClass) {
  104142. result.animations.push(internalClass.Parse(parsedAnimation));
  104143. }
  104144. }
  104145. }
  104146. return result;
  104147. };
  104148. /**
  104149. * Creates a MorphTarget from mesh data
  104150. * @param mesh defines the source mesh
  104151. * @param name defines the name to use for the new target
  104152. * @param influence defines the influence to attach to the target
  104153. * @returns a new MorphTarget
  104154. */
  104155. MorphTarget.FromMesh = function (mesh, name, influence) {
  104156. if (!name) {
  104157. name = mesh.name;
  104158. }
  104159. var result = new MorphTarget(name, influence, mesh.getScene());
  104160. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  104161. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  104162. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  104163. }
  104164. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  104165. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  104166. }
  104167. return result;
  104168. };
  104169. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  104170. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  104171. ], MorphTarget.prototype, "id", void 0);
  104172. return MorphTarget;
  104173. }());
  104174. /***/ }),
  104175. /***/ "./Morph/morphTargetManager.ts":
  104176. /*!*************************************!*\
  104177. !*** ./Morph/morphTargetManager.ts ***!
  104178. \*************************************/
  104179. /*! exports provided: MorphTargetManager */
  104180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104181. "use strict";
  104182. __webpack_require__.r(__webpack_exports__);
  104183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  104184. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  104185. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  104186. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104187. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  104188. /**
  104189. * This class is used to deform meshes using morphing between different targets
  104190. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104191. */
  104192. var MorphTargetManager = /** @class */ (function () {
  104193. /**
  104194. * Creates a new MorphTargetManager
  104195. * @param scene defines the current scene
  104196. */
  104197. function MorphTargetManager(scene) {
  104198. if (scene === void 0) { scene = null; }
  104199. this._targets = new Array();
  104200. this._targetInfluenceChangedObservers = new Array();
  104201. this._targetDataLayoutChangedObservers = new Array();
  104202. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  104203. this._supportsNormals = false;
  104204. this._supportsTangents = false;
  104205. this._vertexCount = 0;
  104206. this._uniqueId = 0;
  104207. this._tempInfluences = new Array();
  104208. if (!scene) {
  104209. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  104210. }
  104211. this._scene = scene;
  104212. if (this._scene) {
  104213. this._scene.morphTargetManagers.push(this);
  104214. this._uniqueId = this._scene.getUniqueId();
  104215. }
  104216. }
  104217. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  104218. /**
  104219. * Gets the unique ID of this manager
  104220. */
  104221. get: function () {
  104222. return this._uniqueId;
  104223. },
  104224. enumerable: true,
  104225. configurable: true
  104226. });
  104227. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  104228. /**
  104229. * Gets the number of vertices handled by this manager
  104230. */
  104231. get: function () {
  104232. return this._vertexCount;
  104233. },
  104234. enumerable: true,
  104235. configurable: true
  104236. });
  104237. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  104238. /**
  104239. * Gets a boolean indicating if this manager supports morphing of normals
  104240. */
  104241. get: function () {
  104242. return this._supportsNormals;
  104243. },
  104244. enumerable: true,
  104245. configurable: true
  104246. });
  104247. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  104248. /**
  104249. * Gets a boolean indicating if this manager supports morphing of tangents
  104250. */
  104251. get: function () {
  104252. return this._supportsTangents;
  104253. },
  104254. enumerable: true,
  104255. configurable: true
  104256. });
  104257. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  104258. /**
  104259. * Gets the number of targets stored in this manager
  104260. */
  104261. get: function () {
  104262. return this._targets.length;
  104263. },
  104264. enumerable: true,
  104265. configurable: true
  104266. });
  104267. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  104268. /**
  104269. * Gets the number of influencers (ie. the number of targets with influences > 0)
  104270. */
  104271. get: function () {
  104272. return this._activeTargets.length;
  104273. },
  104274. enumerable: true,
  104275. configurable: true
  104276. });
  104277. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  104278. /**
  104279. * Gets the list of influences (one per target)
  104280. */
  104281. get: function () {
  104282. return this._influences;
  104283. },
  104284. enumerable: true,
  104285. configurable: true
  104286. });
  104287. /**
  104288. * Gets the active target at specified index. An active target is a target with an influence > 0
  104289. * @param index defines the index to check
  104290. * @returns the requested target
  104291. */
  104292. MorphTargetManager.prototype.getActiveTarget = function (index) {
  104293. return this._activeTargets.data[index];
  104294. };
  104295. /**
  104296. * Gets the target at specified index
  104297. * @param index defines the index to check
  104298. * @returns the requested target
  104299. */
  104300. MorphTargetManager.prototype.getTarget = function (index) {
  104301. return this._targets[index];
  104302. };
  104303. /**
  104304. * Add a new target to this manager
  104305. * @param target defines the target to add
  104306. */
  104307. MorphTargetManager.prototype.addTarget = function (target) {
  104308. var _this = this;
  104309. this._targets.push(target);
  104310. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  104311. _this._syncActiveTargets(needUpdate);
  104312. }));
  104313. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  104314. _this._syncActiveTargets(true);
  104315. }));
  104316. this._syncActiveTargets(true);
  104317. };
  104318. /**
  104319. * Removes a target from the manager
  104320. * @param target defines the target to remove
  104321. */
  104322. MorphTargetManager.prototype.removeTarget = function (target) {
  104323. var index = this._targets.indexOf(target);
  104324. if (index >= 0) {
  104325. this._targets.splice(index, 1);
  104326. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  104327. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  104328. this._syncActiveTargets(true);
  104329. }
  104330. };
  104331. /**
  104332. * Serializes the current manager into a Serialization object
  104333. * @returns the serialized object
  104334. */
  104335. MorphTargetManager.prototype.serialize = function () {
  104336. var serializationObject = {};
  104337. serializationObject.id = this.uniqueId;
  104338. serializationObject.targets = [];
  104339. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  104340. var target = _a[_i];
  104341. serializationObject.targets.push(target.serialize());
  104342. }
  104343. return serializationObject;
  104344. };
  104345. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  104346. var influenceCount = 0;
  104347. this._activeTargets.reset();
  104348. this._supportsNormals = true;
  104349. this._supportsTangents = true;
  104350. this._vertexCount = 0;
  104351. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  104352. var target = _a[_i];
  104353. if (target.influence === 0) {
  104354. continue;
  104355. }
  104356. this._activeTargets.push(target);
  104357. this._tempInfluences[influenceCount++] = target.influence;
  104358. this._supportsNormals = this._supportsNormals && target.hasNormals;
  104359. this._supportsTangents = this._supportsTangents && target.hasTangents;
  104360. var positions = target.getPositions();
  104361. if (positions) {
  104362. var vertexCount = positions.length / 3;
  104363. if (this._vertexCount === 0) {
  104364. this._vertexCount = vertexCount;
  104365. }
  104366. else if (this._vertexCount !== vertexCount) {
  104367. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  104368. return;
  104369. }
  104370. }
  104371. }
  104372. if (!this._influences || this._influences.length !== influenceCount) {
  104373. this._influences = new Float32Array(influenceCount);
  104374. }
  104375. for (var index = 0; index < influenceCount; index++) {
  104376. this._influences[index] = this._tempInfluences[index];
  104377. }
  104378. if (needUpdate) {
  104379. this.synchronize();
  104380. }
  104381. };
  104382. /**
  104383. * Syncrhonize the targets with all the meshes using this morph target manager
  104384. */
  104385. MorphTargetManager.prototype.synchronize = function () {
  104386. if (!this._scene) {
  104387. return;
  104388. }
  104389. // Flag meshes as dirty to resync with the active targets
  104390. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  104391. var mesh = _a[_i];
  104392. if (mesh.morphTargetManager === this) {
  104393. mesh._syncGeometryWithMorphTargetManager();
  104394. }
  104395. }
  104396. };
  104397. // Statics
  104398. /**
  104399. * Creates a new MorphTargetManager from serialized data
  104400. * @param serializationObject defines the serialized data
  104401. * @param scene defines the hosting scene
  104402. * @returns the new MorphTargetManager
  104403. */
  104404. MorphTargetManager.Parse = function (serializationObject, scene) {
  104405. var result = new MorphTargetManager(scene);
  104406. result._uniqueId = serializationObject.id;
  104407. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  104408. var targetData = _a[_i];
  104409. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  104410. }
  104411. return result;
  104412. };
  104413. return MorphTargetManager;
  104414. }());
  104415. /***/ }),
  104416. /***/ "./Offline/database.ts":
  104417. /*!*****************************!*\
  104418. !*** ./Offline/database.ts ***!
  104419. \*****************************/
  104420. /*! exports provided: Database */
  104421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104422. "use strict";
  104423. __webpack_require__.r(__webpack_exports__);
  104424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  104425. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104426. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  104427. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  104428. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  104429. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/webRequest */ "./Misc/webRequest.ts");
  104430. // Sets the default offline provider to Babylon.js
  104431. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  104432. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  104433. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  104434. };
  104435. /**
  104436. * Class used to enable access to IndexedDB
  104437. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104438. */
  104439. var Database = /** @class */ (function () {
  104440. /**
  104441. * Creates a new Database
  104442. * @param urlToScene defines the url to load the scene
  104443. * @param callbackManifestChecked defines the callback to use when manifest is checked
  104444. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  104445. */
  104446. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  104447. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  104448. var _this = this;
  104449. // Handling various flavors of prefixed version of IndexedDB
  104450. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  104451. this._callbackManifestChecked = callbackManifestChecked;
  104452. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  104453. this._db = null;
  104454. this._enableSceneOffline = false;
  104455. this._enableTexturesOffline = false;
  104456. this._manifestVersionFound = 0;
  104457. this._mustUpdateRessources = false;
  104458. this._hasReachedQuota = false;
  104459. if (!Database.IDBStorageEnabled) {
  104460. this._callbackManifestChecked(true);
  104461. }
  104462. else {
  104463. if (disableManifestCheck) {
  104464. this._enableSceneOffline = true;
  104465. this._enableTexturesOffline = true;
  104466. this._manifestVersionFound = 1;
  104467. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  104468. _this._callbackManifestChecked(true);
  104469. });
  104470. }
  104471. else {
  104472. this._checkManifestFile();
  104473. }
  104474. }
  104475. }
  104476. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  104477. /**
  104478. * Gets a boolean indicating if scene must be saved in the database
  104479. */
  104480. get: function () {
  104481. return this._enableSceneOffline;
  104482. },
  104483. enumerable: true,
  104484. configurable: true
  104485. });
  104486. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  104487. /**
  104488. * Gets a boolean indicating if textures must be saved in the database
  104489. */
  104490. get: function () {
  104491. return this._enableTexturesOffline;
  104492. },
  104493. enumerable: true,
  104494. configurable: true
  104495. });
  104496. Database.prototype._checkManifestFile = function () {
  104497. var _this = this;
  104498. var noManifestFile = function () {
  104499. _this._enableSceneOffline = false;
  104500. _this._enableTexturesOffline = false;
  104501. _this._callbackManifestChecked(false);
  104502. };
  104503. var timeStampUsed = false;
  104504. var manifestURL = this._currentSceneUrl + ".manifest";
  104505. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  104506. if (navigator.onLine) {
  104507. // Adding a timestamp to by-pass browsers' cache
  104508. timeStampUsed = true;
  104509. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  104510. }
  104511. xhr.open("GET", manifestURL);
  104512. xhr.addEventListener("load", function () {
  104513. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  104514. try {
  104515. var manifestFile = JSON.parse(xhr.response);
  104516. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  104517. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  104518. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  104519. _this._manifestVersionFound = manifestFile.version;
  104520. }
  104521. if (_this._callbackManifestChecked) {
  104522. _this._callbackManifestChecked(true);
  104523. }
  104524. }
  104525. catch (ex) {
  104526. noManifestFile();
  104527. }
  104528. }
  104529. else {
  104530. noManifestFile();
  104531. }
  104532. }, false);
  104533. xhr.addEventListener("error", function () {
  104534. if (timeStampUsed) {
  104535. timeStampUsed = false;
  104536. // Let's retry without the timeStamp
  104537. // It could fail when coupled with HTML5 Offline API
  104538. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  104539. xhr.open("GET", retryManifestURL);
  104540. xhr.send();
  104541. }
  104542. else {
  104543. noManifestFile();
  104544. }
  104545. }, false);
  104546. try {
  104547. xhr.send();
  104548. }
  104549. catch (ex) {
  104550. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  104551. this._callbackManifestChecked(false);
  104552. }
  104553. };
  104554. /**
  104555. * Open the database and make it available
  104556. * @param successCallback defines the callback to call on success
  104557. * @param errorCallback defines the callback to call on error
  104558. */
  104559. Database.prototype.open = function (successCallback, errorCallback) {
  104560. var _this = this;
  104561. var handleError = function () {
  104562. _this._isSupported = false;
  104563. if (errorCallback) {
  104564. errorCallback();
  104565. }
  104566. };
  104567. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  104568. // Your browser doesn't support IndexedDB
  104569. this._isSupported = false;
  104570. if (errorCallback) {
  104571. errorCallback();
  104572. }
  104573. }
  104574. else {
  104575. // If the DB hasn't been opened or created yet
  104576. if (!this._db) {
  104577. this._hasReachedQuota = false;
  104578. this._isSupported = true;
  104579. var request = this._idbFactory.open("babylonjs", 1);
  104580. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  104581. request.onerror = function () {
  104582. handleError();
  104583. };
  104584. // executes when a version change transaction cannot complete due to other active transactions
  104585. request.onblocked = function () {
  104586. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  104587. handleError();
  104588. };
  104589. // DB has been opened successfully
  104590. request.onsuccess = function () {
  104591. _this._db = request.result;
  104592. successCallback();
  104593. };
  104594. // Initialization of the DB. Creating Scenes & Textures stores
  104595. request.onupgradeneeded = function (event) {
  104596. _this._db = (event.target).result;
  104597. if (_this._db) {
  104598. try {
  104599. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  104600. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  104601. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  104602. }
  104603. catch (ex) {
  104604. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  104605. handleError();
  104606. }
  104607. }
  104608. };
  104609. }
  104610. // DB has already been created and opened
  104611. else {
  104612. if (successCallback) {
  104613. successCallback();
  104614. }
  104615. }
  104616. }
  104617. };
  104618. /**
  104619. * Loads an image from the database
  104620. * @param url defines the url to load from
  104621. * @param image defines the target DOM image
  104622. */
  104623. Database.prototype.loadImage = function (url, image) {
  104624. var _this = this;
  104625. var completeURL = Database._ReturnFullUrlLocation(url);
  104626. var saveAndLoadImage = function () {
  104627. if (!_this._hasReachedQuota && _this._db !== null) {
  104628. // the texture is not yet in the DB, let's try to save it
  104629. _this._saveImageIntoDBAsync(completeURL, image);
  104630. }
  104631. // If the texture is not in the DB and we've reached the DB quota limit
  104632. // let's load it directly from the web
  104633. else {
  104634. image.src = url;
  104635. }
  104636. };
  104637. if (!this._mustUpdateRessources) {
  104638. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  104639. }
  104640. // First time we're download the images or update requested in the manifest file by a version change
  104641. else {
  104642. saveAndLoadImage();
  104643. }
  104644. };
  104645. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  104646. if (this._isSupported && this._db !== null) {
  104647. var texture;
  104648. var transaction = this._db.transaction(["textures"]);
  104649. transaction.onabort = function () {
  104650. image.src = url;
  104651. };
  104652. transaction.oncomplete = function () {
  104653. var blobTextureURL;
  104654. if (texture) {
  104655. var URL = window.URL || window.webkitURL;
  104656. blobTextureURL = URL.createObjectURL(texture.data);
  104657. image.onerror = function () {
  104658. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  104659. image.src = url;
  104660. };
  104661. image.src = blobTextureURL;
  104662. }
  104663. else {
  104664. notInDBCallback();
  104665. }
  104666. };
  104667. var getRequest = transaction.objectStore("textures").get(url);
  104668. getRequest.onsuccess = function (event) {
  104669. texture = (event.target).result;
  104670. };
  104671. getRequest.onerror = function () {
  104672. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  104673. image.src = url;
  104674. };
  104675. }
  104676. else {
  104677. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  104678. image.src = url;
  104679. }
  104680. };
  104681. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  104682. var _this = this;
  104683. if (this._isSupported) {
  104684. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  104685. var generateBlobUrl = function () {
  104686. var blobTextureURL;
  104687. if (blob) {
  104688. var URL = window.URL || window.webkitURL;
  104689. try {
  104690. blobTextureURL = URL.createObjectURL(blob);
  104691. }
  104692. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  104693. catch (ex) {
  104694. blobTextureURL = URL.createObjectURL(blob);
  104695. }
  104696. }
  104697. if (blobTextureURL) {
  104698. image.src = blobTextureURL;
  104699. }
  104700. };
  104701. if (Database.IsUASupportingBlobStorage) { // Create XHR
  104702. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"](), blob;
  104703. xhr.open("GET", url);
  104704. xhr.responseType = "blob";
  104705. xhr.addEventListener("load", function () {
  104706. if (xhr.status === 200 && _this._db) {
  104707. // Blob as response (XHR2)
  104708. blob = xhr.response;
  104709. var transaction = _this._db.transaction(["textures"], "readwrite");
  104710. // the transaction could abort because of a QuotaExceededError error
  104711. transaction.onabort = function (event) {
  104712. try {
  104713. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  104714. var srcElement = (event.srcElement || event.target);
  104715. var error = srcElement.error;
  104716. if (error && error.name === "QuotaExceededError") {
  104717. _this._hasReachedQuota = true;
  104718. }
  104719. }
  104720. catch (ex) { }
  104721. generateBlobUrl();
  104722. };
  104723. transaction.oncomplete = function () {
  104724. generateBlobUrl();
  104725. };
  104726. var newTexture = { textureUrl: url, data: blob };
  104727. try {
  104728. // Put the blob into the dabase
  104729. var addRequest = transaction.objectStore("textures").put(newTexture);
  104730. addRequest.onsuccess = function () {
  104731. };
  104732. addRequest.onerror = function () {
  104733. generateBlobUrl();
  104734. };
  104735. }
  104736. catch (ex) {
  104737. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  104738. if (ex.code === 25) {
  104739. Database.IsUASupportingBlobStorage = false;
  104740. _this._enableTexturesOffline = false;
  104741. }
  104742. image.src = url;
  104743. }
  104744. }
  104745. else {
  104746. image.src = url;
  104747. }
  104748. }, false);
  104749. xhr.addEventListener("error", function () {
  104750. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  104751. image.src = url;
  104752. }, false);
  104753. xhr.send();
  104754. }
  104755. else {
  104756. image.src = url;
  104757. }
  104758. }
  104759. else {
  104760. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  104761. image.src = url;
  104762. }
  104763. };
  104764. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  104765. var _this = this;
  104766. var updateVersion = function () {
  104767. // the version is not yet in the DB or we need to update it
  104768. _this._saveVersionIntoDBAsync(url, versionLoaded);
  104769. };
  104770. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  104771. };
  104772. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  104773. var _this = this;
  104774. if (this._isSupported && this._db) {
  104775. var version;
  104776. try {
  104777. var transaction = this._db.transaction(["versions"]);
  104778. transaction.oncomplete = function () {
  104779. if (version) {
  104780. // If the version in the JSON file is different from the version in DB
  104781. if (_this._manifestVersionFound !== version.data) {
  104782. _this._mustUpdateRessources = true;
  104783. updateInDBCallback();
  104784. }
  104785. else {
  104786. callback(version.data);
  104787. }
  104788. }
  104789. // version was not found in DB
  104790. else {
  104791. _this._mustUpdateRessources = true;
  104792. updateInDBCallback();
  104793. }
  104794. };
  104795. transaction.onabort = function () {
  104796. callback(-1);
  104797. };
  104798. var getRequest = transaction.objectStore("versions").get(url);
  104799. getRequest.onsuccess = function (event) {
  104800. version = (event.target).result;
  104801. };
  104802. getRequest.onerror = function () {
  104803. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  104804. callback(-1);
  104805. };
  104806. }
  104807. catch (ex) {
  104808. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  104809. callback(-1);
  104810. }
  104811. }
  104812. else {
  104813. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  104814. callback(-1);
  104815. }
  104816. };
  104817. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  104818. var _this = this;
  104819. if (this._isSupported && !this._hasReachedQuota && this._db) {
  104820. try {
  104821. // Open a transaction to the database
  104822. var transaction = this._db.transaction(["versions"], "readwrite");
  104823. // the transaction could abort because of a QuotaExceededError error
  104824. transaction.onabort = function (event) {
  104825. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  104826. var error = event.srcElement['error'];
  104827. if (error && error.name === "QuotaExceededError") {
  104828. _this._hasReachedQuota = true;
  104829. }
  104830. }
  104831. catch (ex) { }
  104832. callback(-1);
  104833. };
  104834. transaction.oncomplete = function () {
  104835. callback(_this._manifestVersionFound);
  104836. };
  104837. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  104838. // Put the scene into the database
  104839. var addRequest = transaction.objectStore("versions").put(newVersion);
  104840. addRequest.onsuccess = function () {
  104841. };
  104842. addRequest.onerror = function () {
  104843. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  104844. };
  104845. }
  104846. catch (ex) {
  104847. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  104848. callback(-1);
  104849. }
  104850. }
  104851. else {
  104852. callback(-1);
  104853. }
  104854. };
  104855. /**
  104856. * Loads a file from database
  104857. * @param url defines the URL to load from
  104858. * @param sceneLoaded defines a callback to call on success
  104859. * @param progressCallBack defines a callback to call when progress changed
  104860. * @param errorCallback defines a callback to call on error
  104861. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  104862. */
  104863. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  104864. var _this = this;
  104865. var completeUrl = Database._ReturnFullUrlLocation(url);
  104866. var saveAndLoadFile = function () {
  104867. // the scene is not yet in the DB, let's try to save it
  104868. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  104869. };
  104870. this._checkVersionFromDB(completeUrl, function (version) {
  104871. if (version !== -1) {
  104872. if (!_this._mustUpdateRessources) {
  104873. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  104874. }
  104875. else {
  104876. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  104877. }
  104878. }
  104879. else {
  104880. if (errorCallback) {
  104881. errorCallback();
  104882. }
  104883. }
  104884. });
  104885. };
  104886. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  104887. if (this._isSupported && this._db) {
  104888. var targetStore;
  104889. if (url.indexOf(".babylon") !== -1) {
  104890. targetStore = "scenes";
  104891. }
  104892. else {
  104893. targetStore = "textures";
  104894. }
  104895. var file;
  104896. var transaction = this._db.transaction([targetStore]);
  104897. transaction.oncomplete = function () {
  104898. if (file) {
  104899. callback(file.data);
  104900. }
  104901. // file was not found in DB
  104902. else {
  104903. notInDBCallback();
  104904. }
  104905. };
  104906. transaction.onabort = function () {
  104907. notInDBCallback();
  104908. };
  104909. var getRequest = transaction.objectStore(targetStore).get(url);
  104910. getRequest.onsuccess = function (event) {
  104911. file = (event.target).result;
  104912. };
  104913. getRequest.onerror = function () {
  104914. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  104915. notInDBCallback();
  104916. };
  104917. }
  104918. else {
  104919. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  104920. callback();
  104921. }
  104922. };
  104923. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  104924. var _this = this;
  104925. if (this._isSupported) {
  104926. var targetStore;
  104927. if (url.indexOf(".babylon") !== -1) {
  104928. targetStore = "scenes";
  104929. }
  104930. else {
  104931. targetStore = "textures";
  104932. }
  104933. // Create XHR
  104934. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  104935. var fileData;
  104936. xhr.open("GET", url + "?" + Date.now());
  104937. if (useArrayBuffer) {
  104938. xhr.responseType = "arraybuffer";
  104939. }
  104940. if (progressCallback) {
  104941. xhr.onprogress = progressCallback;
  104942. }
  104943. xhr.addEventListener("load", function () {
  104944. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  104945. // Blob as response (XHR2)
  104946. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  104947. if (!_this._hasReachedQuota && _this._db) {
  104948. // Open a transaction to the database
  104949. var transaction = _this._db.transaction([targetStore], "readwrite");
  104950. // the transaction could abort because of a QuotaExceededError error
  104951. transaction.onabort = function (event) {
  104952. try {
  104953. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  104954. var error = event.srcElement['error'];
  104955. if (error && error.name === "QuotaExceededError") {
  104956. _this._hasReachedQuota = true;
  104957. }
  104958. }
  104959. catch (ex) { }
  104960. callback(fileData);
  104961. };
  104962. transaction.oncomplete = function () {
  104963. callback(fileData);
  104964. };
  104965. var newFile;
  104966. if (targetStore === "scenes") {
  104967. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  104968. }
  104969. else {
  104970. newFile = { textureUrl: url, data: fileData };
  104971. }
  104972. try {
  104973. // Put the scene into the database
  104974. var addRequest = transaction.objectStore(targetStore).put(newFile);
  104975. addRequest.onsuccess = function () {
  104976. };
  104977. addRequest.onerror = function () {
  104978. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  104979. };
  104980. }
  104981. catch (ex) {
  104982. callback(fileData);
  104983. }
  104984. }
  104985. else {
  104986. callback(fileData);
  104987. }
  104988. }
  104989. else {
  104990. if (xhr.status >= 400 && errorCallback) {
  104991. errorCallback(xhr);
  104992. }
  104993. else {
  104994. callback();
  104995. }
  104996. }
  104997. }, false);
  104998. xhr.addEventListener("error", function () {
  104999. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  105000. callback();
  105001. }, false);
  105002. xhr.send();
  105003. }
  105004. else {
  105005. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  105006. callback();
  105007. }
  105008. };
  105009. /**
  105010. * Validates if xhr data is correct
  105011. * @param xhr defines the request to validate
  105012. * @param dataType defines the expected data type
  105013. * @returns true if data is correct
  105014. */
  105015. Database._ValidateXHRData = function (xhr, dataType) {
  105016. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  105017. if (dataType === void 0) { dataType = 7; }
  105018. try {
  105019. if (dataType & 1) {
  105020. if (xhr.responseText && xhr.responseText.length > 0) {
  105021. return true;
  105022. }
  105023. else if (dataType === 1) {
  105024. return false;
  105025. }
  105026. }
  105027. if (dataType & 2) {
  105028. // Check header width and height since there is no "TGA" magic number
  105029. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  105030. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  105031. return true;
  105032. }
  105033. else if (dataType === 2) {
  105034. return false;
  105035. }
  105036. }
  105037. if (dataType & 4) {
  105038. // Check for the "DDS" magic number
  105039. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  105040. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  105041. return true;
  105042. }
  105043. else {
  105044. return false;
  105045. }
  105046. }
  105047. }
  105048. catch (e) {
  105049. // Global protection
  105050. }
  105051. return false;
  105052. };
  105053. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  105054. Database.IsUASupportingBlobStorage = true;
  105055. /**
  105056. * Gets a boolean indicating if Database storate is enabled (off by default)
  105057. */
  105058. Database.IDBStorageEnabled = false;
  105059. Database._ParseURL = function (url) {
  105060. var a = document.createElement('a');
  105061. a.href = url;
  105062. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  105063. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  105064. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  105065. return absLocation;
  105066. };
  105067. Database._ReturnFullUrlLocation = function (url) {
  105068. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  105069. return (Database._ParseURL(window.location.href) + url);
  105070. }
  105071. else {
  105072. return url;
  105073. }
  105074. };
  105075. return Database;
  105076. }());
  105077. /***/ }),
  105078. /***/ "./Offline/index.ts":
  105079. /*!**************************!*\
  105080. !*** ./Offline/index.ts ***!
  105081. \**************************/
  105082. /*! exports provided: Database */
  105083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105084. "use strict";
  105085. __webpack_require__.r(__webpack_exports__);
  105086. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  105087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  105088. /***/ }),
  105089. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  105090. /*!******************************************************!*\
  105091. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  105092. \******************************************************/
  105093. /*! exports provided: BoxParticleEmitter */
  105094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105095. "use strict";
  105096. __webpack_require__.r(__webpack_exports__);
  105097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  105098. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105099. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105100. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105101. /**
  105102. * Particle emitter emitting particles from the inside of a box.
  105103. * It emits the particles randomly between 2 given directions.
  105104. */
  105105. var BoxParticleEmitter = /** @class */ (function () {
  105106. /**
  105107. * Creates a new instance BoxParticleEmitter
  105108. */
  105109. function BoxParticleEmitter() {
  105110. /**
  105111. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105112. */
  105113. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  105114. /**
  105115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105116. */
  105117. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  105118. /**
  105119. * 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.
  105120. */
  105121. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  105122. /**
  105123. * 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.
  105124. */
  105125. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  105126. }
  105127. /**
  105128. * Called by the particle System when the direction is computed for the created particle.
  105129. * @param worldMatrix is the world matrix of the particle system
  105130. * @param directionToUpdate is the direction vector to update with the result
  105131. * @param particle is the particle we are computed the direction for
  105132. */
  105133. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105134. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  105135. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  105136. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  105137. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  105138. };
  105139. /**
  105140. * Called by the particle System when the position is computed for the created particle.
  105141. * @param worldMatrix is the world matrix of the particle system
  105142. * @param positionToUpdate is the position vector to update with the result
  105143. * @param particle is the particle we are computed the position for
  105144. */
  105145. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105146. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  105147. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  105148. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  105149. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  105150. };
  105151. /**
  105152. * Clones the current emitter and returns a copy of it
  105153. * @returns the new emitter
  105154. */
  105155. BoxParticleEmitter.prototype.clone = function () {
  105156. var newOne = new BoxParticleEmitter();
  105157. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  105158. return newOne;
  105159. };
  105160. /**
  105161. * Called by the GPUParticleSystem to setup the update shader
  105162. * @param effect defines the update shader
  105163. */
  105164. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  105165. effect.setVector3("direction1", this.direction1);
  105166. effect.setVector3("direction2", this.direction2);
  105167. effect.setVector3("minEmitBox", this.minEmitBox);
  105168. effect.setVector3("maxEmitBox", this.maxEmitBox);
  105169. };
  105170. /**
  105171. * Returns a string to use to update the GPU particles update shader
  105172. * @returns a string containng the defines string
  105173. */
  105174. BoxParticleEmitter.prototype.getEffectDefines = function () {
  105175. return "#define BOXEMITTER";
  105176. };
  105177. /**
  105178. * Returns the string "BoxParticleEmitter"
  105179. * @returns a string containing the class name
  105180. */
  105181. BoxParticleEmitter.prototype.getClassName = function () {
  105182. return "BoxParticleEmitter";
  105183. };
  105184. /**
  105185. * Serializes the particle system to a JSON object.
  105186. * @returns the JSON object
  105187. */
  105188. BoxParticleEmitter.prototype.serialize = function () {
  105189. var serializationObject = {};
  105190. serializationObject.type = this.getClassName();
  105191. serializationObject.direction1 = this.direction1.asArray();
  105192. serializationObject.direction2 = this.direction2.asArray();
  105193. serializationObject.minEmitBox = this.minEmitBox.asArray();
  105194. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  105195. return serializationObject;
  105196. };
  105197. /**
  105198. * Parse properties from a JSON object
  105199. * @param serializationObject defines the JSON object
  105200. */
  105201. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  105202. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  105203. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  105204. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  105205. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  105206. };
  105207. return BoxParticleEmitter;
  105208. }());
  105209. /***/ }),
  105210. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  105211. /*!*******************************************************!*\
  105212. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  105213. \*******************************************************/
  105214. /*! exports provided: ConeParticleEmitter */
  105215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105216. "use strict";
  105217. __webpack_require__.r(__webpack_exports__);
  105218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  105219. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105220. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105221. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105222. /**
  105223. * Particle emitter emitting particles from the inside of a cone.
  105224. * It emits the particles alongside the cone volume from the base to the particle.
  105225. * The emission direction might be randomized.
  105226. */
  105227. var ConeParticleEmitter = /** @class */ (function () {
  105228. /**
  105229. * Creates a new instance ConeParticleEmitter
  105230. * @param radius the radius of the emission cone (1 by default)
  105231. * @param angle the cone base angle (PI by default)
  105232. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  105233. */
  105234. function ConeParticleEmitter(radius, angle,
  105235. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  105236. directionRandomizer) {
  105237. if (radius === void 0) { radius = 1; }
  105238. if (angle === void 0) { angle = Math.PI; }
  105239. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105240. this.directionRandomizer = directionRandomizer;
  105241. /**
  105242. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  105243. */
  105244. this.radiusRange = 1;
  105245. /**
  105246. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  105247. */
  105248. this.heightRange = 1;
  105249. /**
  105250. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  105251. */
  105252. this.emitFromSpawnPointOnly = false;
  105253. this.angle = angle;
  105254. this.radius = radius;
  105255. }
  105256. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  105257. /**
  105258. * Gets or sets the radius of the emission cone
  105259. */
  105260. get: function () {
  105261. return this._radius;
  105262. },
  105263. set: function (value) {
  105264. this._radius = value;
  105265. this._buildHeight();
  105266. },
  105267. enumerable: true,
  105268. configurable: true
  105269. });
  105270. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  105271. /**
  105272. * Gets or sets the angle of the emission cone
  105273. */
  105274. get: function () {
  105275. return this._angle;
  105276. },
  105277. set: function (value) {
  105278. this._angle = value;
  105279. this._buildHeight();
  105280. },
  105281. enumerable: true,
  105282. configurable: true
  105283. });
  105284. ConeParticleEmitter.prototype._buildHeight = function () {
  105285. if (this._angle !== 0) {
  105286. this._height = this._radius / Math.tan(this._angle / 2);
  105287. }
  105288. else {
  105289. this._height = 1;
  105290. }
  105291. };
  105292. /**
  105293. * Called by the particle System when the direction is computed for the created particle.
  105294. * @param worldMatrix is the world matrix of the particle system
  105295. * @param directionToUpdate is the direction vector to update with the result
  105296. * @param particle is the particle we are computed the direction for
  105297. */
  105298. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105299. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  105300. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  105301. }
  105302. else {
  105303. // measure the direction Vector from the emitter to the particle.
  105304. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  105305. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105306. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105307. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105308. direction.x += randX;
  105309. direction.y += randY;
  105310. direction.z += randZ;
  105311. direction.normalize();
  105312. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  105313. }
  105314. };
  105315. /**
  105316. * Called by the particle System when the position is computed for the created particle.
  105317. * @param worldMatrix is the world matrix of the particle system
  105318. * @param positionToUpdate is the position vector to update with the result
  105319. * @param particle is the particle we are computed the position for
  105320. */
  105321. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105322. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  105323. var h;
  105324. if (!this.emitFromSpawnPointOnly) {
  105325. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  105326. // Better distribution in a cone at normal angles.
  105327. h = 1 - h * h;
  105328. }
  105329. else {
  105330. h = 0.0001;
  105331. }
  105332. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  105333. radius = radius * h;
  105334. var randX = radius * Math.sin(s);
  105335. var randZ = radius * Math.cos(s);
  105336. var randY = h * this._height;
  105337. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  105338. };
  105339. /**
  105340. * Clones the current emitter and returns a copy of it
  105341. * @returns the new emitter
  105342. */
  105343. ConeParticleEmitter.prototype.clone = function () {
  105344. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  105345. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  105346. return newOne;
  105347. };
  105348. /**
  105349. * Called by the GPUParticleSystem to setup the update shader
  105350. * @param effect defines the update shader
  105351. */
  105352. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  105353. effect.setFloat2("radius", this._radius, this.radiusRange);
  105354. effect.setFloat("coneAngle", this._angle);
  105355. effect.setFloat2("height", this._height, this.heightRange);
  105356. effect.setFloat("directionRandomizer", this.directionRandomizer);
  105357. };
  105358. /**
  105359. * Returns a string to use to update the GPU particles update shader
  105360. * @returns a string containng the defines string
  105361. */
  105362. ConeParticleEmitter.prototype.getEffectDefines = function () {
  105363. var defines = "#define CONEEMITTER";
  105364. if (this.emitFromSpawnPointOnly) {
  105365. defines += "\n#define CONEEMITTERSPAWNPOINT";
  105366. }
  105367. return defines;
  105368. };
  105369. /**
  105370. * Returns the string "ConeParticleEmitter"
  105371. * @returns a string containing the class name
  105372. */
  105373. ConeParticleEmitter.prototype.getClassName = function () {
  105374. return "ConeParticleEmitter";
  105375. };
  105376. /**
  105377. * Serializes the particle system to a JSON object.
  105378. * @returns the JSON object
  105379. */
  105380. ConeParticleEmitter.prototype.serialize = function () {
  105381. var serializationObject = {};
  105382. serializationObject.type = this.getClassName();
  105383. serializationObject.radius = this._radius;
  105384. serializationObject.angle = this._angle;
  105385. serializationObject.directionRandomizer = this.directionRandomizer;
  105386. return serializationObject;
  105387. };
  105388. /**
  105389. * Parse properties from a JSON object
  105390. * @param serializationObject defines the JSON object
  105391. */
  105392. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  105393. this.radius = serializationObject.radius;
  105394. this.angle = serializationObject.angle;
  105395. this.directionRandomizer = serializationObject.directionRandomizer;
  105396. };
  105397. return ConeParticleEmitter;
  105398. }());
  105399. /***/ }),
  105400. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  105401. /*!***********************************************************!*\
  105402. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  105403. \***********************************************************/
  105404. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  105405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105406. "use strict";
  105407. __webpack_require__.r(__webpack_exports__);
  105408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  105409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  105410. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105411. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105412. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105413. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105414. /**
  105415. * Particle emitter emitting particles from the inside of a cylinder.
  105416. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  105417. */
  105418. var CylinderParticleEmitter = /** @class */ (function () {
  105419. /**
  105420. * Creates a new instance CylinderParticleEmitter
  105421. * @param radius the radius of the emission cylinder (1 by default)
  105422. * @param height the height of the emission cylinder (1 by default)
  105423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105424. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  105425. */
  105426. function CylinderParticleEmitter(
  105427. /**
  105428. * The radius of the emission cylinder.
  105429. */
  105430. radius,
  105431. /**
  105432. * The height of the emission cylinder.
  105433. */
  105434. height,
  105435. /**
  105436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  105437. */
  105438. radiusRange,
  105439. /**
  105440. * How much to randomize the particle direction [0-1].
  105441. */
  105442. directionRandomizer) {
  105443. if (radius === void 0) { radius = 1; }
  105444. if (height === void 0) { height = 1; }
  105445. if (radiusRange === void 0) { radiusRange = 1; }
  105446. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105447. this.radius = radius;
  105448. this.height = height;
  105449. this.radiusRange = radiusRange;
  105450. this.directionRandomizer = directionRandomizer;
  105451. }
  105452. /**
  105453. * Called by the particle System when the direction is computed for the created particle.
  105454. * @param worldMatrix is the world matrix of the particle system
  105455. * @param directionToUpdate is the direction vector to update with the result
  105456. * @param particle is the particle we are computed the direction for
  105457. */
  105458. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105459. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  105460. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  105461. var angle = Math.atan2(direction.x, direction.z);
  105462. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  105463. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  105464. direction.x = Math.sin(angle);
  105465. direction.z = Math.cos(angle);
  105466. direction.normalize();
  105467. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  105468. };
  105469. /**
  105470. * Called by the particle System when the position is computed for the created particle.
  105471. * @param worldMatrix is the world matrix of the particle system
  105472. * @param positionToUpdate is the position vector to update with the result
  105473. * @param particle is the particle we are computed the position for
  105474. */
  105475. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105476. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  105477. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  105478. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  105479. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  105480. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  105481. var xPos = positionRadius * Math.cos(angle);
  105482. var zPos = positionRadius * Math.sin(angle);
  105483. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  105484. };
  105485. /**
  105486. * Clones the current emitter and returns a copy of it
  105487. * @returns the new emitter
  105488. */
  105489. CylinderParticleEmitter.prototype.clone = function () {
  105490. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  105491. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  105492. return newOne;
  105493. };
  105494. /**
  105495. * Called by the GPUParticleSystem to setup the update shader
  105496. * @param effect defines the update shader
  105497. */
  105498. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  105499. effect.setFloat("radius", this.radius);
  105500. effect.setFloat("height", this.height);
  105501. effect.setFloat("radiusRange", this.radiusRange);
  105502. effect.setFloat("directionRandomizer", this.directionRandomizer);
  105503. };
  105504. /**
  105505. * Returns a string to use to update the GPU particles update shader
  105506. * @returns a string containng the defines string
  105507. */
  105508. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  105509. return "#define CYLINDEREMITTER";
  105510. };
  105511. /**
  105512. * Returns the string "CylinderParticleEmitter"
  105513. * @returns a string containing the class name
  105514. */
  105515. CylinderParticleEmitter.prototype.getClassName = function () {
  105516. return "CylinderParticleEmitter";
  105517. };
  105518. /**
  105519. * Serializes the particle system to a JSON object.
  105520. * @returns the JSON object
  105521. */
  105522. CylinderParticleEmitter.prototype.serialize = function () {
  105523. var serializationObject = {};
  105524. serializationObject.type = this.getClassName();
  105525. serializationObject.radius = this.radius;
  105526. serializationObject.height = this.height;
  105527. serializationObject.radiusRange = this.radiusRange;
  105528. serializationObject.directionRandomizer = this.directionRandomizer;
  105529. return serializationObject;
  105530. };
  105531. /**
  105532. * Parse properties from a JSON object
  105533. * @param serializationObject defines the JSON object
  105534. */
  105535. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  105536. this.radius = serializationObject.radius;
  105537. this.height = serializationObject.height;
  105538. this.radiusRange = serializationObject.radiusRange;
  105539. this.directionRandomizer = serializationObject.directionRandomizer;
  105540. };
  105541. return CylinderParticleEmitter;
  105542. }());
  105543. /**
  105544. * Particle emitter emitting particles from the inside of a cylinder.
  105545. * It emits the particles randomly between two vectors.
  105546. */
  105547. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  105548. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  105549. /**
  105550. * Creates a new instance CylinderDirectedParticleEmitter
  105551. * @param radius the radius of the emission cylinder (1 by default)
  105552. * @param height the height of the emission cylinder (1 by default)
  105553. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105554. * @param direction1 the min limit of the emission direction (up vector by default)
  105555. * @param direction2 the max limit of the emission direction (up vector by default)
  105556. */
  105557. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  105558. /**
  105559. * The min limit of the emission direction.
  105560. */
  105561. direction1,
  105562. /**
  105563. * The max limit of the emission direction.
  105564. */
  105565. direction2) {
  105566. if (radius === void 0) { radius = 1; }
  105567. if (height === void 0) { height = 1; }
  105568. if (radiusRange === void 0) { radiusRange = 1; }
  105569. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  105570. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  105571. var _this = _super.call(this, radius, height, radiusRange) || this;
  105572. _this.direction1 = direction1;
  105573. _this.direction2 = direction2;
  105574. return _this;
  105575. }
  105576. /**
  105577. * Called by the particle System when the direction is computed for the created particle.
  105578. * @param worldMatrix is the world matrix of the particle system
  105579. * @param directionToUpdate is the direction vector to update with the result
  105580. * @param particle is the particle we are computed the direction for
  105581. */
  105582. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105583. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  105584. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  105585. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  105586. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  105587. };
  105588. /**
  105589. * Clones the current emitter and returns a copy of it
  105590. * @returns the new emitter
  105591. */
  105592. CylinderDirectedParticleEmitter.prototype.clone = function () {
  105593. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  105594. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  105595. return newOne;
  105596. };
  105597. /**
  105598. * Called by the GPUParticleSystem to setup the update shader
  105599. * @param effect defines the update shader
  105600. */
  105601. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  105602. effect.setFloat("radius", this.radius);
  105603. effect.setFloat("height", this.height);
  105604. effect.setFloat("radiusRange", this.radiusRange);
  105605. effect.setVector3("direction1", this.direction1);
  105606. effect.setVector3("direction2", this.direction2);
  105607. };
  105608. /**
  105609. * Returns a string to use to update the GPU particles update shader
  105610. * @returns a string containng the defines string
  105611. */
  105612. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  105613. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  105614. };
  105615. /**
  105616. * Returns the string "CylinderDirectedParticleEmitter"
  105617. * @returns a string containing the class name
  105618. */
  105619. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  105620. return "CylinderDirectedParticleEmitter";
  105621. };
  105622. /**
  105623. * Serializes the particle system to a JSON object.
  105624. * @returns the JSON object
  105625. */
  105626. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  105627. var serializationObject = _super.prototype.serialize.call(this);
  105628. serializationObject.direction1 = this.direction1.asArray();
  105629. serializationObject.direction2 = this.direction2.asArray();
  105630. return serializationObject;
  105631. };
  105632. /**
  105633. * Parse properties from a JSON object
  105634. * @param serializationObject defines the JSON object
  105635. */
  105636. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  105637. _super.prototype.parse.call(this, serializationObject);
  105638. this.direction1.copyFrom(serializationObject.direction1);
  105639. this.direction2.copyFrom(serializationObject.direction2);
  105640. };
  105641. return CylinderDirectedParticleEmitter;
  105642. }(CylinderParticleEmitter));
  105643. /***/ }),
  105644. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  105645. /*!**************************************************************!*\
  105646. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  105647. \**************************************************************/
  105648. /*! exports provided: HemisphericParticleEmitter */
  105649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105650. "use strict";
  105651. __webpack_require__.r(__webpack_exports__);
  105652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  105653. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105654. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105655. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105656. /**
  105657. * Particle emitter emitting particles from the inside of a hemisphere.
  105658. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  105659. */
  105660. var HemisphericParticleEmitter = /** @class */ (function () {
  105661. /**
  105662. * Creates a new instance HemisphericParticleEmitter
  105663. * @param radius the radius of the emission hemisphere (1 by default)
  105664. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105665. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  105666. */
  105667. function HemisphericParticleEmitter(
  105668. /**
  105669. * The radius of the emission hemisphere.
  105670. */
  105671. radius,
  105672. /**
  105673. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  105674. */
  105675. radiusRange,
  105676. /**
  105677. * How much to randomize the particle direction [0-1].
  105678. */
  105679. directionRandomizer) {
  105680. if (radius === void 0) { radius = 1; }
  105681. if (radiusRange === void 0) { radiusRange = 1; }
  105682. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105683. this.radius = radius;
  105684. this.radiusRange = radiusRange;
  105685. this.directionRandomizer = directionRandomizer;
  105686. }
  105687. /**
  105688. * Called by the particle System when the direction is computed for the created particle.
  105689. * @param worldMatrix is the world matrix of the particle system
  105690. * @param directionToUpdate is the direction vector to update with the result
  105691. * @param particle is the particle we are computed the direction for
  105692. */
  105693. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105694. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  105695. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105696. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105697. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105698. direction.x += randX;
  105699. direction.y += randY;
  105700. direction.z += randZ;
  105701. direction.normalize();
  105702. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  105703. };
  105704. /**
  105705. * Called by the particle System when the position is computed for the created particle.
  105706. * @param worldMatrix is the world matrix of the particle system
  105707. * @param positionToUpdate is the position vector to update with the result
  105708. * @param particle is the particle we are computed the position for
  105709. */
  105710. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105711. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  105712. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  105713. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  105714. var theta = Math.acos(2 * v - 1);
  105715. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  105716. var randY = randRadius * Math.cos(theta);
  105717. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  105718. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  105719. };
  105720. /**
  105721. * Clones the current emitter and returns a copy of it
  105722. * @returns the new emitter
  105723. */
  105724. HemisphericParticleEmitter.prototype.clone = function () {
  105725. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  105726. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  105727. return newOne;
  105728. };
  105729. /**
  105730. * Called by the GPUParticleSystem to setup the update shader
  105731. * @param effect defines the update shader
  105732. */
  105733. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  105734. effect.setFloat("radius", this.radius);
  105735. effect.setFloat("radiusRange", this.radiusRange);
  105736. effect.setFloat("directionRandomizer", this.directionRandomizer);
  105737. };
  105738. /**
  105739. * Returns a string to use to update the GPU particles update shader
  105740. * @returns a string containng the defines string
  105741. */
  105742. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  105743. return "#define HEMISPHERICEMITTER";
  105744. };
  105745. /**
  105746. * Returns the string "HemisphericParticleEmitter"
  105747. * @returns a string containing the class name
  105748. */
  105749. HemisphericParticleEmitter.prototype.getClassName = function () {
  105750. return "HemisphericParticleEmitter";
  105751. };
  105752. /**
  105753. * Serializes the particle system to a JSON object.
  105754. * @returns the JSON object
  105755. */
  105756. HemisphericParticleEmitter.prototype.serialize = function () {
  105757. var serializationObject = {};
  105758. serializationObject.type = this.getClassName();
  105759. serializationObject.radius = this.radius;
  105760. serializationObject.radiusRange = this.radiusRange;
  105761. serializationObject.directionRandomizer = this.directionRandomizer;
  105762. return serializationObject;
  105763. };
  105764. /**
  105765. * Parse properties from a JSON object
  105766. * @param serializationObject defines the JSON object
  105767. */
  105768. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  105769. this.radius = serializationObject.radius;
  105770. this.radiusRange = serializationObject.radiusRange;
  105771. this.directionRandomizer = serializationObject.directionRandomizer;
  105772. };
  105773. return HemisphericParticleEmitter;
  105774. }());
  105775. /***/ }),
  105776. /***/ "./Particles/EmitterTypes/index.ts":
  105777. /*!*****************************************!*\
  105778. !*** ./Particles/EmitterTypes/index.ts ***!
  105779. \*****************************************/
  105780. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  105781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105782. "use strict";
  105783. __webpack_require__.r(__webpack_exports__);
  105784. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  105785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  105786. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  105787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  105788. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  105789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  105790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  105791. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  105792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  105793. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  105794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  105795. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  105796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  105797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  105798. /***/ }),
  105799. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  105800. /*!********************************************************!*\
  105801. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  105802. \********************************************************/
  105803. /*! exports provided: PointParticleEmitter */
  105804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105805. "use strict";
  105806. __webpack_require__.r(__webpack_exports__);
  105807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  105808. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105809. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105810. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105811. /**
  105812. * Particle emitter emitting particles from a point.
  105813. * It emits the particles randomly between 2 given directions.
  105814. */
  105815. var PointParticleEmitter = /** @class */ (function () {
  105816. /**
  105817. * Creates a new instance PointParticleEmitter
  105818. */
  105819. function PointParticleEmitter() {
  105820. /**
  105821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105822. */
  105823. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  105824. /**
  105825. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105826. */
  105827. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  105828. }
  105829. /**
  105830. * Called by the particle System when the direction is computed for the created particle.
  105831. * @param worldMatrix is the world matrix of the particle system
  105832. * @param directionToUpdate is the direction vector to update with the result
  105833. * @param particle is the particle we are computed the direction for
  105834. */
  105835. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105836. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  105837. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  105838. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  105839. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  105840. };
  105841. /**
  105842. * Called by the particle System when the position is computed for the created particle.
  105843. * @param worldMatrix is the world matrix of the particle system
  105844. * @param positionToUpdate is the position vector to update with the result
  105845. * @param particle is the particle we are computed the position for
  105846. */
  105847. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105848. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  105849. };
  105850. /**
  105851. * Clones the current emitter and returns a copy of it
  105852. * @returns the new emitter
  105853. */
  105854. PointParticleEmitter.prototype.clone = function () {
  105855. var newOne = new PointParticleEmitter();
  105856. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  105857. return newOne;
  105858. };
  105859. /**
  105860. * Called by the GPUParticleSystem to setup the update shader
  105861. * @param effect defines the update shader
  105862. */
  105863. PointParticleEmitter.prototype.applyToShader = function (effect) {
  105864. effect.setVector3("direction1", this.direction1);
  105865. effect.setVector3("direction2", this.direction2);
  105866. };
  105867. /**
  105868. * Returns a string to use to update the GPU particles update shader
  105869. * @returns a string containng the defines string
  105870. */
  105871. PointParticleEmitter.prototype.getEffectDefines = function () {
  105872. return "#define POINTEMITTER";
  105873. };
  105874. /**
  105875. * Returns the string "PointParticleEmitter"
  105876. * @returns a string containing the class name
  105877. */
  105878. PointParticleEmitter.prototype.getClassName = function () {
  105879. return "PointParticleEmitter";
  105880. };
  105881. /**
  105882. * Serializes the particle system to a JSON object.
  105883. * @returns the JSON object
  105884. */
  105885. PointParticleEmitter.prototype.serialize = function () {
  105886. var serializationObject = {};
  105887. serializationObject.type = this.getClassName();
  105888. serializationObject.direction1 = this.direction1.asArray();
  105889. serializationObject.direction2 = this.direction2.asArray();
  105890. return serializationObject;
  105891. };
  105892. /**
  105893. * Parse properties from a JSON object
  105894. * @param serializationObject defines the JSON object
  105895. */
  105896. PointParticleEmitter.prototype.parse = function (serializationObject) {
  105897. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  105898. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  105899. };
  105900. return PointParticleEmitter;
  105901. }());
  105902. /***/ }),
  105903. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  105904. /*!*********************************************************!*\
  105905. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  105906. \*********************************************************/
  105907. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  105908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105909. "use strict";
  105910. __webpack_require__.r(__webpack_exports__);
  105911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  105912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  105913. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105914. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105915. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105916. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105917. /**
  105918. * Particle emitter emitting particles from the inside of a sphere.
  105919. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  105920. */
  105921. var SphereParticleEmitter = /** @class */ (function () {
  105922. /**
  105923. * Creates a new instance SphereParticleEmitter
  105924. * @param radius the radius of the emission sphere (1 by default)
  105925. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105926. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  105927. */
  105928. function SphereParticleEmitter(
  105929. /**
  105930. * The radius of the emission sphere.
  105931. */
  105932. radius,
  105933. /**
  105934. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  105935. */
  105936. radiusRange,
  105937. /**
  105938. * How much to randomize the particle direction [0-1].
  105939. */
  105940. directionRandomizer) {
  105941. if (radius === void 0) { radius = 1; }
  105942. if (radiusRange === void 0) { radiusRange = 1; }
  105943. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105944. this.radius = radius;
  105945. this.radiusRange = radiusRange;
  105946. this.directionRandomizer = directionRandomizer;
  105947. }
  105948. /**
  105949. * Called by the particle System when the direction is computed for the created particle.
  105950. * @param worldMatrix is the world matrix of the particle system
  105951. * @param directionToUpdate is the direction vector to update with the result
  105952. * @param particle is the particle we are computed the direction for
  105953. */
  105954. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105955. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  105956. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105957. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105958. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105959. direction.x += randX;
  105960. direction.y += randY;
  105961. direction.z += randZ;
  105962. direction.normalize();
  105963. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  105964. };
  105965. /**
  105966. * Called by the particle System when the position is computed for the created particle.
  105967. * @param worldMatrix is the world matrix of the particle system
  105968. * @param positionToUpdate is the position vector to update with the result
  105969. * @param particle is the particle we are computed the position for
  105970. */
  105971. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105972. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  105973. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  105974. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  105975. var theta = Math.acos(2 * v - 1);
  105976. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  105977. var randY = randRadius * Math.cos(theta);
  105978. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  105979. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  105980. };
  105981. /**
  105982. * Clones the current emitter and returns a copy of it
  105983. * @returns the new emitter
  105984. */
  105985. SphereParticleEmitter.prototype.clone = function () {
  105986. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  105987. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  105988. return newOne;
  105989. };
  105990. /**
  105991. * Called by the GPUParticleSystem to setup the update shader
  105992. * @param effect defines the update shader
  105993. */
  105994. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  105995. effect.setFloat("radius", this.radius);
  105996. effect.setFloat("radiusRange", this.radiusRange);
  105997. effect.setFloat("directionRandomizer", this.directionRandomizer);
  105998. };
  105999. /**
  106000. * Returns a string to use to update the GPU particles update shader
  106001. * @returns a string containng the defines string
  106002. */
  106003. SphereParticleEmitter.prototype.getEffectDefines = function () {
  106004. return "#define SPHEREEMITTER";
  106005. };
  106006. /**
  106007. * Returns the string "SphereParticleEmitter"
  106008. * @returns a string containing the class name
  106009. */
  106010. SphereParticleEmitter.prototype.getClassName = function () {
  106011. return "SphereParticleEmitter";
  106012. };
  106013. /**
  106014. * Serializes the particle system to a JSON object.
  106015. * @returns the JSON object
  106016. */
  106017. SphereParticleEmitter.prototype.serialize = function () {
  106018. var serializationObject = {};
  106019. serializationObject.type = this.getClassName();
  106020. serializationObject.radius = this.radius;
  106021. serializationObject.radiusRange = this.radiusRange;
  106022. serializationObject.directionRandomizer = this.directionRandomizer;
  106023. return serializationObject;
  106024. };
  106025. /**
  106026. * Parse properties from a JSON object
  106027. * @param serializationObject defines the JSON object
  106028. */
  106029. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  106030. this.radius = serializationObject.radius;
  106031. this.radiusRange = serializationObject.radiusRange;
  106032. this.directionRandomizer = serializationObject.directionRandomizer;
  106033. };
  106034. return SphereParticleEmitter;
  106035. }());
  106036. /**
  106037. * Particle emitter emitting particles from the inside of a sphere.
  106038. * It emits the particles randomly between two vectors.
  106039. */
  106040. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  106041. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  106042. /**
  106043. * Creates a new instance SphereDirectedParticleEmitter
  106044. * @param radius the radius of the emission sphere (1 by default)
  106045. * @param direction1 the min limit of the emission direction (up vector by default)
  106046. * @param direction2 the max limit of the emission direction (up vector by default)
  106047. */
  106048. function SphereDirectedParticleEmitter(radius,
  106049. /**
  106050. * The min limit of the emission direction.
  106051. */
  106052. direction1,
  106053. /**
  106054. * The max limit of the emission direction.
  106055. */
  106056. direction2) {
  106057. if (radius === void 0) { radius = 1; }
  106058. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106059. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106060. var _this = _super.call(this, radius) || this;
  106061. _this.direction1 = direction1;
  106062. _this.direction2 = direction2;
  106063. return _this;
  106064. }
  106065. /**
  106066. * Called by the particle System when the direction is computed for the created particle.
  106067. * @param worldMatrix is the world matrix of the particle system
  106068. * @param directionToUpdate is the direction vector to update with the result
  106069. * @param particle is the particle we are computed the direction for
  106070. */
  106071. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106072. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  106073. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  106074. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  106075. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  106076. };
  106077. /**
  106078. * Clones the current emitter and returns a copy of it
  106079. * @returns the new emitter
  106080. */
  106081. SphereDirectedParticleEmitter.prototype.clone = function () {
  106082. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  106083. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  106084. return newOne;
  106085. };
  106086. /**
  106087. * Called by the GPUParticleSystem to setup the update shader
  106088. * @param effect defines the update shader
  106089. */
  106090. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  106091. effect.setFloat("radius", this.radius);
  106092. effect.setFloat("radiusRange", this.radiusRange);
  106093. effect.setVector3("direction1", this.direction1);
  106094. effect.setVector3("direction2", this.direction2);
  106095. };
  106096. /**
  106097. * Returns a string to use to update the GPU particles update shader
  106098. * @returns a string containng the defines string
  106099. */
  106100. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  106101. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  106102. };
  106103. /**
  106104. * Returns the string "SphereDirectedParticleEmitter"
  106105. * @returns a string containing the class name
  106106. */
  106107. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  106108. return "SphereDirectedParticleEmitter";
  106109. };
  106110. /**
  106111. * Serializes the particle system to a JSON object.
  106112. * @returns the JSON object
  106113. */
  106114. SphereDirectedParticleEmitter.prototype.serialize = function () {
  106115. var serializationObject = _super.prototype.serialize.call(this);
  106116. serializationObject.direction1 = this.direction1.asArray();
  106117. serializationObject.direction2 = this.direction2.asArray();
  106118. return serializationObject;
  106119. };
  106120. /**
  106121. * Parse properties from a JSON object
  106122. * @param serializationObject defines the JSON object
  106123. */
  106124. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  106125. _super.prototype.parse.call(this, serializationObject);
  106126. this.direction1.copyFrom(serializationObject.direction1);
  106127. this.direction2.copyFrom(serializationObject.direction2);
  106128. };
  106129. return SphereDirectedParticleEmitter;
  106130. }(SphereParticleEmitter));
  106131. /***/ }),
  106132. /***/ "./Particles/baseParticleSystem.ts":
  106133. /*!*****************************************!*\
  106134. !*** ./Particles/baseParticleSystem.ts ***!
  106135. \*****************************************/
  106136. /*! exports provided: BaseParticleSystem */
  106137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106138. "use strict";
  106139. __webpack_require__.r(__webpack_exports__);
  106140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  106141. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106142. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  106143. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  106144. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  106145. /**
  106146. * This represents the base class for particle system in Babylon.
  106147. * 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.
  106148. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  106149. * @example https://doc.babylonjs.com/babylon101/particles
  106150. */
  106151. var BaseParticleSystem = /** @class */ (function () {
  106152. /**
  106153. * Instantiates a particle system.
  106154. * 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.
  106155. * @param name The name of the particle system
  106156. */
  106157. function BaseParticleSystem(name) {
  106158. /**
  106159. * List of animations used by the particle system.
  106160. */
  106161. this.animations = [];
  106162. /**
  106163. * The rendering group used by the Particle system to chose when to render.
  106164. */
  106165. this.renderingGroupId = 0;
  106166. /**
  106167. * The emitter represents the Mesh or position we are attaching the particle system to.
  106168. */
  106169. this.emitter = null;
  106170. /**
  106171. * The maximum number of particles to emit per frame
  106172. */
  106173. this.emitRate = 10;
  106174. /**
  106175. * If you want to launch only a few particles at once, that can be done, as well.
  106176. */
  106177. this.manualEmitCount = -1;
  106178. /**
  106179. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  106180. */
  106181. this.updateSpeed = 0.01;
  106182. /**
  106183. * The amount of time the particle system is running (depends of the overall update speed).
  106184. */
  106185. this.targetStopDuration = 0;
  106186. /**
  106187. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  106188. */
  106189. this.disposeOnStop = false;
  106190. /**
  106191. * Minimum power of emitting particles.
  106192. */
  106193. this.minEmitPower = 1;
  106194. /**
  106195. * Maximum power of emitting particles.
  106196. */
  106197. this.maxEmitPower = 1;
  106198. /**
  106199. * Minimum life time of emitting particles.
  106200. */
  106201. this.minLifeTime = 1;
  106202. /**
  106203. * Maximum life time of emitting particles.
  106204. */
  106205. this.maxLifeTime = 1;
  106206. /**
  106207. * Minimum Size of emitting particles.
  106208. */
  106209. this.minSize = 1;
  106210. /**
  106211. * Maximum Size of emitting particles.
  106212. */
  106213. this.maxSize = 1;
  106214. /**
  106215. * Minimum scale of emitting particles on X axis.
  106216. */
  106217. this.minScaleX = 1;
  106218. /**
  106219. * Maximum scale of emitting particles on X axis.
  106220. */
  106221. this.maxScaleX = 1;
  106222. /**
  106223. * Minimum scale of emitting particles on Y axis.
  106224. */
  106225. this.minScaleY = 1;
  106226. /**
  106227. * Maximum scale of emitting particles on Y axis.
  106228. */
  106229. this.maxScaleY = 1;
  106230. /**
  106231. * Gets or sets the minimal initial rotation in radians.
  106232. */
  106233. this.minInitialRotation = 0;
  106234. /**
  106235. * Gets or sets the maximal initial rotation in radians.
  106236. */
  106237. this.maxInitialRotation = 0;
  106238. /**
  106239. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  106240. */
  106241. this.minAngularSpeed = 0;
  106242. /**
  106243. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  106244. */
  106245. this.maxAngularSpeed = 0;
  106246. /**
  106247. * The layer mask we are rendering the particles through.
  106248. */
  106249. this.layerMask = 0x0FFFFFFF;
  106250. /**
  106251. * This can help using your own shader to render the particle system.
  106252. * The according effect will be created
  106253. */
  106254. this.customShader = null;
  106255. /**
  106256. * By default particle system starts as soon as they are created. This prevents the
  106257. * automatic start to happen and let you decide when to start emitting particles.
  106258. */
  106259. this.preventAutoStart = false;
  106260. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  106261. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  106262. /**
  106263. * Callback triggered when the particle animation is ending.
  106264. */
  106265. this.onAnimationEnd = null;
  106266. /**
  106267. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  106268. */
  106269. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  106270. /**
  106271. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106272. * to override the particles.
  106273. */
  106274. this.forceDepthWrite = false;
  106275. /** 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 */
  106276. this.preWarmCycles = 0;
  106277. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  106278. this.preWarmStepOffset = 1;
  106279. /**
  106280. * 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)
  106281. */
  106282. this.spriteCellChangeSpeed = 1;
  106283. /**
  106284. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  106285. */
  106286. this.startSpriteCellID = 0;
  106287. /**
  106288. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  106289. */
  106290. this.endSpriteCellID = 0;
  106291. /**
  106292. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  106293. */
  106294. this.spriteCellWidth = 0;
  106295. /**
  106296. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  106297. */
  106298. this.spriteCellHeight = 0;
  106299. /**
  106300. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  106301. */
  106302. this.spriteRandomStartCell = false;
  106303. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  106304. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  106305. /**
  106306. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  106307. */
  106308. this.beginAnimationOnStart = false;
  106309. /**
  106310. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  106311. */
  106312. this.beginAnimationFrom = 0;
  106313. /**
  106314. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  106315. */
  106316. this.beginAnimationTo = 60;
  106317. /**
  106318. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  106319. */
  106320. this.beginAnimationLoop = false;
  106321. /**
  106322. * Gets or sets a world offset applied to all particles
  106323. */
  106324. this.worldOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  106325. /**
  106326. * You can use gravity if you want to give an orientation to your particles.
  106327. */
  106328. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106329. this._colorGradients = null;
  106330. this._sizeGradients = null;
  106331. this._lifeTimeGradients = null;
  106332. this._angularSpeedGradients = null;
  106333. this._velocityGradients = null;
  106334. this._limitVelocityGradients = null;
  106335. this._dragGradients = null;
  106336. this._emitRateGradients = null;
  106337. this._startSizeGradients = null;
  106338. this._rampGradients = null;
  106339. this._colorRemapGradients = null;
  106340. this._alphaRemapGradients = null;
  106341. /**
  106342. * Defines the delay in milliseconds before starting the system (0 by default)
  106343. */
  106344. this.startDelay = 0;
  106345. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  106346. this.limitVelocityDamping = 0.4;
  106347. /**
  106348. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  106349. */
  106350. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  106351. /**
  106352. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  106353. */
  106354. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  106355. /**
  106356. * Color the particle will have at the end of its lifetime
  106357. */
  106358. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  106359. /**
  106360. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  106361. */
  106362. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  106363. /** @hidden */
  106364. this._isSubEmitter = false;
  106365. /**
  106366. * Gets or sets the billboard mode to use when isBillboardBased = true.
  106367. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  106368. */
  106369. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  106370. this._isBillboardBased = true;
  106371. /**
  106372. * Local cache of defines for image processing.
  106373. */
  106374. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  106375. this.id = name;
  106376. this.name = name;
  106377. }
  106378. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  106379. /**
  106380. * Gets or sets a texture used to add random noise to particle positions
  106381. */
  106382. get: function () {
  106383. return this._noiseTexture;
  106384. },
  106385. set: function (value) {
  106386. if (this._noiseTexture === value) {
  106387. return;
  106388. }
  106389. this._noiseTexture = value;
  106390. this._reset();
  106391. },
  106392. enumerable: true,
  106393. configurable: true
  106394. });
  106395. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  106396. /**
  106397. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  106398. */
  106399. get: function () {
  106400. return this._isAnimationSheetEnabled;
  106401. },
  106402. set: function (value) {
  106403. if (this._isAnimationSheetEnabled == value) {
  106404. return;
  106405. }
  106406. this._isAnimationSheetEnabled = value;
  106407. this._reset();
  106408. },
  106409. enumerable: true,
  106410. configurable: true
  106411. });
  106412. /**
  106413. * Get hosting scene
  106414. * @returns the scene
  106415. */
  106416. BaseParticleSystem.prototype.getScene = function () {
  106417. return this._scene;
  106418. };
  106419. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  106420. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  106421. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  106422. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  106423. };
  106424. /**
  106425. * Gets the current list of drag gradients.
  106426. * You must use addDragGradient and removeDragGradient to udpate this list
  106427. * @returns the list of drag gradients
  106428. */
  106429. BaseParticleSystem.prototype.getDragGradients = function () {
  106430. return this._dragGradients;
  106431. };
  106432. /**
  106433. * Gets the current list of limit velocity gradients.
  106434. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  106435. * @returns the list of limit velocity gradients
  106436. */
  106437. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  106438. return this._limitVelocityGradients;
  106439. };
  106440. /**
  106441. * Gets the current list of color gradients.
  106442. * You must use addColorGradient and removeColorGradient to udpate this list
  106443. * @returns the list of color gradients
  106444. */
  106445. BaseParticleSystem.prototype.getColorGradients = function () {
  106446. return this._colorGradients;
  106447. };
  106448. /**
  106449. * Gets the current list of size gradients.
  106450. * You must use addSizeGradient and removeSizeGradient to udpate this list
  106451. * @returns the list of size gradients
  106452. */
  106453. BaseParticleSystem.prototype.getSizeGradients = function () {
  106454. return this._sizeGradients;
  106455. };
  106456. /**
  106457. * Gets the current list of color remap gradients.
  106458. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  106459. * @returns the list of color remap gradients
  106460. */
  106461. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  106462. return this._colorRemapGradients;
  106463. };
  106464. /**
  106465. * Gets the current list of alpha remap gradients.
  106466. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  106467. * @returns the list of alpha remap gradients
  106468. */
  106469. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  106470. return this._alphaRemapGradients;
  106471. };
  106472. /**
  106473. * Gets the current list of life time gradients.
  106474. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  106475. * @returns the list of life time gradients
  106476. */
  106477. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  106478. return this._lifeTimeGradients;
  106479. };
  106480. /**
  106481. * Gets the current list of angular speed gradients.
  106482. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  106483. * @returns the list of angular speed gradients
  106484. */
  106485. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  106486. return this._angularSpeedGradients;
  106487. };
  106488. /**
  106489. * Gets the current list of velocity gradients.
  106490. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  106491. * @returns the list of velocity gradients
  106492. */
  106493. BaseParticleSystem.prototype.getVelocityGradients = function () {
  106494. return this._velocityGradients;
  106495. };
  106496. /**
  106497. * Gets the current list of start size gradients.
  106498. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  106499. * @returns the list of start size gradients
  106500. */
  106501. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  106502. return this._startSizeGradients;
  106503. };
  106504. /**
  106505. * Gets the current list of emit rate gradients.
  106506. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  106507. * @returns the list of emit rate gradients
  106508. */
  106509. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  106510. return this._emitRateGradients;
  106511. };
  106512. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  106513. /**
  106514. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106515. * This only works when particleEmitterTyps is a BoxParticleEmitter
  106516. */
  106517. get: function () {
  106518. if (this.particleEmitterType.direction1) {
  106519. return this.particleEmitterType.direction1;
  106520. }
  106521. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106522. },
  106523. set: function (value) {
  106524. if (this.particleEmitterType.direction1) {
  106525. this.particleEmitterType.direction1 = value;
  106526. }
  106527. },
  106528. enumerable: true,
  106529. configurable: true
  106530. });
  106531. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  106532. /**
  106533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  106535. */
  106536. get: function () {
  106537. if (this.particleEmitterType.direction2) {
  106538. return this.particleEmitterType.direction2;
  106539. }
  106540. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106541. },
  106542. set: function (value) {
  106543. if (this.particleEmitterType.direction2) {
  106544. this.particleEmitterType.direction2 = value;
  106545. }
  106546. },
  106547. enumerable: true,
  106548. configurable: true
  106549. });
  106550. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  106551. /**
  106552. * 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.
  106553. * This only works when particleEmitterTyps is a BoxParticleEmitter
  106554. */
  106555. get: function () {
  106556. if (this.particleEmitterType.minEmitBox) {
  106557. return this.particleEmitterType.minEmitBox;
  106558. }
  106559. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106560. },
  106561. set: function (value) {
  106562. if (this.particleEmitterType.minEmitBox) {
  106563. this.particleEmitterType.minEmitBox = value;
  106564. }
  106565. },
  106566. enumerable: true,
  106567. configurable: true
  106568. });
  106569. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  106570. /**
  106571. * 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.
  106572. * This only works when particleEmitterTyps is a BoxParticleEmitter
  106573. */
  106574. get: function () {
  106575. if (this.particleEmitterType.maxEmitBox) {
  106576. return this.particleEmitterType.maxEmitBox;
  106577. }
  106578. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106579. },
  106580. set: function (value) {
  106581. if (this.particleEmitterType.maxEmitBox) {
  106582. this.particleEmitterType.maxEmitBox = value;
  106583. }
  106584. },
  106585. enumerable: true,
  106586. configurable: true
  106587. });
  106588. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  106589. /**
  106590. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  106591. */
  106592. get: function () {
  106593. return this._isBillboardBased;
  106594. },
  106595. set: function (value) {
  106596. if (this._isBillboardBased === value) {
  106597. return;
  106598. }
  106599. this._isBillboardBased = value;
  106600. this._reset();
  106601. },
  106602. enumerable: true,
  106603. configurable: true
  106604. });
  106605. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  106606. /**
  106607. * Gets the image processing configuration used either in this material.
  106608. */
  106609. get: function () {
  106610. return this._imageProcessingConfiguration;
  106611. },
  106612. /**
  106613. * Sets the Default image processing configuration used either in the this material.
  106614. *
  106615. * If sets to null, the scene one is in use.
  106616. */
  106617. set: function (value) {
  106618. this._attachImageProcessingConfiguration(value);
  106619. },
  106620. enumerable: true,
  106621. configurable: true
  106622. });
  106623. /**
  106624. * Attaches a new image processing configuration to the Standard Material.
  106625. * @param configuration
  106626. */
  106627. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  106628. if (configuration === this._imageProcessingConfiguration) {
  106629. return;
  106630. }
  106631. // Pick the scene configuration if needed.
  106632. if (!configuration) {
  106633. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  106634. }
  106635. else {
  106636. this._imageProcessingConfiguration = configuration;
  106637. }
  106638. };
  106639. /** @hidden */
  106640. BaseParticleSystem.prototype._reset = function () {
  106641. };
  106642. /** @hidden */
  106643. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  106644. if (!gradients) {
  106645. return this;
  106646. }
  106647. var index = 0;
  106648. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  106649. var valueGradient = gradients_1[_i];
  106650. if (valueGradient.gradient === gradient) {
  106651. gradients.splice(index, 1);
  106652. break;
  106653. }
  106654. index++;
  106655. }
  106656. if (texture) {
  106657. texture.dispose();
  106658. }
  106659. return this;
  106660. };
  106661. /**
  106662. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  106663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  106664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  106665. * @returns the emitter
  106666. */
  106667. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  106668. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  106669. particleEmitter.direction1 = direction1;
  106670. particleEmitter.direction2 = direction2;
  106671. this.particleEmitterType = particleEmitter;
  106672. return particleEmitter;
  106673. };
  106674. /**
  106675. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  106676. * @param radius The radius of the hemisphere to emit from
  106677. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  106678. * @returns the emitter
  106679. */
  106680. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  106681. if (radius === void 0) { radius = 1; }
  106682. if (radiusRange === void 0) { radiusRange = 1; }
  106683. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  106684. this.particleEmitterType = particleEmitter;
  106685. return particleEmitter;
  106686. };
  106687. /**
  106688. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  106689. * @param radius The radius of the sphere to emit from
  106690. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  106691. * @returns the emitter
  106692. */
  106693. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  106694. if (radius === void 0) { radius = 1; }
  106695. if (radiusRange === void 0) { radiusRange = 1; }
  106696. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  106697. this.particleEmitterType = particleEmitter;
  106698. return particleEmitter;
  106699. };
  106700. /**
  106701. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  106702. * @param radius The radius of the sphere to emit from
  106703. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  106704. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  106705. * @returns the emitter
  106706. */
  106707. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  106708. if (radius === void 0) { radius = 1; }
  106709. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  106710. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  106711. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  106712. this.particleEmitterType = particleEmitter;
  106713. return particleEmitter;
  106714. };
  106715. /**
  106716. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  106717. * @param radius The radius of the emission cylinder
  106718. * @param height The height of the emission cylinder
  106719. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  106720. * @param directionRandomizer How much to randomize the particle direction [0-1]
  106721. * @returns the emitter
  106722. */
  106723. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  106724. if (radius === void 0) { radius = 1; }
  106725. if (height === void 0) { height = 1; }
  106726. if (radiusRange === void 0) { radiusRange = 1; }
  106727. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  106728. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  106729. this.particleEmitterType = particleEmitter;
  106730. return particleEmitter;
  106731. };
  106732. /**
  106733. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  106734. * @param radius The radius of the cylinder to emit from
  106735. * @param height The height of the emission cylinder
  106736. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  106738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  106739. * @returns the emitter
  106740. */
  106741. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  106742. if (radius === void 0) { radius = 1; }
  106743. if (height === void 0) { height = 1; }
  106744. if (radiusRange === void 0) { radiusRange = 1; }
  106745. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  106746. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  106747. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  106748. this.particleEmitterType = particleEmitter;
  106749. return particleEmitter;
  106750. };
  106751. /**
  106752. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  106753. * @param radius The radius of the cone to emit from
  106754. * @param angle The base angle of the cone
  106755. * @returns the emitter
  106756. */
  106757. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  106758. if (radius === void 0) { radius = 1; }
  106759. if (angle === void 0) { angle = Math.PI / 4; }
  106760. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  106761. this.particleEmitterType = particleEmitter;
  106762. return particleEmitter;
  106763. };
  106764. /**
  106765. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  106766. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  106767. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  106768. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  106769. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  106770. * @returns the emitter
  106771. */
  106772. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  106773. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  106774. this.particleEmitterType = particleEmitter;
  106775. this.direction1 = direction1;
  106776. this.direction2 = direction2;
  106777. this.minEmitBox = minEmitBox;
  106778. this.maxEmitBox = maxEmitBox;
  106779. return particleEmitter;
  106780. };
  106781. /**
  106782. * Source color is added to the destination color without alpha affecting the result
  106783. */
  106784. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  106785. /**
  106786. * Blend current color and particle color using particle’s alpha
  106787. */
  106788. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  106789. /**
  106790. * Add current color and particle color multiplied by particle’s alpha
  106791. */
  106792. BaseParticleSystem.BLENDMODE_ADD = 2;
  106793. /**
  106794. * Multiply current color with particle color
  106795. */
  106796. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  106797. /**
  106798. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  106799. */
  106800. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  106801. return BaseParticleSystem;
  106802. }());
  106803. /***/ }),
  106804. /***/ "./Particles/gpuParticleSystem.ts":
  106805. /*!****************************************!*\
  106806. !*** ./Particles/gpuParticleSystem.ts ***!
  106807. \****************************************/
  106808. /*! exports provided: GPUParticleSystem */
  106809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106810. "use strict";
  106811. __webpack_require__.r(__webpack_exports__);
  106812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  106813. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  106814. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  106815. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  106816. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106817. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106818. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  106819. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  106820. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  106821. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  106822. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  106823. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  106824. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  106825. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  106826. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  106827. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  106828. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  106829. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106830. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106831. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  106832. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  106833. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  106834. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  106835. /**
  106836. * This represents a GPU particle system in Babylon
  106837. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106838. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106839. */
  106840. var GPUParticleSystem = /** @class */ (function (_super) {
  106841. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  106842. /**
  106843. * Instantiates a GPU particle system.
  106844. * 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.
  106845. * @param name The name of the particle system
  106846. * @param options The options used to create the system
  106847. * @param scene The scene the particle system belongs to
  106848. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  106849. */
  106850. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  106851. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106852. var _this = _super.call(this, name) || this;
  106853. /**
  106854. * The layer mask we are rendering the particles through.
  106855. */
  106856. _this.layerMask = 0x0FFFFFFF;
  106857. _this._accumulatedCount = 0;
  106858. _this._targetIndex = 0;
  106859. _this._currentRenderId = -1;
  106860. _this._started = false;
  106861. _this._stopped = false;
  106862. _this._timeDelta = 0;
  106863. _this._actualFrame = 0;
  106864. _this._rawTextureWidth = 256;
  106865. /**
  106866. * An event triggered when the system is disposed.
  106867. */
  106868. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  106869. /**
  106870. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106871. * to override the particles.
  106872. */
  106873. _this.forceDepthWrite = false;
  106874. _this._preWarmDone = false;
  106875. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  106876. // Setup the default processing configuration to the scene.
  106877. _this._attachImageProcessingConfiguration(null);
  106878. _this._engine = _this._scene.getEngine();
  106879. if (!options.randomTextureSize) {
  106880. delete options.randomTextureSize;
  106881. }
  106882. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  106883. var optionsAsNumber = options;
  106884. if (isFinite(optionsAsNumber)) {
  106885. fullOptions.capacity = optionsAsNumber;
  106886. }
  106887. _this._capacity = fullOptions.capacity;
  106888. _this._activeCount = fullOptions.capacity;
  106889. _this._currentActiveCount = 0;
  106890. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  106891. _this._scene.particleSystems.push(_this);
  106892. _this._updateEffectOptions = {
  106893. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  106894. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  106895. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  106896. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  106897. uniformBuffersNames: [],
  106898. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  106899. defines: "",
  106900. fallbacks: null,
  106901. onCompiled: null,
  106902. onError: null,
  106903. indexParameters: null,
  106904. maxSimultaneousLights: 0,
  106905. transformFeedbackVaryings: []
  106906. };
  106907. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  106908. // Random data
  106909. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  106910. var d = [];
  106911. for (var i = 0; i < maxTextureSize; ++i) {
  106912. d.push(Math.random());
  106913. d.push(Math.random());
  106914. d.push(Math.random());
  106915. d.push(Math.random());
  106916. }
  106917. _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);
  106918. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  106919. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  106920. d = [];
  106921. for (var i = 0; i < maxTextureSize; ++i) {
  106922. d.push(Math.random());
  106923. d.push(Math.random());
  106924. d.push(Math.random());
  106925. d.push(Math.random());
  106926. }
  106927. _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);
  106928. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  106929. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  106930. _this._randomTextureSize = maxTextureSize;
  106931. return _this;
  106932. }
  106933. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  106934. /**
  106935. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106936. */
  106937. get: function () {
  106938. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  106939. return false;
  106940. }
  106941. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  106942. },
  106943. enumerable: true,
  106944. configurable: true
  106945. });
  106946. /**
  106947. * Gets the maximum number of particles active at the same time.
  106948. * @returns The max number of active particles.
  106949. */
  106950. GPUParticleSystem.prototype.getCapacity = function () {
  106951. return this._capacity;
  106952. };
  106953. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  106954. /**
  106955. * Gets or set the number of active particles
  106956. */
  106957. get: function () {
  106958. return this._activeCount;
  106959. },
  106960. set: function (value) {
  106961. this._activeCount = Math.min(value, this._capacity);
  106962. },
  106963. enumerable: true,
  106964. configurable: true
  106965. });
  106966. /**
  106967. * Is this system ready to be used/rendered
  106968. * @return true if the system is ready
  106969. */
  106970. GPUParticleSystem.prototype.isReady = function () {
  106971. if (!this._updateEffect) {
  106972. this._recreateUpdateEffect();
  106973. this._recreateRenderEffect();
  106974. return false;
  106975. }
  106976. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  106977. return false;
  106978. }
  106979. return true;
  106980. };
  106981. /**
  106982. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106983. * @returns True if it has been started, otherwise false.
  106984. */
  106985. GPUParticleSystem.prototype.isStarted = function () {
  106986. return this._started;
  106987. };
  106988. /**
  106989. * Starts the particle system and begins to emit
  106990. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106991. */
  106992. GPUParticleSystem.prototype.start = function (delay) {
  106993. var _this = this;
  106994. if (delay === void 0) { delay = this.startDelay; }
  106995. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  106996. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  106997. }
  106998. if (delay) {
  106999. setTimeout(function () {
  107000. _this.start(0);
  107001. }, delay);
  107002. return;
  107003. }
  107004. this._started = true;
  107005. this._stopped = false;
  107006. this._preWarmDone = false;
  107007. // Animations
  107008. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  107009. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  107010. }
  107011. };
  107012. /**
  107013. * Stops the particle system.
  107014. */
  107015. GPUParticleSystem.prototype.stop = function () {
  107016. this._stopped = true;
  107017. };
  107018. /**
  107019. * Remove all active particles
  107020. */
  107021. GPUParticleSystem.prototype.reset = function () {
  107022. this._releaseBuffers();
  107023. this._releaseVAOs();
  107024. this._currentActiveCount = 0;
  107025. this._targetIndex = 0;
  107026. };
  107027. /**
  107028. * Returns the string "GPUParticleSystem"
  107029. * @returns a string containing the class name
  107030. */
  107031. GPUParticleSystem.prototype.getClassName = function () {
  107032. return "GPUParticleSystem";
  107033. };
  107034. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  107035. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  107036. this._releaseBuffers();
  107037. return this;
  107038. };
  107039. /**
  107040. * Adds a new color gradient
  107041. * @param gradient defines the gradient to use (between 0 and 1)
  107042. * @param color1 defines the color to affect to the specified gradient
  107043. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  107044. * @returns the current particle system
  107045. */
  107046. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  107047. if (!this._colorGradients) {
  107048. this._colorGradients = [];
  107049. }
  107050. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  107051. colorGradient.gradient = gradient;
  107052. colorGradient.color1 = color1;
  107053. this._colorGradients.push(colorGradient);
  107054. this._colorGradients.sort(function (a, b) {
  107055. if (a.gradient < b.gradient) {
  107056. return -1;
  107057. }
  107058. else if (a.gradient > b.gradient) {
  107059. return 1;
  107060. }
  107061. return 0;
  107062. });
  107063. if (this._colorGradientsTexture) {
  107064. this._colorGradientsTexture.dispose();
  107065. this._colorGradientsTexture = null;
  107066. }
  107067. this._releaseBuffers();
  107068. return this;
  107069. };
  107070. /**
  107071. * Remove a specific color gradient
  107072. * @param gradient defines the gradient to remove
  107073. * @returns the current particle system
  107074. */
  107075. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  107076. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  107077. this._colorGradientsTexture = null;
  107078. return this;
  107079. };
  107080. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  107081. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  107082. valueGradient.gradient = gradient;
  107083. valueGradient.factor1 = factor;
  107084. factorGradients.push(valueGradient);
  107085. factorGradients.sort(function (a, b) {
  107086. if (a.gradient < b.gradient) {
  107087. return -1;
  107088. }
  107089. else if (a.gradient > b.gradient) {
  107090. return 1;
  107091. }
  107092. return 0;
  107093. });
  107094. this._releaseBuffers();
  107095. };
  107096. /**
  107097. * Adds a new size gradient
  107098. * @param gradient defines the gradient to use (between 0 and 1)
  107099. * @param factor defines the size factor to affect to the specified gradient
  107100. * @returns the current particle system
  107101. */
  107102. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  107103. if (!this._sizeGradients) {
  107104. this._sizeGradients = [];
  107105. }
  107106. this._addFactorGradient(this._sizeGradients, gradient, factor);
  107107. if (this._sizeGradientsTexture) {
  107108. this._sizeGradientsTexture.dispose();
  107109. this._sizeGradientsTexture = null;
  107110. }
  107111. this._releaseBuffers();
  107112. return this;
  107113. };
  107114. /**
  107115. * Remove a specific size gradient
  107116. * @param gradient defines the gradient to remove
  107117. * @returns the current particle system
  107118. */
  107119. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  107120. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  107121. this._sizeGradientsTexture = null;
  107122. return this;
  107123. };
  107124. /**
  107125. * Adds a new angular speed gradient
  107126. * @param gradient defines the gradient to use (between 0 and 1)
  107127. * @param factor defines the angular speed to affect to the specified gradient
  107128. * @returns the current particle system
  107129. */
  107130. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  107131. if (!this._angularSpeedGradients) {
  107132. this._angularSpeedGradients = [];
  107133. }
  107134. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  107135. if (this._angularSpeedGradientsTexture) {
  107136. this._angularSpeedGradientsTexture.dispose();
  107137. this._angularSpeedGradientsTexture = null;
  107138. }
  107139. this._releaseBuffers();
  107140. return this;
  107141. };
  107142. /**
  107143. * Remove a specific angular speed gradient
  107144. * @param gradient defines the gradient to remove
  107145. * @returns the current particle system
  107146. */
  107147. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  107148. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  107149. this._angularSpeedGradientsTexture = null;
  107150. return this;
  107151. };
  107152. /**
  107153. * Adds a new velocity gradient
  107154. * @param gradient defines the gradient to use (between 0 and 1)
  107155. * @param factor defines the velocity to affect to the specified gradient
  107156. * @returns the current particle system
  107157. */
  107158. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  107159. if (!this._velocityGradients) {
  107160. this._velocityGradients = [];
  107161. }
  107162. this._addFactorGradient(this._velocityGradients, gradient, factor);
  107163. if (this._velocityGradientsTexture) {
  107164. this._velocityGradientsTexture.dispose();
  107165. this._velocityGradientsTexture = null;
  107166. }
  107167. this._releaseBuffers();
  107168. return this;
  107169. };
  107170. /**
  107171. * Remove a specific velocity gradient
  107172. * @param gradient defines the gradient to remove
  107173. * @returns the current particle system
  107174. */
  107175. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  107176. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  107177. this._velocityGradientsTexture = null;
  107178. return this;
  107179. };
  107180. /**
  107181. * Adds a new limit velocity gradient
  107182. * @param gradient defines the gradient to use (between 0 and 1)
  107183. * @param factor defines the limit velocity value to affect to the specified gradient
  107184. * @returns the current particle system
  107185. */
  107186. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  107187. if (!this._limitVelocityGradients) {
  107188. this._limitVelocityGradients = [];
  107189. }
  107190. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  107191. if (this._limitVelocityGradientsTexture) {
  107192. this._limitVelocityGradientsTexture.dispose();
  107193. this._limitVelocityGradientsTexture = null;
  107194. }
  107195. this._releaseBuffers();
  107196. return this;
  107197. };
  107198. /**
  107199. * Remove a specific limit velocity gradient
  107200. * @param gradient defines the gradient to remove
  107201. * @returns the current particle system
  107202. */
  107203. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  107204. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  107205. this._limitVelocityGradientsTexture = null;
  107206. return this;
  107207. };
  107208. /**
  107209. * Adds a new drag gradient
  107210. * @param gradient defines the gradient to use (between 0 and 1)
  107211. * @param factor defines the drag value to affect to the specified gradient
  107212. * @returns the current particle system
  107213. */
  107214. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  107215. if (!this._dragGradients) {
  107216. this._dragGradients = [];
  107217. }
  107218. this._addFactorGradient(this._dragGradients, gradient, factor);
  107219. if (this._dragGradientsTexture) {
  107220. this._dragGradientsTexture.dispose();
  107221. this._dragGradientsTexture = null;
  107222. }
  107223. this._releaseBuffers();
  107224. return this;
  107225. };
  107226. /**
  107227. * Remove a specific drag gradient
  107228. * @param gradient defines the gradient to remove
  107229. * @returns the current particle system
  107230. */
  107231. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  107232. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  107233. this._dragGradientsTexture = null;
  107234. return this;
  107235. };
  107236. /**
  107237. * Not supported by GPUParticleSystem
  107238. * @param gradient defines the gradient to use (between 0 and 1)
  107239. * @param factor defines the emit rate value to affect to the specified gradient
  107240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107241. * @returns the current particle system
  107242. */
  107243. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  107244. // Do nothing as emit rate is not supported by GPUParticleSystem
  107245. return this;
  107246. };
  107247. /**
  107248. * Not supported by GPUParticleSystem
  107249. * @param gradient defines the gradient to remove
  107250. * @returns the current particle system
  107251. */
  107252. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  107253. // Do nothing as emit rate is not supported by GPUParticleSystem
  107254. return this;
  107255. };
  107256. /**
  107257. * Not supported by GPUParticleSystem
  107258. * @param gradient defines the gradient to use (between 0 and 1)
  107259. * @param factor defines the start size value to affect to the specified gradient
  107260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107261. * @returns the current particle system
  107262. */
  107263. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  107264. // Do nothing as start size is not supported by GPUParticleSystem
  107265. return this;
  107266. };
  107267. /**
  107268. * Not supported by GPUParticleSystem
  107269. * @param gradient defines the gradient to remove
  107270. * @returns the current particle system
  107271. */
  107272. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  107273. // Do nothing as start size is not supported by GPUParticleSystem
  107274. return this;
  107275. };
  107276. /**
  107277. * Not supported by GPUParticleSystem
  107278. * @param gradient defines the gradient to use (between 0 and 1)
  107279. * @param min defines the color remap minimal range
  107280. * @param max defines the color remap maximal range
  107281. * @returns the current particle system
  107282. */
  107283. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  107284. // Do nothing as start size is not supported by GPUParticleSystem
  107285. return this;
  107286. };
  107287. /**
  107288. * Not supported by GPUParticleSystem
  107289. * @param gradient defines the gradient to remove
  107290. * @returns the current particle system
  107291. */
  107292. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  107293. // Do nothing as start size is not supported by GPUParticleSystem
  107294. return this;
  107295. };
  107296. /**
  107297. * Not supported by GPUParticleSystem
  107298. * @param gradient defines the gradient to use (between 0 and 1)
  107299. * @param min defines the alpha remap minimal range
  107300. * @param max defines the alpha remap maximal range
  107301. * @returns the current particle system
  107302. */
  107303. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  107304. // Do nothing as start size is not supported by GPUParticleSystem
  107305. return this;
  107306. };
  107307. /**
  107308. * Not supported by GPUParticleSystem
  107309. * @param gradient defines the gradient to remove
  107310. * @returns the current particle system
  107311. */
  107312. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  107313. // Do nothing as start size is not supported by GPUParticleSystem
  107314. return this;
  107315. };
  107316. /**
  107317. * Not supported by GPUParticleSystem
  107318. * @param gradient defines the gradient to use (between 0 and 1)
  107319. * @param color defines the color to affect to the specified gradient
  107320. * @returns the current particle system
  107321. */
  107322. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  107323. //Not supported by GPUParticleSystem
  107324. return this;
  107325. };
  107326. /**
  107327. * Not supported by GPUParticleSystem
  107328. * @param gradient defines the gradient to remove
  107329. * @returns the current particle system
  107330. */
  107331. GPUParticleSystem.prototype.removeRampGradient = function () {
  107332. //Not supported by GPUParticleSystem
  107333. return this;
  107334. };
  107335. /**
  107336. * Not supported by GPUParticleSystem
  107337. * @returns the list of ramp gradients
  107338. */
  107339. GPUParticleSystem.prototype.getRampGradients = function () {
  107340. return null;
  107341. };
  107342. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  107343. /**
  107344. * Not supported by GPUParticleSystem
  107345. * Gets or sets a boolean indicating that ramp gradients must be used
  107346. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107347. */
  107348. get: function () {
  107349. //Not supported by GPUParticleSystem
  107350. return false;
  107351. },
  107352. set: function (value) {
  107353. //Not supported by GPUParticleSystem
  107354. },
  107355. enumerable: true,
  107356. configurable: true
  107357. });
  107358. /**
  107359. * Not supported by GPUParticleSystem
  107360. * @param gradient defines the gradient to use (between 0 and 1)
  107361. * @param factor defines the life time factor to affect to the specified gradient
  107362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107363. * @returns the current particle system
  107364. */
  107365. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  107366. //Not supported by GPUParticleSystem
  107367. return this;
  107368. };
  107369. /**
  107370. * Not supported by GPUParticleSystem
  107371. * @param gradient defines the gradient to remove
  107372. * @returns the current particle system
  107373. */
  107374. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  107375. //Not supported by GPUParticleSystem
  107376. return this;
  107377. };
  107378. GPUParticleSystem.prototype._reset = function () {
  107379. this._releaseBuffers();
  107380. };
  107381. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  107382. var updateVertexBuffers = {};
  107383. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  107384. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  107385. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  107386. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  107387. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  107388. var offset = 12;
  107389. if (!this._colorGradientsTexture) {
  107390. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  107391. offset += 4;
  107392. }
  107393. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  107394. offset += 3;
  107395. if (!this._isBillboardBased) {
  107396. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  107397. offset += 3;
  107398. }
  107399. if (this._angularSpeedGradientsTexture) {
  107400. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  107401. offset += 1;
  107402. }
  107403. else {
  107404. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  107405. offset += 2;
  107406. }
  107407. if (this._isAnimationSheetEnabled) {
  107408. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  107409. offset += 1;
  107410. if (this.spriteRandomStartCell) {
  107411. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  107412. offset += 1;
  107413. }
  107414. }
  107415. if (this.noiseTexture) {
  107416. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  107417. offset += 3;
  107418. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  107419. offset += 3;
  107420. }
  107421. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  107422. this._engine.bindArrayBuffer(null);
  107423. return vao;
  107424. };
  107425. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  107426. var renderVertexBuffers = {};
  107427. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  107428. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  107429. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  107430. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  107431. var offset = 12;
  107432. if (!this._colorGradientsTexture) {
  107433. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  107434. offset += 4;
  107435. }
  107436. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  107437. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  107438. }
  107439. offset += 3; // Direction
  107440. if (!this._isBillboardBased) {
  107441. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  107442. offset += 3;
  107443. }
  107444. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  107445. if (this._angularSpeedGradientsTexture) {
  107446. offset++;
  107447. }
  107448. else {
  107449. offset += 2;
  107450. }
  107451. if (this._isAnimationSheetEnabled) {
  107452. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  107453. offset += 1;
  107454. if (this.spriteRandomStartCell) {
  107455. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  107456. offset += 1;
  107457. }
  107458. }
  107459. if (this.noiseTexture) {
  107460. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  107461. offset += 3;
  107462. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  107463. offset += 3;
  107464. }
  107465. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  107466. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  107467. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  107468. this._engine.bindArrayBuffer(null);
  107469. return vao;
  107470. };
  107471. GPUParticleSystem.prototype._initialize = function (force) {
  107472. if (force === void 0) { force = false; }
  107473. if (this._buffer0 && !force) {
  107474. return;
  107475. }
  107476. var engine = this._scene.getEngine();
  107477. var data = new Array();
  107478. this._attributesStrideSize = 21;
  107479. this._targetIndex = 0;
  107480. if (!this.isBillboardBased) {
  107481. this._attributesStrideSize += 3;
  107482. }
  107483. if (this._colorGradientsTexture) {
  107484. this._attributesStrideSize -= 4;
  107485. }
  107486. if (this._angularSpeedGradientsTexture) {
  107487. this._attributesStrideSize -= 1;
  107488. }
  107489. if (this._isAnimationSheetEnabled) {
  107490. this._attributesStrideSize += 1;
  107491. if (this.spriteRandomStartCell) {
  107492. this._attributesStrideSize += 1;
  107493. }
  107494. }
  107495. if (this.noiseTexture) {
  107496. this._attributesStrideSize += 6;
  107497. }
  107498. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  107499. // position
  107500. data.push(0.0);
  107501. data.push(0.0);
  107502. data.push(0.0);
  107503. // Age and life
  107504. data.push(0.0); // create the particle as a dead one to create a new one at start
  107505. data.push(0.0);
  107506. // Seed
  107507. data.push(Math.random());
  107508. data.push(Math.random());
  107509. data.push(Math.random());
  107510. data.push(Math.random());
  107511. // Size
  107512. data.push(0.0);
  107513. data.push(0.0);
  107514. data.push(0.0);
  107515. if (!this._colorGradientsTexture) {
  107516. // color
  107517. data.push(0.0);
  107518. data.push(0.0);
  107519. data.push(0.0);
  107520. data.push(0.0);
  107521. }
  107522. // direction
  107523. data.push(0.0);
  107524. data.push(0.0);
  107525. data.push(0.0);
  107526. if (!this.isBillboardBased) {
  107527. // initialDirection
  107528. data.push(0.0);
  107529. data.push(0.0);
  107530. data.push(0.0);
  107531. }
  107532. // angle
  107533. data.push(0.0);
  107534. if (!this._angularSpeedGradientsTexture) {
  107535. data.push(0.0);
  107536. }
  107537. if (this._isAnimationSheetEnabled) {
  107538. data.push(0.0);
  107539. if (this.spriteRandomStartCell) {
  107540. data.push(0.0);
  107541. }
  107542. }
  107543. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  107544. data.push(Math.random());
  107545. data.push(Math.random());
  107546. data.push(Math.random());
  107547. data.push(Math.random());
  107548. data.push(Math.random());
  107549. data.push(Math.random());
  107550. }
  107551. }
  107552. // Sprite data
  107553. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  107554. -0.5, 0.5, 0, 1,
  107555. -0.5, -0.5, 0, 0,
  107556. 0.5, -0.5, 1, 0]);
  107557. // Buffers
  107558. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  107559. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  107560. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  107561. // Update VAO
  107562. this._updateVAO = [];
  107563. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  107564. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  107565. // Render VAO
  107566. this._renderVAO = [];
  107567. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  107568. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  107569. // Links
  107570. this._sourceBuffer = this._buffer0;
  107571. this._targetBuffer = this._buffer1;
  107572. };
  107573. /** @hidden */
  107574. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  107575. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  107576. if (this._isBillboardBased) {
  107577. defines += "\n#define BILLBOARD";
  107578. }
  107579. if (this._colorGradientsTexture) {
  107580. defines += "\n#define COLORGRADIENTS";
  107581. }
  107582. if (this._sizeGradientsTexture) {
  107583. defines += "\n#define SIZEGRADIENTS";
  107584. }
  107585. if (this._angularSpeedGradientsTexture) {
  107586. defines += "\n#define ANGULARSPEEDGRADIENTS";
  107587. }
  107588. if (this._velocityGradientsTexture) {
  107589. defines += "\n#define VELOCITYGRADIENTS";
  107590. }
  107591. if (this._limitVelocityGradientsTexture) {
  107592. defines += "\n#define LIMITVELOCITYGRADIENTS";
  107593. }
  107594. if (this._dragGradientsTexture) {
  107595. defines += "\n#define DRAGGRADIENTS";
  107596. }
  107597. if (this.isAnimationSheetEnabled) {
  107598. defines += "\n#define ANIMATESHEET";
  107599. if (this.spriteRandomStartCell) {
  107600. defines += "\n#define ANIMATESHEETRANDOMSTART";
  107601. }
  107602. }
  107603. if (this.noiseTexture) {
  107604. defines += "\n#define NOISE";
  107605. }
  107606. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  107607. return;
  107608. }
  107609. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  107610. if (!this._colorGradientsTexture) {
  107611. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  107612. }
  107613. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  107614. if (!this._isBillboardBased) {
  107615. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  107616. }
  107617. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  107618. if (this.isAnimationSheetEnabled) {
  107619. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  107620. if (this.spriteRandomStartCell) {
  107621. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  107622. }
  107623. }
  107624. if (this.noiseTexture) {
  107625. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  107626. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  107627. }
  107628. this._updateEffectOptions.defines = defines;
  107629. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  107630. };
  107631. /** @hidden */
  107632. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  107633. var defines = "";
  107634. if (this._scene.clipPlane) {
  107635. defines = "\n#define CLIPPLANE";
  107636. }
  107637. if (this._scene.clipPlane2) {
  107638. defines = "\n#define CLIPPLANE2";
  107639. }
  107640. if (this._scene.clipPlane3) {
  107641. defines = "\n#define CLIPPLANE3";
  107642. }
  107643. if (this._scene.clipPlane4) {
  107644. defines = "\n#define CLIPPLANE4";
  107645. }
  107646. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  107647. defines = "\n#define BLENDMULTIPLYMODE";
  107648. }
  107649. if (this._isBillboardBased) {
  107650. defines += "\n#define BILLBOARD";
  107651. switch (this.billboardMode) {
  107652. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  107653. defines += "\n#define BILLBOARDY";
  107654. break;
  107655. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  107656. defines += "\n#define BILLBOARDSTRETCHED";
  107657. break;
  107658. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  107659. default:
  107660. break;
  107661. }
  107662. }
  107663. if (this._colorGradientsTexture) {
  107664. defines += "\n#define COLORGRADIENTS";
  107665. }
  107666. if (this.isAnimationSheetEnabled) {
  107667. defines += "\n#define ANIMATESHEET";
  107668. }
  107669. if (this._imageProcessingConfiguration) {
  107670. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  107671. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  107672. }
  107673. if (this._renderEffect && this._renderEffect.defines === defines) {
  107674. return;
  107675. }
  107676. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  107677. var samplers = ["textureSampler", "colorGradientSampler"];
  107678. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  107679. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  107680. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  107681. }
  107682. 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);
  107683. };
  107684. /**
  107685. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107686. * @param preWarm defines if we are in the pre-warmimg phase
  107687. */
  107688. GPUParticleSystem.prototype.animate = function (preWarm) {
  107689. if (preWarm === void 0) { preWarm = false; }
  107690. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  107691. this._actualFrame += this._timeDelta;
  107692. if (!this._stopped) {
  107693. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  107694. this.stop();
  107695. }
  107696. }
  107697. };
  107698. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  107699. var texture = this[textureName];
  107700. if (!factorGradients || !factorGradients.length || texture) {
  107701. return;
  107702. }
  107703. var data = new Float32Array(this._rawTextureWidth);
  107704. for (var x = 0; x < this._rawTextureWidth; x++) {
  107705. var ratio = x / this._rawTextureWidth;
  107706. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  107707. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  107708. });
  107709. }
  107710. 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);
  107711. };
  107712. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  107713. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  107714. };
  107715. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  107716. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  107717. };
  107718. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  107719. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  107720. };
  107721. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  107722. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  107723. };
  107724. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  107725. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  107726. };
  107727. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  107728. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  107729. return;
  107730. }
  107731. var data = new Uint8Array(this._rawTextureWidth * 4);
  107732. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  107733. for (var x = 0; x < this._rawTextureWidth; x++) {
  107734. var ratio = x / this._rawTextureWidth;
  107735. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  107736. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  107737. data[x * 4] = tmpColor.r * 255;
  107738. data[x * 4 + 1] = tmpColor.g * 255;
  107739. data[x * 4 + 2] = tmpColor.b * 255;
  107740. data[x * 4 + 3] = tmpColor.a * 255;
  107741. });
  107742. }
  107743. 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);
  107744. };
  107745. /**
  107746. * Renders the particle system in its current state
  107747. * @param preWarm defines if the system should only update the particles but not render them
  107748. * @returns the current number of particles
  107749. */
  107750. GPUParticleSystem.prototype.render = function (preWarm) {
  107751. if (preWarm === void 0) { preWarm = false; }
  107752. if (!this._started) {
  107753. return 0;
  107754. }
  107755. this._createColorGradientTexture();
  107756. this._createSizeGradientTexture();
  107757. this._createAngularSpeedGradientTexture();
  107758. this._createVelocityGradientTexture();
  107759. this._createLimitVelocityGradientTexture();
  107760. this._createDragGradientTexture();
  107761. this._recreateUpdateEffect();
  107762. this._recreateRenderEffect();
  107763. if (!this.isReady()) {
  107764. return 0;
  107765. }
  107766. if (!preWarm) {
  107767. if (!this._preWarmDone && this.preWarmCycles) {
  107768. for (var index = 0; index < this.preWarmCycles; index++) {
  107769. this.animate(true);
  107770. this.render(true);
  107771. }
  107772. this._preWarmDone = true;
  107773. }
  107774. if (this._currentRenderId === this._scene.getFrameId()) {
  107775. return 0;
  107776. }
  107777. this._currentRenderId = this._scene.getFrameId();
  107778. }
  107779. // Get everything ready to render
  107780. this._initialize();
  107781. this._accumulatedCount += this.emitRate * this._timeDelta;
  107782. if (this._accumulatedCount > 1) {
  107783. var intPart = this._accumulatedCount | 0;
  107784. this._accumulatedCount -= intPart;
  107785. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  107786. }
  107787. if (!this._currentActiveCount) {
  107788. return 0;
  107789. }
  107790. // Enable update effect
  107791. this._engine.enableEffect(this._updateEffect);
  107792. this._engine.setState(false);
  107793. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  107794. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  107795. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  107796. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  107797. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  107798. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  107799. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  107800. if (!this._colorGradientsTexture) {
  107801. this._updateEffect.setDirectColor4("color1", this.color1);
  107802. this._updateEffect.setDirectColor4("color2", this.color2);
  107803. }
  107804. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  107805. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  107806. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  107807. this._updateEffect.setVector3("gravity", this.gravity);
  107808. if (this._sizeGradientsTexture) {
  107809. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  107810. }
  107811. if (this._angularSpeedGradientsTexture) {
  107812. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  107813. }
  107814. if (this._velocityGradientsTexture) {
  107815. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  107816. }
  107817. if (this._limitVelocityGradientsTexture) {
  107818. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  107819. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  107820. }
  107821. if (this._dragGradientsTexture) {
  107822. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  107823. }
  107824. if (this.particleEmitterType) {
  107825. this.particleEmitterType.applyToShader(this._updateEffect);
  107826. }
  107827. if (this._isAnimationSheetEnabled) {
  107828. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  107829. }
  107830. if (this.noiseTexture) {
  107831. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  107832. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  107833. }
  107834. var emitterWM;
  107835. if (this.emitter.position) {
  107836. var emitterMesh = this.emitter;
  107837. emitterWM = emitterMesh.getWorldMatrix();
  107838. }
  107839. else {
  107840. var emitterPosition = this.emitter;
  107841. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  107842. }
  107843. this._updateEffect.setMatrix("emitterWM", emitterWM);
  107844. // Bind source VAO
  107845. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  107846. // Update
  107847. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  107848. this._engine.setRasterizerState(false);
  107849. this._engine.beginTransformFeedback(true);
  107850. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  107851. this._engine.endTransformFeedback();
  107852. this._engine.setRasterizerState(true);
  107853. this._engine.bindTransformFeedbackBuffer(null);
  107854. if (!preWarm) {
  107855. // Enable render effect
  107856. this._engine.enableEffect(this._renderEffect);
  107857. var viewMatrix = this._scene.getViewMatrix();
  107858. this._renderEffect.setMatrix("view", viewMatrix);
  107859. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  107860. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  107861. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  107862. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  107863. if (this._colorGradientsTexture) {
  107864. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  107865. }
  107866. else {
  107867. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  107868. }
  107869. if (this._isAnimationSheetEnabled && this.particleTexture) {
  107870. var baseSize = this.particleTexture.getBaseSize();
  107871. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  107872. }
  107873. if (this._isBillboardBased) {
  107874. var camera = this._scene.activeCamera;
  107875. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  107876. }
  107877. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  107878. var invView = viewMatrix.clone();
  107879. invView.invert();
  107880. this._renderEffect.setMatrix("invView", invView);
  107881. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  107882. }
  107883. // image processing
  107884. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  107885. this._imageProcessingConfiguration.bind(this._renderEffect);
  107886. }
  107887. // Draw order
  107888. switch (this.blendMode) {
  107889. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  107890. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  107891. break;
  107892. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  107893. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  107894. break;
  107895. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  107896. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  107897. break;
  107898. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  107899. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  107900. break;
  107901. }
  107902. if (this.forceDepthWrite) {
  107903. this._engine.setDepthWrite(true);
  107904. }
  107905. // Bind source VAO
  107906. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  107907. // Render
  107908. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  107909. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  107910. }
  107911. // Switch VAOs
  107912. this._targetIndex++;
  107913. if (this._targetIndex === 2) {
  107914. this._targetIndex = 0;
  107915. }
  107916. // Switch buffers
  107917. var tmpBuffer = this._sourceBuffer;
  107918. this._sourceBuffer = this._targetBuffer;
  107919. this._targetBuffer = tmpBuffer;
  107920. return this._currentActiveCount;
  107921. };
  107922. /**
  107923. * Rebuilds the particle system
  107924. */
  107925. GPUParticleSystem.prototype.rebuild = function () {
  107926. this._initialize(true);
  107927. };
  107928. GPUParticleSystem.prototype._releaseBuffers = function () {
  107929. if (this._buffer0) {
  107930. this._buffer0.dispose();
  107931. this._buffer0 = null;
  107932. }
  107933. if (this._buffer1) {
  107934. this._buffer1.dispose();
  107935. this._buffer1 = null;
  107936. }
  107937. if (this._spriteBuffer) {
  107938. this._spriteBuffer.dispose();
  107939. this._spriteBuffer = null;
  107940. }
  107941. };
  107942. GPUParticleSystem.prototype._releaseVAOs = function () {
  107943. if (!this._updateVAO) {
  107944. return;
  107945. }
  107946. for (var index = 0; index < this._updateVAO.length; index++) {
  107947. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  107948. }
  107949. this._updateVAO = [];
  107950. for (var index = 0; index < this._renderVAO.length; index++) {
  107951. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  107952. }
  107953. this._renderVAO = [];
  107954. };
  107955. /**
  107956. * Disposes the particle system and free the associated resources
  107957. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107958. */
  107959. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  107960. if (disposeTexture === void 0) { disposeTexture = true; }
  107961. var index = this._scene.particleSystems.indexOf(this);
  107962. if (index > -1) {
  107963. this._scene.particleSystems.splice(index, 1);
  107964. }
  107965. this._releaseBuffers();
  107966. this._releaseVAOs();
  107967. if (this._colorGradientsTexture) {
  107968. this._colorGradientsTexture.dispose();
  107969. this._colorGradientsTexture = null;
  107970. }
  107971. if (this._sizeGradientsTexture) {
  107972. this._sizeGradientsTexture.dispose();
  107973. this._sizeGradientsTexture = null;
  107974. }
  107975. if (this._angularSpeedGradientsTexture) {
  107976. this._angularSpeedGradientsTexture.dispose();
  107977. this._angularSpeedGradientsTexture = null;
  107978. }
  107979. if (this._velocityGradientsTexture) {
  107980. this._velocityGradientsTexture.dispose();
  107981. this._velocityGradientsTexture = null;
  107982. }
  107983. if (this._limitVelocityGradientsTexture) {
  107984. this._limitVelocityGradientsTexture.dispose();
  107985. this._limitVelocityGradientsTexture = null;
  107986. }
  107987. if (this._dragGradientsTexture) {
  107988. this._dragGradientsTexture.dispose();
  107989. this._dragGradientsTexture = null;
  107990. }
  107991. if (this._randomTexture) {
  107992. this._randomTexture.dispose();
  107993. this._randomTexture = null;
  107994. }
  107995. if (this._randomTexture2) {
  107996. this._randomTexture2.dispose();
  107997. this._randomTexture2 = null;
  107998. }
  107999. if (disposeTexture && this.particleTexture) {
  108000. this.particleTexture.dispose();
  108001. this.particleTexture = null;
  108002. }
  108003. if (disposeTexture && this.noiseTexture) {
  108004. this.noiseTexture.dispose();
  108005. this.noiseTexture = null;
  108006. }
  108007. // Callback
  108008. this.onDisposeObservable.notifyObservers(this);
  108009. this.onDisposeObservable.clear();
  108010. };
  108011. /**
  108012. * Clones the particle system.
  108013. * @param name The name of the cloned object
  108014. * @param newEmitter The new emitter to use
  108015. * @returns the cloned particle system
  108016. */
  108017. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  108018. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  108019. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  108020. if (newEmitter === undefined) {
  108021. newEmitter = this.emitter;
  108022. }
  108023. result.emitter = newEmitter;
  108024. if (this.particleTexture) {
  108025. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  108026. }
  108027. return result;
  108028. };
  108029. /**
  108030. * Serializes the particle system to a JSON object.
  108031. * @returns the JSON object
  108032. */
  108033. GPUParticleSystem.prototype.serialize = function () {
  108034. var serializationObject = {};
  108035. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  108036. serializationObject.activeParticleCount = this.activeParticleCount;
  108037. return serializationObject;
  108038. };
  108039. /**
  108040. * Parses a JSON object to create a GPU particle system.
  108041. * @param parsedParticleSystem The JSON object to parse
  108042. * @param scene The scene to create the particle system in
  108043. * @param rootUrl The root url to use to load external dependencies like texture
  108044. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108045. * @returns the parsed GPU particle system
  108046. */
  108047. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  108048. if (doNotStart === void 0) { doNotStart = false; }
  108049. var name = parsedParticleSystem.name;
  108050. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  108051. if (parsedParticleSystem.activeParticleCount) {
  108052. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  108053. }
  108054. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  108055. // Auto start
  108056. if (parsedParticleSystem.preventAutoStart) {
  108057. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  108058. }
  108059. if (!doNotStart && !particleSystem.preventAutoStart) {
  108060. particleSystem.start();
  108061. }
  108062. return particleSystem;
  108063. };
  108064. return GPUParticleSystem;
  108065. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  108066. /***/ }),
  108067. /***/ "./Particles/index.ts":
  108068. /*!****************************!*\
  108069. !*** ./Particles/index.ts ***!
  108070. \****************************/
  108071. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  108072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108073. "use strict";
  108074. __webpack_require__.r(__webpack_exports__);
  108075. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  108076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  108077. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  108078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  108079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  108080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  108081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  108082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  108083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  108084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  108085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  108086. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  108087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  108088. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  108089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  108090. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  108091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  108092. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  108093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  108094. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  108095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  108096. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  108097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  108098. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  108099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  108100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  108101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  108102. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  108103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  108104. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  108105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  108106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  108107. /***/ }),
  108108. /***/ "./Particles/particle.ts":
  108109. /*!*******************************!*\
  108110. !*** ./Particles/particle.ts ***!
  108111. \*******************************/
  108112. /*! exports provided: Particle */
  108113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108114. "use strict";
  108115. __webpack_require__.r(__webpack_exports__);
  108116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  108117. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108118. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108119. /**
  108120. * A particle represents one of the element emitted by a particle system.
  108121. * This is mainly define by its coordinates, direction, velocity and age.
  108122. */
  108123. var Particle = /** @class */ (function () {
  108124. /**
  108125. * Creates a new instance Particle
  108126. * @param particleSystem the particle system the particle belongs to
  108127. */
  108128. function Particle(
  108129. /**
  108130. * The particle system the particle belongs to.
  108131. */
  108132. particleSystem) {
  108133. this.particleSystem = particleSystem;
  108134. /**
  108135. * The world position of the particle in the scene.
  108136. */
  108137. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108138. /**
  108139. * The world direction of the particle in the scene.
  108140. */
  108141. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108142. /**
  108143. * The color of the particle.
  108144. */
  108145. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  108146. /**
  108147. * The color change of the particle per step.
  108148. */
  108149. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  108150. /**
  108151. * Defines how long will the life of the particle be.
  108152. */
  108153. this.lifeTime = 1.0;
  108154. /**
  108155. * The current age of the particle.
  108156. */
  108157. this.age = 0;
  108158. /**
  108159. * The current size of the particle.
  108160. */
  108161. this.size = 0;
  108162. /**
  108163. * The current scale of the particle.
  108164. */
  108165. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  108166. /**
  108167. * The current angle of the particle.
  108168. */
  108169. this.angle = 0;
  108170. /**
  108171. * Defines how fast is the angle changing.
  108172. */
  108173. this.angularSpeed = 0;
  108174. /**
  108175. * Defines the cell index used by the particle to be rendered from a sprite.
  108176. */
  108177. this.cellIndex = 0;
  108178. /** @hidden */
  108179. this._attachedSubEmitters = null;
  108180. /** @hidden */
  108181. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  108182. /** @hidden */
  108183. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  108184. /** @hidden */
  108185. this._currentSize1 = 0;
  108186. /** @hidden */
  108187. this._currentSize2 = 0;
  108188. /** @hidden */
  108189. this._currentAngularSpeed1 = 0;
  108190. /** @hidden */
  108191. this._currentAngularSpeed2 = 0;
  108192. /** @hidden */
  108193. this._currentVelocity1 = 0;
  108194. /** @hidden */
  108195. this._currentVelocity2 = 0;
  108196. /** @hidden */
  108197. this._currentLimitVelocity1 = 0;
  108198. /** @hidden */
  108199. this._currentLimitVelocity2 = 0;
  108200. /** @hidden */
  108201. this._currentDrag1 = 0;
  108202. /** @hidden */
  108203. this._currentDrag2 = 0;
  108204. this.id = Particle._Count++;
  108205. if (!this.particleSystem.isAnimationSheetEnabled) {
  108206. return;
  108207. }
  108208. this.updateCellInfoFromSystem();
  108209. }
  108210. Particle.prototype.updateCellInfoFromSystem = function () {
  108211. this.cellIndex = this.particleSystem.startSpriteCellID;
  108212. };
  108213. /**
  108214. * Defines how the sprite cell index is updated for the particle
  108215. */
  108216. Particle.prototype.updateCellIndex = function () {
  108217. var offsetAge = this.age;
  108218. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  108219. if (this.particleSystem.spriteRandomStartCell) {
  108220. if (this._randomCellOffset === undefined) {
  108221. this._randomCellOffset = Math.random() * this.lifeTime;
  108222. }
  108223. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  108224. changeSpeed = 1;
  108225. offsetAge = this._randomCellOffset;
  108226. }
  108227. else {
  108228. offsetAge += this._randomCellOffset;
  108229. }
  108230. }
  108231. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  108232. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  108233. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  108234. };
  108235. /** @hidden */
  108236. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  108237. if (subEmitter.particleSystem.emitter.position) {
  108238. var emitterMesh = subEmitter.particleSystem.emitter;
  108239. emitterMesh.position.copyFrom(this.position);
  108240. if (subEmitter.inheritDirection) {
  108241. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  108242. // Look at using Y as forward
  108243. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  108244. }
  108245. }
  108246. else {
  108247. var emitterPosition = subEmitter.particleSystem.emitter;
  108248. emitterPosition.copyFrom(this.position);
  108249. }
  108250. // Set inheritedVelocityOffset to be used when new particles are created
  108251. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  108252. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  108253. };
  108254. /** @hidden */
  108255. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  108256. var _this = this;
  108257. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  108258. this._attachedSubEmitters.forEach(function (subEmitter) {
  108259. _this._inheritParticleInfoToSubEmitter(subEmitter);
  108260. });
  108261. }
  108262. };
  108263. /** @hidden */
  108264. Particle.prototype._reset = function () {
  108265. this.age = 0;
  108266. this._currentColorGradient = null;
  108267. this._currentSizeGradient = null;
  108268. this._currentAngularSpeedGradient = null;
  108269. this._currentVelocityGradient = null;
  108270. this._currentLimitVelocityGradient = null;
  108271. this._currentDragGradient = null;
  108272. this.cellIndex = this.particleSystem.startSpriteCellID;
  108273. this._randomCellOffset = undefined;
  108274. };
  108275. /**
  108276. * Copy the properties of particle to another one.
  108277. * @param other the particle to copy the information to.
  108278. */
  108279. Particle.prototype.copyTo = function (other) {
  108280. other.position.copyFrom(this.position);
  108281. if (this._initialDirection) {
  108282. if (other._initialDirection) {
  108283. other._initialDirection.copyFrom(this._initialDirection);
  108284. }
  108285. else {
  108286. other._initialDirection = this._initialDirection.clone();
  108287. }
  108288. }
  108289. else {
  108290. other._initialDirection = null;
  108291. }
  108292. other.direction.copyFrom(this.direction);
  108293. other.color.copyFrom(this.color);
  108294. other.colorStep.copyFrom(this.colorStep);
  108295. other.lifeTime = this.lifeTime;
  108296. other.age = this.age;
  108297. other._randomCellOffset = this._randomCellOffset;
  108298. other.size = this.size;
  108299. other.scale.copyFrom(this.scale);
  108300. other.angle = this.angle;
  108301. other.angularSpeed = this.angularSpeed;
  108302. other.particleSystem = this.particleSystem;
  108303. other.cellIndex = this.cellIndex;
  108304. other.id = this.id;
  108305. other._attachedSubEmitters = this._attachedSubEmitters;
  108306. if (this._currentColorGradient) {
  108307. other._currentColorGradient = this._currentColorGradient;
  108308. other._currentColor1.copyFrom(this._currentColor1);
  108309. other._currentColor2.copyFrom(this._currentColor2);
  108310. }
  108311. if (this._currentSizeGradient) {
  108312. other._currentSizeGradient = this._currentSizeGradient;
  108313. other._currentSize1 = this._currentSize1;
  108314. other._currentSize2 = this._currentSize2;
  108315. }
  108316. if (this._currentAngularSpeedGradient) {
  108317. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  108318. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  108319. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  108320. }
  108321. if (this._currentVelocityGradient) {
  108322. other._currentVelocityGradient = this._currentVelocityGradient;
  108323. other._currentVelocity1 = this._currentVelocity1;
  108324. other._currentVelocity2 = this._currentVelocity2;
  108325. }
  108326. if (this._currentLimitVelocityGradient) {
  108327. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  108328. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  108329. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  108330. }
  108331. if (this._currentDragGradient) {
  108332. other._currentDragGradient = this._currentDragGradient;
  108333. other._currentDrag1 = this._currentDrag1;
  108334. other._currentDrag2 = this._currentDrag2;
  108335. }
  108336. if (this.particleSystem.isAnimationSheetEnabled) {
  108337. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  108338. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  108339. }
  108340. if (this.particleSystem.useRampGradients) {
  108341. other.remapData.copyFrom(this.remapData);
  108342. }
  108343. if (this._randomNoiseCoordinates1) {
  108344. if (other._randomNoiseCoordinates1) {
  108345. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  108346. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  108347. }
  108348. else {
  108349. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  108350. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  108351. }
  108352. }
  108353. };
  108354. Particle._Count = 0;
  108355. return Particle;
  108356. }());
  108357. /***/ }),
  108358. /***/ "./Particles/particleHelper.ts":
  108359. /*!*************************************!*\
  108360. !*** ./Particles/particleHelper.ts ***!
  108361. \*************************************/
  108362. /*! exports provided: ParticleHelper */
  108363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108364. "use strict";
  108365. __webpack_require__.r(__webpack_exports__);
  108366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  108367. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  108368. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108369. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  108370. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  108371. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  108372. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  108373. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  108374. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108375. /**
  108376. * This class is made for on one-liner static method to help creating particle system set.
  108377. */
  108378. var ParticleHelper = /** @class */ (function () {
  108379. function ParticleHelper() {
  108380. }
  108381. /**
  108382. * Create a default particle system that you can tweak
  108383. * @param emitter defines the emitter to use
  108384. * @param capacity defines the system capacity (default is 500 particles)
  108385. * @param scene defines the hosting scene
  108386. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108387. * @returns the new Particle system
  108388. */
  108389. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  108390. if (capacity === void 0) { capacity = 500; }
  108391. if (useGPU === void 0) { useGPU = false; }
  108392. var system;
  108393. if (useGPU) {
  108394. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  108395. }
  108396. else {
  108397. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  108398. }
  108399. system.emitter = emitter;
  108400. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  108401. system.createConeEmitter(0.1, Math.PI / 4);
  108402. // Particle color
  108403. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  108404. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  108405. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  108406. // Particle Size
  108407. system.minSize = 0.1;
  108408. system.maxSize = 0.1;
  108409. // Emission speed
  108410. system.minEmitPower = 2;
  108411. system.maxEmitPower = 2;
  108412. // Update speed
  108413. system.updateSpeed = 1 / 60;
  108414. system.emitRate = 30;
  108415. return system;
  108416. };
  108417. /**
  108418. * This is the main static method (one-liner) of this helper to create different particle systems
  108419. * @param type This string represents the type to the particle system to create
  108420. * @param scene The scene where the particle system should live
  108421. * @param gpu If the system will use gpu
  108422. * @returns the ParticleSystemSet created
  108423. */
  108424. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  108425. if (gpu === void 0) { gpu = false; }
  108426. if (!scene) {
  108427. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  108428. }
  108429. var token = {};
  108430. scene._addPendingData(token);
  108431. return new Promise(function (resolve, reject) {
  108432. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  108433. scene._removePendingData(token);
  108434. return reject("Particle system with GPU is not supported.");
  108435. }
  108436. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  108437. scene._removePendingData(token);
  108438. var newData = JSON.parse(data.toString());
  108439. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  108440. }, undefined, undefined, undefined, function () {
  108441. scene._removePendingData(token);
  108442. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  108443. });
  108444. });
  108445. };
  108446. /**
  108447. * Static function used to export a particle system to a ParticleSystemSet variable.
  108448. * Please note that the emitter shape is not exported
  108449. * @param systems defines the particle systems to export
  108450. * @returns the created particle system set
  108451. */
  108452. ParticleHelper.ExportSet = function (systems) {
  108453. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  108454. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  108455. var system = systems_1[_i];
  108456. set.systems.push(system);
  108457. }
  108458. return set;
  108459. };
  108460. /**
  108461. * Gets or sets base Assets URL
  108462. */
  108463. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  108464. return ParticleHelper;
  108465. }());
  108466. /***/ }),
  108467. /***/ "./Particles/particleSystem.ts":
  108468. /*!*************************************!*\
  108469. !*** ./Particles/particleSystem.ts ***!
  108470. \*************************************/
  108471. /*! exports provided: ParticleSystem */
  108472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108473. "use strict";
  108474. __webpack_require__.r(__webpack_exports__);
  108475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  108476. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  108477. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  108478. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  108479. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108480. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108481. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  108482. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  108483. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  108484. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  108485. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  108486. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  108487. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  108488. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  108489. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  108490. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  108491. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  108492. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  108493. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  108494. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108495. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  108496. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  108497. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  108498. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  108499. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  108500. /**
  108501. * This represents a particle system in Babylon.
  108502. * 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.
  108503. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  108504. * @example https://doc.babylonjs.com/babylon101/particles
  108505. */
  108506. var ParticleSystem = /** @class */ (function (_super) {
  108507. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  108508. /**
  108509. * Instantiates a particle system.
  108510. * 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.
  108511. * @param name The name of the particle system
  108512. * @param capacity The max number of particles alive at the same time
  108513. * @param scene The scene the particle system belongs to
  108514. * @param customEffect a custom effect used to change the way particles are rendered by default
  108515. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108516. * @param epsilon Offset used to render the particles
  108517. */
  108518. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  108519. if (customEffect === void 0) { customEffect = null; }
  108520. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  108521. if (epsilon === void 0) { epsilon = 0.01; }
  108522. var _this = _super.call(this, name) || this;
  108523. /**
  108524. * @hidden
  108525. */
  108526. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  108527. /**
  108528. * An event triggered when the system is disposed
  108529. */
  108530. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  108531. _this._particles = new Array();
  108532. _this._stockParticles = new Array();
  108533. _this._newPartsExcess = 0;
  108534. _this._vertexBuffers = {};
  108535. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  108536. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  108537. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  108538. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  108539. _this._currentRenderId = -1;
  108540. _this._useInstancing = false;
  108541. _this._started = false;
  108542. _this._stopped = false;
  108543. _this._actualFrame = 0;
  108544. /** @hidden */
  108545. _this._currentEmitRate1 = 0;
  108546. /** @hidden */
  108547. _this._currentEmitRate2 = 0;
  108548. /** @hidden */
  108549. _this._currentStartSize1 = 0;
  108550. /** @hidden */
  108551. _this._currentStartSize2 = 0;
  108552. _this._rawTextureWidth = 256;
  108553. _this._useRampGradients = false;
  108554. /**
  108555. * @hidden
  108556. * If the particle systems emitter should be disposed when the particle system is disposed
  108557. */
  108558. _this._disposeEmitterOnDispose = false;
  108559. // start of sub system methods
  108560. /**
  108561. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  108562. * Its lifetime will start back at 0.
  108563. */
  108564. _this.recycleParticle = function (particle) {
  108565. // move particle from activeParticle list to stock particles
  108566. var lastParticle = _this._particles.pop();
  108567. if (lastParticle !== particle) {
  108568. lastParticle.copyTo(particle);
  108569. }
  108570. _this._stockParticles.push(lastParticle);
  108571. };
  108572. _this._createParticle = function () {
  108573. var particle;
  108574. if (_this._stockParticles.length !== 0) {
  108575. particle = _this._stockParticles.pop();
  108576. particle._reset();
  108577. }
  108578. else {
  108579. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  108580. }
  108581. // Attach emitters
  108582. if (_this._subEmitters && _this._subEmitters.length > 0) {
  108583. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  108584. particle._attachedSubEmitters = [];
  108585. subEmitters.forEach(function (subEmitter) {
  108586. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  108587. var newEmitter = subEmitter.clone();
  108588. particle._attachedSubEmitters.push(newEmitter);
  108589. newEmitter.particleSystem.start();
  108590. }
  108591. });
  108592. }
  108593. return particle;
  108594. };
  108595. _this._emitFromParticle = function (particle) {
  108596. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  108597. return;
  108598. }
  108599. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  108600. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  108601. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  108602. var subSystem = subEmitter.clone();
  108603. particle._inheritParticleInfoToSubEmitter(subSystem);
  108604. subSystem.particleSystem._rootParticleSystem = _this;
  108605. _this.activeSubSystems.push(subSystem.particleSystem);
  108606. subSystem.particleSystem.start();
  108607. }
  108608. });
  108609. };
  108610. _this._capacity = capacity;
  108611. _this._epsilon = epsilon;
  108612. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  108613. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  108614. // Setup the default processing configuration to the scene.
  108615. _this._attachImageProcessingConfiguration(null);
  108616. _this._customEffect = customEffect;
  108617. _this._scene.particleSystems.push(_this);
  108618. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  108619. _this._createIndexBuffer();
  108620. _this._createVertexBuffers();
  108621. // Default emitter type
  108622. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  108623. // Update
  108624. _this.updateFunction = function (particles) {
  108625. var noiseTextureSize = null;
  108626. var noiseTextureData = null;
  108627. if (_this.noiseTexture) { // We need to get texture data back to CPU
  108628. noiseTextureSize = _this.noiseTexture.getSize();
  108629. noiseTextureData = (_this.noiseTexture.getContent());
  108630. }
  108631. var _loop_1 = function () {
  108632. particle = particles[index];
  108633. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  108634. var previousAge = particle.age;
  108635. particle.age += scaledUpdateSpeed;
  108636. // Evaluate step to death
  108637. if (particle.age > particle.lifeTime) {
  108638. var diff = particle.age - previousAge;
  108639. var oldDiff = particle.lifeTime - previousAge;
  108640. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  108641. particle.age = particle.lifeTime;
  108642. }
  108643. var ratio = particle.age / particle.lifeTime;
  108644. // Color
  108645. if (_this._colorGradients && _this._colorGradients.length > 0) {
  108646. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  108647. if (currentGradient !== particle._currentColorGradient) {
  108648. particle._currentColor1.copyFrom(particle._currentColor2);
  108649. nextGradient.getColorToRef(particle._currentColor2);
  108650. particle._currentColorGradient = currentGradient;
  108651. }
  108652. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  108653. });
  108654. }
  108655. else {
  108656. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  108657. particle.color.addInPlace(_this._scaledColorStep);
  108658. if (particle.color.a < 0) {
  108659. particle.color.a = 0;
  108660. }
  108661. }
  108662. // Angular speed
  108663. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  108664. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  108665. if (currentGradient !== particle._currentAngularSpeedGradient) {
  108666. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  108667. particle._currentAngularSpeed2 = nextGradient.getFactor();
  108668. particle._currentAngularSpeedGradient = currentGradient;
  108669. }
  108670. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  108671. });
  108672. }
  108673. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  108674. // Direction
  108675. var directionScale = scaledUpdateSpeed;
  108676. /// Velocity
  108677. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  108678. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  108679. if (currentGradient !== particle._currentVelocityGradient) {
  108680. particle._currentVelocity1 = particle._currentVelocity2;
  108681. particle._currentVelocity2 = nextGradient.getFactor();
  108682. particle._currentVelocityGradient = currentGradient;
  108683. }
  108684. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  108685. });
  108686. }
  108687. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  108688. /// Limit velocity
  108689. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  108690. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  108691. if (currentGradient !== particle._currentLimitVelocityGradient) {
  108692. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  108693. particle._currentLimitVelocity2 = nextGradient.getFactor();
  108694. particle._currentLimitVelocityGradient = currentGradient;
  108695. }
  108696. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  108697. var currentVelocity = particle.direction.length();
  108698. if (currentVelocity > limitVelocity) {
  108699. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  108700. }
  108701. });
  108702. }
  108703. /// Drag
  108704. if (_this._dragGradients && _this._dragGradients.length > 0) {
  108705. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  108706. if (currentGradient !== particle._currentDragGradient) {
  108707. particle._currentDrag1 = particle._currentDrag2;
  108708. particle._currentDrag2 = nextGradient.getFactor();
  108709. particle._currentDragGradient = currentGradient;
  108710. }
  108711. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  108712. _this._scaledDirection.scaleInPlace(1.0 - drag);
  108713. });
  108714. }
  108715. particle.position.addInPlace(_this._scaledDirection);
  108716. // Noise
  108717. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  108718. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  108719. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  108720. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  108721. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  108722. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  108723. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  108724. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  108725. particle.direction.addInPlace(scaledForce);
  108726. }
  108727. // Gravity
  108728. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  108729. particle.direction.addInPlace(_this._scaledGravity);
  108730. // Size
  108731. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  108732. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  108733. if (currentGradient !== particle._currentSizeGradient) {
  108734. particle._currentSize1 = particle._currentSize2;
  108735. particle._currentSize2 = nextGradient.getFactor();
  108736. particle._currentSizeGradient = currentGradient;
  108737. }
  108738. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  108739. });
  108740. }
  108741. // Remap data
  108742. if (_this._useRampGradients) {
  108743. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  108744. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  108745. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  108746. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  108747. particle.remapData.x = min;
  108748. particle.remapData.y = max - min;
  108749. });
  108750. }
  108751. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  108752. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  108753. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  108754. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  108755. particle.remapData.z = min;
  108756. particle.remapData.w = max - min;
  108757. });
  108758. }
  108759. }
  108760. if (_this._isAnimationSheetEnabled) {
  108761. particle.updateCellIndex();
  108762. }
  108763. // Update the position of the attached sub-emitters to match their attached particle
  108764. particle._inheritParticleInfoToSubEmitters();
  108765. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  108766. _this._emitFromParticle(particle);
  108767. if (particle._attachedSubEmitters) {
  108768. particle._attachedSubEmitters.forEach(function (subEmitter) {
  108769. subEmitter.particleSystem.disposeOnStop = true;
  108770. subEmitter.particleSystem.stop();
  108771. });
  108772. particle._attachedSubEmitters = null;
  108773. }
  108774. _this.recycleParticle(particle);
  108775. index--;
  108776. return "continue";
  108777. }
  108778. };
  108779. var particle;
  108780. for (var index = 0; index < particles.length; index++) {
  108781. _loop_1();
  108782. }
  108783. };
  108784. return _this;
  108785. }
  108786. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  108787. /**
  108788. * Sets a callback that will be triggered when the system is disposed
  108789. */
  108790. set: function (callback) {
  108791. if (this._onDisposeObserver) {
  108792. this.onDisposeObservable.remove(this._onDisposeObserver);
  108793. }
  108794. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  108795. },
  108796. enumerable: true,
  108797. configurable: true
  108798. });
  108799. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  108800. /** Gets or sets a boolean indicating that ramp gradients must be used
  108801. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108802. */
  108803. get: function () {
  108804. return this._useRampGradients;
  108805. },
  108806. set: function (value) {
  108807. if (this._useRampGradients === value) {
  108808. return;
  108809. }
  108810. this._useRampGradients = value;
  108811. this._resetEffect();
  108812. },
  108813. enumerable: true,
  108814. configurable: true
  108815. });
  108816. Object.defineProperty(ParticleSystem.prototype, "particles", {
  108817. //end of Sub-emitter
  108818. /**
  108819. * Gets the current list of active particles
  108820. */
  108821. get: function () {
  108822. return this._particles;
  108823. },
  108824. enumerable: true,
  108825. configurable: true
  108826. });
  108827. /**
  108828. * Returns the string "ParticleSystem"
  108829. * @returns a string containing the class name
  108830. */
  108831. ParticleSystem.prototype.getClassName = function () {
  108832. return "ParticleSystem";
  108833. };
  108834. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  108835. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  108836. newGradient.gradient = gradient;
  108837. newGradient.factor1 = factor;
  108838. newGradient.factor2 = factor2;
  108839. factorGradients.push(newGradient);
  108840. factorGradients.sort(function (a, b) {
  108841. if (a.gradient < b.gradient) {
  108842. return -1;
  108843. }
  108844. else if (a.gradient > b.gradient) {
  108845. return 1;
  108846. }
  108847. return 0;
  108848. });
  108849. };
  108850. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  108851. if (!factorGradients) {
  108852. return;
  108853. }
  108854. var index = 0;
  108855. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  108856. var factorGradient = factorGradients_1[_i];
  108857. if (factorGradient.gradient === gradient) {
  108858. factorGradients.splice(index, 1);
  108859. break;
  108860. }
  108861. index++;
  108862. }
  108863. };
  108864. /**
  108865. * Adds a new life time gradient
  108866. * @param gradient defines the gradient to use (between 0 and 1)
  108867. * @param factor defines the life time factor to affect to the specified gradient
  108868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108869. * @returns the current particle system
  108870. */
  108871. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  108872. if (!this._lifeTimeGradients) {
  108873. this._lifeTimeGradients = [];
  108874. }
  108875. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  108876. return this;
  108877. };
  108878. /**
  108879. * Remove a specific life time gradient
  108880. * @param gradient defines the gradient to remove
  108881. * @returns the current particle system
  108882. */
  108883. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  108884. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  108885. return this;
  108886. };
  108887. /**
  108888. * Adds a new size gradient
  108889. * @param gradient defines the gradient to use (between 0 and 1)
  108890. * @param factor defines the size factor to affect to the specified gradient
  108891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108892. * @returns the current particle system
  108893. */
  108894. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  108895. if (!this._sizeGradients) {
  108896. this._sizeGradients = [];
  108897. }
  108898. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  108899. return this;
  108900. };
  108901. /**
  108902. * Remove a specific size gradient
  108903. * @param gradient defines the gradient to remove
  108904. * @returns the current particle system
  108905. */
  108906. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  108907. this._removeFactorGradient(this._sizeGradients, gradient);
  108908. return this;
  108909. };
  108910. /**
  108911. * Adds a new color remap gradient
  108912. * @param gradient defines the gradient to use (between 0 and 1)
  108913. * @param min defines the color remap minimal range
  108914. * @param max defines the color remap maximal range
  108915. * @returns the current particle system
  108916. */
  108917. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  108918. if (!this._colorRemapGradients) {
  108919. this._colorRemapGradients = [];
  108920. }
  108921. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  108922. return this;
  108923. };
  108924. /**
  108925. * Remove a specific color remap gradient
  108926. * @param gradient defines the gradient to remove
  108927. * @returns the current particle system
  108928. */
  108929. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  108930. this._removeFactorGradient(this._colorRemapGradients, gradient);
  108931. return this;
  108932. };
  108933. /**
  108934. * Adds a new alpha remap gradient
  108935. * @param gradient defines the gradient to use (between 0 and 1)
  108936. * @param min defines the alpha remap minimal range
  108937. * @param max defines the alpha remap maximal range
  108938. * @returns the current particle system
  108939. */
  108940. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  108941. if (!this._alphaRemapGradients) {
  108942. this._alphaRemapGradients = [];
  108943. }
  108944. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  108945. return this;
  108946. };
  108947. /**
  108948. * Remove a specific alpha remap gradient
  108949. * @param gradient defines the gradient to remove
  108950. * @returns the current particle system
  108951. */
  108952. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  108953. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  108954. return this;
  108955. };
  108956. /**
  108957. * Adds a new angular speed gradient
  108958. * @param gradient defines the gradient to use (between 0 and 1)
  108959. * @param factor defines the angular speed to affect to the specified gradient
  108960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108961. * @returns the current particle system
  108962. */
  108963. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  108964. if (!this._angularSpeedGradients) {
  108965. this._angularSpeedGradients = [];
  108966. }
  108967. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  108968. return this;
  108969. };
  108970. /**
  108971. * Remove a specific angular speed gradient
  108972. * @param gradient defines the gradient to remove
  108973. * @returns the current particle system
  108974. */
  108975. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  108976. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  108977. return this;
  108978. };
  108979. /**
  108980. * Adds a new velocity gradient
  108981. * @param gradient defines the gradient to use (between 0 and 1)
  108982. * @param factor defines the velocity to affect to the specified gradient
  108983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108984. * @returns the current particle system
  108985. */
  108986. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  108987. if (!this._velocityGradients) {
  108988. this._velocityGradients = [];
  108989. }
  108990. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  108991. return this;
  108992. };
  108993. /**
  108994. * Remove a specific velocity gradient
  108995. * @param gradient defines the gradient to remove
  108996. * @returns the current particle system
  108997. */
  108998. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  108999. this._removeFactorGradient(this._velocityGradients, gradient);
  109000. return this;
  109001. };
  109002. /**
  109003. * Adds a new limit velocity gradient
  109004. * @param gradient defines the gradient to use (between 0 and 1)
  109005. * @param factor defines the limit velocity value to affect to the specified gradient
  109006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109007. * @returns the current particle system
  109008. */
  109009. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  109010. if (!this._limitVelocityGradients) {
  109011. this._limitVelocityGradients = [];
  109012. }
  109013. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  109014. return this;
  109015. };
  109016. /**
  109017. * Remove a specific limit velocity gradient
  109018. * @param gradient defines the gradient to remove
  109019. * @returns the current particle system
  109020. */
  109021. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  109022. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  109023. return this;
  109024. };
  109025. /**
  109026. * Adds a new drag gradient
  109027. * @param gradient defines the gradient to use (between 0 and 1)
  109028. * @param factor defines the drag value to affect to the specified gradient
  109029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109030. * @returns the current particle system
  109031. */
  109032. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  109033. if (!this._dragGradients) {
  109034. this._dragGradients = [];
  109035. }
  109036. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  109037. return this;
  109038. };
  109039. /**
  109040. * Remove a specific drag gradient
  109041. * @param gradient defines the gradient to remove
  109042. * @returns the current particle system
  109043. */
  109044. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  109045. this._removeFactorGradient(this._dragGradients, gradient);
  109046. return this;
  109047. };
  109048. /**
  109049. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  109050. * @param gradient defines the gradient to use (between 0 and 1)
  109051. * @param factor defines the emit rate value to affect to the specified gradient
  109052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109053. * @returns the current particle system
  109054. */
  109055. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  109056. if (!this._emitRateGradients) {
  109057. this._emitRateGradients = [];
  109058. }
  109059. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  109060. return this;
  109061. };
  109062. /**
  109063. * Remove a specific emit rate gradient
  109064. * @param gradient defines the gradient to remove
  109065. * @returns the current particle system
  109066. */
  109067. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  109068. this._removeFactorGradient(this._emitRateGradients, gradient);
  109069. return this;
  109070. };
  109071. /**
  109072. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  109073. * @param gradient defines the gradient to use (between 0 and 1)
  109074. * @param factor defines the start size value to affect to the specified gradient
  109075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109076. * @returns the current particle system
  109077. */
  109078. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  109079. if (!this._startSizeGradients) {
  109080. this._startSizeGradients = [];
  109081. }
  109082. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  109083. return this;
  109084. };
  109085. /**
  109086. * Remove a specific start size gradient
  109087. * @param gradient defines the gradient to remove
  109088. * @returns the current particle system
  109089. */
  109090. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  109091. this._removeFactorGradient(this._emitRateGradients, gradient);
  109092. return this;
  109093. };
  109094. ParticleSystem.prototype._createRampGradientTexture = function () {
  109095. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  109096. return;
  109097. }
  109098. var data = new Uint8Array(this._rawTextureWidth * 4);
  109099. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  109100. for (var x = 0; x < this._rawTextureWidth; x++) {
  109101. var ratio = x / this._rawTextureWidth;
  109102. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  109103. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  109104. data[x * 4] = tmpColor.r * 255;
  109105. data[x * 4 + 1] = tmpColor.g * 255;
  109106. data[x * 4 + 2] = tmpColor.b * 255;
  109107. data[x * 4 + 3] = 255;
  109108. });
  109109. }
  109110. 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);
  109111. };
  109112. /**
  109113. * Gets the current list of ramp gradients.
  109114. * You must use addRampGradient and removeRampGradient to udpate this list
  109115. * @returns the list of ramp gradients
  109116. */
  109117. ParticleSystem.prototype.getRampGradients = function () {
  109118. return this._rampGradients;
  109119. };
  109120. /**
  109121. * Adds a new ramp gradient used to remap particle colors
  109122. * @param gradient defines the gradient to use (between 0 and 1)
  109123. * @param color defines the color to affect to the specified gradient
  109124. * @returns the current particle system
  109125. */
  109126. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  109127. if (!this._rampGradients) {
  109128. this._rampGradients = [];
  109129. }
  109130. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  109131. rampGradient.gradient = gradient;
  109132. rampGradient.color = color;
  109133. this._rampGradients.push(rampGradient);
  109134. this._rampGradients.sort(function (a, b) {
  109135. if (a.gradient < b.gradient) {
  109136. return -1;
  109137. }
  109138. else if (a.gradient > b.gradient) {
  109139. return 1;
  109140. }
  109141. return 0;
  109142. });
  109143. if (this._rampGradientsTexture) {
  109144. this._rampGradientsTexture.dispose();
  109145. this._rampGradientsTexture = null;
  109146. }
  109147. this._createRampGradientTexture();
  109148. return this;
  109149. };
  109150. /**
  109151. * Remove a specific ramp gradient
  109152. * @param gradient defines the gradient to remove
  109153. * @returns the current particle system
  109154. */
  109155. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  109156. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  109157. this._rampGradientsTexture = null;
  109158. if (this._rampGradients && this._rampGradients.length > 0) {
  109159. this._createRampGradientTexture();
  109160. }
  109161. return this;
  109162. };
  109163. /**
  109164. * Adds a new color gradient
  109165. * @param gradient defines the gradient to use (between 0 and 1)
  109166. * @param color1 defines the color to affect to the specified gradient
  109167. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  109168. * @returns this particle system
  109169. */
  109170. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  109171. if (!this._colorGradients) {
  109172. this._colorGradients = [];
  109173. }
  109174. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  109175. colorGradient.gradient = gradient;
  109176. colorGradient.color1 = color1;
  109177. colorGradient.color2 = color2;
  109178. this._colorGradients.push(colorGradient);
  109179. this._colorGradients.sort(function (a, b) {
  109180. if (a.gradient < b.gradient) {
  109181. return -1;
  109182. }
  109183. else if (a.gradient > b.gradient) {
  109184. return 1;
  109185. }
  109186. return 0;
  109187. });
  109188. return this;
  109189. };
  109190. /**
  109191. * Remove a specific color gradient
  109192. * @param gradient defines the gradient to remove
  109193. * @returns this particle system
  109194. */
  109195. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  109196. if (!this._colorGradients) {
  109197. return this;
  109198. }
  109199. var index = 0;
  109200. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  109201. var colorGradient = _a[_i];
  109202. if (colorGradient.gradient === gradient) {
  109203. this._colorGradients.splice(index, 1);
  109204. break;
  109205. }
  109206. index++;
  109207. }
  109208. return this;
  109209. };
  109210. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  109211. u = Math.abs(u) * 0.5 + 0.5;
  109212. v = Math.abs(v) * 0.5 + 0.5;
  109213. var wrappedU = ((u * width) % width) | 0;
  109214. var wrappedV = ((v * height) % height) | 0;
  109215. var position = (wrappedU + wrappedV * width) * 4;
  109216. return pixels[position] / 255;
  109217. };
  109218. ParticleSystem.prototype._reset = function () {
  109219. this._resetEffect();
  109220. };
  109221. ParticleSystem.prototype._resetEffect = function () {
  109222. if (this._vertexBuffer) {
  109223. this._vertexBuffer.dispose();
  109224. this._vertexBuffer = null;
  109225. }
  109226. if (this._spriteBuffer) {
  109227. this._spriteBuffer.dispose();
  109228. this._spriteBuffer = null;
  109229. }
  109230. this._createVertexBuffers();
  109231. };
  109232. ParticleSystem.prototype._createVertexBuffers = function () {
  109233. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  109234. if (this._isAnimationSheetEnabled) {
  109235. this._vertexBufferSize += 1;
  109236. }
  109237. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  109238. this._vertexBufferSize += 3;
  109239. }
  109240. if (this._useRampGradients) {
  109241. this._vertexBufferSize += 4;
  109242. }
  109243. var engine = this._scene.getEngine();
  109244. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  109245. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  109246. var dataOffset = 0;
  109247. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  109248. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  109249. dataOffset += 3;
  109250. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  109251. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  109252. dataOffset += 4;
  109253. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  109254. this._vertexBuffers["angle"] = options;
  109255. dataOffset += 1;
  109256. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  109257. this._vertexBuffers["size"] = size;
  109258. dataOffset += 2;
  109259. if (this._isAnimationSheetEnabled) {
  109260. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  109261. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  109262. dataOffset += 1;
  109263. }
  109264. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  109265. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  109266. this._vertexBuffers["direction"] = directionBuffer;
  109267. dataOffset += 3;
  109268. }
  109269. if (this._useRampGradients) {
  109270. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  109271. this._vertexBuffers["remapData"] = rampDataBuffer;
  109272. dataOffset += 4;
  109273. }
  109274. var offsets;
  109275. if (this._useInstancing) {
  109276. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  109277. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  109278. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  109279. }
  109280. else {
  109281. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  109282. dataOffset += 2;
  109283. }
  109284. this._vertexBuffers["offset"] = offsets;
  109285. };
  109286. ParticleSystem.prototype._createIndexBuffer = function () {
  109287. if (this._useInstancing) {
  109288. return;
  109289. }
  109290. var indices = [];
  109291. var index = 0;
  109292. for (var count = 0; count < this._capacity; count++) {
  109293. indices.push(index);
  109294. indices.push(index + 1);
  109295. indices.push(index + 2);
  109296. indices.push(index);
  109297. indices.push(index + 2);
  109298. indices.push(index + 3);
  109299. index += 4;
  109300. }
  109301. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  109302. };
  109303. /**
  109304. * Gets the maximum number of particles active at the same time.
  109305. * @returns The max number of active particles.
  109306. */
  109307. ParticleSystem.prototype.getCapacity = function () {
  109308. return this._capacity;
  109309. };
  109310. /**
  109311. * Gets whether there are still active particles in the system.
  109312. * @returns True if it is alive, otherwise false.
  109313. */
  109314. ParticleSystem.prototype.isAlive = function () {
  109315. return this._alive;
  109316. };
  109317. /**
  109318. * Gets if the system has been started. (Note: this will still be true after stop is called)
  109319. * @returns True if it has been started, otherwise false.
  109320. */
  109321. ParticleSystem.prototype.isStarted = function () {
  109322. return this._started;
  109323. };
  109324. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  109325. var _this = this;
  109326. this._subEmitters = new Array();
  109327. if (this.subEmitters) {
  109328. this.subEmitters.forEach(function (subEmitter) {
  109329. if (subEmitter instanceof ParticleSystem) {
  109330. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  109331. }
  109332. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  109333. _this._subEmitters.push([subEmitter]);
  109334. }
  109335. else if (subEmitter instanceof Array) {
  109336. _this._subEmitters.push(subEmitter);
  109337. }
  109338. });
  109339. }
  109340. };
  109341. /**
  109342. * Starts the particle system and begins to emit
  109343. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  109344. */
  109345. ParticleSystem.prototype.start = function (delay) {
  109346. var _this = this;
  109347. if (delay === void 0) { delay = this.startDelay; }
  109348. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  109349. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  109350. }
  109351. if (delay) {
  109352. setTimeout(function () {
  109353. _this.start(0);
  109354. }, delay);
  109355. return;
  109356. }
  109357. // Convert the subEmitters field to the constant type field _subEmitters
  109358. this._prepareSubEmitterInternalArray();
  109359. this._started = true;
  109360. this._stopped = false;
  109361. this._actualFrame = 0;
  109362. if (this._subEmitters && this._subEmitters.length != 0) {
  109363. this.activeSubSystems = new Array();
  109364. }
  109365. // Reset emit gradient so it acts the same on every start
  109366. if (this._emitRateGradients) {
  109367. if (this._emitRateGradients.length > 0) {
  109368. this._currentEmitRateGradient = this._emitRateGradients[0];
  109369. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  109370. this._currentEmitRate2 = this._currentEmitRate1;
  109371. }
  109372. if (this._emitRateGradients.length > 1) {
  109373. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  109374. }
  109375. }
  109376. // Reset start size gradient so it acts the same on every start
  109377. if (this._startSizeGradients) {
  109378. if (this._startSizeGradients.length > 0) {
  109379. this._currentStartSizeGradient = this._startSizeGradients[0];
  109380. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  109381. this._currentStartSize2 = this._currentStartSize1;
  109382. }
  109383. if (this._startSizeGradients.length > 1) {
  109384. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  109385. }
  109386. }
  109387. if (this.preWarmCycles) {
  109388. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  109389. this.emitter.computeWorldMatrix(true);
  109390. }
  109391. var noiseTextureAsProcedural_1 = this.noiseTexture;
  109392. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  109393. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  109394. setTimeout(function () {
  109395. for (var index = 0; index < _this.preWarmCycles; index++) {
  109396. _this.animate(true);
  109397. noiseTextureAsProcedural_1.render();
  109398. }
  109399. });
  109400. });
  109401. }
  109402. else {
  109403. for (var index = 0; index < this.preWarmCycles; index++) {
  109404. this.animate(true);
  109405. }
  109406. }
  109407. }
  109408. // Animations
  109409. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  109410. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  109411. }
  109412. };
  109413. /**
  109414. * Stops the particle system.
  109415. * @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.
  109416. */
  109417. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  109418. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  109419. this._stopped = true;
  109420. if (stopSubEmitters) {
  109421. this._stopSubEmitters();
  109422. }
  109423. };
  109424. // animation sheet
  109425. /**
  109426. * Remove all active particles
  109427. */
  109428. ParticleSystem.prototype.reset = function () {
  109429. this._stockParticles = [];
  109430. this._particles = [];
  109431. };
  109432. /**
  109433. * @hidden (for internal use only)
  109434. */
  109435. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  109436. var offset = index * this._vertexBufferSize;
  109437. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  109438. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  109439. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  109440. this._vertexData[offset++] = particle.color.r;
  109441. this._vertexData[offset++] = particle.color.g;
  109442. this._vertexData[offset++] = particle.color.b;
  109443. this._vertexData[offset++] = particle.color.a;
  109444. this._vertexData[offset++] = particle.angle;
  109445. this._vertexData[offset++] = particle.scale.x * particle.size;
  109446. this._vertexData[offset++] = particle.scale.y * particle.size;
  109447. if (this._isAnimationSheetEnabled) {
  109448. this._vertexData[offset++] = particle.cellIndex;
  109449. }
  109450. if (!this._isBillboardBased) {
  109451. if (particle._initialDirection) {
  109452. this._vertexData[offset++] = particle._initialDirection.x;
  109453. this._vertexData[offset++] = particle._initialDirection.y;
  109454. this._vertexData[offset++] = particle._initialDirection.z;
  109455. }
  109456. else {
  109457. this._vertexData[offset++] = particle.direction.x;
  109458. this._vertexData[offset++] = particle.direction.y;
  109459. this._vertexData[offset++] = particle.direction.z;
  109460. }
  109461. }
  109462. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  109463. this._vertexData[offset++] = particle.direction.x;
  109464. this._vertexData[offset++] = particle.direction.y;
  109465. this._vertexData[offset++] = particle.direction.z;
  109466. }
  109467. if (this._useRampGradients) {
  109468. this._vertexData[offset++] = particle.remapData.x;
  109469. this._vertexData[offset++] = particle.remapData.y;
  109470. this._vertexData[offset++] = particle.remapData.z;
  109471. this._vertexData[offset++] = particle.remapData.w;
  109472. }
  109473. if (!this._useInstancing) {
  109474. if (this._isAnimationSheetEnabled) {
  109475. if (offsetX === 0) {
  109476. offsetX = this._epsilon;
  109477. }
  109478. else if (offsetX === 1) {
  109479. offsetX = 1 - this._epsilon;
  109480. }
  109481. if (offsetY === 0) {
  109482. offsetY = this._epsilon;
  109483. }
  109484. else if (offsetY === 1) {
  109485. offsetY = 1 - this._epsilon;
  109486. }
  109487. }
  109488. this._vertexData[offset++] = offsetX;
  109489. this._vertexData[offset++] = offsetY;
  109490. }
  109491. };
  109492. ParticleSystem.prototype._stopSubEmitters = function () {
  109493. if (!this.activeSubSystems) {
  109494. return;
  109495. }
  109496. this.activeSubSystems.forEach(function (subSystem) {
  109497. subSystem.stop(true);
  109498. });
  109499. this.activeSubSystems = new Array();
  109500. };
  109501. ParticleSystem.prototype._removeFromRoot = function () {
  109502. if (!this._rootParticleSystem) {
  109503. return;
  109504. }
  109505. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  109506. if (index !== -1) {
  109507. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  109508. }
  109509. this._rootParticleSystem = null;
  109510. };
  109511. // End of sub system methods
  109512. ParticleSystem.prototype._update = function (newParticles) {
  109513. var _this = this;
  109514. // Update current
  109515. this._alive = this._particles.length > 0;
  109516. if (this.emitter.position) {
  109517. var emitterMesh = this.emitter;
  109518. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  109519. }
  109520. else {
  109521. var emitterPosition = this.emitter;
  109522. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  109523. }
  109524. this.updateFunction(this._particles);
  109525. // Add new ones
  109526. var particle;
  109527. var _loop_2 = function () {
  109528. if (this_1._particles.length === this_1._capacity) {
  109529. return "break";
  109530. }
  109531. particle = this_1._createParticle();
  109532. this_1._particles.push(particle);
  109533. // Emitter
  109534. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  109535. if (this_1.startPositionFunction) {
  109536. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  109537. }
  109538. else {
  109539. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  109540. }
  109541. if (this_1.startDirectionFunction) {
  109542. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  109543. }
  109544. else {
  109545. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  109546. }
  109547. if (emitPower === 0) {
  109548. if (!particle._initialDirection) {
  109549. particle._initialDirection = particle.direction.clone();
  109550. }
  109551. else {
  109552. particle._initialDirection.copyFrom(particle.direction);
  109553. }
  109554. }
  109555. else {
  109556. particle._initialDirection = null;
  109557. }
  109558. particle.direction.scaleInPlace(emitPower);
  109559. // Life time
  109560. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  109561. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  109562. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  109563. var factorGradient1 = currentGradient;
  109564. var factorGradient2 = nextGradient;
  109565. var lifeTime1 = factorGradient1.getFactor();
  109566. var lifeTime2 = factorGradient2.getFactor();
  109567. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  109568. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  109569. });
  109570. }
  109571. else {
  109572. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  109573. }
  109574. // Size
  109575. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  109576. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  109577. }
  109578. else {
  109579. particle._currentSizeGradient = this_1._sizeGradients[0];
  109580. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  109581. particle.size = particle._currentSize1;
  109582. if (this_1._sizeGradients.length > 1) {
  109583. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  109584. }
  109585. else {
  109586. particle._currentSize2 = particle._currentSize1;
  109587. }
  109588. }
  109589. // Size and scale
  109590. 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));
  109591. // Adjust scale by start size
  109592. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  109593. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  109594. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  109595. if (currentGradient !== _this._currentStartSizeGradient) {
  109596. _this._currentStartSize1 = _this._currentStartSize2;
  109597. _this._currentStartSize2 = nextGradient.getFactor();
  109598. _this._currentStartSizeGradient = currentGradient;
  109599. }
  109600. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  109601. particle.scale.scaleInPlace(value);
  109602. });
  109603. }
  109604. // Angle
  109605. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  109606. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  109607. }
  109608. else {
  109609. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  109610. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  109611. particle._currentAngularSpeed1 = particle.angularSpeed;
  109612. if (this_1._angularSpeedGradients.length > 1) {
  109613. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  109614. }
  109615. else {
  109616. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  109617. }
  109618. }
  109619. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  109620. // Velocity
  109621. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  109622. particle._currentVelocityGradient = this_1._velocityGradients[0];
  109623. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  109624. if (this_1._velocityGradients.length > 1) {
  109625. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  109626. }
  109627. else {
  109628. particle._currentVelocity2 = particle._currentVelocity1;
  109629. }
  109630. }
  109631. // Limit velocity
  109632. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  109633. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  109634. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  109635. if (this_1._limitVelocityGradients.length > 1) {
  109636. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  109637. }
  109638. else {
  109639. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  109640. }
  109641. }
  109642. // Drag
  109643. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  109644. particle._currentDragGradient = this_1._dragGradients[0];
  109645. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  109646. if (this_1._dragGradients.length > 1) {
  109647. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  109648. }
  109649. else {
  109650. particle._currentDrag2 = particle._currentDrag1;
  109651. }
  109652. }
  109653. // Color
  109654. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  109655. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  109656. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  109657. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  109658. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  109659. }
  109660. else {
  109661. particle._currentColorGradient = this_1._colorGradients[0];
  109662. particle._currentColorGradient.getColorToRef(particle.color);
  109663. particle._currentColor1.copyFrom(particle.color);
  109664. if (this_1._colorGradients.length > 1) {
  109665. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  109666. }
  109667. else {
  109668. particle._currentColor2.copyFrom(particle.color);
  109669. }
  109670. }
  109671. // Sheet
  109672. if (this_1._isAnimationSheetEnabled) {
  109673. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  109674. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  109675. }
  109676. // Inherited Velocity
  109677. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  109678. // Ramp
  109679. if (this_1._useRampGradients) {
  109680. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  109681. }
  109682. // Noise texture coordinates
  109683. if (this_1.noiseTexture) {
  109684. if (particle._randomNoiseCoordinates1) {
  109685. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  109686. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  109687. }
  109688. else {
  109689. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  109690. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  109691. }
  109692. }
  109693. // Update the position of the attached sub-emitters to match their attached particle
  109694. particle._inheritParticleInfoToSubEmitters();
  109695. };
  109696. var this_1 = this, step;
  109697. for (var index = 0; index < newParticles; index++) {
  109698. var state_1 = _loop_2();
  109699. if (state_1 === "break")
  109700. break;
  109701. }
  109702. };
  109703. /** @hidden */
  109704. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  109705. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  109706. if (isBillboardBased === void 0) { isBillboardBased = false; }
  109707. if (useRampGradients === void 0) { useRampGradients = false; }
  109708. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  109709. if (isAnimationSheetEnabled) {
  109710. attributeNamesOrOptions.push("cellIndex");
  109711. }
  109712. if (!isBillboardBased) {
  109713. attributeNamesOrOptions.push("direction");
  109714. }
  109715. if (useRampGradients) {
  109716. attributeNamesOrOptions.push("remapData");
  109717. }
  109718. return attributeNamesOrOptions;
  109719. };
  109720. /** @hidden */
  109721. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  109722. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  109723. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  109724. if (isAnimationSheetEnabled) {
  109725. effectCreationOption.push("particlesInfos");
  109726. }
  109727. return effectCreationOption;
  109728. };
  109729. /** @hidden */
  109730. ParticleSystem.prototype._getEffect = function (blendMode) {
  109731. if (this._customEffect) {
  109732. return this._customEffect;
  109733. }
  109734. var defines = [];
  109735. if (this._scene.clipPlane) {
  109736. defines.push("#define CLIPPLANE");
  109737. }
  109738. if (this._scene.clipPlane2) {
  109739. defines.push("#define CLIPPLANE2");
  109740. }
  109741. if (this._scene.clipPlane3) {
  109742. defines.push("#define CLIPPLANE3");
  109743. }
  109744. if (this._scene.clipPlane4) {
  109745. defines.push("#define CLIPPLANE4");
  109746. }
  109747. if (this._isAnimationSheetEnabled) {
  109748. defines.push("#define ANIMATESHEET");
  109749. }
  109750. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  109751. defines.push("#define BLENDMULTIPLYMODE");
  109752. }
  109753. if (this._useRampGradients) {
  109754. defines.push("#define RAMPGRADIENT");
  109755. }
  109756. if (this._isBillboardBased) {
  109757. defines.push("#define BILLBOARD");
  109758. switch (this.billboardMode) {
  109759. case ParticleSystem.BILLBOARDMODE_Y:
  109760. defines.push("#define BILLBOARDY");
  109761. break;
  109762. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  109763. defines.push("#define BILLBOARDSTRETCHED");
  109764. break;
  109765. case ParticleSystem.BILLBOARDMODE_ALL:
  109766. default:
  109767. break;
  109768. }
  109769. }
  109770. if (this._imageProcessingConfiguration) {
  109771. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  109772. defines.push(this._imageProcessingConfigurationDefines.toString());
  109773. }
  109774. // Effect
  109775. var join = defines.join("\n");
  109776. if (this._cachedDefines !== join) {
  109777. this._cachedDefines = join;
  109778. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  109779. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  109780. var samplers = ["diffuseSampler", "rampSampler"];
  109781. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  109782. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  109783. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  109784. }
  109785. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  109786. }
  109787. return this._effect;
  109788. };
  109789. /**
  109790. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  109791. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  109792. */
  109793. ParticleSystem.prototype.animate = function (preWarmOnly) {
  109794. var _this = this;
  109795. if (preWarmOnly === void 0) { preWarmOnly = false; }
  109796. if (!this._started) {
  109797. return;
  109798. }
  109799. if (!preWarmOnly) {
  109800. // Check
  109801. if (!this.isReady()) {
  109802. return;
  109803. }
  109804. if (this._currentRenderId === this._scene.getFrameId()) {
  109805. return;
  109806. }
  109807. this._currentRenderId = this._scene.getFrameId();
  109808. }
  109809. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  109810. // Determine the number of particles we need to create
  109811. var newParticles;
  109812. if (this.manualEmitCount > -1) {
  109813. newParticles = this.manualEmitCount;
  109814. this._newPartsExcess = 0;
  109815. this.manualEmitCount = 0;
  109816. }
  109817. else {
  109818. var rate_1 = this.emitRate;
  109819. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  109820. var ratio = this._actualFrame / this.targetStopDuration;
  109821. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  109822. if (currentGradient !== _this._currentEmitRateGradient) {
  109823. _this._currentEmitRate1 = _this._currentEmitRate2;
  109824. _this._currentEmitRate2 = nextGradient.getFactor();
  109825. _this._currentEmitRateGradient = currentGradient;
  109826. }
  109827. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  109828. });
  109829. }
  109830. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  109831. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  109832. }
  109833. if (this._newPartsExcess > 1.0) {
  109834. newParticles += this._newPartsExcess >> 0;
  109835. this._newPartsExcess -= this._newPartsExcess >> 0;
  109836. }
  109837. this._alive = false;
  109838. if (!this._stopped) {
  109839. this._actualFrame += this._scaledUpdateSpeed;
  109840. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  109841. this.stop();
  109842. }
  109843. }
  109844. else {
  109845. newParticles = 0;
  109846. }
  109847. this._update(newParticles);
  109848. // Stopped?
  109849. if (this._stopped) {
  109850. if (!this._alive) {
  109851. this._started = false;
  109852. if (this.onAnimationEnd) {
  109853. this.onAnimationEnd();
  109854. }
  109855. if (this.disposeOnStop) {
  109856. this._scene._toBeDisposed.push(this);
  109857. }
  109858. }
  109859. }
  109860. if (!preWarmOnly) {
  109861. // Update VBO
  109862. var offset = 0;
  109863. for (var index = 0; index < this._particles.length; index++) {
  109864. var particle = this._particles[index];
  109865. this._appendParticleVertices(offset, particle);
  109866. offset += this._useInstancing ? 1 : 4;
  109867. }
  109868. if (this._vertexBuffer) {
  109869. this._vertexBuffer.update(this._vertexData);
  109870. }
  109871. }
  109872. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  109873. this.stop();
  109874. }
  109875. };
  109876. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  109877. this._appendParticleVertex(offset++, particle, 0, 0);
  109878. if (!this._useInstancing) {
  109879. this._appendParticleVertex(offset++, particle, 1, 0);
  109880. this._appendParticleVertex(offset++, particle, 1, 1);
  109881. this._appendParticleVertex(offset++, particle, 0, 1);
  109882. }
  109883. };
  109884. /**
  109885. * Rebuilds the particle system.
  109886. */
  109887. ParticleSystem.prototype.rebuild = function () {
  109888. this._createIndexBuffer();
  109889. if (this._vertexBuffer) {
  109890. this._vertexBuffer._rebuild();
  109891. }
  109892. };
  109893. /**
  109894. * Is this system ready to be used/rendered
  109895. * @return true if the system is ready
  109896. */
  109897. ParticleSystem.prototype.isReady = function () {
  109898. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  109899. return false;
  109900. }
  109901. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  109902. if (!this._getEffect(this.blendMode).isReady()) {
  109903. return false;
  109904. }
  109905. }
  109906. else {
  109907. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  109908. return false;
  109909. }
  109910. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  109911. return false;
  109912. }
  109913. }
  109914. return true;
  109915. };
  109916. ParticleSystem.prototype._render = function (blendMode) {
  109917. var effect = this._getEffect(blendMode);
  109918. var engine = this._scene.getEngine();
  109919. // Render
  109920. engine.enableEffect(effect);
  109921. var viewMatrix = this._scene.getViewMatrix();
  109922. effect.setTexture("diffuseSampler", this.particleTexture);
  109923. effect.setMatrix("view", viewMatrix);
  109924. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  109925. if (this._isAnimationSheetEnabled && this.particleTexture) {
  109926. var baseSize = this.particleTexture.getBaseSize();
  109927. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  109928. }
  109929. effect.setVector2("translationPivot", this.translationPivot);
  109930. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  109931. if (this._isBillboardBased) {
  109932. var camera = this._scene.activeCamera;
  109933. effect.setVector3("eyePosition", camera.globalPosition);
  109934. }
  109935. if (this._rampGradientsTexture) {
  109936. effect.setTexture("rampSampler", this._rampGradientsTexture);
  109937. }
  109938. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  109939. var invView = viewMatrix.clone();
  109940. invView.invert();
  109941. effect.setMatrix("invView", invView);
  109942. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  109943. }
  109944. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  109945. // image processing
  109946. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  109947. this._imageProcessingConfiguration.bind(effect);
  109948. }
  109949. // Draw order
  109950. switch (blendMode) {
  109951. case ParticleSystem.BLENDMODE_ADD:
  109952. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  109953. break;
  109954. case ParticleSystem.BLENDMODE_ONEONE:
  109955. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  109956. break;
  109957. case ParticleSystem.BLENDMODE_STANDARD:
  109958. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  109959. break;
  109960. case ParticleSystem.BLENDMODE_MULTIPLY:
  109961. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  109962. break;
  109963. }
  109964. if (this._useInstancing) {
  109965. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  109966. }
  109967. else {
  109968. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  109969. }
  109970. return this._particles.length;
  109971. };
  109972. /**
  109973. * Renders the particle system in its current state.
  109974. * @returns the current number of particles
  109975. */
  109976. ParticleSystem.prototype.render = function () {
  109977. // Check
  109978. if (!this.isReady() || !this._particles.length) {
  109979. return 0;
  109980. }
  109981. var engine = this._scene.getEngine();
  109982. engine.setState(false);
  109983. if (this.forceDepthWrite) {
  109984. engine.setDepthWrite(true);
  109985. }
  109986. var outparticles = 0;
  109987. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  109988. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  109989. }
  109990. outparticles = this._render(this.blendMode);
  109991. engine.unbindInstanceAttributes();
  109992. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  109993. return outparticles;
  109994. };
  109995. /**
  109996. * Disposes the particle system and free the associated resources
  109997. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  109998. */
  109999. ParticleSystem.prototype.dispose = function (disposeTexture) {
  110000. if (disposeTexture === void 0) { disposeTexture = true; }
  110001. if (this._vertexBuffer) {
  110002. this._vertexBuffer.dispose();
  110003. this._vertexBuffer = null;
  110004. }
  110005. if (this._spriteBuffer) {
  110006. this._spriteBuffer.dispose();
  110007. this._spriteBuffer = null;
  110008. }
  110009. if (this._indexBuffer) {
  110010. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  110011. this._indexBuffer = null;
  110012. }
  110013. if (disposeTexture && this.particleTexture) {
  110014. this.particleTexture.dispose();
  110015. this.particleTexture = null;
  110016. }
  110017. if (disposeTexture && this.noiseTexture) {
  110018. this.noiseTexture.dispose();
  110019. this.noiseTexture = null;
  110020. }
  110021. if (this._rampGradientsTexture) {
  110022. this._rampGradientsTexture.dispose();
  110023. this._rampGradientsTexture = null;
  110024. }
  110025. this._removeFromRoot();
  110026. if (this._subEmitters && this._subEmitters.length) {
  110027. for (var index = 0; index < this._subEmitters.length; index++) {
  110028. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  110029. var subEmitter = _a[_i];
  110030. subEmitter.dispose();
  110031. }
  110032. }
  110033. this._subEmitters = [];
  110034. this.subEmitters = [];
  110035. }
  110036. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  110037. this.emitter.dispose(true);
  110038. }
  110039. // Remove from scene
  110040. var index = this._scene.particleSystems.indexOf(this);
  110041. if (index > -1) {
  110042. this._scene.particleSystems.splice(index, 1);
  110043. }
  110044. this._scene._activeParticleSystems.dispose();
  110045. // Callback
  110046. this.onDisposeObservable.notifyObservers(this);
  110047. this.onDisposeObservable.clear();
  110048. this.reset();
  110049. };
  110050. // Clone
  110051. /**
  110052. * Clones the particle system.
  110053. * @param name The name of the cloned object
  110054. * @param newEmitter The new emitter to use
  110055. * @returns the cloned particle system
  110056. */
  110057. ParticleSystem.prototype.clone = function (name, newEmitter) {
  110058. var custom = null;
  110059. var program = null;
  110060. if (this.customShader != null) {
  110061. program = this.customShader;
  110062. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  110063. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  110064. }
  110065. else if (this._customEffect) {
  110066. custom = this._customEffect;
  110067. }
  110068. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  110069. result.customShader = program;
  110070. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  110071. if (newEmitter === undefined) {
  110072. newEmitter = this.emitter;
  110073. }
  110074. result.noiseTexture = this.noiseTexture;
  110075. result.emitter = newEmitter;
  110076. if (this.particleTexture) {
  110077. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  110078. }
  110079. // Clone gradients
  110080. if (this._colorGradients) {
  110081. this._colorGradients.forEach(function (v) {
  110082. result.addColorGradient(v.gradient, v.color1, v.color2);
  110083. });
  110084. }
  110085. if (this._dragGradients) {
  110086. this._dragGradients.forEach(function (v) {
  110087. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  110088. });
  110089. }
  110090. if (this._angularSpeedGradients) {
  110091. this._angularSpeedGradients.forEach(function (v) {
  110092. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  110093. });
  110094. }
  110095. if (this._emitRateGradients) {
  110096. this._emitRateGradients.forEach(function (v) {
  110097. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  110098. });
  110099. }
  110100. if (this._lifeTimeGradients) {
  110101. this._lifeTimeGradients.forEach(function (v) {
  110102. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  110103. });
  110104. }
  110105. if (this._limitVelocityGradients) {
  110106. this._limitVelocityGradients.forEach(function (v) {
  110107. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  110108. });
  110109. }
  110110. if (this._sizeGradients) {
  110111. this._sizeGradients.forEach(function (v) {
  110112. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  110113. });
  110114. }
  110115. if (this._startSizeGradients) {
  110116. this._startSizeGradients.forEach(function (v) {
  110117. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  110118. });
  110119. }
  110120. if (this._velocityGradients) {
  110121. this._velocityGradients.forEach(function (v) {
  110122. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  110123. });
  110124. }
  110125. if (this._rampGradients) {
  110126. this._rampGradients.forEach(function (v) {
  110127. result.addRampGradient(v.gradient, v.color);
  110128. });
  110129. }
  110130. if (this._colorRemapGradients) {
  110131. this._colorRemapGradients.forEach(function (v) {
  110132. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  110133. });
  110134. }
  110135. if (this._alphaRemapGradients) {
  110136. this._alphaRemapGradients.forEach(function (v) {
  110137. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  110138. });
  110139. }
  110140. if (!this.preventAutoStart) {
  110141. result.start();
  110142. }
  110143. return result;
  110144. };
  110145. /**
  110146. * Serializes the particle system to a JSON object.
  110147. * @returns the JSON object
  110148. */
  110149. ParticleSystem.prototype.serialize = function () {
  110150. var serializationObject = {};
  110151. ParticleSystem._Serialize(serializationObject, this);
  110152. serializationObject.textureMask = this.textureMask.asArray();
  110153. serializationObject.customShader = this.customShader;
  110154. serializationObject.preventAutoStart = this.preventAutoStart;
  110155. // SubEmitters
  110156. if (this.subEmitters) {
  110157. serializationObject.subEmitters = [];
  110158. if (!this._subEmitters) {
  110159. this._prepareSubEmitterInternalArray();
  110160. }
  110161. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  110162. var subs = _a[_i];
  110163. var cell = [];
  110164. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  110165. var sub = subs_1[_b];
  110166. cell.push(sub.serialize());
  110167. }
  110168. serializationObject.subEmitters.push(cell);
  110169. }
  110170. }
  110171. return serializationObject;
  110172. };
  110173. /** @hidden */
  110174. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  110175. serializationObject.name = particleSystem.name;
  110176. serializationObject.id = particleSystem.id;
  110177. serializationObject.capacity = particleSystem.getCapacity();
  110178. // Emitter
  110179. if (particleSystem.emitter.position) {
  110180. var emitterMesh = particleSystem.emitter;
  110181. serializationObject.emitterId = emitterMesh.id;
  110182. }
  110183. else {
  110184. var emitterPosition = particleSystem.emitter;
  110185. serializationObject.emitter = emitterPosition.asArray();
  110186. }
  110187. // Emitter
  110188. if (particleSystem.particleEmitterType) {
  110189. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  110190. }
  110191. if (particleSystem.particleTexture) {
  110192. serializationObject.textureName = particleSystem.particleTexture.name;
  110193. serializationObject.invertY = particleSystem.particleTexture._invertY;
  110194. }
  110195. // Animations
  110196. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  110197. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  110198. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  110199. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  110200. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  110201. // Particle system
  110202. serializationObject.startDelay = particleSystem.startDelay;
  110203. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  110204. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  110205. serializationObject.billboardMode = particleSystem.billboardMode;
  110206. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  110207. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  110208. serializationObject.minSize = particleSystem.minSize;
  110209. serializationObject.maxSize = particleSystem.maxSize;
  110210. serializationObject.minScaleX = particleSystem.minScaleX;
  110211. serializationObject.maxScaleX = particleSystem.maxScaleX;
  110212. serializationObject.minScaleY = particleSystem.minScaleY;
  110213. serializationObject.maxScaleY = particleSystem.maxScaleY;
  110214. serializationObject.minEmitPower = particleSystem.minEmitPower;
  110215. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  110216. serializationObject.minLifeTime = particleSystem.minLifeTime;
  110217. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  110218. serializationObject.emitRate = particleSystem.emitRate;
  110219. serializationObject.gravity = particleSystem.gravity.asArray();
  110220. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  110221. serializationObject.color1 = particleSystem.color1.asArray();
  110222. serializationObject.color2 = particleSystem.color2.asArray();
  110223. serializationObject.colorDead = particleSystem.colorDead.asArray();
  110224. serializationObject.updateSpeed = particleSystem.updateSpeed;
  110225. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  110226. serializationObject.blendMode = particleSystem.blendMode;
  110227. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  110228. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  110229. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  110230. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  110231. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  110232. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  110233. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  110234. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  110235. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  110236. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  110237. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  110238. var colorGradients = particleSystem.getColorGradients();
  110239. if (colorGradients) {
  110240. serializationObject.colorGradients = [];
  110241. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  110242. var colorGradient = colorGradients_1[_i];
  110243. var serializedGradient = {
  110244. gradient: colorGradient.gradient,
  110245. color1: colorGradient.color1.asArray()
  110246. };
  110247. if (colorGradient.color2) {
  110248. serializedGradient.color2 = colorGradient.color2.asArray();
  110249. }
  110250. serializationObject.colorGradients.push(serializedGradient);
  110251. }
  110252. }
  110253. var rampGradients = particleSystem.getRampGradients();
  110254. if (rampGradients) {
  110255. serializationObject.rampGradients = [];
  110256. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  110257. var rampGradient = rampGradients_1[_a];
  110258. var serializedGradient = {
  110259. gradient: rampGradient.gradient,
  110260. color: rampGradient.color.asArray()
  110261. };
  110262. serializationObject.rampGradients.push(serializedGradient);
  110263. }
  110264. serializationObject.useRampGradients = particleSystem.useRampGradients;
  110265. }
  110266. var colorRemapGradients = particleSystem.getColorRemapGradients();
  110267. if (colorRemapGradients) {
  110268. serializationObject.colorRemapGradients = [];
  110269. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  110270. var colorRemapGradient = colorRemapGradients_1[_b];
  110271. var serializedGradient = {
  110272. gradient: colorRemapGradient.gradient,
  110273. factor1: colorRemapGradient.factor1
  110274. };
  110275. if (colorRemapGradient.factor2 !== undefined) {
  110276. serializedGradient.factor2 = colorRemapGradient.factor2;
  110277. }
  110278. serializationObject.colorRemapGradients.push(serializedGradient);
  110279. }
  110280. }
  110281. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  110282. if (alphaRemapGradients) {
  110283. serializationObject.alphaRemapGradients = [];
  110284. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  110285. var alphaRemapGradient = alphaRemapGradients_1[_c];
  110286. var serializedGradient = {
  110287. gradient: alphaRemapGradient.gradient,
  110288. factor1: alphaRemapGradient.factor1
  110289. };
  110290. if (alphaRemapGradient.factor2 !== undefined) {
  110291. serializedGradient.factor2 = alphaRemapGradient.factor2;
  110292. }
  110293. serializationObject.alphaRemapGradients.push(serializedGradient);
  110294. }
  110295. }
  110296. var sizeGradients = particleSystem.getSizeGradients();
  110297. if (sizeGradients) {
  110298. serializationObject.sizeGradients = [];
  110299. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  110300. var sizeGradient = sizeGradients_1[_d];
  110301. var serializedGradient = {
  110302. gradient: sizeGradient.gradient,
  110303. factor1: sizeGradient.factor1
  110304. };
  110305. if (sizeGradient.factor2 !== undefined) {
  110306. serializedGradient.factor2 = sizeGradient.factor2;
  110307. }
  110308. serializationObject.sizeGradients.push(serializedGradient);
  110309. }
  110310. }
  110311. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  110312. if (angularSpeedGradients) {
  110313. serializationObject.angularSpeedGradients = [];
  110314. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  110315. var angularSpeedGradient = angularSpeedGradients_1[_e];
  110316. var serializedGradient = {
  110317. gradient: angularSpeedGradient.gradient,
  110318. factor1: angularSpeedGradient.factor1
  110319. };
  110320. if (angularSpeedGradient.factor2 !== undefined) {
  110321. serializedGradient.factor2 = angularSpeedGradient.factor2;
  110322. }
  110323. serializationObject.angularSpeedGradients.push(serializedGradient);
  110324. }
  110325. }
  110326. var velocityGradients = particleSystem.getVelocityGradients();
  110327. if (velocityGradients) {
  110328. serializationObject.velocityGradients = [];
  110329. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  110330. var velocityGradient = velocityGradients_1[_f];
  110331. var serializedGradient = {
  110332. gradient: velocityGradient.gradient,
  110333. factor1: velocityGradient.factor1
  110334. };
  110335. if (velocityGradient.factor2 !== undefined) {
  110336. serializedGradient.factor2 = velocityGradient.factor2;
  110337. }
  110338. serializationObject.velocityGradients.push(serializedGradient);
  110339. }
  110340. }
  110341. var dragGradients = particleSystem.getDragGradients();
  110342. if (dragGradients) {
  110343. serializationObject.dragyGradients = [];
  110344. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  110345. var dragGradient = dragGradients_1[_g];
  110346. var serializedGradient = {
  110347. gradient: dragGradient.gradient,
  110348. factor1: dragGradient.factor1
  110349. };
  110350. if (dragGradient.factor2 !== undefined) {
  110351. serializedGradient.factor2 = dragGradient.factor2;
  110352. }
  110353. serializationObject.dragGradients.push(serializedGradient);
  110354. }
  110355. }
  110356. var emitRateGradients = particleSystem.getEmitRateGradients();
  110357. if (emitRateGradients) {
  110358. serializationObject.emitRateGradients = [];
  110359. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  110360. var emitRateGradient = emitRateGradients_1[_h];
  110361. var serializedGradient = {
  110362. gradient: emitRateGradient.gradient,
  110363. factor1: emitRateGradient.factor1
  110364. };
  110365. if (emitRateGradient.factor2 !== undefined) {
  110366. serializedGradient.factor2 = emitRateGradient.factor2;
  110367. }
  110368. serializationObject.emitRateGradients.push(serializedGradient);
  110369. }
  110370. }
  110371. var startSizeGradients = particleSystem.getStartSizeGradients();
  110372. if (startSizeGradients) {
  110373. serializationObject.startSizeGradients = [];
  110374. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  110375. var startSizeGradient = startSizeGradients_1[_j];
  110376. var serializedGradient = {
  110377. gradient: startSizeGradient.gradient,
  110378. factor1: startSizeGradient.factor1
  110379. };
  110380. if (startSizeGradient.factor2 !== undefined) {
  110381. serializedGradient.factor2 = startSizeGradient.factor2;
  110382. }
  110383. serializationObject.startSizeGradients.push(serializedGradient);
  110384. }
  110385. }
  110386. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  110387. if (lifeTimeGradients) {
  110388. serializationObject.lifeTimeGradients = [];
  110389. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  110390. var lifeTimeGradient = lifeTimeGradients_1[_k];
  110391. var serializedGradient = {
  110392. gradient: lifeTimeGradient.gradient,
  110393. factor1: lifeTimeGradient.factor1
  110394. };
  110395. if (lifeTimeGradient.factor2 !== undefined) {
  110396. serializedGradient.factor2 = lifeTimeGradient.factor2;
  110397. }
  110398. serializationObject.lifeTimeGradients.push(serializedGradient);
  110399. }
  110400. }
  110401. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  110402. if (limitVelocityGradients) {
  110403. serializationObject.limitVelocityGradients = [];
  110404. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  110405. var limitVelocityGradient = limitVelocityGradients_1[_l];
  110406. var serializedGradient = {
  110407. gradient: limitVelocityGradient.gradient,
  110408. factor1: limitVelocityGradient.factor1
  110409. };
  110410. if (limitVelocityGradient.factor2 !== undefined) {
  110411. serializedGradient.factor2 = limitVelocityGradient.factor2;
  110412. }
  110413. serializationObject.limitVelocityGradients.push(serializedGradient);
  110414. }
  110415. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  110416. }
  110417. if (particleSystem.noiseTexture) {
  110418. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  110419. }
  110420. };
  110421. /** @hidden */
  110422. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  110423. // Texture
  110424. if (parsedParticleSystem.textureName) {
  110425. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  110426. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  110427. }
  110428. // Emitter
  110429. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  110430. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110431. }
  110432. else if (parsedParticleSystem.emitterId) {
  110433. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  110434. }
  110435. else {
  110436. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  110437. }
  110438. // Misc.
  110439. if (parsedParticleSystem.renderingGroupId !== undefined) {
  110440. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  110441. }
  110442. if (parsedParticleSystem.isBillboardBased !== undefined) {
  110443. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  110444. }
  110445. if (parsedParticleSystem.billboardMode !== undefined) {
  110446. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  110447. }
  110448. // Animations
  110449. if (parsedParticleSystem.animations) {
  110450. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  110451. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  110452. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  110453. if (internalClass) {
  110454. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  110455. }
  110456. }
  110457. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  110458. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  110459. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  110460. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  110461. }
  110462. if (parsedParticleSystem.autoAnimate) {
  110463. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  110464. }
  110465. // Particle system
  110466. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  110467. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  110468. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  110469. particleSystem.minSize = parsedParticleSystem.minSize;
  110470. particleSystem.maxSize = parsedParticleSystem.maxSize;
  110471. if (parsedParticleSystem.minScaleX) {
  110472. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  110473. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  110474. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  110475. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  110476. }
  110477. if (parsedParticleSystem.preWarmCycles !== undefined) {
  110478. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  110479. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  110480. }
  110481. if (parsedParticleSystem.minInitialRotation !== undefined) {
  110482. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  110483. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  110484. }
  110485. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  110486. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  110487. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  110488. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  110489. particleSystem.emitRate = parsedParticleSystem.emitRate;
  110490. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  110491. if (parsedParticleSystem.noiseStrength) {
  110492. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  110493. }
  110494. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  110495. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  110496. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  110497. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  110498. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  110499. particleSystem.blendMode = parsedParticleSystem.blendMode;
  110500. if (parsedParticleSystem.colorGradients) {
  110501. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  110502. var colorGradient = _a[_i];
  110503. 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);
  110504. }
  110505. }
  110506. if (parsedParticleSystem.rampGradients) {
  110507. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  110508. var rampGradient = _c[_b];
  110509. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  110510. }
  110511. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  110512. }
  110513. if (parsedParticleSystem.colorRemapGradients) {
  110514. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  110515. var colorRemapGradient = _e[_d];
  110516. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  110517. }
  110518. }
  110519. if (parsedParticleSystem.alphaRemapGradients) {
  110520. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  110521. var alphaRemapGradient = _g[_f];
  110522. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  110523. }
  110524. }
  110525. if (parsedParticleSystem.sizeGradients) {
  110526. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  110527. var sizeGradient = _j[_h];
  110528. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  110529. }
  110530. }
  110531. if (parsedParticleSystem.sizeGradients) {
  110532. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  110533. var sizeGradient = _l[_k];
  110534. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  110535. }
  110536. }
  110537. if (parsedParticleSystem.angularSpeedGradients) {
  110538. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  110539. var angularSpeedGradient = _o[_m];
  110540. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  110541. }
  110542. }
  110543. if (parsedParticleSystem.velocityGradients) {
  110544. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  110545. var velocityGradient = _q[_p];
  110546. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  110547. }
  110548. }
  110549. if (parsedParticleSystem.dragGradients) {
  110550. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  110551. var dragGradient = _s[_r];
  110552. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  110553. }
  110554. }
  110555. if (parsedParticleSystem.emitRateGradients) {
  110556. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  110557. var emitRateGradient = _u[_t];
  110558. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  110559. }
  110560. }
  110561. if (parsedParticleSystem.startSizeGradients) {
  110562. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  110563. var startSizeGradient = _w[_v];
  110564. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  110565. }
  110566. }
  110567. if (parsedParticleSystem.lifeTimeGradients) {
  110568. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  110569. var lifeTimeGradient = _y[_x];
  110570. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  110571. }
  110572. }
  110573. if (parsedParticleSystem.limitVelocityGradients) {
  110574. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  110575. var limitVelocityGradient = _0[_z];
  110576. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  110577. }
  110578. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  110579. }
  110580. if (parsedParticleSystem.noiseTexture) {
  110581. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  110582. }
  110583. // Emitter
  110584. var emitterType;
  110585. if (parsedParticleSystem.particleEmitterType) {
  110586. switch (parsedParticleSystem.particleEmitterType.type) {
  110587. case "SphereParticleEmitter":
  110588. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  110589. break;
  110590. case "SphereDirectedParticleEmitter":
  110591. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  110592. break;
  110593. case "ConeEmitter":
  110594. case "ConeParticleEmitter":
  110595. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  110596. break;
  110597. case "CylinderParticleEmitter":
  110598. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  110599. break;
  110600. case "HemisphericParticleEmitter":
  110601. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  110602. break;
  110603. case "BoxEmitter":
  110604. case "BoxParticleEmitter":
  110605. default:
  110606. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  110607. break;
  110608. }
  110609. emitterType.parse(parsedParticleSystem.particleEmitterType);
  110610. }
  110611. else {
  110612. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  110613. emitterType.parse(parsedParticleSystem);
  110614. }
  110615. particleSystem.particleEmitterType = emitterType;
  110616. // Animation sheet
  110617. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  110618. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  110619. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  110620. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  110621. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  110622. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  110623. };
  110624. /**
  110625. * Parses a JSON object to create a particle system.
  110626. * @param parsedParticleSystem The JSON object to parse
  110627. * @param scene The scene to create the particle system in
  110628. * @param rootUrl The root url to use to load external dependencies like texture
  110629. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110630. * @returns the Parsed particle system
  110631. */
  110632. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  110633. if (doNotStart === void 0) { doNotStart = false; }
  110634. var name = parsedParticleSystem.name;
  110635. var custom = null;
  110636. var program = null;
  110637. if (parsedParticleSystem.customShader) {
  110638. program = parsedParticleSystem.customShader;
  110639. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  110640. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  110641. }
  110642. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  110643. particleSystem.customShader = program;
  110644. if (parsedParticleSystem.id) {
  110645. particleSystem.id = parsedParticleSystem.id;
  110646. }
  110647. // SubEmitters
  110648. if (parsedParticleSystem.subEmitters) {
  110649. particleSystem.subEmitters = [];
  110650. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  110651. var cell = _a[_i];
  110652. var cellArray = [];
  110653. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  110654. var sub = cell_1[_b];
  110655. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  110656. }
  110657. particleSystem.subEmitters.push(cellArray);
  110658. }
  110659. }
  110660. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  110661. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  110662. // Auto start
  110663. if (parsedParticleSystem.preventAutoStart) {
  110664. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  110665. }
  110666. if (!doNotStart && !particleSystem.preventAutoStart) {
  110667. particleSystem.start();
  110668. }
  110669. return particleSystem;
  110670. };
  110671. /**
  110672. * Billboard mode will only apply to Y axis
  110673. */
  110674. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  110675. /**
  110676. * Billboard mode will apply to all axes
  110677. */
  110678. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  110679. /**
  110680. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  110681. */
  110682. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  110683. return ParticleSystem;
  110684. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  110685. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  110686. /***/ }),
  110687. /***/ "./Particles/particleSystemComponent.ts":
  110688. /*!**********************************************!*\
  110689. !*** ./Particles/particleSystemComponent.ts ***!
  110690. \**********************************************/
  110691. /*! exports provided: _IDoNeedToBeInTheBuild */
  110692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110693. "use strict";
  110694. __webpack_require__.r(__webpack_exports__);
  110695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  110696. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  110697. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  110698. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  110699. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  110700. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  110701. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  110702. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  110703. // Adds the parsers to the scene parsers.
  110704. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  110705. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  110706. if (!individualParser) {
  110707. return;
  110708. }
  110709. // Particles Systems
  110710. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  110711. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  110712. var parsedParticleSystem = parsedData.particleSystems[index];
  110713. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  110714. }
  110715. }
  110716. });
  110717. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  110718. if (parsedParticleSystem.activeParticleCount) {
  110719. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  110720. return ps;
  110721. }
  110722. else {
  110723. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  110724. return ps;
  110725. }
  110726. });
  110727. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  110728. if (uniformsNames === void 0) { uniformsNames = []; }
  110729. if (samplers === void 0) { samplers = []; }
  110730. if (defines === void 0) { defines = ""; }
  110731. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  110732. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  110733. if (defines.indexOf(" BILLBOARD") === -1) {
  110734. defines += "\n#define BILLBOARD\n";
  110735. }
  110736. if (samplers.indexOf("diffuseSampler") === -1) {
  110737. samplers.push("diffuseSampler");
  110738. }
  110739. return this.createEffect({
  110740. vertex: "particles",
  110741. fragmentElement: fragmentName
  110742. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  110743. };
  110744. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  110745. var results = new Array();
  110746. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  110747. var particleSystem = this.getScene().particleSystems[index];
  110748. if (particleSystem.emitter === this) {
  110749. results.push(particleSystem);
  110750. }
  110751. }
  110752. return results;
  110753. };
  110754. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  110755. var results = new Array();
  110756. var descendants = this.getDescendants();
  110757. descendants.push(this);
  110758. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  110759. var particleSystem = this.getScene().particleSystems[index];
  110760. var emitter = particleSystem.emitter;
  110761. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  110762. results.push(particleSystem);
  110763. }
  110764. }
  110765. return results;
  110766. };
  110767. /**
  110768. * @hidden
  110769. */
  110770. var _IDoNeedToBeInTheBuild = 42;
  110771. /***/ }),
  110772. /***/ "./Particles/particleSystemSet.ts":
  110773. /*!****************************************!*\
  110774. !*** ./Particles/particleSystemSet.ts ***!
  110775. \****************************************/
  110776. /*! exports provided: ParticleSystemSet */
  110777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110778. "use strict";
  110779. __webpack_require__.r(__webpack_exports__);
  110780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  110781. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110782. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  110783. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  110784. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  110785. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  110786. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  110787. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  110788. /** Internal class used to store shapes for emitters */
  110789. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  110790. function ParticleSystemSetEmitterCreationOptions() {
  110791. }
  110792. return ParticleSystemSetEmitterCreationOptions;
  110793. }());
  110794. /**
  110795. * Represents a set of particle systems working together to create a specific effect
  110796. */
  110797. var ParticleSystemSet = /** @class */ (function () {
  110798. function ParticleSystemSet() {
  110799. /**
  110800. * Gets the particle system list
  110801. */
  110802. this.systems = new Array();
  110803. }
  110804. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  110805. /**
  110806. * Gets the emitter node used with this set
  110807. */
  110808. get: function () {
  110809. return this._emitterNode;
  110810. },
  110811. enumerable: true,
  110812. configurable: true
  110813. });
  110814. /**
  110815. * Creates a new emitter mesh as a sphere
  110816. * @param options defines the options used to create the sphere
  110817. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110818. * @param scene defines the hosting scene
  110819. */
  110820. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  110821. if (this._emitterNode) {
  110822. this._emitterNode.dispose();
  110823. }
  110824. this._emitterCreationOptions = {
  110825. kind: "Sphere",
  110826. options: options,
  110827. renderingGroupId: renderingGroupId
  110828. };
  110829. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  110830. emitterMesh.renderingGroupId = renderingGroupId;
  110831. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  110832. material.emissiveColor = options.color;
  110833. emitterMesh.material = material;
  110834. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  110835. var system = _a[_i];
  110836. system.emitter = emitterMesh;
  110837. }
  110838. this._emitterNode = emitterMesh;
  110839. };
  110840. /**
  110841. * Starts all particle systems of the set
  110842. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110843. */
  110844. ParticleSystemSet.prototype.start = function (emitter) {
  110845. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  110846. var system = _a[_i];
  110847. if (emitter) {
  110848. system.emitter = emitter;
  110849. }
  110850. system.start();
  110851. }
  110852. };
  110853. /**
  110854. * Release all associated resources
  110855. */
  110856. ParticleSystemSet.prototype.dispose = function () {
  110857. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  110858. var system = _a[_i];
  110859. system.dispose();
  110860. }
  110861. this.systems = [];
  110862. if (this._emitterNode) {
  110863. this._emitterNode.dispose();
  110864. this._emitterNode = null;
  110865. }
  110866. };
  110867. /**
  110868. * Serialize the set into a JSON compatible object
  110869. * @returns a JSON compatible representation of the set
  110870. */
  110871. ParticleSystemSet.prototype.serialize = function () {
  110872. var result = {};
  110873. result.systems = [];
  110874. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  110875. var system = _a[_i];
  110876. result.systems.push(system.serialize());
  110877. }
  110878. if (this._emitterNode) {
  110879. result.emitter = this._emitterCreationOptions;
  110880. }
  110881. return result;
  110882. };
  110883. /**
  110884. * Parse a new ParticleSystemSet from a serialized source
  110885. * @param data defines a JSON compatible representation of the set
  110886. * @param scene defines the hosting scene
  110887. * @param gpu defines if we want GPU particles or CPU particles
  110888. * @returns a new ParticleSystemSet
  110889. */
  110890. ParticleSystemSet.Parse = function (data, scene, gpu) {
  110891. if (gpu === void 0) { gpu = false; }
  110892. var result = new ParticleSystemSet();
  110893. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  110894. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  110895. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  110896. var system = _a[_i];
  110897. 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));
  110898. }
  110899. if (data.emitter) {
  110900. var options = data.emitter.options;
  110901. switch (data.emitter.kind) {
  110902. case "Sphere":
  110903. result.setEmitterAsSphere({
  110904. diameter: options.diameter,
  110905. segments: options.segments,
  110906. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  110907. }, data.emitter.renderingGroupId, scene);
  110908. break;
  110909. }
  110910. }
  110911. return result;
  110912. };
  110913. return ParticleSystemSet;
  110914. }());
  110915. /***/ }),
  110916. /***/ "./Particles/solidParticle.ts":
  110917. /*!************************************!*\
  110918. !*** ./Particles/solidParticle.ts ***!
  110919. \************************************/
  110920. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  110921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110922. "use strict";
  110923. __webpack_require__.r(__webpack_exports__);
  110924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  110925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  110926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  110927. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110928. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  110929. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  110930. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110931. /**
  110932. * Represents one particle of a solid particle system.
  110933. */
  110934. var SolidParticle = /** @class */ (function () {
  110935. /**
  110936. * Creates a Solid Particle object.
  110937. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110938. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  110939. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110940. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110941. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110942. * @param shapeId (integer) is the model shape identifier in the SPS.
  110943. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110944. * @param sps defines the sps it is associated to
  110945. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110946. */
  110947. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  110948. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  110949. /**
  110950. * particle global index
  110951. */
  110952. this.idx = 0;
  110953. /**
  110954. * The color of the particle
  110955. */
  110956. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  110957. /**
  110958. * The world space position of the particle.
  110959. */
  110960. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110961. /**
  110962. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110963. */
  110964. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110965. /**
  110966. * The scaling of the particle.
  110967. */
  110968. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  110969. /**
  110970. * The uvs of the particle.
  110971. */
  110972. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  110973. /**
  110974. * The current speed of the particle.
  110975. */
  110976. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110977. /**
  110978. * The pivot point in the particle local space.
  110979. */
  110980. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110981. /**
  110982. * Must the particle be translated from its pivot point in its local space ?
  110983. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110984. * Default : false
  110985. */
  110986. this.translateFromPivot = false;
  110987. /**
  110988. * Is the particle active or not ?
  110989. */
  110990. this.alive = true;
  110991. /**
  110992. * Is the particle visible or not ?
  110993. */
  110994. this.isVisible = true;
  110995. /**
  110996. * Index of this particle in the global "positions" array (Internal use)
  110997. * @hidden
  110998. */
  110999. this._pos = 0;
  111000. /**
  111001. * @hidden Index of this particle in the global "indices" array (Internal use)
  111002. */
  111003. this._ind = 0;
  111004. /**
  111005. * ModelShape id of this particle
  111006. */
  111007. this.shapeId = 0;
  111008. /**
  111009. * Index of the particle in its shape id (Internal use)
  111010. */
  111011. this.idxInShape = 0;
  111012. /**
  111013. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  111014. */
  111015. this._stillInvisible = false;
  111016. /**
  111017. * @hidden Last computed particle rotation matrix
  111018. */
  111019. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  111020. /**
  111021. * Parent particle Id, if any.
  111022. * Default null.
  111023. */
  111024. this.parentId = null;
  111025. /**
  111026. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  111027. * The possible values are :
  111028. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111029. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111030. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111031. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111032. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111033. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  111034. * */
  111035. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  111036. /**
  111037. * @hidden Internal global position in the SPS.
  111038. */
  111039. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111040. this.idx = particleIndex;
  111041. this._pos = positionIndex;
  111042. this._ind = indiceIndex;
  111043. this._model = model;
  111044. this.shapeId = shapeId;
  111045. this.idxInShape = idxInShape;
  111046. this._sps = sps;
  111047. if (modelBoundingInfo) {
  111048. this._modelBoundingInfo = modelBoundingInfo;
  111049. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  111050. }
  111051. }
  111052. Object.defineProperty(SolidParticle.prototype, "scale", {
  111053. /**
  111054. * Legacy support, changed scale to scaling
  111055. */
  111056. get: function () {
  111057. return this.scaling;
  111058. },
  111059. /**
  111060. * Legacy support, changed scale to scaling
  111061. */
  111062. set: function (scale) {
  111063. this.scaling = scale;
  111064. },
  111065. enumerable: true,
  111066. configurable: true
  111067. });
  111068. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  111069. /**
  111070. * Legacy support, changed quaternion to rotationQuaternion
  111071. */
  111072. get: function () {
  111073. return this.rotationQuaternion;
  111074. },
  111075. /**
  111076. * Legacy support, changed quaternion to rotationQuaternion
  111077. */
  111078. set: function (q) {
  111079. this.rotationQuaternion = q;
  111080. },
  111081. enumerable: true,
  111082. configurable: true
  111083. });
  111084. /**
  111085. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111086. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111087. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111088. * @returns true if it intersects
  111089. */
  111090. SolidParticle.prototype.intersectsMesh = function (target) {
  111091. if (!this._boundingInfo || !target._boundingInfo) {
  111092. return false;
  111093. }
  111094. if (this._sps._bSphereOnly) {
  111095. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  111096. }
  111097. return this._boundingInfo.intersects(target._boundingInfo, false);
  111098. };
  111099. /**
  111100. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111101. * A particle is in the frustum if its bounding box intersects the frustum
  111102. * @param frustumPlanes defines the frustum to test
  111103. * @returns true if the particle is in the frustum planes
  111104. */
  111105. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  111106. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  111107. };
  111108. /**
  111109. * get the rotation matrix of the particle
  111110. * @hidden
  111111. */
  111112. SolidParticle.prototype.getRotationMatrix = function (m) {
  111113. var quaternion;
  111114. if (this.rotationQuaternion) {
  111115. quaternion = this.rotationQuaternion;
  111116. }
  111117. else {
  111118. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  111119. var rotation = this.rotation;
  111120. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  111121. }
  111122. quaternion.toRotationMatrix(m);
  111123. };
  111124. return SolidParticle;
  111125. }());
  111126. /**
  111127. * Represents the shape of the model used by one particle of a solid particle system.
  111128. * SPS internal tool, don't use it manually.
  111129. */
  111130. var ModelShape = /** @class */ (function () {
  111131. /**
  111132. * 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.
  111133. * SPS internal tool, don't use it manually.
  111134. * @hidden
  111135. */
  111136. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  111137. /**
  111138. * length of the shape in the model indices array (internal use)
  111139. * @hidden
  111140. */
  111141. this._indicesLength = 0;
  111142. this.shapeID = id;
  111143. this._shape = shape;
  111144. this._indicesLength = indicesLength;
  111145. this._shapeUV = shapeUV;
  111146. this._positionFunction = posFunction;
  111147. this._vertexFunction = vtxFunction;
  111148. }
  111149. return ModelShape;
  111150. }());
  111151. /**
  111152. * Represents a Depth Sorted Particle in the solid particle system.
  111153. */
  111154. var DepthSortedParticle = /** @class */ (function () {
  111155. function DepthSortedParticle() {
  111156. /**
  111157. * Index of the particle in the "indices" array
  111158. */
  111159. this.ind = 0;
  111160. /**
  111161. * Length of the particle shape in the "indices" array
  111162. */
  111163. this.indicesLength = 0;
  111164. /**
  111165. * Squared distance from the particle to the camera
  111166. */
  111167. this.sqDistance = 0.0;
  111168. }
  111169. return DepthSortedParticle;
  111170. }());
  111171. /***/ }),
  111172. /***/ "./Particles/solidParticleSystem.ts":
  111173. /*!******************************************!*\
  111174. !*** ./Particles/solidParticleSystem.ts ***!
  111175. \******************************************/
  111176. /*! exports provided: SolidParticleSystem */
  111177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111178. "use strict";
  111179. __webpack_require__.r(__webpack_exports__);
  111180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  111181. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111182. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  111183. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  111184. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  111185. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  111186. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  111187. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  111188. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  111189. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  111190. /**
  111191. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111192. *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.
  111193. * The SPS is also a particle system. It provides some methods to manage the particles.
  111194. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111195. *
  111196. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  111197. */
  111198. var SolidParticleSystem = /** @class */ (function () {
  111199. /**
  111200. * Creates a SPS (Solid Particle System) object.
  111201. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111202. * @param scene (Scene) is the scene in which the SPS is added.
  111203. * @param options defines the options of the sps e.g.
  111204. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111205. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111206. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111207. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111208. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111209. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111210. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111211. */
  111212. function SolidParticleSystem(name, scene, options) {
  111213. /**
  111214. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111215. * Example : var p = SPS.particles[i];
  111216. */
  111217. this.particles = new Array();
  111218. /**
  111219. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111220. */
  111221. this.nbParticles = 0;
  111222. /**
  111223. * If the particles must ever face the camera (default false). Useful for planar particles.
  111224. */
  111225. this.billboard = false;
  111226. /**
  111227. * Recompute normals when adding a shape
  111228. */
  111229. this.recomputeNormals = true;
  111230. /**
  111231. * This a counter ofr your own usage. It's not set by any SPS functions.
  111232. */
  111233. this.counter = 0;
  111234. /**
  111235. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111236. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  111237. */
  111238. this.vars = {};
  111239. /**
  111240. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111241. * @hidden
  111242. */
  111243. this._bSphereOnly = false;
  111244. /**
  111245. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111246. * @hidden
  111247. */
  111248. this._bSphereRadiusFactor = 1.0;
  111249. this._positions = new Array();
  111250. this._indices = new Array();
  111251. this._normals = new Array();
  111252. this._colors = new Array();
  111253. this._uvs = new Array();
  111254. this._index = 0; // indices index
  111255. this._updatable = true;
  111256. this._pickable = false;
  111257. this._isVisibilityBoxLocked = false;
  111258. this._alwaysVisible = false;
  111259. this._depthSort = false;
  111260. this._shapeCounter = 0;
  111261. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  111262. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  111263. this._computeParticleColor = true;
  111264. this._computeParticleTexture = true;
  111265. this._computeParticleRotation = true;
  111266. this._computeParticleVertex = false;
  111267. this._computeBoundingBox = false;
  111268. this._depthSortParticles = true;
  111269. this._mustUnrotateFixedNormals = false;
  111270. this._particlesIntersect = false;
  111271. this._needs32Bits = false;
  111272. this.name = name;
  111273. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  111274. this._camera = scene.activeCamera;
  111275. this._pickable = options ? options.isPickable : false;
  111276. this._depthSort = options ? options.enableDepthSort : false;
  111277. this._particlesIntersect = options ? options.particleIntersection : false;
  111278. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  111279. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  111280. if (options && options.updatable !== undefined) {
  111281. this._updatable = options.updatable;
  111282. }
  111283. else {
  111284. this._updatable = true;
  111285. }
  111286. if (this._pickable) {
  111287. this.pickedParticles = [];
  111288. }
  111289. if (this._depthSort) {
  111290. this.depthSortedParticles = [];
  111291. }
  111292. }
  111293. /**
  111294. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111295. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111296. * @returns the created mesh
  111297. */
  111298. SolidParticleSystem.prototype.buildMesh = function () {
  111299. if (this.nbParticles === 0) {
  111300. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  111301. this.addShape(triangle, 1);
  111302. triangle.dispose();
  111303. }
  111304. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  111305. this._positions32 = new Float32Array(this._positions);
  111306. this._uvs32 = new Float32Array(this._uvs);
  111307. this._colors32 = new Float32Array(this._colors);
  111308. if (this.recomputeNormals) {
  111309. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  111310. }
  111311. this._normals32 = new Float32Array(this._normals);
  111312. this._fixedNormal32 = new Float32Array(this._normals);
  111313. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  111314. this._unrotateFixedNormals();
  111315. }
  111316. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  111317. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  111318. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  111319. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  111320. if (this._uvs32.length > 0) {
  111321. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  111322. }
  111323. if (this._colors32.length > 0) {
  111324. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  111325. }
  111326. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  111327. vertexData.applyToMesh(mesh, this._updatable);
  111328. this.mesh = mesh;
  111329. this.mesh.isPickable = this._pickable;
  111330. // free memory
  111331. if (!this._depthSort) {
  111332. this._indices = null;
  111333. }
  111334. this._positions = null;
  111335. this._normals = null;
  111336. this._uvs = null;
  111337. this._colors = null;
  111338. if (!this._updatable) {
  111339. this.particles.length = 0;
  111340. }
  111341. return mesh;
  111342. };
  111343. /**
  111344. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111345. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111346. * Thus the particles generated from `digest()` have their property `position` set yet.
  111347. * @param mesh ( Mesh ) is the mesh to be digested
  111348. * @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
  111349. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111350. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111351. * @returns the current SPS
  111352. */
  111353. SolidParticleSystem.prototype.digest = function (mesh, options) {
  111354. var size = (options && options.facetNb) || 1;
  111355. var number = (options && options.number) || 0;
  111356. var delta = (options && options.delta) || 0;
  111357. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  111358. var meshInd = mesh.getIndices();
  111359. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  111360. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  111361. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  111362. var f = 0; // facet counter
  111363. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  111364. // compute size from number
  111365. if (number) {
  111366. number = (number > totalFacets) ? totalFacets : number;
  111367. size = Math.round(totalFacets / number);
  111368. delta = 0;
  111369. }
  111370. else {
  111371. size = (size > totalFacets) ? totalFacets : size;
  111372. }
  111373. var facetPos = []; // submesh positions
  111374. var facetInd = []; // submesh indices
  111375. var facetUV = []; // submesh UV
  111376. var facetCol = []; // submesh colors
  111377. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111378. var sizeO = size;
  111379. while (f < totalFacets) {
  111380. size = sizeO + Math.floor((1 + delta) * Math.random());
  111381. if (f > totalFacets - size) {
  111382. size = totalFacets - f;
  111383. }
  111384. // reset temp arrays
  111385. facetPos.length = 0;
  111386. facetInd.length = 0;
  111387. facetUV.length = 0;
  111388. facetCol.length = 0;
  111389. // iterate over "size" facets
  111390. var fi = 0;
  111391. for (var j = f * 3; j < (f + size) * 3; j++) {
  111392. facetInd.push(fi);
  111393. var i = meshInd[j];
  111394. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  111395. if (meshUV) {
  111396. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  111397. }
  111398. if (meshCol) {
  111399. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  111400. }
  111401. fi++;
  111402. }
  111403. // create a model shape for each single particle
  111404. var idx = this.nbParticles;
  111405. var shape = this._posToShape(facetPos);
  111406. var shapeUV = this._uvsToShapeUV(facetUV);
  111407. // compute the barycenter of the shape
  111408. var v;
  111409. for (v = 0; v < shape.length; v++) {
  111410. barycenter.addInPlace(shape[v]);
  111411. }
  111412. barycenter.scaleInPlace(1 / shape.length);
  111413. // shift the shape from its barycenter to the origin
  111414. for (v = 0; v < shape.length; v++) {
  111415. shape[v].subtractInPlace(barycenter);
  111416. }
  111417. var bInfo;
  111418. if (this._particlesIntersect) {
  111419. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  111420. }
  111421. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  111422. // add the particle in the SPS
  111423. var currentPos = this._positions.length;
  111424. var currentInd = this._indices.length;
  111425. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  111426. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  111427. // initialize the particle position
  111428. this.particles[this.nbParticles].position.addInPlace(barycenter);
  111429. this._index += shape.length;
  111430. idx++;
  111431. this.nbParticles++;
  111432. this._shapeCounter++;
  111433. f += size;
  111434. }
  111435. return this;
  111436. };
  111437. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111438. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  111439. var index = 0;
  111440. var idx = 0;
  111441. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  111442. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  111443. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  111444. for (var p = 0; p < this.particles.length; p++) {
  111445. var particle = this.particles[p];
  111446. var shape = particle._model._shape;
  111447. // computing the inverse of the rotation matrix from the quaternion
  111448. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  111449. if (particle.rotationQuaternion) {
  111450. particle.rotationQuaternion.conjugateToRef(quaternion);
  111451. }
  111452. else {
  111453. var rotation = particle.rotation;
  111454. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  111455. quaternion.conjugateInPlace();
  111456. }
  111457. quaternion.toRotationMatrix(invertedRotMatrix);
  111458. for (var pt = 0; pt < shape.length; pt++) {
  111459. idx = index + pt * 3;
  111460. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  111461. tmpNormal.toArray(this._fixedNormal32, idx);
  111462. }
  111463. index = idx + 3;
  111464. }
  111465. };
  111466. //reset copy
  111467. SolidParticleSystem.prototype._resetCopy = function () {
  111468. var copy = this._copy;
  111469. copy.position.setAll(0);
  111470. copy.rotation.setAll(0);
  111471. copy.rotationQuaternion = null;
  111472. copy.scaling.setAll(1);
  111473. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  111474. copy.color = null;
  111475. copy.translateFromPivot = false;
  111476. };
  111477. // _meshBuilder : inserts the shape model in the global SPS mesh
  111478. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  111479. var i;
  111480. var u = 0;
  111481. var c = 0;
  111482. var n = 0;
  111483. this._resetCopy();
  111484. var copy = this._copy;
  111485. if (options && options.positionFunction) { // call to custom positionFunction
  111486. options.positionFunction(copy, idx, idxInShape);
  111487. this._mustUnrotateFixedNormals = true;
  111488. }
  111489. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  111490. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  111491. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  111492. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  111493. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  111494. copy.getRotationMatrix(rotMatrix);
  111495. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  111496. if (copy.translateFromPivot) {
  111497. pivotBackTranslation.setAll(0.0);
  111498. }
  111499. else {
  111500. pivotBackTranslation.copyFrom(scaledPivot);
  111501. }
  111502. for (i = 0; i < shape.length; i++) {
  111503. tmpVertex.copyFrom(shape[i]);
  111504. if (options && options.vertexFunction) {
  111505. options.vertexFunction(copy, tmpVertex, i);
  111506. }
  111507. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  111508. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  111509. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  111510. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  111511. if (meshUV) {
  111512. var copyUvs = copy.uvs;
  111513. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  111514. u += 2;
  111515. }
  111516. if (copy.color) {
  111517. this._color = copy.color;
  111518. }
  111519. else {
  111520. var color = this._color;
  111521. if (meshCol && meshCol[c] !== undefined) {
  111522. color.r = meshCol[c];
  111523. color.g = meshCol[c + 1];
  111524. color.b = meshCol[c + 2];
  111525. color.a = meshCol[c + 3];
  111526. }
  111527. else {
  111528. color.r = 1.0;
  111529. color.g = 1.0;
  111530. color.b = 1.0;
  111531. color.a = 1.0;
  111532. }
  111533. }
  111534. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  111535. c += 4;
  111536. if (!this.recomputeNormals && meshNor) {
  111537. tmpVertex.x = meshNor[n];
  111538. tmpVertex.y = meshNor[n + 1];
  111539. tmpVertex.z = meshNor[n + 2];
  111540. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  111541. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  111542. n += 3;
  111543. }
  111544. }
  111545. for (i = 0; i < meshInd.length; i++) {
  111546. var current_ind = p + meshInd[i];
  111547. indices.push(current_ind);
  111548. if (current_ind > 65535) {
  111549. this._needs32Bits = true;
  111550. }
  111551. }
  111552. if (this._pickable) {
  111553. var nbfaces = meshInd.length / 3;
  111554. for (i = 0; i < nbfaces; i++) {
  111555. this.pickedParticles.push({ idx: idx, faceId: i });
  111556. }
  111557. }
  111558. if (this._depthSort) {
  111559. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  111560. }
  111561. return copy;
  111562. };
  111563. // returns a shape array from positions array
  111564. SolidParticleSystem.prototype._posToShape = function (positions) {
  111565. var shape = [];
  111566. for (var i = 0; i < positions.length; i += 3) {
  111567. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  111568. }
  111569. return shape;
  111570. };
  111571. // returns a shapeUV array from a Vector4 uvs
  111572. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  111573. var shapeUV = [];
  111574. if (uvs) {
  111575. for (var i = 0; i < uvs.length; i++) {
  111576. shapeUV.push(uvs[i]);
  111577. }
  111578. }
  111579. return shapeUV;
  111580. };
  111581. // adds a new particle object in the particles array
  111582. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  111583. if (bInfo === void 0) { bInfo = null; }
  111584. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  111585. this.particles.push(sp);
  111586. return sp;
  111587. };
  111588. /**
  111589. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111590. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  111591. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111592. * @param nb (positive integer) the number of particles to be created from this model
  111593. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111594. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111595. * @returns the number of shapes in the system
  111596. */
  111597. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  111598. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  111599. var meshInd = mesh.getIndices();
  111600. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  111601. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  111602. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  111603. var bbInfo;
  111604. if (this._particlesIntersect) {
  111605. bbInfo = mesh.getBoundingInfo();
  111606. }
  111607. var shape = this._posToShape(meshPos);
  111608. var shapeUV = this._uvsToShapeUV(meshUV);
  111609. var posfunc = options ? options.positionFunction : null;
  111610. var vtxfunc = options ? options.vertexFunction : null;
  111611. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  111612. // particles
  111613. var sp;
  111614. var currentCopy;
  111615. var idx = this.nbParticles;
  111616. for (var i = 0; i < nb; i++) {
  111617. var currentPos = this._positions.length;
  111618. var currentInd = this._indices.length;
  111619. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  111620. if (this._updatable) {
  111621. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  111622. sp.position.copyFrom(currentCopy.position);
  111623. sp.rotation.copyFrom(currentCopy.rotation);
  111624. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  111625. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  111626. }
  111627. if (currentCopy.color && sp.color) {
  111628. sp.color.copyFrom(currentCopy.color);
  111629. }
  111630. sp.scaling.copyFrom(currentCopy.scaling);
  111631. sp.uvs.copyFrom(currentCopy.uvs);
  111632. }
  111633. this._index += shape.length;
  111634. idx++;
  111635. }
  111636. this.nbParticles += nb;
  111637. this._shapeCounter++;
  111638. return this._shapeCounter - 1;
  111639. };
  111640. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111641. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  111642. this._resetCopy();
  111643. var copy = this._copy;
  111644. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  111645. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  111646. }
  111647. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  111648. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  111649. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  111650. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  111651. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  111652. copy.getRotationMatrix(rotMatrix);
  111653. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  111654. if (copy.translateFromPivot) {
  111655. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  111656. }
  111657. else {
  111658. pivotBackTranslation.copyFrom(scaledPivot);
  111659. }
  111660. var shape = particle._model._shape;
  111661. for (var pt = 0; pt < shape.length; pt++) {
  111662. tmpVertex.copyFrom(shape[pt]);
  111663. if (particle._model._vertexFunction) {
  111664. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  111665. }
  111666. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  111667. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  111668. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  111669. }
  111670. particle.position.setAll(0.0);
  111671. particle.rotation.setAll(0.0);
  111672. particle.rotationQuaternion = null;
  111673. particle.scaling.setAll(1.0);
  111674. particle.uvs.setAll(0.0);
  111675. particle.pivot.setAll(0.0);
  111676. particle.translateFromPivot = false;
  111677. particle.parentId = null;
  111678. };
  111679. /**
  111680. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111681. * @returns the SPS.
  111682. */
  111683. SolidParticleSystem.prototype.rebuildMesh = function () {
  111684. for (var p = 0; p < this.particles.length; p++) {
  111685. this._rebuildParticle(this.particles[p]);
  111686. }
  111687. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  111688. return this;
  111689. };
  111690. /**
  111691. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111692. * This method calls `updateParticle()` for each particle of the SPS.
  111693. * For an animated SPS, it is usually called within the render loop.
  111694. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111695. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111696. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111697. * @returns the SPS.
  111698. */
  111699. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  111700. if (start === void 0) { start = 0; }
  111701. if (end === void 0) { end = this.nbParticles - 1; }
  111702. if (update === void 0) { update = true; }
  111703. if (!this._updatable) {
  111704. return this;
  111705. }
  111706. // custom beforeUpdate
  111707. this.beforeUpdateParticles(start, end, update);
  111708. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  111709. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  111710. var mesh = this.mesh;
  111711. var colors32 = this._colors32;
  111712. var positions32 = this._positions32;
  111713. var normals32 = this._normals32;
  111714. var uvs32 = this._uvs32;
  111715. var indices32 = this._indices32;
  111716. var indices = this._indices;
  111717. var fixedNormal32 = this._fixedNormal32;
  111718. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  111719. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  111720. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  111721. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  111722. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  111723. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  111724. var camInvertedPosition = tempVectors[10].setAll(0);
  111725. // cases when the World Matrix is to be computed first
  111726. if (this.billboard || this._depthSort) {
  111727. this.mesh.computeWorldMatrix(true);
  111728. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  111729. }
  111730. // if the particles will always face the camera
  111731. if (this.billboard) {
  111732. // compute the camera position and un-rotate it by the current mesh rotation
  111733. var tmpVertex = tempVectors[0];
  111734. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  111735. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  111736. camAxisZ.normalize();
  111737. // same for camera up vector extracted from the cam view matrix
  111738. var view = this._camera.getViewMatrix(true);
  111739. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  111740. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  111741. camAxisY.normalize();
  111742. camAxisX.normalize();
  111743. }
  111744. // if depthSort, compute the camera global position in the mesh local system
  111745. if (this._depthSort) {
  111746. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  111747. }
  111748. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  111749. var idx = 0; // current position index in the global array positions32
  111750. var index = 0; // position start index in the global array positions32 of the current particle
  111751. var colidx = 0; // current color index in the global array colors32
  111752. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  111753. var uvidx = 0; // current uv index in the global array uvs32
  111754. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  111755. var pt = 0; // current index in the particle model shape
  111756. if (this.mesh.isFacetDataEnabled) {
  111757. this._computeBoundingBox = true;
  111758. }
  111759. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  111760. if (this._computeBoundingBox) {
  111761. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  111762. var boundingInfo = this.mesh._boundingInfo;
  111763. if (boundingInfo) {
  111764. minimum.copyFrom(boundingInfo.minimum);
  111765. maximum.copyFrom(boundingInfo.maximum);
  111766. }
  111767. }
  111768. }
  111769. // particle loop
  111770. index = this.particles[start]._pos;
  111771. var vpos = (index / 3) | 0;
  111772. colorIndex = vpos * 4;
  111773. uvIndex = vpos * 2;
  111774. for (var p = start; p <= end; p++) {
  111775. var particle = this.particles[p];
  111776. // call to custom user function to update the particle properties
  111777. this.updateParticle(particle);
  111778. var shape = particle._model._shape;
  111779. var shapeUV = particle._model._shapeUV;
  111780. var particleRotationMatrix = particle._rotationMatrix;
  111781. var particlePosition = particle.position;
  111782. var particleRotation = particle.rotation;
  111783. var particleScaling = particle.scaling;
  111784. var particleGlobalPosition = particle._globalPosition;
  111785. // camera-particle distance for depth sorting
  111786. if (this._depthSort && this._depthSortParticles) {
  111787. var dsp = this.depthSortedParticles[p];
  111788. dsp.ind = particle._ind;
  111789. dsp.indicesLength = particle._model._indicesLength;
  111790. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  111791. }
  111792. // skip the computations for inactive or already invisible particles
  111793. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  111794. // increment indexes for the next particle
  111795. pt = shape.length;
  111796. index += pt * 3;
  111797. colorIndex += pt * 4;
  111798. uvIndex += pt * 2;
  111799. continue;
  111800. }
  111801. if (particle.isVisible) {
  111802. particle._stillInvisible = false; // un-mark permanent invisibility
  111803. var scaledPivot = tempVectors[12];
  111804. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  111805. // particle rotation matrix
  111806. if (this.billboard) {
  111807. particleRotation.x = 0.0;
  111808. particleRotation.y = 0.0;
  111809. }
  111810. if (this._computeParticleRotation || this.billboard) {
  111811. particle.getRotationMatrix(rotMatrix);
  111812. }
  111813. var particleHasParent = (particle.parentId !== null);
  111814. if (particleHasParent) {
  111815. var parent_1 = this.particles[particle.parentId];
  111816. var parentRotationMatrix = parent_1._rotationMatrix;
  111817. var parentGlobalPosition = parent_1._globalPosition;
  111818. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  111819. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  111820. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  111821. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  111822. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  111823. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  111824. if (this._computeParticleRotation || this.billboard) {
  111825. var rotMatrixValues = rotMatrix.m;
  111826. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  111827. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  111828. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  111829. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  111830. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  111831. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  111832. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  111833. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  111834. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  111835. }
  111836. }
  111837. else {
  111838. particleGlobalPosition.x = particlePosition.x;
  111839. particleGlobalPosition.y = particlePosition.y;
  111840. particleGlobalPosition.z = particlePosition.z;
  111841. if (this._computeParticleRotation || this.billboard) {
  111842. var rotMatrixValues = rotMatrix.m;
  111843. particleRotationMatrix[0] = rotMatrixValues[0];
  111844. particleRotationMatrix[1] = rotMatrixValues[1];
  111845. particleRotationMatrix[2] = rotMatrixValues[2];
  111846. particleRotationMatrix[3] = rotMatrixValues[4];
  111847. particleRotationMatrix[4] = rotMatrixValues[5];
  111848. particleRotationMatrix[5] = rotMatrixValues[6];
  111849. particleRotationMatrix[6] = rotMatrixValues[8];
  111850. particleRotationMatrix[7] = rotMatrixValues[9];
  111851. particleRotationMatrix[8] = rotMatrixValues[10];
  111852. }
  111853. }
  111854. var pivotBackTranslation = tempVectors[11];
  111855. if (particle.translateFromPivot) {
  111856. pivotBackTranslation.setAll(0.0);
  111857. }
  111858. else {
  111859. pivotBackTranslation.copyFrom(scaledPivot);
  111860. }
  111861. // particle vertex loop
  111862. for (pt = 0; pt < shape.length; pt++) {
  111863. idx = index + pt * 3;
  111864. colidx = colorIndex + pt * 4;
  111865. uvidx = uvIndex + pt * 2;
  111866. var tmpVertex = tempVectors[0];
  111867. tmpVertex.copyFrom(shape[pt]);
  111868. if (this._computeParticleVertex) {
  111869. this.updateParticleVertex(particle, tmpVertex, pt);
  111870. }
  111871. // positions
  111872. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  111873. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  111874. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  111875. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  111876. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  111877. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  111878. rotatedX += pivotBackTranslation.x;
  111879. rotatedY += pivotBackTranslation.y;
  111880. rotatedZ += pivotBackTranslation.z;
  111881. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  111882. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  111883. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  111884. if (this._computeBoundingBox) {
  111885. minimum.minimizeInPlaceFromFloats(px, py, pz);
  111886. maximum.maximizeInPlaceFromFloats(px, py, pz);
  111887. }
  111888. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  111889. if (!this._computeParticleVertex) {
  111890. var normalx = fixedNormal32[idx];
  111891. var normaly = fixedNormal32[idx + 1];
  111892. var normalz = fixedNormal32[idx + 2];
  111893. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  111894. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  111895. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  111896. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  111897. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  111898. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  111899. }
  111900. if (this._computeParticleColor && particle.color) {
  111901. var color = particle.color;
  111902. var colors32_1 = this._colors32;
  111903. colors32_1[colidx] = color.r;
  111904. colors32_1[colidx + 1] = color.g;
  111905. colors32_1[colidx + 2] = color.b;
  111906. colors32_1[colidx + 3] = color.a;
  111907. }
  111908. if (this._computeParticleTexture) {
  111909. var uvs = particle.uvs;
  111910. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  111911. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  111912. }
  111913. }
  111914. }
  111915. // particle just set invisible : scaled to zero and positioned at the origin
  111916. else {
  111917. particle._stillInvisible = true; // mark the particle as invisible
  111918. for (pt = 0; pt < shape.length; pt++) {
  111919. idx = index + pt * 3;
  111920. colidx = colorIndex + pt * 4;
  111921. uvidx = uvIndex + pt * 2;
  111922. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  111923. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  111924. if (this._computeParticleColor && particle.color) {
  111925. var color = particle.color;
  111926. colors32[colidx] = color.r;
  111927. colors32[colidx + 1] = color.g;
  111928. colors32[colidx + 2] = color.b;
  111929. colors32[colidx + 3] = color.a;
  111930. }
  111931. if (this._computeParticleTexture) {
  111932. var uvs = particle.uvs;
  111933. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  111934. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  111935. }
  111936. }
  111937. }
  111938. // if the particle intersections must be computed : update the bbInfo
  111939. if (this._particlesIntersect) {
  111940. var bInfo = particle._boundingInfo;
  111941. var bBox = bInfo.boundingBox;
  111942. var bSphere = bInfo.boundingSphere;
  111943. var modelBoundingInfo = particle._modelBoundingInfo;
  111944. if (!this._bSphereOnly) {
  111945. // place, scale and rotate the particle bbox within the SPS local system, then update it
  111946. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  111947. var tempMin = tempVectors[1];
  111948. var tempMax = tempVectors[2];
  111949. tempMin.setAll(Number.MAX_VALUE);
  111950. tempMax.setAll(-Number.MAX_VALUE);
  111951. for (var b = 0; b < 8; b++) {
  111952. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  111953. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  111954. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  111955. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  111956. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  111957. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  111958. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  111959. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  111960. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  111961. tempMin.minimizeInPlaceFromFloats(x, y, z);
  111962. tempMax.maximizeInPlaceFromFloats(x, y, z);
  111963. }
  111964. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  111965. }
  111966. // place and scale the particle bouding sphere in the SPS local system, then update it
  111967. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  111968. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  111969. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  111970. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  111971. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  111972. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  111973. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  111974. }
  111975. // increment indexes for the next particle
  111976. index = idx + 3;
  111977. colorIndex = colidx + 4;
  111978. uvIndex = uvidx + 2;
  111979. }
  111980. // if the VBO must be updated
  111981. if (update) {
  111982. if (this._computeParticleColor) {
  111983. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  111984. }
  111985. if (this._computeParticleTexture) {
  111986. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  111987. }
  111988. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  111989. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  111990. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  111991. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  111992. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  111993. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  111994. for (var i = 0; i < normals32.length; i++) {
  111995. fixedNormal32[i] = normals32[i];
  111996. }
  111997. }
  111998. if (!mesh.areNormalsFrozen) {
  111999. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  112000. }
  112001. }
  112002. if (this._depthSort && this._depthSortParticles) {
  112003. var depthSortedParticles = this.depthSortedParticles;
  112004. depthSortedParticles.sort(depthSortFunction);
  112005. var dspl = depthSortedParticles.length;
  112006. var sid = 0;
  112007. for (var sorted = 0; sorted < dspl; sorted++) {
  112008. var lind = depthSortedParticles[sorted].indicesLength;
  112009. var sind = depthSortedParticles[sorted].ind;
  112010. for (var i = 0; i < lind; i++) {
  112011. indices32[sid] = indices[sind + i];
  112012. sid++;
  112013. }
  112014. }
  112015. mesh.updateIndices(indices32);
  112016. }
  112017. }
  112018. if (this._computeBoundingBox) {
  112019. if (mesh._boundingInfo) {
  112020. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  112021. }
  112022. else {
  112023. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  112024. }
  112025. }
  112026. this.afterUpdateParticles(start, end, update);
  112027. return this;
  112028. };
  112029. /**
  112030. * Disposes the SPS.
  112031. */
  112032. SolidParticleSystem.prototype.dispose = function () {
  112033. this.mesh.dispose();
  112034. this.vars = null;
  112035. // drop references to internal big arrays for the GC
  112036. this._positions = null;
  112037. this._indices = null;
  112038. this._normals = null;
  112039. this._uvs = null;
  112040. this._colors = null;
  112041. this._indices32 = null;
  112042. this._positions32 = null;
  112043. this._normals32 = null;
  112044. this._fixedNormal32 = null;
  112045. this._uvs32 = null;
  112046. this._colors32 = null;
  112047. this.pickedParticles = null;
  112048. };
  112049. /**
  112050. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  112051. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112052. * @returns the SPS.
  112053. */
  112054. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  112055. if (!this._isVisibilityBoxLocked) {
  112056. this.mesh.refreshBoundingInfo();
  112057. }
  112058. return this;
  112059. };
  112060. /**
  112061. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  112062. * @param size the size (float) of the visibility box
  112063. * note : this doesn't lock the SPS mesh bounding box.
  112064. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112065. */
  112066. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  112067. var vis = size / 2;
  112068. 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));
  112069. };
  112070. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  112071. /**
  112072. * Gets whether the SPS as always visible or not
  112073. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112074. */
  112075. get: function () {
  112076. return this._alwaysVisible;
  112077. },
  112078. /**
  112079. * Sets the SPS as always visible or not
  112080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112081. */
  112082. set: function (val) {
  112083. this._alwaysVisible = val;
  112084. this.mesh.alwaysSelectAsActiveMesh = val;
  112085. },
  112086. enumerable: true,
  112087. configurable: true
  112088. });
  112089. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  112090. /**
  112091. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112092. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112093. */
  112094. get: function () {
  112095. return this._isVisibilityBoxLocked;
  112096. },
  112097. /**
  112098. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112099. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112100. */
  112101. set: function (val) {
  112102. this._isVisibilityBoxLocked = val;
  112103. var boundingInfo = this.mesh.getBoundingInfo();
  112104. boundingInfo.isLocked = val;
  112105. },
  112106. enumerable: true,
  112107. configurable: true
  112108. });
  112109. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  112110. /**
  112111. * Gets if `setParticles()` computes the particle rotations or not.
  112112. * Default value : true. The SPS is faster when it's set to false.
  112113. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112114. */
  112115. get: function () {
  112116. return this._computeParticleRotation;
  112117. },
  112118. /**
  112119. * Tells to `setParticles()` to compute the particle rotations or not.
  112120. * Default value : true. The SPS is faster when it's set to false.
  112121. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112122. */
  112123. set: function (val) {
  112124. this._computeParticleRotation = val;
  112125. },
  112126. enumerable: true,
  112127. configurable: true
  112128. });
  112129. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  112130. /**
  112131. * Gets if `setParticles()` computes the particle colors or not.
  112132. * Default value : true. The SPS is faster when it's set to false.
  112133. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112134. */
  112135. get: function () {
  112136. return this._computeParticleColor;
  112137. },
  112138. /**
  112139. * Tells to `setParticles()` to compute the particle colors or not.
  112140. * Default value : true. The SPS is faster when it's set to false.
  112141. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112142. */
  112143. set: function (val) {
  112144. this._computeParticleColor = val;
  112145. },
  112146. enumerable: true,
  112147. configurable: true
  112148. });
  112149. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  112150. /**
  112151. * Gets if `setParticles()` computes the particle textures or not.
  112152. * Default value : true. The SPS is faster when it's set to false.
  112153. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  112154. */
  112155. get: function () {
  112156. return this._computeParticleTexture;
  112157. },
  112158. set: function (val) {
  112159. this._computeParticleTexture = val;
  112160. },
  112161. enumerable: true,
  112162. configurable: true
  112163. });
  112164. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  112165. /**
  112166. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  112167. * Default value : false. The SPS is faster when it's set to false.
  112168. * Note : the particle custom vertex positions aren't stored values.
  112169. */
  112170. get: function () {
  112171. return this._computeParticleVertex;
  112172. },
  112173. /**
  112174. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  112175. * Default value : false. The SPS is faster when it's set to false.
  112176. * Note : the particle custom vertex positions aren't stored values.
  112177. */
  112178. set: function (val) {
  112179. this._computeParticleVertex = val;
  112180. },
  112181. enumerable: true,
  112182. configurable: true
  112183. });
  112184. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  112185. /**
  112186. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  112187. */
  112188. get: function () {
  112189. return this._computeBoundingBox;
  112190. },
  112191. /**
  112192. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  112193. */
  112194. set: function (val) {
  112195. this._computeBoundingBox = val;
  112196. },
  112197. enumerable: true,
  112198. configurable: true
  112199. });
  112200. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  112201. /**
  112202. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  112203. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112204. * Default : `true`
  112205. */
  112206. get: function () {
  112207. return this._depthSortParticles;
  112208. },
  112209. /**
  112210. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  112211. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112212. * Default : `true`
  112213. */
  112214. set: function (val) {
  112215. this._depthSortParticles = val;
  112216. },
  112217. enumerable: true,
  112218. configurable: true
  112219. });
  112220. // =======================================================================
  112221. // Particle behavior logic
  112222. // these following methods may be overwritten by the user to fit his needs
  112223. /**
  112224. * This function does nothing. It may be overwritten to set all the particle first values.
  112225. * The SPS doesn't call this function, you may have to call it by your own.
  112226. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  112227. */
  112228. SolidParticleSystem.prototype.initParticles = function () {
  112229. };
  112230. /**
  112231. * This function does nothing. It may be overwritten to recycle a particle.
  112232. * The SPS doesn't call this function, you may have to call it by your own.
  112233. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  112234. * @param particle The particle to recycle
  112235. * @returns the recycled particle
  112236. */
  112237. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  112238. return particle;
  112239. };
  112240. /**
  112241. * Updates a particle : this function should be overwritten by the user.
  112242. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  112243. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  112244. * @example : just set a particle position or velocity and recycle conditions
  112245. * @param particle The particle to update
  112246. * @returns the updated particle
  112247. */
  112248. SolidParticleSystem.prototype.updateParticle = function (particle) {
  112249. return particle;
  112250. };
  112251. /**
  112252. * Updates a vertex of a particle : it can be overwritten by the user.
  112253. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  112254. * @param particle the current particle
  112255. * @param vertex the current index of the current particle
  112256. * @param pt the index of the current vertex in the particle shape
  112257. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  112258. * @example : just set a vertex particle position
  112259. * @returns the updated vertex
  112260. */
  112261. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  112262. return vertex;
  112263. };
  112264. /**
  112265. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  112266. * This does nothing and may be overwritten by the user.
  112267. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112268. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112269. * @param update the boolean update value actually passed to setParticles()
  112270. */
  112271. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  112272. };
  112273. /**
  112274. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  112275. * This will be passed three parameters.
  112276. * This does nothing and may be overwritten by the user.
  112277. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112278. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112279. * @param update the boolean update value actually passed to setParticles()
  112280. */
  112281. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  112282. };
  112283. return SolidParticleSystem;
  112284. }());
  112285. /***/ }),
  112286. /***/ "./Particles/subEmitter.ts":
  112287. /*!*********************************!*\
  112288. !*** ./Particles/subEmitter.ts ***!
  112289. \*********************************/
  112290. /*! exports provided: SubEmitterType, SubEmitter */
  112291. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112292. "use strict";
  112293. __webpack_require__.r(__webpack_exports__);
  112294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  112295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  112296. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112297. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  112298. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112299. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  112300. /**
  112301. * Type of sub emitter
  112302. */
  112303. var SubEmitterType;
  112304. (function (SubEmitterType) {
  112305. /**
  112306. * Attached to the particle over it's lifetime
  112307. */
  112308. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  112309. /**
  112310. * Created when the particle dies
  112311. */
  112312. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  112313. })(SubEmitterType || (SubEmitterType = {}));
  112314. /**
  112315. * Sub emitter class used to emit particles from an existing particle
  112316. */
  112317. var SubEmitter = /** @class */ (function () {
  112318. /**
  112319. * Creates a sub emitter
  112320. * @param particleSystem the particle system to be used by the sub emitter
  112321. */
  112322. function SubEmitter(
  112323. /**
  112324. * the particle system to be used by the sub emitter
  112325. */
  112326. particleSystem) {
  112327. this.particleSystem = particleSystem;
  112328. /**
  112329. * Type of the submitter (Default: END)
  112330. */
  112331. this.type = SubEmitterType.END;
  112332. /**
  112333. * 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)
  112334. * Note: This only is supported when using an emitter of type Mesh
  112335. */
  112336. this.inheritDirection = false;
  112337. /**
  112338. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  112339. */
  112340. this.inheritedVelocityAmount = 0;
  112341. // Create mesh as emitter to support rotation
  112342. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  112343. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  112344. }
  112345. // Automatically dispose of subemitter when system is disposed
  112346. particleSystem.onDisposeObservable.add(function () {
  112347. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  112348. particleSystem.emitter.dispose();
  112349. }
  112350. });
  112351. }
  112352. /**
  112353. * Clones the sub emitter
  112354. * @returns the cloned sub emitter
  112355. */
  112356. SubEmitter.prototype.clone = function () {
  112357. // Clone particle system
  112358. var emitter = this.particleSystem.emitter;
  112359. if (!emitter) {
  112360. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  112361. }
  112362. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  112363. emitter = emitter.clone();
  112364. }
  112365. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  112366. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  112367. emitter.isVisible = false;
  112368. }
  112369. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  112370. // Clone properties
  112371. clone.type = this.type;
  112372. clone.inheritDirection = this.inheritDirection;
  112373. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  112374. clone.particleSystem._disposeEmitterOnDispose = true;
  112375. clone.particleSystem.disposeOnStop = true;
  112376. return clone;
  112377. };
  112378. /**
  112379. * Serialize current object to a JSON object
  112380. * @returns the serialized object
  112381. */
  112382. SubEmitter.prototype.serialize = function () {
  112383. var serializationObject = {};
  112384. serializationObject.type = this.type;
  112385. serializationObject.inheritDirection = this.inheritDirection;
  112386. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  112387. serializationObject.particleSystem = this.particleSystem.serialize();
  112388. return serializationObject;
  112389. };
  112390. /** @hidden */
  112391. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  112392. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  112393. };
  112394. /**
  112395. * Creates a new SubEmitter from a serialized JSON version
  112396. * @param serializationObject defines the JSON object to read from
  112397. * @param scene defines the hosting scene
  112398. * @param rootUrl defines the rootUrl for data loading
  112399. * @returns a new SubEmitter
  112400. */
  112401. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  112402. var system = serializationObject.particleSystem;
  112403. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  112404. subEmitter.type = serializationObject.type;
  112405. subEmitter.inheritDirection = serializationObject.inheritDirection;
  112406. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  112407. subEmitter.particleSystem._isSubEmitter = true;
  112408. return subEmitter;
  112409. };
  112410. /** Release associated resources */
  112411. SubEmitter.prototype.dispose = function () {
  112412. this.particleSystem.dispose();
  112413. };
  112414. return SubEmitter;
  112415. }());
  112416. /***/ }),
  112417. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  112418. /*!*****************************************!*\
  112419. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  112420. \*****************************************/
  112421. /*! exports provided: AmmoJSPlugin */
  112422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112423. "use strict";
  112424. __webpack_require__.r(__webpack_exports__);
  112425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  112426. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  112427. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  112428. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  112429. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  112430. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  112431. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  112432. /* harmony import */ var _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Meshes/Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  112433. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  112434. /**
  112435. * AmmoJS Physics plugin
  112436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112437. * @see https://github.com/kripken/ammo.js/
  112438. */
  112439. var AmmoJSPlugin = /** @class */ (function () {
  112440. /**
  112441. * Initializes the ammoJS plugin
  112442. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112443. * @param ammoInjection can be used to inject your own ammo reference
  112444. */
  112445. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  112446. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  112447. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  112448. var _this = this;
  112449. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  112450. /**
  112451. * Reference to the Ammo library
  112452. */
  112453. this.bjsAMMO = {};
  112454. /**
  112455. * Name of the plugin
  112456. */
  112457. this.name = "AmmoJSPlugin";
  112458. this._timeStep = 1 / 60;
  112459. this._fixedTimeStep = 1 / 60;
  112460. this._maxSteps = 5;
  112461. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  112462. this._tmpContactCallbackResult = false;
  112463. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  112464. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  112465. if (typeof ammoInjection === "function") {
  112466. ammoInjection(this.bjsAMMO);
  112467. }
  112468. else {
  112469. this.bjsAMMO = ammoInjection;
  112470. }
  112471. if (!this.isSupported()) {
  112472. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  112473. return;
  112474. }
  112475. // Initialize the physics world
  112476. this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration();
  112477. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  112478. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  112479. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  112480. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver();
  112481. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver);
  112482. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  112483. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  112484. // Create temp ammo variables
  112485. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  112486. this._tmpAmmoTransform.setIdentity();
  112487. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  112488. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  112489. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  112490. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  112491. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0);
  112492. }
  112493. /**
  112494. * Sets the gravity of the physics world (m/(s^2))
  112495. * @param gravity Gravity to set
  112496. */
  112497. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  112498. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  112499. this.world.setGravity(this._tmpAmmoVectorA);
  112500. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
  112501. };
  112502. /**
  112503. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112504. * @param timeStep timestep to use in seconds
  112505. */
  112506. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  112507. this._timeStep = timeStep;
  112508. };
  112509. /**
  112510. * 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)
  112511. * @param fixedTimeStep fixedTimeStep to use in seconds
  112512. */
  112513. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  112514. this._fixedTimeStep = fixedTimeStep;
  112515. };
  112516. /**
  112517. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112518. * @param maxSteps the maximum number of steps by the physics engine per frame
  112519. */
  112520. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  112521. this._maxSteps = maxSteps;
  112522. };
  112523. /**
  112524. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112525. * @returns the current timestep in seconds
  112526. */
  112527. AmmoJSPlugin.prototype.getTimeStep = function () {
  112528. return this._timeStep;
  112529. };
  112530. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  112531. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  112532. this._tmpContactCallbackResult = false;
  112533. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  112534. return this._tmpContactCallbackResult;
  112535. };
  112536. // Ammo's collision events have some weird quirks
  112537. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  112538. // so only fire event if both contactTest and contactPairTest have a hit
  112539. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  112540. this._tmpContactCallbackResult = false;
  112541. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  112542. return this._tmpContactCallbackResult;
  112543. };
  112544. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  112545. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  112546. //
  112547. // When maxSteps is 0 do the entire simulation in one step
  112548. // 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)
  112549. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  112550. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  112551. if (timeStep === void 0) { timeStep = 1 / 60; }
  112552. if (maxSteps === void 0) { maxSteps = 10; }
  112553. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  112554. if (maxSteps == 0) {
  112555. this.world.stepSimulation(timeStep, 0);
  112556. }
  112557. else {
  112558. while (maxSteps > 0 && timeStep > 0) {
  112559. if (timeStep - fixedTimeStep < fixedTimeStep) {
  112560. this.world.stepSimulation(timeStep, 0);
  112561. timeStep = 0;
  112562. }
  112563. else {
  112564. timeStep -= fixedTimeStep;
  112565. this.world.stepSimulation(fixedTimeStep, 0);
  112566. }
  112567. maxSteps--;
  112568. }
  112569. }
  112570. };
  112571. /**
  112572. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112573. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112574. * After the step the babylon meshes are set to the position of the physics imposters
  112575. * @param delta amount of time to step forward
  112576. * @param impostors array of imposters to update before/after the step
  112577. */
  112578. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  112579. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  112580. var impostor = impostors_1[_i];
  112581. // Update physics world objects to match babylon world
  112582. if (!impostor.soft) {
  112583. impostor.beforeStep();
  112584. }
  112585. }
  112586. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  112587. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  112588. var mainImpostor = impostors_2[_a];
  112589. // After physics update make babylon world objects match physics world objects
  112590. if (mainImpostor.soft) {
  112591. this._afterSoftStep(mainImpostor);
  112592. }
  112593. else {
  112594. mainImpostor.afterStep();
  112595. }
  112596. // Handle collision event
  112597. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  112598. if (this._isImpostorInContact(mainImpostor)) {
  112599. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  112600. var collideCallback = _c[_b];
  112601. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  112602. var otherImpostor = _e[_d];
  112603. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  112604. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  112605. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  112606. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  112607. }
  112608. }
  112609. }
  112610. }
  112611. }
  112612. }
  112613. }
  112614. };
  112615. /**
  112616. * Update babylon mesh to match physics world object
  112617. * @param impostor imposter to match
  112618. */
  112619. AmmoJSPlugin.prototype._afterSoftStep = function (impostor) {
  112620. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor) {
  112621. this._ropeStep(impostor);
  112622. }
  112623. else {
  112624. this._softbodyOrClothStep(impostor);
  112625. }
  112626. };
  112627. /**
  112628. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112629. * @param impostor imposter to match
  112630. */
  112631. AmmoJSPlugin.prototype._ropeStep = function (impostor) {
  112632. var bodyVertices = impostor.physicsBody.get_m_nodes();
  112633. var nbVertices = bodyVertices.size();
  112634. var node;
  112635. var nodePositions;
  112636. var x, y, z;
  112637. var path = new Array();
  112638. for (var n = 0; n < nbVertices; n++) {
  112639. node = bodyVertices.at(n);
  112640. nodePositions = node.get_m_x();
  112641. x = nodePositions.x();
  112642. y = nodePositions.y();
  112643. z = nodePositions.z();
  112644. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](x, y, z));
  112645. }
  112646. var object = impostor.object;
  112647. var shape = impostor.getParam("shape");
  112648. if (impostor._isFromLine) {
  112649. impostor.object = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines("lines", { points: path, instance: object });
  112650. }
  112651. else {
  112652. impostor.object = _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__["ShapeBuilder"].ExtrudeShape("ext", { shape: shape, path: path, instance: object });
  112653. }
  112654. };
  112655. /**
  112656. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112657. * @param impostor imposter to match
  112658. */
  112659. AmmoJSPlugin.prototype._softbodyOrClothStep = function (impostor) {
  112660. var normalDirection = (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor) ? 1 : -1;
  112661. var object = impostor.object;
  112662. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  112663. if (!vertexPositions) {
  112664. vertexPositions = [];
  112665. }
  112666. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  112667. if (!vertexNormals) {
  112668. vertexNormals = [];
  112669. }
  112670. var nbVertices = vertexPositions.length / 3;
  112671. var bodyVertices = impostor.physicsBody.get_m_nodes();
  112672. var node;
  112673. var nodePositions;
  112674. var nodeNormals;
  112675. var x, y, z;
  112676. var nx, ny, nz;
  112677. for (var n = 0; n < nbVertices; n++) {
  112678. node = bodyVertices.at(n);
  112679. nodePositions = node.get_m_x();
  112680. x = nodePositions.x();
  112681. y = nodePositions.y();
  112682. z = nodePositions.z() * normalDirection;
  112683. var nodeNormals = node.get_m_n();
  112684. nx = nodeNormals.x();
  112685. ny = nodeNormals.y();
  112686. nz = nodeNormals.z() * normalDirection;
  112687. vertexPositions[3 * n] = x;
  112688. vertexPositions[3 * n + 1] = y;
  112689. vertexPositions[3 * n + 2] = z;
  112690. vertexNormals[3 * n] = nx;
  112691. vertexNormals[3 * n + 1] = ny;
  112692. vertexNormals[3 * n + 2] = nz;
  112693. }
  112694. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  112695. vertex_data.positions = vertexPositions;
  112696. vertex_data.normals = vertexNormals;
  112697. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  112698. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  112699. if (object && object.getIndices) {
  112700. vertex_data.indices = object.getIndices();
  112701. }
  112702. vertex_data.applyToMesh(object);
  112703. };
  112704. /**
  112705. * Applies an impulse on the imposter
  112706. * @param impostor imposter to apply impulse to
  112707. * @param force amount of force to be applied to the imposter
  112708. * @param contactPoint the location to apply the impulse on the imposter
  112709. */
  112710. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  112711. if (!impostor.soft) {
  112712. impostor.physicsBody.activate();
  112713. var worldPoint = this._tmpAmmoVectorA;
  112714. var impulse = this._tmpAmmoVectorB;
  112715. // Convert contactPoint into world space
  112716. if (impostor.object && impostor.object.getWorldMatrix) {
  112717. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  112718. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  112719. contactPoint = this._tmpVector;
  112720. }
  112721. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  112722. impulse.setValue(force.x, force.y, force.z);
  112723. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  112724. }
  112725. else {
  112726. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  112727. }
  112728. };
  112729. /**
  112730. * Applies a force on the imposter
  112731. * @param impostor imposter to apply force
  112732. * @param force amount of force to be applied to the imposter
  112733. * @param contactPoint the location to apply the force on the imposter
  112734. */
  112735. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  112736. if (!impostor.soft) {
  112737. impostor.physicsBody.activate();
  112738. var worldPoint = this._tmpAmmoVectorA;
  112739. var impulse = this._tmpAmmoVectorB;
  112740. // Convert contactPoint into world space
  112741. if (impostor.object && impostor.object.getWorldMatrix) {
  112742. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  112743. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  112744. contactPoint = this._tmpVector;
  112745. }
  112746. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  112747. impulse.setValue(force.x, force.y, force.z);
  112748. impostor.physicsBody.applyForce(impulse, worldPoint);
  112749. }
  112750. else {
  112751. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  112752. }
  112753. };
  112754. /**
  112755. * Creates a physics body using the plugin
  112756. * @param impostor the imposter to create the physics body on
  112757. */
  112758. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  112759. impostor._pluginData = { toDispose: [] };
  112760. //parent-child relationship
  112761. if (impostor.parent) {
  112762. if (impostor.physicsBody) {
  112763. this.removePhysicsBody(impostor);
  112764. impostor.forceUpdate();
  112765. }
  112766. return;
  112767. }
  112768. if (impostor.isBodyInitRequired()) {
  112769. var colShape = this._createShape(impostor);
  112770. var mass = impostor.getParam("mass");
  112771. impostor._pluginData.mass = mass;
  112772. if (impostor.soft) {
  112773. colShape.get_m_cfg().set_collisions(0x11);
  112774. colShape.get_m_cfg().set_kDP(impostor.getParam("damping"));
  112775. Ammo.castObject(colShape, Ammo.btCollisionObject).getCollisionShape().setMargin(impostor.getParam("margin"));
  112776. colShape.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  112777. this.world.addSoftBody(colShape, 1, -1);
  112778. impostor.physicsBody = colShape;
  112779. impostor._pluginData.toDispose.concat([colShape]);
  112780. this.setBodyPressure(impostor, 0);
  112781. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  112782. this.setBodyPressure(impostor, impostor.getParam("pressure"));
  112783. }
  112784. this.setBodyStiffness(impostor, impostor.getParam("stiffness"));
  112785. this.setBodyVelocityIterations(impostor, impostor.getParam("velocityIterations"));
  112786. this.setBodyPositionIterations(impostor, impostor.getParam("positionIterations"));
  112787. }
  112788. else {
  112789. var localInertia = new Ammo.btVector3(0, 0, 0);
  112790. var startTransform = new Ammo.btTransform();
  112791. startTransform.setIdentity();
  112792. if (mass !== 0) {
  112793. colShape.calculateLocalInertia(mass, localInertia);
  112794. }
  112795. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  112796. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  112797. startTransform.setOrigin(this._tmpAmmoVectorA);
  112798. startTransform.setRotation(this._tmpAmmoQuaternion);
  112799. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  112800. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  112801. var body = new Ammo.btRigidBody(rbInfo);
  112802. // Make objects kinematic if it's mass is 0
  112803. if (mass === 0) {
  112804. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  112805. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  112806. }
  112807. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  112808. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  112809. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  112810. }
  112811. this.world.addRigidBody(body);
  112812. impostor.physicsBody = body;
  112813. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  112814. }
  112815. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  112816. this.setBodyFriction(impostor, impostor.getParam("friction"));
  112817. }
  112818. };
  112819. /**
  112820. * Removes the physics body from the imposter and disposes of the body's memory
  112821. * @param impostor imposter to remove the physics body from
  112822. */
  112823. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  112824. var _this = this;
  112825. if (this.world) {
  112826. this.world.removeRigidBody(impostor.physicsBody);
  112827. impostor._pluginData.toDispose.forEach(function (d) {
  112828. _this.bjsAMMO.destroy(d);
  112829. });
  112830. }
  112831. };
  112832. /**
  112833. * Generates a joint
  112834. * @param impostorJoint the imposter joint to create the joint with
  112835. */
  112836. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  112837. var mainBody = impostorJoint.mainImpostor.physicsBody;
  112838. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  112839. if (!mainBody || !connectedBody) {
  112840. return;
  112841. }
  112842. var jointData = impostorJoint.joint.jointData;
  112843. if (!jointData.mainPivot) {
  112844. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  112845. }
  112846. if (!jointData.connectedPivot) {
  112847. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  112848. }
  112849. var joint;
  112850. switch (impostorJoint.joint.type) {
  112851. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  112852. var distance = jointData.maxDistance;
  112853. if (distance) {
  112854. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  112855. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  112856. }
  112857. 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));
  112858. break;
  112859. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  112860. if (!jointData.mainAxis) {
  112861. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  112862. }
  112863. if (!jointData.connectedAxis) {
  112864. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  112865. }
  112866. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  112867. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  112868. 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);
  112869. break;
  112870. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  112871. 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));
  112872. break;
  112873. default:
  112874. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  112875. 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));
  112876. break;
  112877. }
  112878. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  112879. impostorJoint.joint.physicsJoint = joint;
  112880. };
  112881. /**
  112882. * Removes a joint
  112883. * @param impostorJoint the imposter joint to remove the joint from
  112884. */
  112885. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  112886. if (this.world) {
  112887. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  112888. }
  112889. };
  112890. // adds all verticies (including child verticies) to the triangle mesh
  112891. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  112892. var _this = this;
  112893. var triangleCount = 0;
  112894. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  112895. var indices = object.getIndices();
  112896. if (!indices) {
  112897. indices = [];
  112898. }
  112899. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  112900. if (!vertexPositions) {
  112901. vertexPositions = [];
  112902. }
  112903. object.computeWorldMatrix(false);
  112904. var faceCount = indices.length / 3;
  112905. for (var i = 0; i < faceCount; i++) {
  112906. var triPoints = [];
  112907. for (var point = 0; point < 3; point++) {
  112908. 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]);
  112909. // Adjust for initial scaling
  112910. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  112911. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  112912. var vec;
  112913. if (point == 0) {
  112914. vec = this._tmpAmmoVectorA;
  112915. }
  112916. else if (point == 1) {
  112917. vec = this._tmpAmmoVectorB;
  112918. }
  112919. else {
  112920. vec = this._tmpAmmoVectorC;
  112921. }
  112922. vec.setValue(v.x, v.y, v.z);
  112923. triPoints.push(vec);
  112924. }
  112925. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  112926. triangleCount++;
  112927. }
  112928. object.getChildMeshes().forEach(function (m) {
  112929. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  112930. });
  112931. }
  112932. return triangleCount;
  112933. };
  112934. /**
  112935. * Initialise the soft body vertices to match its object's (mesh) vertices
  112936. * Softbody vertices (nodes) are in world space and to match this
  112937. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112938. * @param impostor to create the softbody for
  112939. */
  112940. AmmoJSPlugin.prototype._softVertexData = function (impostor) {
  112941. var object = impostor.object;
  112942. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  112943. var indices = object.getIndices();
  112944. if (!indices) {
  112945. indices = [];
  112946. }
  112947. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  112948. if (!vertexPositions) {
  112949. vertexPositions = [];
  112950. }
  112951. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  112952. if (!vertexNormals) {
  112953. vertexNormals = [];
  112954. }
  112955. object.computeWorldMatrix(false);
  112956. var newPoints = [];
  112957. var newNorms = [];
  112958. for (var i = 0; i < vertexPositions.length; i += 3) {
  112959. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  112960. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  112961. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  112962. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(n, object.getWorldMatrix());
  112963. newPoints.push(v.x, v.y, v.z);
  112964. newNorms.push(n.x, n.y, n.z);
  112965. }
  112966. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  112967. vertex_data.positions = newPoints;
  112968. vertex_data.normals = newNorms;
  112969. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  112970. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  112971. if (object && object.getIndices) {
  112972. vertex_data.indices = object.getIndices();
  112973. }
  112974. vertex_data.applyToMesh(object);
  112975. object.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112976. object.rotationQuaternion = null;
  112977. object.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112978. object.computeWorldMatrix(true);
  112979. return vertex_data;
  112980. }
  112981. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"].ExtractFromMesh(object);
  112982. };
  112983. /**
  112984. * Create an impostor's soft body
  112985. * @param impostor to create the softbody for
  112986. */
  112987. AmmoJSPlugin.prototype._createSoftbody = function (impostor) {
  112988. var object = impostor.object;
  112989. if (object && object.getIndices) {
  112990. var indices = object.getIndices();
  112991. if (!indices) {
  112992. indices = [];
  112993. }
  112994. var vertex_data = this._softVertexData(impostor);
  112995. var vertexPositions = vertex_data.positions;
  112996. var vertexNormals = vertex_data.normals;
  112997. if (vertexPositions === null || vertexNormals === null) {
  112998. return new Ammo.btCompoundShape();
  112999. }
  113000. else {
  113001. var triPoints = [];
  113002. var triNorms = [];
  113003. for (var i = 0; i < vertexPositions.length; i += 3) {
  113004. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  113005. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  113006. triPoints.push(v.x, v.y, -v.z);
  113007. triNorms.push(n.x, n.y, -n.z);
  113008. }
  113009. var softBody = new Ammo.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), triPoints, object.getIndices(), indices.length / 3, true);
  113010. var nbVertices = vertexPositions.length / 3;
  113011. var bodyVertices = softBody.get_m_nodes();
  113012. var node;
  113013. var nodeNormals;
  113014. for (var i = 0; i < nbVertices; i++) {
  113015. node = bodyVertices.at(i);
  113016. var nodeNormals = node.get_m_n();
  113017. nodeNormals.setX(triNorms[3 * i]);
  113018. nodeNormals.setY(triNorms[3 * i + 1]);
  113019. nodeNormals.setZ(triNorms[3 * i + 2]);
  113020. }
  113021. return softBody;
  113022. }
  113023. }
  113024. };
  113025. /**
  113026. * Create cloth for an impostor
  113027. * @param impostor to create the softbody for
  113028. */
  113029. AmmoJSPlugin.prototype._createCloth = function (impostor) {
  113030. var object = impostor.object;
  113031. if (object && object.getIndices) {
  113032. var indices = object.getIndices();
  113033. if (!indices) {
  113034. indices = [];
  113035. }
  113036. var vertex_data = this._softVertexData(impostor);
  113037. var vertexPositions = vertex_data.positions;
  113038. var vertexNormals = vertex_data.normals;
  113039. if (vertexPositions === null || vertexNormals === null) {
  113040. return new Ammo.btCompoundShape();
  113041. }
  113042. else {
  113043. var len = vertexPositions.length;
  113044. var segments = Math.sqrt(len / 3);
  113045. impostor.segments = segments;
  113046. var segs = segments - 1;
  113047. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  113048. this._tmpAmmoVectorB.setValue(vertexPositions[3 * segs], vertexPositions[3 * segs + 1], vertexPositions[3 * segs + 2]);
  113049. this._tmpAmmoVectorD.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  113050. this._tmpAmmoVectorC.setValue(vertexPositions[len - 3 - 3 * segs], vertexPositions[len - 2 - 3 * segs], vertexPositions[len - 1 - 3 * segs]);
  113051. var clothBody = new Ammo.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, segments, segments, impostor.getParam("fixedPoints"), true);
  113052. return clothBody;
  113053. }
  113054. }
  113055. };
  113056. /**
  113057. * Create rope for an impostor
  113058. * @param impostor to create the softbody for
  113059. */
  113060. AmmoJSPlugin.prototype._createRope = function (impostor) {
  113061. var len;
  113062. var segments;
  113063. var vertex_data = this._softVertexData(impostor);
  113064. var vertexPositions = vertex_data.positions;
  113065. var vertexNormals = vertex_data.normals;
  113066. if (vertexPositions === null || vertexNormals === null) {
  113067. return new Ammo.btCompoundShape();
  113068. }
  113069. //force the mesh to be updatable
  113070. vertex_data.applyToMesh(impostor.object, true);
  113071. impostor._isFromLine = true;
  113072. // If in lines mesh all normals will be zero
  113073. var vertexSquared = vertexNormals.map(function (x) { return x * x; });
  113074. var reducer = function (accumulator, currentValue) { return accumulator + currentValue; };
  113075. var reduced = vertexSquared.reduce(reducer);
  113076. if (reduced === 0) { // line mesh
  113077. len = vertexPositions.length;
  113078. segments = len / 3 - 1;
  113079. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  113080. this._tmpAmmoVectorB.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  113081. }
  113082. else { //extruded mesh
  113083. impostor._isFromLine = false;
  113084. var pathVectors = impostor.getParam("path");
  113085. var shape = impostor.getParam("shape");
  113086. if (shape === null) {
  113087. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("No shape available for extruded mesh");
  113088. return new Ammo.btCompoundShape();
  113089. }
  113090. if ((vertexPositions.length % (3 * pathVectors.length)) !== 0) {
  113091. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Path does not match extrusion");
  113092. return new Ammo.btCompoundShape();
  113093. }
  113094. len = pathVectors.length;
  113095. segments = len - 1;
  113096. this._tmpAmmoVectorA.setValue(pathVectors[0].x, pathVectors[0].y, pathVectors[0].z);
  113097. this._tmpAmmoVectorB.setValue(pathVectors[len - 1].x, pathVectors[len - 1].y, pathVectors[len - 1].z);
  113098. }
  113099. impostor.segments = segments;
  113100. var fixedPoints = impostor.getParam("fixedPoints");
  113101. fixedPoints = (fixedPoints > 3) ? 3 : fixedPoints;
  113102. var ropeBody = new Ammo.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, segments - 1, fixedPoints);
  113103. ropeBody.get_m_cfg().set_collisions(0x11);
  113104. return ropeBody;
  113105. };
  113106. // adds all verticies (including child verticies) to the convex hull shape
  113107. AmmoJSPlugin.prototype._addHullVerts = function (btConvexHullShape, topLevelObject, object) {
  113108. var _this = this;
  113109. var triangleCount = 0;
  113110. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  113111. var indices = object.getIndices();
  113112. if (!indices) {
  113113. indices = [];
  113114. }
  113115. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  113116. if (!vertexPositions) {
  113117. vertexPositions = [];
  113118. }
  113119. object.computeWorldMatrix(false);
  113120. var faceCount = indices.length / 3;
  113121. for (var i = 0; i < faceCount; i++) {
  113122. var triPoints = [];
  113123. for (var point = 0; point < 3; point++) {
  113124. 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]);
  113125. // Adjust for initial scaling
  113126. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  113127. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  113128. var vec;
  113129. if (point == 0) {
  113130. vec = this._tmpAmmoVectorA;
  113131. }
  113132. else if (point == 1) {
  113133. vec = this._tmpAmmoVectorB;
  113134. }
  113135. else {
  113136. vec = this._tmpAmmoVectorC;
  113137. }
  113138. vec.setValue(v.x, v.y, v.z);
  113139. triPoints.push(vec);
  113140. }
  113141. btConvexHullShape.addPoint(triPoints[0], true);
  113142. btConvexHullShape.addPoint(triPoints[1], true);
  113143. btConvexHullShape.addPoint(triPoints[2], true);
  113144. triangleCount++;
  113145. }
  113146. object.getChildMeshes().forEach(function (m) {
  113147. triangleCount += _this._addHullVerts(btConvexHullShape, topLevelObject, m);
  113148. });
  113149. }
  113150. return triangleCount;
  113151. };
  113152. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  113153. var _this = this;
  113154. if (ignoreChildren === void 0) { ignoreChildren = false; }
  113155. var object = impostor.object;
  113156. var returnValue;
  113157. var extendSize = impostor.getObjectExtendSize();
  113158. if (!ignoreChildren) {
  113159. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  113160. returnValue = new Ammo.btCompoundShape();
  113161. // Add shape of all children to the compound shape
  113162. var childrenAdded = 0;
  113163. meshChildren.forEach(function (childMesh) {
  113164. var childImpostor = childMesh.getPhysicsImpostor();
  113165. if (childImpostor) {
  113166. var shape = _this._createShape(childImpostor);
  113167. // Position needs to be scaled based on parent's scaling
  113168. var parentMat = childMesh.parent.getWorldMatrix().clone();
  113169. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  113170. parentMat.decompose(s);
  113171. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  113172. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  113173. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  113174. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  113175. childImpostor.dispose();
  113176. childrenAdded++;
  113177. }
  113178. });
  113179. if (childrenAdded > 0) {
  113180. // Add parents shape as a child if present
  113181. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  113182. var shape = this._createShape(impostor, true);
  113183. if (shape) {
  113184. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  113185. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  113186. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  113187. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  113188. }
  113189. }
  113190. return returnValue;
  113191. }
  113192. else {
  113193. // If no children with impostors create the actual shape below instead
  113194. Ammo.destroy(returnValue);
  113195. returnValue = null;
  113196. }
  113197. }
  113198. switch (impostor.type) {
  113199. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  113200. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  113201. break;
  113202. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  113203. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  113204. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  113205. break;
  113206. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  113207. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  113208. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  113209. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  113210. break;
  113211. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  113212. if (impostor.getParam("mass") == 0) {
  113213. // Only create btBvhTriangleMeshShape impostor is static
  113214. // See https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=7283
  113215. var tetraMesh = new Ammo.btTriangleMesh();
  113216. impostor._pluginData.toDispose.concat([tetraMesh]);
  113217. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  113218. if (triangeCount == 0) {
  113219. returnValue = new Ammo.btCompoundShape();
  113220. }
  113221. else {
  113222. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  113223. }
  113224. break;
  113225. }
  113226. // Otherwise create convexHullImpostor
  113227. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ConvexHullImpostor:
  113228. var convexMesh = new Ammo.btConvexHullShape();
  113229. var triangeCount = this._addHullVerts(convexMesh, object, object);
  113230. if (triangeCount == 0) {
  113231. // Cleanup Unused Convex Hull Shape
  113232. impostor._pluginData.toDispose.concat([convexMesh]);
  113233. returnValue = new Ammo.btCompoundShape();
  113234. }
  113235. else {
  113236. returnValue = convexMesh;
  113237. }
  113238. break;
  113239. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  113240. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  113241. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  113242. break;
  113243. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor:
  113244. // Only usable with a mesh that has sufficient and shared vertices
  113245. returnValue = this._createSoftbody(impostor);
  113246. break;
  113247. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor:
  113248. // Only usable with a ground mesh that has sufficient and shared vertices
  113249. returnValue = this._createCloth(impostor);
  113250. break;
  113251. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor:
  113252. // Only usable with a line mesh or an extruded mesh that is updatable
  113253. returnValue = this._createRope(impostor);
  113254. break;
  113255. default:
  113256. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  113257. break;
  113258. }
  113259. return returnValue;
  113260. };
  113261. /**
  113262. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  113263. * @param impostor imposter containing the physics body and babylon object
  113264. */
  113265. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  113266. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  113267. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  113268. if (!impostor.object.rotationQuaternion) {
  113269. if (impostor.object.rotation) {
  113270. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  113271. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  113272. }
  113273. }
  113274. else {
  113275. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  113276. }
  113277. };
  113278. /**
  113279. * Sets the babylon object's position/rotation from the physics body's position/rotation
  113280. * @param impostor imposter containing the physics body and babylon object
  113281. * @param newPosition new position
  113282. * @param newRotation new rotation
  113283. */
  113284. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  113285. var trans = impostor.physicsBody.getWorldTransform();
  113286. // If rotation/position has changed update and activate riged body
  113287. if (trans.getOrigin().x() != newPosition.x ||
  113288. trans.getOrigin().y() != newPosition.y ||
  113289. trans.getOrigin().z() != newPosition.z ||
  113290. trans.getRotation().x() != newRotation.x ||
  113291. trans.getRotation().y() != newRotation.y ||
  113292. trans.getRotation().z() != newRotation.z ||
  113293. trans.getRotation().w() != newRotation.w) {
  113294. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  113295. trans.setOrigin(this._tmpAmmoVectorA);
  113296. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  113297. trans.setRotation(this._tmpAmmoQuaternion);
  113298. impostor.physicsBody.setWorldTransform(trans);
  113299. if (impostor.mass == 0) {
  113300. // Kinematic objects must be updated using motion state
  113301. var motionState = impostor.physicsBody.getMotionState();
  113302. if (motionState) {
  113303. motionState.setWorldTransform(trans);
  113304. }
  113305. }
  113306. else {
  113307. impostor.physicsBody.activate();
  113308. }
  113309. }
  113310. };
  113311. /**
  113312. * If this plugin is supported
  113313. * @returns true if its supported
  113314. */
  113315. AmmoJSPlugin.prototype.isSupported = function () {
  113316. return this.bjsAMMO !== undefined;
  113317. };
  113318. /**
  113319. * Sets the linear velocity of the physics body
  113320. * @param impostor imposter to set the velocity on
  113321. * @param velocity velocity to set
  113322. */
  113323. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  113324. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  113325. if (impostor.soft) {
  113326. impostor.physicsBody.linearVelocity(this._tmpAmmoVectorA);
  113327. }
  113328. else {
  113329. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  113330. }
  113331. };
  113332. /**
  113333. * Sets the angular velocity of the physics body
  113334. * @param impostor imposter to set the velocity on
  113335. * @param velocity velocity to set
  113336. */
  113337. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  113338. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  113339. if (impostor.soft) {
  113340. impostor.physicsBody.angularVelocity(this._tmpAmmoVectorA);
  113341. }
  113342. else {
  113343. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  113344. }
  113345. };
  113346. /**
  113347. * gets the linear velocity
  113348. * @param impostor imposter to get linear velocity from
  113349. * @returns linear velocity
  113350. */
  113351. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  113352. if (impostor.soft) {
  113353. var v = impostor.physicsBody.linearVelocity();
  113354. }
  113355. else {
  113356. var v = impostor.physicsBody.getLinearVelocity();
  113357. }
  113358. if (!v) {
  113359. return null;
  113360. }
  113361. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  113362. };
  113363. /**
  113364. * gets the angular velocity
  113365. * @param impostor imposter to get angular velocity from
  113366. * @returns angular velocity
  113367. */
  113368. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  113369. if (impostor.soft) {
  113370. var v = impostor.physicsBody.angularVelocity();
  113371. }
  113372. else {
  113373. var v = impostor.physicsBody.getAngularVelocity();
  113374. }
  113375. if (!v) {
  113376. return null;
  113377. }
  113378. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  113379. };
  113380. /**
  113381. * Sets the mass of physics body
  113382. * @param impostor imposter to set the mass on
  113383. * @param mass mass to set
  113384. */
  113385. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  113386. if (impostor.soft) {
  113387. impostor.physicsBody.setTotalMass(mass, false);
  113388. }
  113389. else {
  113390. impostor.physicsBody.setMassProps(mass);
  113391. }
  113392. impostor._pluginData.mass = mass;
  113393. };
  113394. /**
  113395. * Gets the mass of the physics body
  113396. * @param impostor imposter to get the mass from
  113397. * @returns mass
  113398. */
  113399. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  113400. return impostor._pluginData.mass;
  113401. };
  113402. /**
  113403. * Gets friction of the impostor
  113404. * @param impostor impostor to get friction from
  113405. * @returns friction value
  113406. */
  113407. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  113408. return impostor._pluginData.friction;
  113409. };
  113410. /**
  113411. * Sets friction of the impostor
  113412. * @param impostor impostor to set friction on
  113413. * @param friction friction value
  113414. */
  113415. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  113416. if (impostor.soft) {
  113417. impostor.physicsBody.get_m_cfg().set_kDF(friction);
  113418. }
  113419. else {
  113420. impostor.physicsBody.setFriction(friction);
  113421. }
  113422. impostor._pluginData.friction = friction;
  113423. };
  113424. /**
  113425. * Gets restitution of the impostor
  113426. * @param impostor impostor to get restitution from
  113427. * @returns restitution value
  113428. */
  113429. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  113430. return impostor._pluginData.restitution;
  113431. };
  113432. /**
  113433. * Sets resitution of the impostor
  113434. * @param impostor impostor to set resitution on
  113435. * @param restitution resitution value
  113436. */
  113437. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  113438. impostor.physicsBody.setRestitution(restitution);
  113439. impostor._pluginData.restitution = restitution;
  113440. };
  113441. /**
  113442. * Gets pressure inside the impostor
  113443. * @param impostor impostor to get pressure from
  113444. * @returns pressure value
  113445. */
  113446. AmmoJSPlugin.prototype.getBodyPressure = function (impostor) {
  113447. if (!impostor.soft) {
  113448. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure is not a property of a rigid body");
  113449. return 0;
  113450. }
  113451. return impostor._pluginData.pressure;
  113452. };
  113453. /**
  113454. * Sets pressure inside a soft body impostor
  113455. * Cloth and rope must remain 0 pressure
  113456. * @param impostor impostor to set pressure on
  113457. * @param pressure pressure value
  113458. */
  113459. AmmoJSPlugin.prototype.setBodyPressure = function (impostor, pressure) {
  113460. if (impostor.soft) {
  113461. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  113462. impostor.physicsBody.get_m_cfg().set_kPR(pressure);
  113463. impostor._pluginData.pressure = pressure;
  113464. }
  113465. else {
  113466. impostor.physicsBody.get_m_cfg().set_kPR(0);
  113467. impostor._pluginData.pressure = 0;
  113468. }
  113469. }
  113470. else {
  113471. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure can only be applied to a softbody");
  113472. }
  113473. };
  113474. /**
  113475. * Gets stiffness of the impostor
  113476. * @param impostor impostor to get stiffness from
  113477. * @returns pressure value
  113478. */
  113479. AmmoJSPlugin.prototype.getBodyStiffness = function (impostor) {
  113480. if (!impostor.soft) {
  113481. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness is not a property of a rigid body");
  113482. return 0;
  113483. }
  113484. return impostor._pluginData.stiffness;
  113485. };
  113486. /**
  113487. * Sets stiffness of the impostor
  113488. * @param impostor impostor to set stiffness on
  113489. * @param stiffness stiffness value from 0 to 1
  113490. */
  113491. AmmoJSPlugin.prototype.setBodyStiffness = function (impostor, stiffness) {
  113492. if (impostor.soft) {
  113493. stiffness = stiffness < 0 ? 0 : stiffness;
  113494. stiffness = stiffness > 1 ? 1 : stiffness;
  113495. impostor.physicsBody.get_m_materials().at(0).set_m_kLST(stiffness);
  113496. impostor._pluginData.stiffness = stiffness;
  113497. }
  113498. else {
  113499. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness cannot be applied to a rigid body");
  113500. }
  113501. };
  113502. /**
  113503. * Gets velocityIterations of the impostor
  113504. * @param impostor impostor to get velocity iterations from
  113505. * @returns velocityIterations value
  113506. */
  113507. AmmoJSPlugin.prototype.getBodyVelocityIterations = function (impostor) {
  113508. if (!impostor.soft) {
  113509. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations is not a property of a rigid body");
  113510. return 0;
  113511. }
  113512. return impostor._pluginData.velocityIterations;
  113513. };
  113514. /**
  113515. * Sets velocityIterations of the impostor
  113516. * @param impostor impostor to set velocity iterations on
  113517. * @param velocityIterations velocityIterations value
  113518. */
  113519. AmmoJSPlugin.prototype.setBodyVelocityIterations = function (impostor, velocityIterations) {
  113520. if (impostor.soft) {
  113521. velocityIterations = velocityIterations < 0 ? 0 : velocityIterations;
  113522. impostor.physicsBody.get_m_cfg().set_viterations(velocityIterations);
  113523. impostor._pluginData.velocityIterations = velocityIterations;
  113524. }
  113525. else {
  113526. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations cannot be applied to a rigid body");
  113527. }
  113528. };
  113529. /**
  113530. * Gets positionIterations of the impostor
  113531. * @param impostor impostor to get position iterations from
  113532. * @returns positionIterations value
  113533. */
  113534. AmmoJSPlugin.prototype.getBodyPositionIterations = function (impostor) {
  113535. if (!impostor.soft) {
  113536. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations is not a property of a rigid body");
  113537. return 0;
  113538. }
  113539. return impostor._pluginData.positionIterations;
  113540. };
  113541. /**
  113542. * Sets positionIterations of the impostor
  113543. * @param impostor impostor to set position on
  113544. * @param positionIterations positionIterations value
  113545. */
  113546. AmmoJSPlugin.prototype.setBodyPositionIterations = function (impostor, positionIterations) {
  113547. if (impostor.soft) {
  113548. positionIterations = positionIterations < 0 ? 0 : positionIterations;
  113549. impostor.physicsBody.get_m_cfg().set_piterations(positionIterations);
  113550. impostor._pluginData.positionIterations = positionIterations;
  113551. }
  113552. else {
  113553. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations cannot be applied to a rigid body");
  113554. }
  113555. };
  113556. /**
  113557. * Append an anchor to a cloth object
  113558. * @param impostor is the cloth impostor to add anchor to
  113559. * @param otherImpostor is the rigid impostor to anchor to
  113560. * @param width ratio across width from 0 to 1
  113561. * @param height ratio up height from 0 to 1
  113562. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113563. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113564. */
  113565. AmmoJSPlugin.prototype.appendAnchor = function (impostor, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  113566. if (influence === void 0) { influence = 1; }
  113567. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  113568. var segs = impostor.segments;
  113569. var nbAcross = Math.round((segs - 1) * width);
  113570. var nbUp = Math.round((segs - 1) * height);
  113571. var nbDown = segs - 1 - nbUp;
  113572. var node = nbAcross + segs * nbDown;
  113573. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  113574. };
  113575. /**
  113576. * Append an hook to a rope object
  113577. * @param impostor is the rope impostor to add hook to
  113578. * @param otherImpostor is the rigid impostor to hook to
  113579. * @param length ratio along the rope from 0 to 1
  113580. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  113581. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113582. */
  113583. AmmoJSPlugin.prototype.appendHook = function (impostor, otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  113584. if (influence === void 0) { influence = 1; }
  113585. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  113586. var node = Math.round(impostor.segments * length);
  113587. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  113588. };
  113589. /**
  113590. * Sleeps the physics body and stops it from being active
  113591. * @param impostor impostor to sleep
  113592. */
  113593. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  113594. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  113595. };
  113596. /**
  113597. * Activates the physics body
  113598. * @param impostor impostor to activate
  113599. */
  113600. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  113601. impostor.physicsBody.activate();
  113602. };
  113603. /**
  113604. * Updates the distance parameters of the joint
  113605. * @param joint joint to update
  113606. * @param maxDistance maximum distance of the joint
  113607. * @param minDistance minimum distance of the joint
  113608. */
  113609. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  113610. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  113611. };
  113612. /**
  113613. * Sets a motor on the joint
  113614. * @param joint joint to set motor on
  113615. * @param speed speed of the motor
  113616. * @param maxForce maximum force of the motor
  113617. * @param motorIndex index of the motor
  113618. */
  113619. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  113620. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  113621. };
  113622. /**
  113623. * Sets the motors limit
  113624. * @param joint joint to set limit on
  113625. * @param upperLimit upper limit
  113626. * @param lowerLimit lower limit
  113627. */
  113628. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  113629. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  113630. };
  113631. /**
  113632. * Syncs the position and rotation of a mesh with the impostor
  113633. * @param mesh mesh to sync
  113634. * @param impostor impostor to update the mesh with
  113635. */
  113636. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  113637. var body = impostor.physicsBody;
  113638. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  113639. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  113640. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  113641. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  113642. if (mesh.rotationQuaternion) {
  113643. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  113644. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  113645. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  113646. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  113647. }
  113648. };
  113649. /**
  113650. * Gets the radius of the impostor
  113651. * @param impostor impostor to get radius from
  113652. * @returns the radius
  113653. */
  113654. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  113655. var exntend = impostor.getObjectExtendSize();
  113656. return exntend.x / 2;
  113657. };
  113658. /**
  113659. * Gets the box size of the impostor
  113660. * @param impostor impostor to get box size from
  113661. * @param result the resulting box size
  113662. */
  113663. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  113664. var exntend = impostor.getObjectExtendSize();
  113665. result.x = exntend.x;
  113666. result.y = exntend.y;
  113667. result.z = exntend.z;
  113668. };
  113669. /**
  113670. * Disposes of the impostor
  113671. */
  113672. AmmoJSPlugin.prototype.dispose = function () {
  113673. // Dispose of world
  113674. Ammo.destroy(this.world);
  113675. Ammo.destroy(this._solver);
  113676. Ammo.destroy(this._overlappingPairCache);
  113677. Ammo.destroy(this._dispatcher);
  113678. Ammo.destroy(this._collisionConfiguration);
  113679. // Dispose of tmp variables
  113680. Ammo.destroy(this._tmpAmmoVectorA);
  113681. Ammo.destroy(this._tmpAmmoVectorB);
  113682. Ammo.destroy(this._tmpAmmoVectorC);
  113683. Ammo.destroy(this._tmpAmmoTransform);
  113684. Ammo.destroy(this._tmpAmmoQuaternion);
  113685. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  113686. this.world = null;
  113687. };
  113688. /**
  113689. * Does a raycast in the physics world
  113690. * @param from when should the ray start?
  113691. * @param to when should the ray end?
  113692. * @returns PhysicsRaycastResult
  113693. */
  113694. AmmoJSPlugin.prototype.raycast = function (from, to) {
  113695. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(from.x, from.y, from.z);
  113696. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(to.x, to.y, to.z);
  113697. var rayCallback = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
  113698. this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, rayCallback);
  113699. this._raycastResult.reset(from, to);
  113700. if (rayCallback.hasHit()) {
  113701. // TODO: do we want/need the body? If so, set all the data
  113702. /*
  113703. var rigidBody = this.bjsAMMO.btRigidBody.prototype.upcast(
  113704. rayCallback.get_m_collisionObject()
  113705. );
  113706. var body = {};
  113707. */
  113708. this._raycastResult.setHitData({
  113709. x: rayCallback.get_m_hitNormalWorld().x(),
  113710. y: rayCallback.get_m_hitNormalWorld().y(),
  113711. z: rayCallback.get_m_hitNormalWorld().z(),
  113712. }, {
  113713. x: rayCallback.get_m_hitPointWorld().x(),
  113714. y: rayCallback.get_m_hitPointWorld().y(),
  113715. z: rayCallback.get_m_hitPointWorld().z(),
  113716. });
  113717. this._raycastResult.calculateHitDistance();
  113718. }
  113719. return this._raycastResult;
  113720. };
  113721. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  113722. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  113723. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  113724. return AmmoJSPlugin;
  113725. }());
  113726. /***/ }),
  113727. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  113728. /*!*******************************************!*\
  113729. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  113730. \*******************************************/
  113731. /*! exports provided: CannonJSPlugin */
  113732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113733. "use strict";
  113734. __webpack_require__.r(__webpack_exports__);
  113735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  113736. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  113737. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  113738. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  113739. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  113740. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  113741. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  113742. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  113743. /** @hidden */
  113744. var CannonJSPlugin = /** @class */ (function () {
  113745. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  113746. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  113747. if (iterations === void 0) { iterations = 10; }
  113748. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  113749. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  113750. this.name = "CannonJSPlugin";
  113751. this._physicsMaterials = new Array();
  113752. this._fixedTimeStep = 1 / 60;
  113753. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  113754. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  113755. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  113756. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  113757. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  113758. this.BJSCANNON = cannonInjection;
  113759. if (!this.isSupported()) {
  113760. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  113761. return;
  113762. }
  113763. this._extendNamespace();
  113764. this.world = new this.BJSCANNON.World();
  113765. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  113766. this.world.solver.iterations = iterations;
  113767. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();
  113768. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__["PhysicsRaycastResult"]();
  113769. }
  113770. CannonJSPlugin.prototype.setGravity = function (gravity) {
  113771. this.world.gravity.copy(gravity);
  113772. };
  113773. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  113774. this._fixedTimeStep = timeStep;
  113775. };
  113776. CannonJSPlugin.prototype.getTimeStep = function () {
  113777. return this._fixedTimeStep;
  113778. };
  113779. CannonJSPlugin.prototype.executeStep = function (delta) {
  113780. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  113781. };
  113782. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  113783. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  113784. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  113785. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  113786. };
  113787. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  113788. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  113789. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  113790. impostor.physicsBody.applyForce(impulse, worldPoint);
  113791. };
  113792. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  113793. //parent-child relationship. Does this impostor has a parent impostor?
  113794. if (impostor.parent) {
  113795. if (impostor.physicsBody) {
  113796. this.removePhysicsBody(impostor);
  113797. //TODO is that needed?
  113798. impostor.forceUpdate();
  113799. }
  113800. return;
  113801. }
  113802. //should a new body be created for this impostor?
  113803. if (impostor.isBodyInitRequired()) {
  113804. var shape = this._createShape(impostor);
  113805. //unregister events, if body is being changed
  113806. var oldBody = impostor.physicsBody;
  113807. if (oldBody) {
  113808. this.removePhysicsBody(impostor);
  113809. }
  113810. //create the body and material
  113811. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  113812. var bodyCreationObject = {
  113813. mass: impostor.getParam("mass"),
  113814. material: material
  113815. };
  113816. // A simple extend, in case native options were used.
  113817. var nativeOptions = impostor.getParam("nativeOptions");
  113818. for (var key in nativeOptions) {
  113819. if (nativeOptions.hasOwnProperty(key)) {
  113820. bodyCreationObject[key] = nativeOptions[key];
  113821. }
  113822. }
  113823. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  113824. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  113825. this.world.addEventListener("preStep", impostor.beforeStep);
  113826. this.world.addEventListener("postStep", impostor.afterStep);
  113827. impostor.physicsBody.addShape(shape);
  113828. this.world.add(impostor.physicsBody);
  113829. //try to keep the body moving in the right direction by taking old properties.
  113830. //Should be tested!
  113831. if (oldBody) {
  113832. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  113833. impostor.physicsBody[param].copy(oldBody[param]);
  113834. });
  113835. }
  113836. this._processChildMeshes(impostor);
  113837. }
  113838. //now update the body's transformation
  113839. this._updatePhysicsBodyTransformation(impostor);
  113840. };
  113841. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  113842. var _this = this;
  113843. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  113844. var currentRotation = mainImpostor.object.rotationQuaternion;
  113845. if (meshChildren.length) {
  113846. var processMesh = function (localPosition, mesh) {
  113847. if (!currentRotation || !mesh.rotationQuaternion) {
  113848. return;
  113849. }
  113850. var childImpostor = mesh.getPhysicsImpostor();
  113851. if (childImpostor) {
  113852. var parent = childImpostor.parent;
  113853. if (parent !== mainImpostor) {
  113854. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  113855. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  113856. if (childImpostor.physicsBody) {
  113857. _this.removePhysicsBody(childImpostor);
  113858. childImpostor.physicsBody = null;
  113859. }
  113860. childImpostor.parent = mainImpostor;
  113861. childImpostor.resetUpdateFlags();
  113862. 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));
  113863. //Add the mass of the children.
  113864. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  113865. }
  113866. }
  113867. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  113868. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  113869. };
  113870. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  113871. }
  113872. };
  113873. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  113874. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  113875. this.world.removeEventListener("preStep", impostor.beforeStep);
  113876. this.world.removeEventListener("postStep", impostor.afterStep);
  113877. this.world.remove(impostor.physicsBody);
  113878. };
  113879. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  113880. var mainBody = impostorJoint.mainImpostor.physicsBody;
  113881. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  113882. if (!mainBody || !connectedBody) {
  113883. return;
  113884. }
  113885. var constraint;
  113886. var jointData = impostorJoint.joint.jointData;
  113887. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  113888. var constraintData = {
  113889. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  113890. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  113891. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  113892. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  113893. maxForce: jointData.nativeParams.maxForce,
  113894. collideConnected: !!jointData.collision
  113895. };
  113896. switch (impostorJoint.joint.type) {
  113897. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  113898. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  113899. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  113900. break;
  113901. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  113902. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  113903. break;
  113904. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  113905. var springData = jointData;
  113906. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  113907. restLength: springData.length,
  113908. stiffness: springData.stiffness,
  113909. damping: springData.damping,
  113910. localAnchorA: constraintData.pivotA,
  113911. localAnchorB: constraintData.pivotB
  113912. });
  113913. break;
  113914. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  113915. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  113916. break;
  113917. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  113918. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  113919. default:
  113920. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  113921. break;
  113922. }
  113923. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  113924. constraint.collideConnected = !!jointData.collision;
  113925. impostorJoint.joint.physicsJoint = constraint;
  113926. //don't add spring as constraint, as it is not one.
  113927. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  113928. this.world.addConstraint(constraint);
  113929. }
  113930. else {
  113931. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  113932. constraint.applyForce();
  113933. };
  113934. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  113935. }
  113936. };
  113937. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  113938. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  113939. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  113940. }
  113941. else {
  113942. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  113943. }
  113944. };
  113945. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  113946. var index;
  113947. var mat;
  113948. for (index = 0; index < this._physicsMaterials.length; index++) {
  113949. mat = this._physicsMaterials[index];
  113950. if (mat.friction === friction && mat.restitution === restitution) {
  113951. return mat;
  113952. }
  113953. }
  113954. var currentMat = new this.BJSCANNON.Material(name);
  113955. currentMat.friction = friction;
  113956. currentMat.restitution = restitution;
  113957. this._physicsMaterials.push(currentMat);
  113958. return currentMat;
  113959. };
  113960. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  113961. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  113962. };
  113963. CannonJSPlugin.prototype._createShape = function (impostor) {
  113964. var object = impostor.object;
  113965. var returnValue;
  113966. var extendSize = impostor.getObjectExtendSize();
  113967. switch (impostor.type) {
  113968. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  113969. var radiusX = extendSize.x;
  113970. var radiusY = extendSize.y;
  113971. var radiusZ = extendSize.z;
  113972. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  113973. break;
  113974. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  113975. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  113976. var nativeParams = impostor.getParam("nativeOptions");
  113977. if (!nativeParams) {
  113978. nativeParams = {};
  113979. }
  113980. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  113981. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  113982. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  113983. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  113984. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  113985. // Rotate 90 degrees as this shape is horizontal in cannon
  113986. var quat = new this.BJSCANNON.Quaternion();
  113987. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  113988. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  113989. returnValue.transformAllPoints(translation, quat);
  113990. break;
  113991. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  113992. var box = extendSize.scale(0.5);
  113993. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  113994. break;
  113995. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  113996. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  113997. returnValue = new this.BJSCANNON.Plane();
  113998. break;
  113999. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  114000. // should transform the vertex data to world coordinates!!
  114001. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  114002. var rawFaces = object.getIndices ? object.getIndices() : [];
  114003. if (!rawVerts) {
  114004. return;
  114005. }
  114006. // get only scale! so the object could transform correctly.
  114007. var oldPosition = object.position.clone();
  114008. var oldRotation = object.rotation && object.rotation.clone();
  114009. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  114010. object.position.copyFromFloats(0, 0, 0);
  114011. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  114012. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  114013. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  114014. var transform = object.computeWorldMatrix(true);
  114015. // convert rawVerts to object space
  114016. var temp = new Array();
  114017. var index;
  114018. for (index = 0; index < rawVerts.length; index += 3) {
  114019. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  114020. }
  114021. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  114022. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  114023. //now set back the transformation!
  114024. object.position.copyFrom(oldPosition);
  114025. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  114026. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  114027. break;
  114028. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  114029. var oldPosition2 = object.position.clone();
  114030. var oldRotation2 = object.rotation && object.rotation.clone();
  114031. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  114032. object.position.copyFromFloats(0, 0, 0);
  114033. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  114034. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  114035. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  114036. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  114037. returnValue = this._createHeightmap(object);
  114038. object.position.copyFrom(oldPosition2);
  114039. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  114040. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  114041. object.computeWorldMatrix(true);
  114042. break;
  114043. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  114044. returnValue = new this.BJSCANNON.Particle();
  114045. break;
  114046. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  114047. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  114048. break;
  114049. }
  114050. return returnValue;
  114051. };
  114052. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  114053. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  114054. var transform = object.computeWorldMatrix(true);
  114055. // convert rawVerts to object space
  114056. var temp = new Array();
  114057. var index;
  114058. for (index = 0; index < pos.length; index += 3) {
  114059. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  114060. }
  114061. pos = temp;
  114062. var matrix = new Array();
  114063. //For now pointDepth will not be used and will be automatically calculated.
  114064. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  114065. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  114066. var boundingInfo = object.getBoundingInfo();
  114067. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  114068. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  114069. var elementSize = dim * 2 / arraySize;
  114070. for (var i = 0; i < pos.length; i = i + 3) {
  114071. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  114072. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  114073. var y = -pos[i + 2] + minY;
  114074. if (!matrix[x]) {
  114075. matrix[x] = [];
  114076. }
  114077. if (!matrix[x][z]) {
  114078. matrix[x][z] = y;
  114079. }
  114080. matrix[x][z] = Math.max(y, matrix[x][z]);
  114081. }
  114082. for (var x = 0; x <= arraySize; ++x) {
  114083. if (!matrix[x]) {
  114084. var loc = 1;
  114085. while (!matrix[(x + loc) % arraySize]) {
  114086. loc++;
  114087. }
  114088. matrix[x] = matrix[(x + loc) % arraySize].slice();
  114089. //console.log("missing x", x);
  114090. }
  114091. for (var z = 0; z <= arraySize; ++z) {
  114092. if (!matrix[x][z]) {
  114093. var loc = 1;
  114094. var newValue;
  114095. while (newValue === undefined) {
  114096. newValue = matrix[x][(z + loc++) % arraySize];
  114097. }
  114098. matrix[x][z] = newValue;
  114099. }
  114100. }
  114101. }
  114102. var shape = new this.BJSCANNON.Heightfield(matrix, {
  114103. elementSize: elementSize
  114104. });
  114105. //For future reference, needed for body transformation
  114106. shape.minY = minY;
  114107. return shape;
  114108. };
  114109. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  114110. var object = impostor.object;
  114111. //make sure it is updated...
  114112. object.computeWorldMatrix && object.computeWorldMatrix(true);
  114113. // The delta between the mesh position and the mesh bounding box center
  114114. var bInfo = object.getBoundingInfo();
  114115. if (!bInfo) {
  114116. return;
  114117. }
  114118. var center = impostor.getObjectCenter();
  114119. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  114120. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  114121. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  114122. this._tmpPosition.copyFrom(center);
  114123. var quaternion = object.rotationQuaternion;
  114124. if (!quaternion) {
  114125. return;
  114126. }
  114127. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  114128. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  114129. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  114130. //-90 DEG in X, precalculated
  114131. quaternion = quaternion.multiply(this._minus90X);
  114132. //Invert! (Precalculated, 90 deg in X)
  114133. //No need to clone. this will never change.
  114134. impostor.setDeltaRotation(this._plus90X);
  114135. }
  114136. //If it is a heightfield, if should be centered.
  114137. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  114138. var mesh = object;
  114139. var boundingInfo = mesh.getBoundingInfo();
  114140. //calculate the correct body position:
  114141. var rotationQuaternion = mesh.rotationQuaternion;
  114142. mesh.rotationQuaternion = this._tmpUnityRotation;
  114143. mesh.computeWorldMatrix(true);
  114144. //get original center with no rotation
  114145. var c = center.clone();
  114146. var oldPivot = mesh.getPivotMatrix();
  114147. if (oldPivot) {
  114148. // create a copy the pivot Matrix as it is modified in place
  114149. oldPivot = oldPivot.clone();
  114150. }
  114151. else {
  114152. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  114153. }
  114154. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  114155. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  114156. mesh.setPreTransformMatrix(p);
  114157. mesh.computeWorldMatrix(true);
  114158. //calculate the translation
  114159. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  114160. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  114161. //add it inverted to the delta
  114162. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  114163. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  114164. //rotation is back
  114165. mesh.rotationQuaternion = rotationQuaternion;
  114166. mesh.setPreTransformMatrix(oldPivot);
  114167. mesh.computeWorldMatrix(true);
  114168. }
  114169. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  114170. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  114171. //this._tmpPosition.copyFrom(object.position);
  114172. }
  114173. impostor.setDeltaPosition(this._tmpDeltaPosition);
  114174. //Now update the impostor object
  114175. impostor.physicsBody.position.copy(this._tmpPosition);
  114176. impostor.physicsBody.quaternion.copy(quaternion);
  114177. };
  114178. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  114179. impostor.object.position.copyFrom(impostor.physicsBody.position);
  114180. if (impostor.object.rotationQuaternion) {
  114181. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  114182. }
  114183. };
  114184. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  114185. impostor.physicsBody.position.copy(newPosition);
  114186. impostor.physicsBody.quaternion.copy(newRotation);
  114187. };
  114188. CannonJSPlugin.prototype.isSupported = function () {
  114189. return this.BJSCANNON !== undefined;
  114190. };
  114191. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  114192. impostor.physicsBody.velocity.copy(velocity);
  114193. };
  114194. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  114195. impostor.physicsBody.angularVelocity.copy(velocity);
  114196. };
  114197. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  114198. var v = impostor.physicsBody.velocity;
  114199. if (!v) {
  114200. return null;
  114201. }
  114202. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  114203. };
  114204. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  114205. var v = impostor.physicsBody.angularVelocity;
  114206. if (!v) {
  114207. return null;
  114208. }
  114209. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  114210. };
  114211. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  114212. impostor.physicsBody.mass = mass;
  114213. impostor.physicsBody.updateMassProperties();
  114214. };
  114215. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  114216. return impostor.physicsBody.mass;
  114217. };
  114218. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  114219. return impostor.physicsBody.material.friction;
  114220. };
  114221. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  114222. impostor.physicsBody.material.friction = friction;
  114223. };
  114224. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  114225. return impostor.physicsBody.material.restitution;
  114226. };
  114227. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  114228. impostor.physicsBody.material.restitution = restitution;
  114229. };
  114230. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  114231. impostor.physicsBody.sleep();
  114232. };
  114233. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  114234. impostor.physicsBody.wakeUp();
  114235. };
  114236. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  114237. joint.physicsJoint.distance = maxDistance;
  114238. };
  114239. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  114240. // if (!motorIndex) {
  114241. // joint.physicsJoint.enableMotor();
  114242. // }
  114243. // }
  114244. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  114245. // if (!motorIndex) {
  114246. // joint.physicsJoint.disableMotor();
  114247. // }
  114248. // }
  114249. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  114250. if (!motorIndex) {
  114251. joint.physicsJoint.enableMotor();
  114252. joint.physicsJoint.setMotorSpeed(speed);
  114253. if (maxForce) {
  114254. this.setLimit(joint, maxForce);
  114255. }
  114256. }
  114257. };
  114258. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  114259. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  114260. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  114261. };
  114262. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  114263. var body = impostor.physicsBody;
  114264. mesh.position.x = body.position.x;
  114265. mesh.position.y = body.position.y;
  114266. mesh.position.z = body.position.z;
  114267. if (mesh.rotationQuaternion) {
  114268. mesh.rotationQuaternion.x = body.quaternion.x;
  114269. mesh.rotationQuaternion.y = body.quaternion.y;
  114270. mesh.rotationQuaternion.z = body.quaternion.z;
  114271. mesh.rotationQuaternion.w = body.quaternion.w;
  114272. }
  114273. };
  114274. CannonJSPlugin.prototype.getRadius = function (impostor) {
  114275. var shape = impostor.physicsBody.shapes[0];
  114276. return shape.boundingSphereRadius;
  114277. };
  114278. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  114279. var shape = impostor.physicsBody.shapes[0];
  114280. result.x = shape.halfExtents.x * 2;
  114281. result.y = shape.halfExtents.y * 2;
  114282. result.z = shape.halfExtents.z * 2;
  114283. };
  114284. CannonJSPlugin.prototype.dispose = function () {
  114285. };
  114286. CannonJSPlugin.prototype._extendNamespace = function () {
  114287. //this will force cannon to execute at least one step when using interpolation
  114288. var step_tmp1 = new this.BJSCANNON.Vec3();
  114289. var Engine = this.BJSCANNON;
  114290. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  114291. maxSubSteps = maxSubSteps || 10;
  114292. timeSinceLastCalled = timeSinceLastCalled || 0;
  114293. if (timeSinceLastCalled === 0) {
  114294. this.internalStep(dt);
  114295. this.time += dt;
  114296. }
  114297. else {
  114298. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  114299. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  114300. var t0 = performance.now();
  114301. for (var i = 0; i !== internalSteps; i++) {
  114302. this.internalStep(dt);
  114303. if (performance.now() - t0 > dt * 1000) {
  114304. break;
  114305. }
  114306. }
  114307. this.time += timeSinceLastCalled;
  114308. var h = this.time % dt;
  114309. var h_div_dt = h / dt;
  114310. var interpvelo = step_tmp1;
  114311. var bodies = this.bodies;
  114312. for (var j = 0; j !== bodies.length; j++) {
  114313. var b = bodies[j];
  114314. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  114315. b.position.vsub(b.previousPosition, interpvelo);
  114316. interpvelo.scale(h_div_dt, interpvelo);
  114317. b.position.vadd(interpvelo, b.interpolatedPosition);
  114318. }
  114319. else {
  114320. b.interpolatedPosition.copy(b.position);
  114321. b.interpolatedQuaternion.copy(b.quaternion);
  114322. }
  114323. }
  114324. }
  114325. };
  114326. };
  114327. /**
  114328. * Does a raycast in the physics world
  114329. * @param from when should the ray start?
  114330. * @param to when should the ray end?
  114331. * @returns PhysicsRaycastResult
  114332. */
  114333. CannonJSPlugin.prototype.raycast = function (from, to) {
  114334. this._cannonRaycastResult.reset();
  114335. this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);
  114336. this._raycastResult.reset(from, to);
  114337. if (this._cannonRaycastResult.hasHit) {
  114338. // TODO: do we also want to get the body it hit?
  114339. this._raycastResult.setHitData({
  114340. x: this._cannonRaycastResult.hitNormalWorld.x,
  114341. y: this._cannonRaycastResult.hitNormalWorld.y,
  114342. z: this._cannonRaycastResult.hitNormalWorld.z,
  114343. }, {
  114344. x: this._cannonRaycastResult.hitPointWorld.x,
  114345. y: this._cannonRaycastResult.hitPointWorld.y,
  114346. z: this._cannonRaycastResult.hitPointWorld.z,
  114347. });
  114348. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);
  114349. }
  114350. return this._raycastResult;
  114351. };
  114352. return CannonJSPlugin;
  114353. }());
  114354. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  114355. /***/ }),
  114356. /***/ "./Physics/Plugins/index.ts":
  114357. /*!**********************************!*\
  114358. !*** ./Physics/Plugins/index.ts ***!
  114359. \**********************************/
  114360. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  114361. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114362. "use strict";
  114363. __webpack_require__.r(__webpack_exports__);
  114364. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  114365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  114366. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  114367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  114368. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  114369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  114370. /***/ }),
  114371. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  114372. /*!*****************************************!*\
  114373. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  114374. \*****************************************/
  114375. /*! exports provided: OimoJSPlugin */
  114376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114377. "use strict";
  114378. __webpack_require__.r(__webpack_exports__);
  114379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  114380. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  114381. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  114382. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  114383. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  114384. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  114385. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  114386. /** @hidden */
  114387. var OimoJSPlugin = /** @class */ (function () {
  114388. function OimoJSPlugin(iterations, oimoInjection) {
  114389. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  114390. this.name = "OimoJSPlugin";
  114391. this._tmpImpostorsArray = [];
  114392. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  114393. this.BJSOIMO = oimoInjection;
  114394. this.world = new this.BJSOIMO.World({
  114395. iterations: iterations
  114396. });
  114397. this.world.clear();
  114398. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__["PhysicsRaycastResult"]();
  114399. }
  114400. OimoJSPlugin.prototype.setGravity = function (gravity) {
  114401. this.world.gravity.copy(gravity);
  114402. };
  114403. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  114404. this.world.timeStep = timeStep;
  114405. };
  114406. OimoJSPlugin.prototype.getTimeStep = function () {
  114407. return this.world.timeStep;
  114408. };
  114409. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  114410. var _this = this;
  114411. impostors.forEach(function (impostor) {
  114412. impostor.beforeStep();
  114413. });
  114414. this.world.step();
  114415. impostors.forEach(function (impostor) {
  114416. impostor.afterStep();
  114417. //update the ordered impostors array
  114418. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  114419. });
  114420. //check for collisions
  114421. var contact = this.world.contacts;
  114422. while (contact !== null) {
  114423. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  114424. contact = contact.next;
  114425. continue;
  114426. }
  114427. //is this body colliding with any other? get the impostor
  114428. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  114429. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  114430. if (!mainImpostor || !collidingImpostor) {
  114431. contact = contact.next;
  114432. continue;
  114433. }
  114434. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  114435. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  114436. contact = contact.next;
  114437. }
  114438. };
  114439. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  114440. var mass = impostor.physicsBody.mass;
  114441. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  114442. };
  114443. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  114444. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  114445. this.applyImpulse(impostor, force, contactPoint);
  114446. };
  114447. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  114448. var _this = this;
  114449. //parent-child relationship. Does this impostor has a parent impostor?
  114450. if (impostor.parent) {
  114451. if (impostor.physicsBody) {
  114452. this.removePhysicsBody(impostor);
  114453. //TODO is that needed?
  114454. impostor.forceUpdate();
  114455. }
  114456. return;
  114457. }
  114458. if (impostor.isBodyInitRequired()) {
  114459. var bodyConfig = {
  114460. name: impostor.uniqueId,
  114461. //Oimo must have mass, also for static objects.
  114462. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  114463. size: [],
  114464. type: [],
  114465. pos: [],
  114466. posShape: [],
  114467. rot: [],
  114468. rotShape: [],
  114469. move: impostor.getParam("mass") !== 0,
  114470. density: impostor.getParam("mass"),
  114471. friction: impostor.getParam("friction"),
  114472. restitution: impostor.getParam("restitution"),
  114473. //Supporting older versions of Oimo
  114474. world: this.world
  114475. };
  114476. var impostors = [impostor];
  114477. var addToArray = function (parent) {
  114478. if (!parent.getChildMeshes) {
  114479. return;
  114480. }
  114481. parent.getChildMeshes().forEach(function (m) {
  114482. if (m.physicsImpostor) {
  114483. impostors.push(m.physicsImpostor);
  114484. //m.physicsImpostor._init();
  114485. }
  114486. });
  114487. };
  114488. addToArray(impostor.object);
  114489. var checkWithEpsilon_1 = function (value) {
  114490. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  114491. };
  114492. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  114493. impostors.forEach(function (i) {
  114494. if (!i.object.rotationQuaternion) {
  114495. return;
  114496. }
  114497. //get the correct bounding box
  114498. var oldQuaternion = i.object.rotationQuaternion;
  114499. globalQuaternion_1 = oldQuaternion.clone();
  114500. var rot = oldQuaternion.toEulerAngles();
  114501. var extendSize = i.getObjectExtendSize();
  114502. var radToDeg = 57.295779513082320876;
  114503. if (i === impostor) {
  114504. var center = impostor.getObjectCenter();
  114505. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  114506. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  114507. //Can also use Array.prototype.push.apply
  114508. bodyConfig.pos.push(center.x);
  114509. bodyConfig.pos.push(center.y);
  114510. bodyConfig.pos.push(center.z);
  114511. bodyConfig.posShape.push(0, 0, 0);
  114512. bodyConfig.rotShape.push(0, 0, 0);
  114513. }
  114514. else {
  114515. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  114516. bodyConfig.posShape.push(localPosition.x);
  114517. bodyConfig.posShape.push(localPosition.y);
  114518. bodyConfig.posShape.push(localPosition.z);
  114519. bodyConfig.pos.push(0, 0, 0);
  114520. bodyConfig.rotShape.push(rot.x * radToDeg);
  114521. bodyConfig.rotShape.push(rot.y * radToDeg);
  114522. bodyConfig.rotShape.push(rot.z * radToDeg);
  114523. }
  114524. // register mesh
  114525. switch (i.type) {
  114526. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  114527. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  114528. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  114529. var radiusX = extendSize.x;
  114530. var radiusY = extendSize.y;
  114531. var radiusZ = extendSize.z;
  114532. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  114533. bodyConfig.type.push('sphere');
  114534. //due to the way oimo works with compounds, add 3 times
  114535. bodyConfig.size.push(size);
  114536. bodyConfig.size.push(size);
  114537. bodyConfig.size.push(size);
  114538. break;
  114539. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  114540. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  114541. var sizeY = checkWithEpsilon_1(extendSize.y);
  114542. bodyConfig.type.push('cylinder');
  114543. bodyConfig.size.push(sizeX);
  114544. bodyConfig.size.push(sizeY);
  114545. //due to the way oimo works with compounds, add one more value.
  114546. bodyConfig.size.push(sizeY);
  114547. break;
  114548. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  114549. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  114550. default:
  114551. var sizeX = checkWithEpsilon_1(extendSize.x);
  114552. var sizeY = checkWithEpsilon_1(extendSize.y);
  114553. var sizeZ = checkWithEpsilon_1(extendSize.z);
  114554. bodyConfig.type.push('box');
  114555. //if (i === impostor) {
  114556. bodyConfig.size.push(sizeX);
  114557. bodyConfig.size.push(sizeY);
  114558. bodyConfig.size.push(sizeZ);
  114559. //} else {
  114560. // bodyConfig.size.push(0,0,0);
  114561. //}
  114562. break;
  114563. }
  114564. //actually not needed, but hey...
  114565. i.object.rotationQuaternion = oldQuaternion;
  114566. });
  114567. impostor.physicsBody = this.world.add(bodyConfig);
  114568. // set the quaternion, ignoring the previously defined (euler) rotation
  114569. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  114570. // update with delta 0, so the body will reveive the new rotation.
  114571. impostor.physicsBody.updatePosition(0);
  114572. }
  114573. else {
  114574. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  114575. }
  114576. impostor.setDeltaPosition(this._tmpPositionVector);
  114577. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  114578. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  114579. };
  114580. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  114581. //impostor.physicsBody.dispose();
  114582. //Same as : (older oimo versions)
  114583. this.world.removeRigidBody(impostor.physicsBody);
  114584. };
  114585. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  114586. var mainBody = impostorJoint.mainImpostor.physicsBody;
  114587. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  114588. if (!mainBody || !connectedBody) {
  114589. return;
  114590. }
  114591. var jointData = impostorJoint.joint.jointData;
  114592. var options = jointData.nativeParams || {};
  114593. var type;
  114594. var nativeJointData = {
  114595. body1: mainBody,
  114596. body2: connectedBody,
  114597. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  114598. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  114599. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  114600. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  114601. min: options.min,
  114602. max: options.max,
  114603. collision: options.collision || jointData.collision,
  114604. spring: options.spring,
  114605. //supporting older version of Oimo
  114606. world: this.world
  114607. };
  114608. switch (impostorJoint.joint.type) {
  114609. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  114610. type = "jointBall";
  114611. break;
  114612. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  114613. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  114614. var springData = jointData;
  114615. nativeJointData.min = springData.length || nativeJointData.min;
  114616. //Max should also be set, just make sure it is at least min
  114617. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  114618. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  114619. type = "jointDistance";
  114620. nativeJointData.max = jointData.maxDistance;
  114621. break;
  114622. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  114623. type = "jointPrisme";
  114624. break;
  114625. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  114626. type = "jointSlide";
  114627. break;
  114628. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  114629. type = "jointWheel";
  114630. break;
  114631. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  114632. default:
  114633. type = "jointHinge";
  114634. break;
  114635. }
  114636. nativeJointData.type = type;
  114637. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  114638. };
  114639. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  114640. //Bug in Oimo prevents us from disposing a joint in the playground
  114641. //joint.joint.physicsJoint.dispose();
  114642. //So we will bruteforce it!
  114643. try {
  114644. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  114645. }
  114646. catch (e) {
  114647. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  114648. }
  114649. };
  114650. OimoJSPlugin.prototype.isSupported = function () {
  114651. return this.BJSOIMO !== undefined;
  114652. };
  114653. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  114654. if (!impostor.physicsBody.sleeping) {
  114655. //TODO check that
  114656. /*if (impostor.physicsBody.shapes.next) {
  114657. var parentShape = this._getLastShape(impostor.physicsBody);
  114658. impostor.object.position.copyFrom(parentShape.position);
  114659. console.log(parentShape.position);
  114660. } else {*/
  114661. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  114662. //}
  114663. if (impostor.object.rotationQuaternion) {
  114664. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  114665. }
  114666. }
  114667. };
  114668. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  114669. var body = impostor.physicsBody;
  114670. body.position.copy(newPosition);
  114671. body.orientation.copy(newRotation);
  114672. body.syncShapes();
  114673. body.awake();
  114674. };
  114675. /*private _getLastShape(body: any): any {
  114676. var lastShape = body.shapes;
  114677. while (lastShape.next) {
  114678. lastShape = lastShape.next;
  114679. }
  114680. return lastShape;
  114681. }*/
  114682. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  114683. impostor.physicsBody.linearVelocity.copy(velocity);
  114684. };
  114685. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  114686. impostor.physicsBody.angularVelocity.copy(velocity);
  114687. };
  114688. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  114689. var v = impostor.physicsBody.linearVelocity;
  114690. if (!v) {
  114691. return null;
  114692. }
  114693. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  114694. };
  114695. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  114696. var v = impostor.physicsBody.angularVelocity;
  114697. if (!v) {
  114698. return null;
  114699. }
  114700. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  114701. };
  114702. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  114703. var staticBody = mass === 0;
  114704. //this will actually set the body's density and not its mass.
  114705. //But this is how oimo treats the mass variable.
  114706. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  114707. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  114708. };
  114709. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  114710. return impostor.physicsBody.shapes.density;
  114711. };
  114712. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  114713. return impostor.physicsBody.shapes.friction;
  114714. };
  114715. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  114716. impostor.physicsBody.shapes.friction = friction;
  114717. };
  114718. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  114719. return impostor.physicsBody.shapes.restitution;
  114720. };
  114721. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  114722. impostor.physicsBody.shapes.restitution = restitution;
  114723. };
  114724. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  114725. impostor.physicsBody.sleep();
  114726. };
  114727. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  114728. impostor.physicsBody.awake();
  114729. };
  114730. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  114731. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  114732. if (minDistance !== void 0) {
  114733. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  114734. }
  114735. };
  114736. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  114737. if (force !== undefined) {
  114738. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  114739. }
  114740. else {
  114741. force = 1e6;
  114742. }
  114743. speed *= -1;
  114744. //TODO separate rotational and transational motors.
  114745. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  114746. if (motor) {
  114747. motor.setMotor(speed, force);
  114748. }
  114749. };
  114750. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  114751. //TODO separate rotational and transational motors.
  114752. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  114753. if (motor) {
  114754. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  114755. }
  114756. };
  114757. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  114758. var body = impostor.physicsBody;
  114759. mesh.position.x = body.position.x;
  114760. mesh.position.y = body.position.y;
  114761. mesh.position.z = body.position.z;
  114762. if (mesh.rotationQuaternion) {
  114763. mesh.rotationQuaternion.x = body.orientation.x;
  114764. mesh.rotationQuaternion.y = body.orientation.y;
  114765. mesh.rotationQuaternion.z = body.orientation.z;
  114766. mesh.rotationQuaternion.w = body.orientation.s;
  114767. }
  114768. };
  114769. OimoJSPlugin.prototype.getRadius = function (impostor) {
  114770. return impostor.physicsBody.shapes.radius;
  114771. };
  114772. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  114773. var shape = impostor.physicsBody.shapes;
  114774. result.x = shape.halfWidth * 2;
  114775. result.y = shape.halfHeight * 2;
  114776. result.z = shape.halfDepth * 2;
  114777. };
  114778. OimoJSPlugin.prototype.dispose = function () {
  114779. this.world.clear();
  114780. };
  114781. /**
  114782. * Does a raycast in the physics world
  114783. * @param from when should the ray start?
  114784. * @param to when should the ray end?
  114785. * @returns PhysicsRaycastResult
  114786. */
  114787. OimoJSPlugin.prototype.raycast = function (from, to) {
  114788. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("raycast is not currently supported by the Oimo physics plugin");
  114789. this._raycastResult.reset(from, to);
  114790. return this._raycastResult;
  114791. };
  114792. return OimoJSPlugin;
  114793. }());
  114794. /***/ }),
  114795. /***/ "./Physics/index.ts":
  114796. /*!**************************!*\
  114797. !*** ./Physics/index.ts ***!
  114798. \**************************/
  114799. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  114800. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114801. "use strict";
  114802. __webpack_require__.r(__webpack_exports__);
  114803. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  114804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  114805. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  114806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  114807. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  114808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  114809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEventOptions"]; });
  114810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEventOptions"]; });
  114811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEventOptions"]; });
  114812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  114813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  114814. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  114815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  114816. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  114817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  114818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  114819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  114820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  114821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  114822. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  114823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  114824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  114825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  114826. /***/ }),
  114827. /***/ "./Physics/physicsEngine.ts":
  114828. /*!**********************************!*\
  114829. !*** ./Physics/physicsEngine.ts ***!
  114830. \**********************************/
  114831. /*! exports provided: PhysicsEngine */
  114832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114833. "use strict";
  114834. __webpack_require__.r(__webpack_exports__);
  114835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  114836. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  114837. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  114838. /**
  114839. * Class used to control physics engine
  114840. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114841. */
  114842. var PhysicsEngine = /** @class */ (function () {
  114843. /**
  114844. * Creates a new Physics Engine
  114845. * @param gravity defines the gravity vector used by the simulation
  114846. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114847. */
  114848. function PhysicsEngine(gravity, _physicsPlugin) {
  114849. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  114850. this._physicsPlugin = _physicsPlugin;
  114851. this._impostors = [];
  114852. this._joints = [];
  114853. if (!this._physicsPlugin.isSupported()) {
  114854. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  114855. + "Please make sure it is included.");
  114856. }
  114857. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  114858. this.setGravity(gravity);
  114859. this.setTimeStep();
  114860. }
  114861. /**
  114862. * Factory used to create the default physics plugin.
  114863. * @returns The default physics plugin
  114864. */
  114865. PhysicsEngine.DefaultPluginFactory = function () {
  114866. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  114867. };
  114868. /**
  114869. * Sets the gravity vector used by the simulation
  114870. * @param gravity defines the gravity vector to use
  114871. */
  114872. PhysicsEngine.prototype.setGravity = function (gravity) {
  114873. this.gravity = gravity;
  114874. this._physicsPlugin.setGravity(this.gravity);
  114875. };
  114876. /**
  114877. * Set the time step of the physics engine.
  114878. * Default is 1/60.
  114879. * To slow it down, enter 1/600 for example.
  114880. * To speed it up, 1/30
  114881. * @param newTimeStep defines the new timestep to apply to this world.
  114882. */
  114883. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  114884. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  114885. this._physicsPlugin.setTimeStep(newTimeStep);
  114886. };
  114887. /**
  114888. * Get the time step of the physics engine.
  114889. * @returns the current time step
  114890. */
  114891. PhysicsEngine.prototype.getTimeStep = function () {
  114892. return this._physicsPlugin.getTimeStep();
  114893. };
  114894. /**
  114895. * Release all resources
  114896. */
  114897. PhysicsEngine.prototype.dispose = function () {
  114898. this._impostors.forEach(function (impostor) {
  114899. impostor.dispose();
  114900. });
  114901. this._physicsPlugin.dispose();
  114902. };
  114903. /**
  114904. * Gets the name of the current physics plugin
  114905. * @returns the name of the plugin
  114906. */
  114907. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  114908. return this._physicsPlugin.name;
  114909. };
  114910. /**
  114911. * Adding a new impostor for the impostor tracking.
  114912. * This will be done by the impostor itself.
  114913. * @param impostor the impostor to add
  114914. */
  114915. PhysicsEngine.prototype.addImpostor = function (impostor) {
  114916. impostor.uniqueId = this._impostors.push(impostor);
  114917. //if no parent, generate the body
  114918. if (!impostor.parent) {
  114919. this._physicsPlugin.generatePhysicsBody(impostor);
  114920. }
  114921. };
  114922. /**
  114923. * Remove an impostor from the engine.
  114924. * This impostor and its mesh will not longer be updated by the physics engine.
  114925. * @param impostor the impostor to remove
  114926. */
  114927. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  114928. var index = this._impostors.indexOf(impostor);
  114929. if (index > -1) {
  114930. var removed = this._impostors.splice(index, 1);
  114931. //Is it needed?
  114932. if (removed.length) {
  114933. //this will also remove it from the world.
  114934. removed[0].physicsBody = null;
  114935. }
  114936. }
  114937. };
  114938. /**
  114939. * Add a joint to the physics engine
  114940. * @param mainImpostor defines the main impostor to which the joint is added.
  114941. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114942. * @param joint defines the joint that will connect both impostors.
  114943. */
  114944. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  114945. var impostorJoint = {
  114946. mainImpostor: mainImpostor,
  114947. connectedImpostor: connectedImpostor,
  114948. joint: joint
  114949. };
  114950. joint.physicsPlugin = this._physicsPlugin;
  114951. this._joints.push(impostorJoint);
  114952. this._physicsPlugin.generateJoint(impostorJoint);
  114953. };
  114954. /**
  114955. * Removes a joint from the simulation
  114956. * @param mainImpostor defines the impostor used with the joint
  114957. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114958. * @param joint defines the joint to remove
  114959. */
  114960. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  114961. var matchingJoints = this._joints.filter(function (impostorJoint) {
  114962. return (impostorJoint.connectedImpostor === connectedImpostor
  114963. && impostorJoint.joint === joint
  114964. && impostorJoint.mainImpostor === mainImpostor);
  114965. });
  114966. if (matchingJoints.length) {
  114967. this._physicsPlugin.removeJoint(matchingJoints[0]);
  114968. //TODO remove it from the list as well
  114969. }
  114970. };
  114971. /**
  114972. * Called by the scene. No need to call it.
  114973. * @param delta defines the timespam between frames
  114974. */
  114975. PhysicsEngine.prototype._step = function (delta) {
  114976. var _this = this;
  114977. //check if any mesh has no body / requires an update
  114978. this._impostors.forEach(function (impostor) {
  114979. if (impostor.isBodyInitRequired()) {
  114980. _this._physicsPlugin.generatePhysicsBody(impostor);
  114981. }
  114982. });
  114983. if (delta > 0.1) {
  114984. delta = 0.1;
  114985. }
  114986. else if (delta <= 0) {
  114987. delta = 1.0 / 60.0;
  114988. }
  114989. this._physicsPlugin.executeStep(delta, this._impostors);
  114990. };
  114991. /**
  114992. * Gets the current plugin used to run the simulation
  114993. * @returns current plugin
  114994. */
  114995. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  114996. return this._physicsPlugin;
  114997. };
  114998. /**
  114999. * Gets the list of physic impostors
  115000. * @returns an array of PhysicsImpostor
  115001. */
  115002. PhysicsEngine.prototype.getImpostors = function () {
  115003. return this._impostors;
  115004. };
  115005. /**
  115006. * Gets the impostor for a physics enabled object
  115007. * @param object defines the object impersonated by the impostor
  115008. * @returns the PhysicsImpostor or null if not found
  115009. */
  115010. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  115011. for (var i = 0; i < this._impostors.length; ++i) {
  115012. if (this._impostors[i].object === object) {
  115013. return this._impostors[i];
  115014. }
  115015. }
  115016. return null;
  115017. };
  115018. /**
  115019. * Gets the impostor for a physics body object
  115020. * @param body defines physics body used by the impostor
  115021. * @returns the PhysicsImpostor or null if not found
  115022. */
  115023. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  115024. for (var i = 0; i < this._impostors.length; ++i) {
  115025. if (this._impostors[i].physicsBody === body) {
  115026. return this._impostors[i];
  115027. }
  115028. }
  115029. return null;
  115030. };
  115031. /**
  115032. * Does a raycast in the physics world
  115033. * @param from when should the ray start?
  115034. * @param to when should the ray end?
  115035. * @returns PhysicsRaycastResult
  115036. */
  115037. PhysicsEngine.prototype.raycast = function (from, to) {
  115038. return this._physicsPlugin.raycast(from, to);
  115039. };
  115040. /**
  115041. * Global value used to control the smallest number supported by the simulation
  115042. */
  115043. PhysicsEngine.Epsilon = 0.001;
  115044. return PhysicsEngine;
  115045. }());
  115046. /***/ }),
  115047. /***/ "./Physics/physicsEngineComponent.ts":
  115048. /*!*******************************************!*\
  115049. !*** ./Physics/physicsEngineComponent.ts ***!
  115050. \*******************************************/
  115051. /*! exports provided: PhysicsEngineSceneComponent */
  115052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115053. "use strict";
  115054. __webpack_require__.r(__webpack_exports__);
  115055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  115056. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  115057. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  115058. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  115059. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  115060. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  115061. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  115062. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  115063. /**
  115064. * Gets the current physics engine
  115065. * @returns a IPhysicsEngine or null if none attached
  115066. */
  115067. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  115068. return this._physicsEngine;
  115069. };
  115070. /**
  115071. * Enables physics to the current scene
  115072. * @param gravity defines the scene's gravity for the physics engine
  115073. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  115074. * @return a boolean indicating if the physics engine was initialized
  115075. */
  115076. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  115077. if (gravity === void 0) { gravity = null; }
  115078. if (this._physicsEngine) {
  115079. return true;
  115080. }
  115081. // Register the component to the scene
  115082. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  115083. if (!component) {
  115084. component = new PhysicsEngineSceneComponent(this);
  115085. this._addComponent(component);
  115086. }
  115087. try {
  115088. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  115089. return true;
  115090. }
  115091. catch (e) {
  115092. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  115093. return false;
  115094. }
  115095. };
  115096. /**
  115097. * Disables and disposes the physics engine associated with the scene
  115098. */
  115099. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  115100. if (!this._physicsEngine) {
  115101. return;
  115102. }
  115103. this._physicsEngine.dispose();
  115104. this._physicsEngine = null;
  115105. };
  115106. /**
  115107. * Gets a boolean indicating if there is an active physics engine
  115108. * @returns a boolean indicating if there is an active physics engine
  115109. */
  115110. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  115111. return this._physicsEngine !== undefined;
  115112. };
  115113. /**
  115114. * Deletes a physics compound impostor
  115115. * @param compound defines the compound to delete
  115116. */
  115117. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  115118. var mesh = compound.parts[0].mesh;
  115119. if (mesh.physicsImpostor) {
  115120. mesh.physicsImpostor.dispose( /*true*/);
  115121. mesh.physicsImpostor = null;
  115122. }
  115123. };
  115124. /** @hidden */
  115125. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  115126. if (this._physicsEngine) {
  115127. this.onBeforePhysicsObservable.notifyObservers(this);
  115128. this._physicsEngine._step(step / 1000);
  115129. this.onAfterPhysicsObservable.notifyObservers(this);
  115130. }
  115131. };
  115132. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  115133. get: function () {
  115134. return this._physicsImpostor;
  115135. },
  115136. set: function (value) {
  115137. var _this = this;
  115138. if (this._physicsImpostor === value) {
  115139. return;
  115140. }
  115141. if (this._disposePhysicsObserver) {
  115142. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  115143. }
  115144. this._physicsImpostor = value;
  115145. if (value) {
  115146. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  115147. // Physics
  115148. if (_this.physicsImpostor) {
  115149. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  115150. _this.physicsImpostor = null;
  115151. }
  115152. });
  115153. }
  115154. },
  115155. enumerable: true,
  115156. configurable: true
  115157. });
  115158. /**
  115159. * Gets the current physics impostor
  115160. * @see http://doc.babylonjs.com/features/physics_engine
  115161. * @returns a physics impostor or null
  115162. */
  115163. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  115164. return this.physicsImpostor;
  115165. };
  115166. /**
  115167. * Apply a physic impulse to the mesh
  115168. * @param force defines the force to apply
  115169. * @param contactPoint defines where to apply the force
  115170. * @returns the current mesh
  115171. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  115172. */
  115173. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  115174. if (!this.physicsImpostor) {
  115175. return this;
  115176. }
  115177. this.physicsImpostor.applyImpulse(force, contactPoint);
  115178. return this;
  115179. };
  115180. /**
  115181. * Creates a physic joint between two meshes
  115182. * @param otherMesh defines the other mesh to use
  115183. * @param pivot1 defines the pivot to use on this mesh
  115184. * @param pivot2 defines the pivot to use on the other mesh
  115185. * @param options defines additional options (can be plugin dependent)
  115186. * @returns the current mesh
  115187. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  115188. */
  115189. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  115190. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  115191. return this;
  115192. }
  115193. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  115194. mainPivot: pivot1,
  115195. connectedPivot: pivot2,
  115196. nativeParams: options
  115197. });
  115198. return this;
  115199. };
  115200. /**
  115201. * Defines the physics engine scene component responsible to manage a physics engine
  115202. */
  115203. var PhysicsEngineSceneComponent = /** @class */ (function () {
  115204. /**
  115205. * Creates a new instance of the component for the given scene
  115206. * @param scene Defines the scene to register the component in
  115207. */
  115208. function PhysicsEngineSceneComponent(scene) {
  115209. var _this = this;
  115210. /**
  115211. * The component name helpful to identify the component in the list of scene components.
  115212. */
  115213. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  115214. this.scene = scene;
  115215. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  115216. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  115217. // Replace the function used to get the deterministic frame time
  115218. this.scene.getDeterministicFrameTime = function () {
  115219. if (_this.scene._physicsEngine) {
  115220. return _this.scene._physicsEngine.getTimeStep() * 1000;
  115221. }
  115222. return 1000.0 / 60.0;
  115223. };
  115224. }
  115225. /**
  115226. * Registers the component in a given scene
  115227. */
  115228. PhysicsEngineSceneComponent.prototype.register = function () {
  115229. };
  115230. /**
  115231. * Rebuilds the elements related to this component in case of
  115232. * context lost for instance.
  115233. */
  115234. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  115235. // Nothing to do for this component
  115236. };
  115237. /**
  115238. * Disposes the component and the associated ressources
  115239. */
  115240. PhysicsEngineSceneComponent.prototype.dispose = function () {
  115241. this.scene.onBeforePhysicsObservable.clear();
  115242. this.scene.onAfterPhysicsObservable.clear();
  115243. if (this.scene._physicsEngine) {
  115244. this.scene.disablePhysicsEngine();
  115245. }
  115246. };
  115247. return PhysicsEngineSceneComponent;
  115248. }());
  115249. /***/ }),
  115250. /***/ "./Physics/physicsHelper.ts":
  115251. /*!**********************************!*\
  115252. !*** ./Physics/physicsHelper.ts ***!
  115253. \**********************************/
  115254. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  115255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115256. "use strict";
  115257. __webpack_require__.r(__webpack_exports__);
  115258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  115259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return PhysicsRadialExplosionEventOptions; });
  115260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return PhysicsUpdraftEventOptions; });
  115261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return PhysicsVortexEventOptions; });
  115262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  115263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  115264. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115265. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  115266. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115267. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  115268. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  115269. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  115270. /**
  115271. * A helper for physics simulations
  115272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115273. */
  115274. var PhysicsHelper = /** @class */ (function () {
  115275. /**
  115276. * Initializes the Physics helper
  115277. * @param scene Babylon.js scene
  115278. */
  115279. function PhysicsHelper(scene) {
  115280. this._scene = scene;
  115281. this._physicsEngine = this._scene.getPhysicsEngine();
  115282. if (!this._physicsEngine) {
  115283. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  115284. return;
  115285. }
  115286. }
  115287. /**
  115288. * Applies a radial explosion impulse
  115289. * @param origin the origin of the explosion
  115290. * @param radiusOrEventOptions the radius or the options of radial explosion
  115291. * @param strength the explosion strength
  115292. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115293. * @returns A physics radial explosion event, or null
  115294. */
  115295. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radiusOrEventOptions, strength, falloff) {
  115296. if (!this._physicsEngine) {
  115297. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  115298. return null;
  115299. }
  115300. var impostors = this._physicsEngine.getImpostors();
  115301. if (impostors.length === 0) {
  115302. return null;
  115303. }
  115304. if (typeof radiusOrEventOptions === 'number') {
  115305. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  115306. radiusOrEventOptions.radius = radiusOrEventOptions;
  115307. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115308. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  115309. }
  115310. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  115311. impostors.forEach(function (impostor) {
  115312. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin);
  115313. if (!impostorForceAndContactPoint) {
  115314. return;
  115315. }
  115316. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  115317. });
  115318. event.dispose(false);
  115319. return event;
  115320. };
  115321. /**
  115322. * Applies a radial explosion force
  115323. * @param origin the origin of the explosion
  115324. * @param radiusOrEventOptions the radius or the options of radial explosion
  115325. * @param strength the explosion strength
  115326. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115327. * @returns A physics radial explosion event, or null
  115328. */
  115329. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radiusOrEventOptions, strength, falloff) {
  115330. if (!this._physicsEngine) {
  115331. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115332. return null;
  115333. }
  115334. var impostors = this._physicsEngine.getImpostors();
  115335. if (impostors.length === 0) {
  115336. return null;
  115337. }
  115338. if (typeof radiusOrEventOptions === 'number') {
  115339. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  115340. radiusOrEventOptions.radius = radiusOrEventOptions;
  115341. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115342. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  115343. }
  115344. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  115345. impostors.forEach(function (impostor) {
  115346. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin);
  115347. if (!impostorForceAndContactPoint) {
  115348. return;
  115349. }
  115350. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  115351. });
  115352. event.dispose(false);
  115353. return event;
  115354. };
  115355. /**
  115356. * Creates a gravitational field
  115357. * @param origin the origin of the explosion
  115358. * @param radiusOrEventOptions the radius or the options of radial explosion
  115359. * @param strength the explosion strength
  115360. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115361. * @returns A physics gravitational field event, or null
  115362. */
  115363. PhysicsHelper.prototype.gravitationalField = function (origin, radiusOrEventOptions, strength, falloff) {
  115364. if (!this._physicsEngine) {
  115365. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115366. return null;
  115367. }
  115368. var impostors = this._physicsEngine.getImpostors();
  115369. if (impostors.length === 0) {
  115370. return null;
  115371. }
  115372. if (typeof radiusOrEventOptions === 'number') {
  115373. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  115374. radiusOrEventOptions.radius = radiusOrEventOptions;
  115375. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115376. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  115377. }
  115378. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radiusOrEventOptions);
  115379. event.dispose(false);
  115380. return event;
  115381. };
  115382. /**
  115383. * Creates a physics updraft event
  115384. * @param origin the origin of the updraft
  115385. * @param radiusOrEventOptions the radius or the options of the updraft
  115386. * @param strength the strength of the updraft
  115387. * @param height the height of the updraft
  115388. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  115389. * @returns A physics updraft event, or null
  115390. */
  115391. PhysicsHelper.prototype.updraft = function (origin, radiusOrEventOptions, strength, height, updraftMode) {
  115392. if (!this._physicsEngine) {
  115393. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115394. return null;
  115395. }
  115396. if (this._physicsEngine.getImpostors().length === 0) {
  115397. return null;
  115398. }
  115399. if (typeof radiusOrEventOptions === 'number') {
  115400. radiusOrEventOptions = new PhysicsUpdraftEventOptions();
  115401. radiusOrEventOptions.radius = radiusOrEventOptions;
  115402. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115403. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  115404. radiusOrEventOptions.updraftMode = updraftMode || radiusOrEventOptions.updraftMode;
  115405. }
  115406. var event = new PhysicsUpdraftEvent(this._scene, origin, radiusOrEventOptions);
  115407. event.dispose(false);
  115408. return event;
  115409. };
  115410. /**
  115411. * Creates a physics vortex event
  115412. * @param origin the of the vortex
  115413. * @param radiusOrEventOptions the radius or the options of the vortex
  115414. * @param strength the strength of the vortex
  115415. * @param height the height of the vortex
  115416. * @returns a Physics vortex event, or null
  115417. * A physics vortex event or null
  115418. */
  115419. PhysicsHelper.prototype.vortex = function (origin, radiusOrEventOptions, strength, height) {
  115420. if (!this._physicsEngine) {
  115421. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115422. return null;
  115423. }
  115424. if (this._physicsEngine.getImpostors().length === 0) {
  115425. return null;
  115426. }
  115427. if (typeof radiusOrEventOptions === 'number') {
  115428. radiusOrEventOptions = new PhysicsVortexEventOptions();
  115429. radiusOrEventOptions.radius = radiusOrEventOptions;
  115430. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115431. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  115432. }
  115433. var event = new PhysicsVortexEvent(this._scene, origin, radiusOrEventOptions);
  115434. event.dispose(false);
  115435. return event;
  115436. };
  115437. return PhysicsHelper;
  115438. }());
  115439. /**
  115440. * Represents a physics radial explosion event
  115441. */
  115442. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  115443. /**
  115444. * Initializes a radial explosioin event
  115445. * @param _scene BabylonJS scene
  115446. * @param _options The options for the vortex event
  115447. */
  115448. function PhysicsRadialExplosionEvent(_scene, _options) {
  115449. this._scene = _scene;
  115450. this._options = _options;
  115451. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  115452. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  115453. }
  115454. /**
  115455. * Returns the data related to the radial explosion event (sphere).
  115456. * @returns The radial explosion event data
  115457. */
  115458. PhysicsRadialExplosionEvent.prototype.getData = function () {
  115459. this._dataFetched = true;
  115460. return {
  115461. sphere: this._sphere,
  115462. };
  115463. };
  115464. /**
  115465. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  115466. * @param impostor A physics imposter
  115467. * @param origin the origin of the explosion
  115468. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  115469. */
  115470. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin) {
  115471. if (impostor.mass === 0) {
  115472. return null;
  115473. }
  115474. if (!this._intersectsWithSphere(impostor, origin, this._options.radius)) {
  115475. return null;
  115476. }
  115477. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  115478. return null;
  115479. }
  115480. var impostorObjectCenter = impostor.getObjectCenter();
  115481. var direction = impostorObjectCenter.subtract(origin);
  115482. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, this._options.radius);
  115483. var hit = ray.intersectsMesh(impostor.object);
  115484. var contactPoint = hit.pickedPoint;
  115485. if (!contactPoint) {
  115486. return null;
  115487. }
  115488. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(origin, contactPoint);
  115489. if (distanceFromOrigin > this._options.radius) {
  115490. return null;
  115491. }
  115492. var multiplier = this._options.falloff === PhysicsRadialImpulseFalloff.Constant
  115493. ? this._options.strength
  115494. : this._options.strength * (1 - (distanceFromOrigin / this._options.radius));
  115495. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  115496. return { force: force, contactPoint: contactPoint };
  115497. };
  115498. /**
  115499. * Disposes the sphere.
  115500. * @param force Specifies if the sphere should be disposed by force
  115501. */
  115502. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  115503. var _this = this;
  115504. if (force === void 0) { force = true; }
  115505. if (force) {
  115506. this._sphere.dispose();
  115507. }
  115508. else {
  115509. setTimeout(function () {
  115510. if (!_this._dataFetched) {
  115511. _this._sphere.dispose();
  115512. }
  115513. }, 0);
  115514. }
  115515. };
  115516. /*** Helpers ***/
  115517. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  115518. if (!this._sphere) {
  115519. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._options.sphere, this._scene);
  115520. this._sphere.isVisible = false;
  115521. }
  115522. };
  115523. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  115524. var impostorObject = impostor.object;
  115525. this._prepareSphere();
  115526. this._sphere.position = origin;
  115527. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * 2, radius * 2, radius * 2);
  115528. this._sphere._updateBoundingInfo();
  115529. this._sphere.computeWorldMatrix(true);
  115530. return this._sphere.intersectsMesh(impostorObject, true);
  115531. };
  115532. return PhysicsRadialExplosionEvent;
  115533. }());
  115534. /**
  115535. * Represents a gravitational field event
  115536. */
  115537. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  115538. /**
  115539. * Initializes the physics gravitational field event
  115540. * @param _physicsHelper A physics helper
  115541. * @param _scene BabylonJS scene
  115542. * @param _origin The origin position of the gravitational field event
  115543. * @param _options The options for the vortex event
  115544. */
  115545. function PhysicsGravitationalFieldEvent(_physicsHelper, _scene, _origin, _options) {
  115546. this._physicsHelper = _physicsHelper;
  115547. this._scene = _scene;
  115548. this._origin = _origin;
  115549. this._options = _options;
  115550. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  115551. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  115552. this._tickCallback = this._tick.bind(this);
  115553. this._options.strength = this._options.strength * -1;
  115554. }
  115555. /**
  115556. * Returns the data related to the gravitational field event (sphere).
  115557. * @returns A gravitational field event
  115558. */
  115559. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  115560. this._dataFetched = true;
  115561. return {
  115562. sphere: this._sphere,
  115563. };
  115564. };
  115565. /**
  115566. * Enables the gravitational field.
  115567. */
  115568. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  115569. this._tickCallback.call(this);
  115570. this._scene.registerBeforeRender(this._tickCallback);
  115571. };
  115572. /**
  115573. * Disables the gravitational field.
  115574. */
  115575. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  115576. this._scene.unregisterBeforeRender(this._tickCallback);
  115577. };
  115578. /**
  115579. * Disposes the sphere.
  115580. * @param force The force to dispose from the gravitational field event
  115581. */
  115582. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  115583. var _this = this;
  115584. if (force === void 0) { force = true; }
  115585. if (force) {
  115586. this._sphere.dispose();
  115587. }
  115588. else {
  115589. setTimeout(function () {
  115590. if (!_this._dataFetched) {
  115591. _this._sphere.dispose();
  115592. }
  115593. }, 0);
  115594. }
  115595. };
  115596. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  115597. // Since the params won't change, we fetch the event only once
  115598. if (this._sphere) {
  115599. this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  115600. }
  115601. else {
  115602. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  115603. if (radialExplosionEvent) {
  115604. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  115605. }
  115606. }
  115607. };
  115608. return PhysicsGravitationalFieldEvent;
  115609. }());
  115610. /**
  115611. * Represents a physics updraft event
  115612. */
  115613. var PhysicsUpdraftEvent = /** @class */ (function () {
  115614. /**
  115615. * Initializes the physics updraft event
  115616. * @param _scene BabylonJS scene
  115617. * @param _origin The origin position of the updraft
  115618. * @param _options The options for the updraft event
  115619. */
  115620. function PhysicsUpdraftEvent(_scene, _origin, _options) {
  115621. this._scene = _scene;
  115622. this._origin = _origin;
  115623. this._options = _options;
  115624. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  115625. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  115626. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  115627. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  115628. this._physicsEngine = this._scene.getPhysicsEngine();
  115629. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsUpdraftEventOptions()), this._options);
  115630. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  115631. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  115632. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  115633. this._originDirection = this._origin.subtract(this._originTop).normalize();
  115634. }
  115635. this._tickCallback = this._tick.bind(this);
  115636. this._prepareCylinder();
  115637. }
  115638. /**
  115639. * Returns the data related to the updraft event (cylinder).
  115640. * @returns A physics updraft event
  115641. */
  115642. PhysicsUpdraftEvent.prototype.getData = function () {
  115643. this._dataFetched = true;
  115644. return {
  115645. cylinder: this._cylinder,
  115646. };
  115647. };
  115648. /**
  115649. * Enables the updraft.
  115650. */
  115651. PhysicsUpdraftEvent.prototype.enable = function () {
  115652. this._tickCallback.call(this);
  115653. this._scene.registerBeforeRender(this._tickCallback);
  115654. };
  115655. /**
  115656. * Disables the updraft.
  115657. */
  115658. PhysicsUpdraftEvent.prototype.disable = function () {
  115659. this._scene.unregisterBeforeRender(this._tickCallback);
  115660. };
  115661. /**
  115662. * Disposes the cylinder.
  115663. * @param force Specifies if the updraft should be disposed by force
  115664. */
  115665. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  115666. var _this = this;
  115667. if (force === void 0) { force = true; }
  115668. if (!this._cylinder) {
  115669. return;
  115670. }
  115671. if (force) {
  115672. this._cylinder.dispose();
  115673. }
  115674. else {
  115675. setTimeout(function () {
  115676. if (!_this._dataFetched) {
  115677. _this._cylinder.dispose();
  115678. }
  115679. }, 0);
  115680. }
  115681. };
  115682. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  115683. if (impostor.mass === 0) {
  115684. return null;
  115685. }
  115686. if (!this._intersectsWithCylinder(impostor)) {
  115687. return null;
  115688. }
  115689. var impostorObjectCenter = impostor.getObjectCenter();
  115690. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  115691. var direction = this._originDirection;
  115692. }
  115693. else {
  115694. var direction = impostorObjectCenter.subtract(this._originTop);
  115695. }
  115696. var multiplier = this._options.strength * -1;
  115697. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  115698. return { force: force, contactPoint: impostorObjectCenter };
  115699. };
  115700. PhysicsUpdraftEvent.prototype._tick = function () {
  115701. var _this = this;
  115702. this._physicsEngine.getImpostors().forEach(function (impostor) {
  115703. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  115704. if (!impostorForceAndContactPoint) {
  115705. return;
  115706. }
  115707. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  115708. });
  115709. };
  115710. /*** Helpers ***/
  115711. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  115712. if (!this._cylinder) {
  115713. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  115714. height: this._options.height,
  115715. diameter: this._options.radius * 2,
  115716. }, this._scene);
  115717. this._cylinder.isVisible = false;
  115718. }
  115719. };
  115720. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  115721. var impostorObject = impostor.object;
  115722. this._cylinder.position = this._cylinderPosition;
  115723. return this._cylinder.intersectsMesh(impostorObject, true);
  115724. };
  115725. return PhysicsUpdraftEvent;
  115726. }());
  115727. /**
  115728. * Represents a physics vortex event
  115729. */
  115730. var PhysicsVortexEvent = /** @class */ (function () {
  115731. /**
  115732. * Initializes the physics vortex event
  115733. * @param _scene The BabylonJS scene
  115734. * @param _origin The origin position of the vortex
  115735. * @param _options The options for the vortex event
  115736. */
  115737. function PhysicsVortexEvent(_scene, _origin, _options) {
  115738. this._scene = _scene;
  115739. this._origin = _origin;
  115740. this._options = _options;
  115741. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  115742. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  115743. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  115744. this._physicsEngine = this._scene.getPhysicsEngine();
  115745. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsVortexEventOptions()), this._options);
  115746. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  115747. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  115748. this._tickCallback = this._tick.bind(this);
  115749. this._prepareCylinder();
  115750. }
  115751. /**
  115752. * Returns the data related to the vortex event (cylinder).
  115753. * @returns The physics vortex event data
  115754. */
  115755. PhysicsVortexEvent.prototype.getData = function () {
  115756. this._dataFetched = true;
  115757. return {
  115758. cylinder: this._cylinder,
  115759. };
  115760. };
  115761. /**
  115762. * Enables the vortex.
  115763. */
  115764. PhysicsVortexEvent.prototype.enable = function () {
  115765. this._tickCallback.call(this);
  115766. this._scene.registerBeforeRender(this._tickCallback);
  115767. };
  115768. /**
  115769. * Disables the cortex.
  115770. */
  115771. PhysicsVortexEvent.prototype.disable = function () {
  115772. this._scene.unregisterBeforeRender(this._tickCallback);
  115773. };
  115774. /**
  115775. * Disposes the sphere.
  115776. * @param force
  115777. */
  115778. PhysicsVortexEvent.prototype.dispose = function (force) {
  115779. var _this = this;
  115780. if (force === void 0) { force = true; }
  115781. if (force) {
  115782. this._cylinder.dispose();
  115783. }
  115784. else {
  115785. setTimeout(function () {
  115786. if (!_this._dataFetched) {
  115787. _this._cylinder.dispose();
  115788. }
  115789. }, 0);
  115790. }
  115791. };
  115792. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  115793. if (impostor.mass === 0) {
  115794. return null;
  115795. }
  115796. if (!this._intersectsWithCylinder(impostor)) {
  115797. return null;
  115798. }
  115799. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  115800. return null;
  115801. }
  115802. var impostorObjectCenter = impostor.getObjectCenter();
  115803. var originOnPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
  115804. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  115805. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](originOnPlane, originToImpostorDirection, this._options.radius);
  115806. var hit = ray.intersectsMesh(impostor.object);
  115807. var contactPoint = hit.pickedPoint;
  115808. if (!contactPoint) {
  115809. return null;
  115810. }
  115811. var absoluteDistanceFromOrigin = hit.distance / this._options.radius;
  115812. var directionToOrigin = contactPoint.normalize();
  115813. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  115814. directionToOrigin = directionToOrigin.negate();
  115815. }
  115816. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  115817. var forceX = directionToOrigin.x * this._options.centripetalForceMultiplier;
  115818. var forceY = directionToOrigin.y * this._options.updraftForceMultiplier;
  115819. var forceZ = directionToOrigin.z * this._options.centripetalForceMultiplier;
  115820. }
  115821. else {
  115822. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  115823. var forceX = (perpendicularDirection.x + directionToOrigin.x) * this._options.centrifugalForceMultiplier;
  115824. var forceY = this._originTop.y * this._options.updraftForceMultiplier;
  115825. var forceZ = (perpendicularDirection.z + directionToOrigin.z) * this._options.centrifugalForceMultiplier;
  115826. }
  115827. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](forceX, forceY, forceZ);
  115828. force = force.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength);
  115829. return { force: force, contactPoint: impostorObjectCenter };
  115830. };
  115831. PhysicsVortexEvent.prototype._tick = function () {
  115832. var _this = this;
  115833. this._physicsEngine.getImpostors().forEach(function (impostor) {
  115834. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  115835. if (!impostorForceAndContactPoint) {
  115836. return;
  115837. }
  115838. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  115839. });
  115840. };
  115841. /*** Helpers ***/
  115842. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  115843. if (!this._cylinder) {
  115844. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  115845. height: this._options.height,
  115846. diameter: this._options.radius * 2,
  115847. }, this._scene);
  115848. this._cylinder.isVisible = false;
  115849. }
  115850. };
  115851. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  115852. var impostorObject = impostor.object;
  115853. this._cylinder.position = this._cylinderPosition;
  115854. return this._cylinder.intersectsMesh(impostorObject, true);
  115855. };
  115856. return PhysicsVortexEvent;
  115857. }());
  115858. /**
  115859. * Options fot the radial explosion event
  115860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115861. */
  115862. var PhysicsRadialExplosionEventOptions = /** @class */ (function () {
  115863. function PhysicsRadialExplosionEventOptions() {
  115864. /**
  115865. * The radius of the sphere for the radial explosion.
  115866. */
  115867. this.radius = 5;
  115868. /**
  115869. * The strenth of the explosion.
  115870. */
  115871. this.strength = 10;
  115872. /**
  115873. * The strenght of the force in correspondence to the distance of the affected object
  115874. */
  115875. this.falloff = PhysicsRadialImpulseFalloff.Constant;
  115876. /**
  115877. * Sphere options for the radial explosion.
  115878. */
  115879. this.sphere = { segments: 32, diameter: 1 };
  115880. }
  115881. return PhysicsRadialExplosionEventOptions;
  115882. }());
  115883. /**
  115884. * Options fot the updraft event
  115885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115886. */
  115887. var PhysicsUpdraftEventOptions = /** @class */ (function () {
  115888. function PhysicsUpdraftEventOptions() {
  115889. /**
  115890. * The radius of the cylinder for the vortex
  115891. */
  115892. this.radius = 5;
  115893. /**
  115894. * The strenth of the updraft.
  115895. */
  115896. this.strength = 10;
  115897. /**
  115898. * The height of the cylinder for the updraft.
  115899. */
  115900. this.height = 10;
  115901. /**
  115902. * The mode for the the updraft.
  115903. */
  115904. this.updraftMode = PhysicsUpdraftMode.Center;
  115905. }
  115906. return PhysicsUpdraftEventOptions;
  115907. }());
  115908. /**
  115909. * Options fot the vortex event
  115910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115911. */
  115912. var PhysicsVortexEventOptions = /** @class */ (function () {
  115913. function PhysicsVortexEventOptions() {
  115914. /**
  115915. * The radius of the cylinder for the vortex
  115916. */
  115917. this.radius = 5;
  115918. /**
  115919. * The strenth of the vortex.
  115920. */
  115921. this.strength = 10;
  115922. /**
  115923. * The height of the cylinder for the vortex.
  115924. */
  115925. this.height = 10;
  115926. /**
  115927. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  115928. */
  115929. this.centripetalForceThreshold = 0.7;
  115930. /**
  115931. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  115932. */
  115933. this.centripetalForceMultiplier = 5;
  115934. /**
  115935. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  115936. */
  115937. this.centrifugalForceMultiplier = 0.5;
  115938. /**
  115939. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  115940. */
  115941. this.updraftForceMultiplier = 0.02;
  115942. }
  115943. return PhysicsVortexEventOptions;
  115944. }());
  115945. /**
  115946. * The strenght of the force in correspondence to the distance of the affected object
  115947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115948. */
  115949. var PhysicsRadialImpulseFalloff;
  115950. (function (PhysicsRadialImpulseFalloff) {
  115951. /** Defines that impulse is constant in strength across it's whole radius */
  115952. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  115953. /** Defines that impulse gets weaker if it's further from the origin */
  115954. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  115955. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  115956. /**
  115957. * The strength of the force in correspondence to the distance of the affected object
  115958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115959. */
  115960. var PhysicsUpdraftMode;
  115961. (function (PhysicsUpdraftMode) {
  115962. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  115963. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  115964. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  115965. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  115966. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  115967. /***/ }),
  115968. /***/ "./Physics/physicsImpostor.ts":
  115969. /*!************************************!*\
  115970. !*** ./Physics/physicsImpostor.ts ***!
  115971. \************************************/
  115972. /*! exports provided: PhysicsImpostor */
  115973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115974. "use strict";
  115975. __webpack_require__.r(__webpack_exports__);
  115976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  115977. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  115978. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  115979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115980. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  115981. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  115982. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  115983. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  115984. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  115985. mass: jsonObject.physicsMass,
  115986. friction: jsonObject.physicsFriction,
  115987. restitution: jsonObject.physicsRestitution
  115988. }, scene);
  115989. };
  115990. /**
  115991. * Represents a physics imposter
  115992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  115993. */
  115994. var PhysicsImpostor = /** @class */ (function () {
  115995. /**
  115996. * Initializes the physics imposter
  115997. * @param object The physics-enabled object used as the physics imposter
  115998. * @param type The type of the physics imposter
  115999. * @param _options The options for the physics imposter
  116000. * @param _scene The Babylon scene
  116001. */
  116002. function PhysicsImpostor(
  116003. /**
  116004. * The physics-enabled object used as the physics imposter
  116005. */
  116006. object,
  116007. /**
  116008. * The type of the physics imposter
  116009. */
  116010. type, _options, _scene) {
  116011. if (_options === void 0) { _options = { mass: 0 }; }
  116012. var _this = this;
  116013. this.object = object;
  116014. this.type = type;
  116015. this._options = _options;
  116016. this._scene = _scene;
  116017. this._bodyUpdateRequired = false;
  116018. this._onBeforePhysicsStepCallbacks = new Array();
  116019. this._onAfterPhysicsStepCallbacks = new Array();
  116020. /** @hidden */
  116021. this._onPhysicsCollideCallbacks = [];
  116022. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  116023. this._isDisposed = false;
  116024. /**
  116025. * @hidden
  116026. */
  116027. this.soft = false;
  116028. /**
  116029. * @hidden
  116030. */
  116031. this.segments = 0;
  116032. //temp variables for parent rotation calculations
  116033. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  116034. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  116035. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  116036. /**
  116037. * this function is executed by the physics engine.
  116038. */
  116039. this.beforeStep = function () {
  116040. if (!_this._physicsEngine) {
  116041. return;
  116042. }
  116043. _this.object.translate(_this._deltaPosition, -1);
  116044. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  116045. _this.object.computeWorldMatrix(false);
  116046. if (_this.object.parent && _this.object.rotationQuaternion) {
  116047. _this.getParentsRotation();
  116048. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  116049. }
  116050. else {
  116051. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  116052. }
  116053. if (!_this._options.disableBidirectionalTransformation) {
  116054. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  116055. }
  116056. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  116057. func(_this);
  116058. });
  116059. };
  116060. /**
  116061. * this function is executed by the physics engine
  116062. */
  116063. this.afterStep = function () {
  116064. if (!_this._physicsEngine) {
  116065. return;
  116066. }
  116067. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  116068. func(_this);
  116069. });
  116070. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  116071. // object has now its world rotation. needs to be converted to local.
  116072. if (_this.object.parent && _this.object.rotationQuaternion) {
  116073. _this.getParentsRotation();
  116074. _this._tmpQuat.conjugateInPlace();
  116075. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  116076. }
  116077. // take the position set and make it the absolute position of this object.
  116078. _this.object.setAbsolutePosition(_this.object.position);
  116079. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  116080. _this.object.translate(_this._deltaPosition, 1);
  116081. };
  116082. /**
  116083. * Legacy collision detection event support
  116084. */
  116085. this.onCollideEvent = null;
  116086. /**
  116087. * event and body object due to cannon's event-based architecture.
  116088. */
  116089. this.onCollide = function (e) {
  116090. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  116091. return;
  116092. }
  116093. if (!_this._physicsEngine) {
  116094. return;
  116095. }
  116096. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  116097. if (otherImpostor) {
  116098. // Legacy collision detection event support
  116099. if (_this.onCollideEvent) {
  116100. _this.onCollideEvent(_this, otherImpostor);
  116101. }
  116102. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  116103. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  116104. }).forEach(function (obj) {
  116105. obj.callback(_this, otherImpostor);
  116106. });
  116107. }
  116108. };
  116109. //sanity check!
  116110. if (!this.object) {
  116111. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  116112. return;
  116113. }
  116114. // Legacy support for old syntax.
  116115. if (!this._scene && object.getScene) {
  116116. this._scene = object.getScene();
  116117. }
  116118. if (!this._scene) {
  116119. return;
  116120. }
  116121. if (this.type > 100) {
  116122. this.soft = true;
  116123. }
  116124. this._physicsEngine = this._scene.getPhysicsEngine();
  116125. if (!this._physicsEngine) {
  116126. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  116127. }
  116128. else {
  116129. //set the object's quaternion, if not set
  116130. if (!this.object.rotationQuaternion) {
  116131. if (this.object.rotation) {
  116132. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  116133. }
  116134. else {
  116135. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  116136. }
  116137. }
  116138. //default options params
  116139. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  116140. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  116141. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  116142. if (this.soft) {
  116143. //softbody mass must be above 0;
  116144. this._options.mass = this._options.mass > 0 ? this._options.mass : 1;
  116145. this._options.pressure = (_options.pressure === void 0) ? 200 : _options.pressure;
  116146. this._options.stiffness = (_options.stiffness === void 0) ? 1 : _options.stiffness;
  116147. this._options.velocityIterations = (_options.velocityIterations === void 0) ? 20 : _options.velocityIterations;
  116148. this._options.positionIterations = (_options.positionIterations === void 0) ? 20 : _options.positionIterations;
  116149. this._options.fixedPoints = (_options.fixedPoints === void 0) ? 0 : _options.fixedPoints;
  116150. this._options.margin = (_options.margin === void 0) ? 0 : _options.margin;
  116151. this._options.damping = (_options.damping === void 0) ? 0 : _options.damping;
  116152. this._options.path = (_options.path === void 0) ? null : _options.path;
  116153. this._options.shape = (_options.shape === void 0) ? null : _options.shape;
  116154. }
  116155. this._joints = [];
  116156. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  116157. if (!this.object.parent || this._options.ignoreParent) {
  116158. this._init();
  116159. }
  116160. else if (this.object.parent.physicsImpostor) {
  116161. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  116162. }
  116163. }
  116164. }
  116165. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  116166. /**
  116167. * Specifies if the physics imposter is disposed
  116168. */
  116169. get: function () {
  116170. return this._isDisposed;
  116171. },
  116172. enumerable: true,
  116173. configurable: true
  116174. });
  116175. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  116176. /**
  116177. * Gets the mass of the physics imposter
  116178. */
  116179. get: function () {
  116180. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  116181. },
  116182. set: function (value) {
  116183. this.setMass(value);
  116184. },
  116185. enumerable: true,
  116186. configurable: true
  116187. });
  116188. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  116189. /**
  116190. * Gets the coefficient of friction
  116191. */
  116192. get: function () {
  116193. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  116194. },
  116195. /**
  116196. * Sets the coefficient of friction
  116197. */
  116198. set: function (value) {
  116199. if (!this._physicsEngine) {
  116200. return;
  116201. }
  116202. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  116203. },
  116204. enumerable: true,
  116205. configurable: true
  116206. });
  116207. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  116208. /**
  116209. * Gets the coefficient of restitution
  116210. */
  116211. get: function () {
  116212. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  116213. },
  116214. /**
  116215. * Sets the coefficient of restitution
  116216. */
  116217. set: function (value) {
  116218. if (!this._physicsEngine) {
  116219. return;
  116220. }
  116221. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  116222. },
  116223. enumerable: true,
  116224. configurable: true
  116225. });
  116226. Object.defineProperty(PhysicsImpostor.prototype, "pressure", {
  116227. /**
  116228. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  116229. */
  116230. get: function () {
  116231. if (!this._physicsEngine) {
  116232. return 0;
  116233. }
  116234. var plugin = this._physicsEngine.getPhysicsPlugin();
  116235. if (!plugin.setBodyPressure) {
  116236. return 0;
  116237. }
  116238. return plugin.getBodyPressure(this);
  116239. },
  116240. /**
  116241. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  116242. */
  116243. set: function (value) {
  116244. if (!this._physicsEngine) {
  116245. return;
  116246. }
  116247. var plugin = this._physicsEngine.getPhysicsPlugin();
  116248. if (!plugin.setBodyPressure) {
  116249. return;
  116250. }
  116251. plugin.setBodyPressure(this, value);
  116252. },
  116253. enumerable: true,
  116254. configurable: true
  116255. });
  116256. Object.defineProperty(PhysicsImpostor.prototype, "stiffness", {
  116257. /**
  116258. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  116259. */
  116260. get: function () {
  116261. if (!this._physicsEngine) {
  116262. return 0;
  116263. }
  116264. var plugin = this._physicsEngine.getPhysicsPlugin();
  116265. if (!plugin.getBodyStiffness) {
  116266. return 0;
  116267. }
  116268. return plugin.getBodyStiffness(this);
  116269. },
  116270. /**
  116271. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  116272. */
  116273. set: function (value) {
  116274. if (!this._physicsEngine) {
  116275. return;
  116276. }
  116277. var plugin = this._physicsEngine.getPhysicsPlugin();
  116278. if (!plugin.setBodyStiffness) {
  116279. return;
  116280. }
  116281. plugin.setBodyStiffness(this, value);
  116282. },
  116283. enumerable: true,
  116284. configurable: true
  116285. });
  116286. Object.defineProperty(PhysicsImpostor.prototype, "velocityIterations", {
  116287. /**
  116288. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  116289. */
  116290. get: function () {
  116291. if (!this._physicsEngine) {
  116292. return 0;
  116293. }
  116294. var plugin = this._physicsEngine.getPhysicsPlugin();
  116295. if (!plugin.getBodyVelocityIterations) {
  116296. return 0;
  116297. }
  116298. return plugin.getBodyVelocityIterations(this);
  116299. },
  116300. /**
  116301. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  116302. */
  116303. set: function (value) {
  116304. if (!this._physicsEngine) {
  116305. return;
  116306. }
  116307. var plugin = this._physicsEngine.getPhysicsPlugin();
  116308. if (!plugin.setBodyVelocityIterations) {
  116309. return;
  116310. }
  116311. plugin.setBodyVelocityIterations(this, value);
  116312. },
  116313. enumerable: true,
  116314. configurable: true
  116315. });
  116316. Object.defineProperty(PhysicsImpostor.prototype, "positionIterations", {
  116317. /**
  116318. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  116319. */
  116320. get: function () {
  116321. if (!this._physicsEngine) {
  116322. return 0;
  116323. }
  116324. var plugin = this._physicsEngine.getPhysicsPlugin();
  116325. if (!plugin.getBodyPositionIterations) {
  116326. return 0;
  116327. }
  116328. return plugin.getBodyPositionIterations(this);
  116329. },
  116330. /**
  116331. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  116332. */
  116333. set: function (value) {
  116334. if (!this._physicsEngine) {
  116335. return;
  116336. }
  116337. var plugin = this._physicsEngine.getPhysicsPlugin();
  116338. if (!plugin.setBodyPositionIterations) {
  116339. return;
  116340. }
  116341. plugin.setBodyPositionIterations(this, value);
  116342. },
  116343. enumerable: true,
  116344. configurable: true
  116345. });
  116346. /**
  116347. * This function will completly initialize this impostor.
  116348. * It will create a new body - but only if this mesh has no parent.
  116349. * If it has, this impostor will not be used other than to define the impostor
  116350. * of the child mesh.
  116351. * @hidden
  116352. */
  116353. PhysicsImpostor.prototype._init = function () {
  116354. if (!this._physicsEngine) {
  116355. return;
  116356. }
  116357. this._physicsEngine.removeImpostor(this);
  116358. this.physicsBody = null;
  116359. this._parent = this._parent || this._getPhysicsParent();
  116360. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  116361. this._physicsEngine.addImpostor(this);
  116362. }
  116363. };
  116364. PhysicsImpostor.prototype._getPhysicsParent = function () {
  116365. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  116366. var parentMesh = this.object.parent;
  116367. return parentMesh.physicsImpostor;
  116368. }
  116369. return null;
  116370. };
  116371. /**
  116372. * Should a new body be generated.
  116373. * @returns boolean specifying if body initialization is required
  116374. */
  116375. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  116376. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  116377. };
  116378. /**
  116379. * Sets the updated scaling
  116380. * @param updated Specifies if the scaling is updated
  116381. */
  116382. PhysicsImpostor.prototype.setScalingUpdated = function () {
  116383. this.forceUpdate();
  116384. };
  116385. /**
  116386. * Force a regeneration of this or the parent's impostor's body.
  116387. * Use under cautious - This will remove all joints already implemented.
  116388. */
  116389. PhysicsImpostor.prototype.forceUpdate = function () {
  116390. this._init();
  116391. if (this.parent && !this._options.ignoreParent) {
  116392. this.parent.forceUpdate();
  116393. }
  116394. };
  116395. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  116396. /*public get mesh(): AbstractMesh {
  116397. return this._mesh;
  116398. }*/
  116399. /**
  116400. * Gets the body that holds this impostor. Either its own, or its parent.
  116401. */
  116402. get: function () {
  116403. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  116404. },
  116405. /**
  116406. * Set the physics body. Used mainly by the physics engine/plugin
  116407. */
  116408. set: function (physicsBody) {
  116409. if (this._physicsBody && this._physicsEngine) {
  116410. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  116411. }
  116412. this._physicsBody = physicsBody;
  116413. this.resetUpdateFlags();
  116414. },
  116415. enumerable: true,
  116416. configurable: true
  116417. });
  116418. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  116419. /**
  116420. * Get the parent of the physics imposter
  116421. * @returns Physics imposter or null
  116422. */
  116423. get: function () {
  116424. return !this._options.ignoreParent && this._parent ? this._parent : null;
  116425. },
  116426. /**
  116427. * Sets the parent of the physics imposter
  116428. */
  116429. set: function (value) {
  116430. this._parent = value;
  116431. },
  116432. enumerable: true,
  116433. configurable: true
  116434. });
  116435. /**
  116436. * Resets the update flags
  116437. */
  116438. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  116439. this._bodyUpdateRequired = false;
  116440. };
  116441. /**
  116442. * Gets the object extend size
  116443. * @returns the object extend size
  116444. */
  116445. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  116446. if (this.object.getBoundingInfo) {
  116447. var q = this.object.rotationQuaternion;
  116448. //reset rotation
  116449. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  116450. //calculate the world matrix with no rotation
  116451. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  116452. var boundingInfo = this.object.getBoundingInfo();
  116453. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  116454. //bring back the rotation
  116455. this.object.rotationQuaternion = q;
  116456. //calculate the world matrix with the new rotation
  116457. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  116458. return size;
  116459. }
  116460. else {
  116461. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  116462. }
  116463. };
  116464. /**
  116465. * Gets the object center
  116466. * @returns The object center
  116467. */
  116468. PhysicsImpostor.prototype.getObjectCenter = function () {
  116469. if (this.object.getBoundingInfo) {
  116470. var boundingInfo = this.object.getBoundingInfo();
  116471. return boundingInfo.boundingBox.centerWorld;
  116472. }
  116473. else {
  116474. return this.object.position;
  116475. }
  116476. };
  116477. /**
  116478. * Get a specific parametes from the options parameter
  116479. * @param paramName The object parameter name
  116480. * @returns The object parameter
  116481. */
  116482. PhysicsImpostor.prototype.getParam = function (paramName) {
  116483. return this._options[paramName];
  116484. };
  116485. /**
  116486. * Sets a specific parameter in the options given to the physics plugin
  116487. * @param paramName The parameter name
  116488. * @param value The value of the parameter
  116489. */
  116490. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  116491. this._options[paramName] = value;
  116492. this._bodyUpdateRequired = true;
  116493. };
  116494. /**
  116495. * Specifically change the body's mass option. Won't recreate the physics body object
  116496. * @param mass The mass of the physics imposter
  116497. */
  116498. PhysicsImpostor.prototype.setMass = function (mass) {
  116499. if (this.getParam("mass") !== mass) {
  116500. this.setParam("mass", mass);
  116501. }
  116502. if (this._physicsEngine) {
  116503. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  116504. }
  116505. };
  116506. /**
  116507. * Gets the linear velocity
  116508. * @returns linear velocity or null
  116509. */
  116510. PhysicsImpostor.prototype.getLinearVelocity = function () {
  116511. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  116512. };
  116513. /**
  116514. * Sets the linear velocity
  116515. * @param velocity linear velocity or null
  116516. */
  116517. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  116518. if (this._physicsEngine) {
  116519. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  116520. }
  116521. };
  116522. /**
  116523. * Gets the angular velocity
  116524. * @returns angular velocity or null
  116525. */
  116526. PhysicsImpostor.prototype.getAngularVelocity = function () {
  116527. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  116528. };
  116529. /**
  116530. * Sets the angular velocity
  116531. * @param velocity The velocity or null
  116532. */
  116533. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  116534. if (this._physicsEngine) {
  116535. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  116536. }
  116537. };
  116538. /**
  116539. * Execute a function with the physics plugin native code
  116540. * Provide a function the will have two variables - the world object and the physics body object
  116541. * @param func The function to execute with the physics plugin native code
  116542. */
  116543. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  116544. if (this._physicsEngine) {
  116545. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  116546. }
  116547. };
  116548. /**
  116549. * Register a function that will be executed before the physics world is stepping forward
  116550. * @param func The function to execute before the physics world is stepped forward
  116551. */
  116552. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  116553. this._onBeforePhysicsStepCallbacks.push(func);
  116554. };
  116555. /**
  116556. * Unregister a function that will be executed before the physics world is stepping forward
  116557. * @param func The function to execute before the physics world is stepped forward
  116558. */
  116559. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  116560. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  116561. if (index > -1) {
  116562. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  116563. }
  116564. else {
  116565. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  116566. }
  116567. };
  116568. /**
  116569. * Register a function that will be executed after the physics step
  116570. * @param func The function to execute after physics step
  116571. */
  116572. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  116573. this._onAfterPhysicsStepCallbacks.push(func);
  116574. };
  116575. /**
  116576. * Unregisters a function that will be executed after the physics step
  116577. * @param func The function to execute after physics step
  116578. */
  116579. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  116580. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  116581. if (index > -1) {
  116582. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  116583. }
  116584. else {
  116585. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  116586. }
  116587. };
  116588. /**
  116589. * register a function that will be executed when this impostor collides against a different body
  116590. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  116591. * @param func Callback that is executed on collision
  116592. */
  116593. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  116594. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  116595. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  116596. };
  116597. /**
  116598. * Unregisters the physics imposter on contact
  116599. * @param collideAgainst The physics object to collide against
  116600. * @param func Callback to execute on collision
  116601. */
  116602. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  116603. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  116604. var index = -1;
  116605. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  116606. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  116607. // chcek the arrays match
  116608. var sameList = cbDef.otherImpostors.every(function (impostor) {
  116609. return collidedAgainstList.indexOf(impostor) > -1;
  116610. });
  116611. if (sameList) {
  116612. index = idx;
  116613. }
  116614. return sameList;
  116615. }
  116616. return false;
  116617. });
  116618. if (found) {
  116619. this._onPhysicsCollideCallbacks.splice(index, 1);
  116620. }
  116621. else {
  116622. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  116623. }
  116624. };
  116625. /**
  116626. * Get the parent rotation
  116627. * @returns The parent rotation
  116628. */
  116629. PhysicsImpostor.prototype.getParentsRotation = function () {
  116630. var parent = this.object.parent;
  116631. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  116632. while (parent) {
  116633. if (parent.rotationQuaternion) {
  116634. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  116635. }
  116636. else {
  116637. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  116638. }
  116639. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  116640. parent = parent.parent;
  116641. }
  116642. return this._tmpQuat;
  116643. };
  116644. /**
  116645. * Apply a force
  116646. * @param force The force to apply
  116647. * @param contactPoint The contact point for the force
  116648. * @returns The physics imposter
  116649. */
  116650. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  116651. if (this._physicsEngine) {
  116652. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  116653. }
  116654. return this;
  116655. };
  116656. /**
  116657. * Apply an impulse
  116658. * @param force The impulse force
  116659. * @param contactPoint The contact point for the impulse force
  116660. * @returns The physics imposter
  116661. */
  116662. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  116663. if (this._physicsEngine) {
  116664. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  116665. }
  116666. return this;
  116667. };
  116668. /**
  116669. * A help function to create a joint
  116670. * @param otherImpostor A physics imposter used to create a joint
  116671. * @param jointType The type of joint
  116672. * @param jointData The data for the joint
  116673. * @returns The physics imposter
  116674. */
  116675. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  116676. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  116677. this.addJoint(otherImpostor, joint);
  116678. return this;
  116679. };
  116680. /**
  116681. * Add a joint to this impostor with a different impostor
  116682. * @param otherImpostor A physics imposter used to add a joint
  116683. * @param joint The joint to add
  116684. * @returns The physics imposter
  116685. */
  116686. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  116687. this._joints.push({
  116688. otherImpostor: otherImpostor,
  116689. joint: joint
  116690. });
  116691. if (this._physicsEngine) {
  116692. this._physicsEngine.addJoint(this, otherImpostor, joint);
  116693. }
  116694. return this;
  116695. };
  116696. /**
  116697. * Add an anchor to a cloth impostor
  116698. * @param otherImpostor rigid impostor to anchor to
  116699. * @param width ratio across width from 0 to 1
  116700. * @param height ratio up height from 0 to 1
  116701. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116702. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  116703. * @returns impostor the soft imposter
  116704. */
  116705. PhysicsImpostor.prototype.addAnchor = function (otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  116706. if (!this._physicsEngine) {
  116707. return this;
  116708. }
  116709. var plugin = this._physicsEngine.getPhysicsPlugin();
  116710. if (!plugin.appendAnchor) {
  116711. return this;
  116712. }
  116713. if (this._physicsEngine) {
  116714. plugin.appendAnchor(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);
  116715. }
  116716. return this;
  116717. };
  116718. /**
  116719. * Add a hook to a rope impostor
  116720. * @param otherImpostor rigid impostor to anchor to
  116721. * @param length ratio across rope from 0 to 1
  116722. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  116723. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116724. * @returns impostor the rope imposter
  116725. */
  116726. PhysicsImpostor.prototype.addHook = function (otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  116727. if (!this._physicsEngine) {
  116728. return this;
  116729. }
  116730. var plugin = this._physicsEngine.getPhysicsPlugin();
  116731. if (!plugin.appendAnchor) {
  116732. return this;
  116733. }
  116734. if (this._physicsEngine) {
  116735. plugin.appendHook(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);
  116736. }
  116737. return this;
  116738. };
  116739. /**
  116740. * Will keep this body still, in a sleep mode.
  116741. * @returns the physics imposter
  116742. */
  116743. PhysicsImpostor.prototype.sleep = function () {
  116744. if (this._physicsEngine) {
  116745. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  116746. }
  116747. return this;
  116748. };
  116749. /**
  116750. * Wake the body up.
  116751. * @returns The physics imposter
  116752. */
  116753. PhysicsImpostor.prototype.wakeUp = function () {
  116754. if (this._physicsEngine) {
  116755. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  116756. }
  116757. return this;
  116758. };
  116759. /**
  116760. * Clones the physics imposter
  116761. * @param newObject The physics imposter clones to this physics-enabled object
  116762. * @returns A nullable physics imposter
  116763. */
  116764. PhysicsImpostor.prototype.clone = function (newObject) {
  116765. if (!newObject) {
  116766. return null;
  116767. }
  116768. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  116769. };
  116770. /**
  116771. * Disposes the physics imposter
  116772. */
  116773. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  116774. var _this = this;
  116775. //no dispose if no physics engine is available.
  116776. if (!this._physicsEngine) {
  116777. return;
  116778. }
  116779. this._joints.forEach(function (j) {
  116780. if (_this._physicsEngine) {
  116781. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  116782. }
  116783. });
  116784. //dispose the physics body
  116785. this._physicsEngine.removeImpostor(this);
  116786. if (this.parent) {
  116787. this.parent.forceUpdate();
  116788. }
  116789. else {
  116790. /*this._object.getChildMeshes().forEach(function(mesh) {
  116791. if (mesh.physicsImpostor) {
  116792. if (disposeChildren) {
  116793. mesh.physicsImpostor.dispose();
  116794. mesh.physicsImpostor = null;
  116795. }
  116796. }
  116797. })*/
  116798. }
  116799. this._isDisposed = true;
  116800. };
  116801. /**
  116802. * Sets the delta position
  116803. * @param position The delta position amount
  116804. */
  116805. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  116806. this._deltaPosition.copyFrom(position);
  116807. };
  116808. /**
  116809. * Sets the delta rotation
  116810. * @param rotation The delta rotation amount
  116811. */
  116812. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  116813. if (!this._deltaRotation) {
  116814. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  116815. }
  116816. this._deltaRotation.copyFrom(rotation);
  116817. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  116818. };
  116819. /**
  116820. * Gets the box size of the physics imposter and stores the result in the input parameter
  116821. * @param result Stores the box size
  116822. * @returns The physics imposter
  116823. */
  116824. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  116825. if (this._physicsEngine) {
  116826. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  116827. }
  116828. return this;
  116829. };
  116830. /**
  116831. * Gets the radius of the physics imposter
  116832. * @returns Radius of the physics imposter
  116833. */
  116834. PhysicsImpostor.prototype.getRadius = function () {
  116835. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  116836. };
  116837. /**
  116838. * Sync a bone with this impostor
  116839. * @param bone The bone to sync to the impostor.
  116840. * @param boneMesh The mesh that the bone is influencing.
  116841. * @param jointPivot The pivot of the joint / bone in local space.
  116842. * @param distToJoint Optional distance from the impostor to the joint.
  116843. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  116844. */
  116845. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  116846. var tempVec = PhysicsImpostor._tmpVecs[0];
  116847. var mesh = this.object;
  116848. if (mesh.rotationQuaternion) {
  116849. if (adjustRotation) {
  116850. var tempQuat = PhysicsImpostor._tmpQuat;
  116851. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  116852. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  116853. }
  116854. else {
  116855. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  116856. }
  116857. }
  116858. tempVec.x = 0;
  116859. tempVec.y = 0;
  116860. tempVec.z = 0;
  116861. if (jointPivot) {
  116862. tempVec.x = jointPivot.x;
  116863. tempVec.y = jointPivot.y;
  116864. tempVec.z = jointPivot.z;
  116865. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  116866. if (distToJoint === undefined || distToJoint === null) {
  116867. distToJoint = jointPivot.length();
  116868. }
  116869. tempVec.x *= distToJoint;
  116870. tempVec.y *= distToJoint;
  116871. tempVec.z *= distToJoint;
  116872. }
  116873. if (bone.getParent()) {
  116874. tempVec.addInPlace(mesh.getAbsolutePosition());
  116875. bone.setAbsolutePosition(tempVec, boneMesh);
  116876. }
  116877. else {
  116878. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  116879. boneMesh.position.x -= tempVec.x;
  116880. boneMesh.position.y -= tempVec.y;
  116881. boneMesh.position.z -= tempVec.z;
  116882. }
  116883. };
  116884. /**
  116885. * Sync impostor to a bone
  116886. * @param bone The bone that the impostor will be synced to.
  116887. * @param boneMesh The mesh that the bone is influencing.
  116888. * @param jointPivot The pivot of the joint / bone in local space.
  116889. * @param distToJoint Optional distance from the impostor to the joint.
  116890. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  116891. * @param boneAxis Optional vector3 axis the bone is aligned with
  116892. */
  116893. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  116894. var mesh = this.object;
  116895. if (mesh.rotationQuaternion) {
  116896. if (adjustRotation) {
  116897. var tempQuat = PhysicsImpostor._tmpQuat;
  116898. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  116899. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  116900. }
  116901. else {
  116902. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  116903. }
  116904. }
  116905. var pos = PhysicsImpostor._tmpVecs[0];
  116906. var boneDir = PhysicsImpostor._tmpVecs[1];
  116907. if (!boneAxis) {
  116908. boneAxis = PhysicsImpostor._tmpVecs[2];
  116909. boneAxis.x = 0;
  116910. boneAxis.y = 1;
  116911. boneAxis.z = 0;
  116912. }
  116913. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  116914. bone.getAbsolutePositionToRef(boneMesh, pos);
  116915. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  116916. distToJoint = jointPivot.length();
  116917. }
  116918. if (distToJoint !== undefined && distToJoint !== null) {
  116919. pos.x += boneDir.x * distToJoint;
  116920. pos.y += boneDir.y * distToJoint;
  116921. pos.z += boneDir.z * distToJoint;
  116922. }
  116923. mesh.setAbsolutePosition(pos);
  116924. };
  116925. /**
  116926. * The default object size of the imposter
  116927. */
  116928. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  116929. /**
  116930. * The identity quaternion of the imposter
  116931. */
  116932. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  116933. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  116934. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  116935. //Impostor types
  116936. /**
  116937. * No-Imposter type
  116938. */
  116939. PhysicsImpostor.NoImpostor = 0;
  116940. /**
  116941. * Sphere-Imposter type
  116942. */
  116943. PhysicsImpostor.SphereImpostor = 1;
  116944. /**
  116945. * Box-Imposter type
  116946. */
  116947. PhysicsImpostor.BoxImpostor = 2;
  116948. /**
  116949. * Plane-Imposter type
  116950. */
  116951. PhysicsImpostor.PlaneImpostor = 3;
  116952. /**
  116953. * Mesh-imposter type
  116954. */
  116955. PhysicsImpostor.MeshImpostor = 4;
  116956. /**
  116957. * Cylinder-Imposter type
  116958. */
  116959. PhysicsImpostor.CylinderImpostor = 7;
  116960. /**
  116961. * Particle-Imposter type
  116962. */
  116963. PhysicsImpostor.ParticleImpostor = 8;
  116964. /**
  116965. * Heightmap-Imposter type
  116966. */
  116967. PhysicsImpostor.HeightmapImpostor = 9;
  116968. /**
  116969. * ConvexHull-Impostor type (Ammo.js plugin only)
  116970. */
  116971. PhysicsImpostor.ConvexHullImpostor = 10;
  116972. /**
  116973. * Rope-Imposter type
  116974. */
  116975. PhysicsImpostor.RopeImpostor = 101;
  116976. /**
  116977. * Cloth-Imposter type
  116978. */
  116979. PhysicsImpostor.ClothImpostor = 102;
  116980. /**
  116981. * Softbody-Imposter type
  116982. */
  116983. PhysicsImpostor.SoftbodyImpostor = 103;
  116984. return PhysicsImpostor;
  116985. }());
  116986. /***/ }),
  116987. /***/ "./Physics/physicsJoint.ts":
  116988. /*!*********************************!*\
  116989. !*** ./Physics/physicsJoint.ts ***!
  116990. \*********************************/
  116991. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  116992. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116993. "use strict";
  116994. __webpack_require__.r(__webpack_exports__);
  116995. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  116996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  116997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  116998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  116999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  117000. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117001. /**
  117002. * This is a holder class for the physics joint created by the physics plugin
  117003. * It holds a set of functions to control the underlying joint
  117004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117005. */
  117006. var PhysicsJoint = /** @class */ (function () {
  117007. /**
  117008. * Initializes the physics joint
  117009. * @param type The type of the physics joint
  117010. * @param jointData The data for the physics joint
  117011. */
  117012. function PhysicsJoint(
  117013. /**
  117014. * The type of the physics joint
  117015. */
  117016. type,
  117017. /**
  117018. * The data for the physics joint
  117019. */
  117020. jointData) {
  117021. this.type = type;
  117022. this.jointData = jointData;
  117023. jointData.nativeParams = jointData.nativeParams || {};
  117024. }
  117025. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  117026. /**
  117027. * Gets the physics joint
  117028. */
  117029. get: function () {
  117030. return this._physicsJoint;
  117031. },
  117032. /**
  117033. * Sets the physics joint
  117034. */
  117035. set: function (newJoint) {
  117036. if (this._physicsJoint) {
  117037. //remove from the wolrd
  117038. }
  117039. this._physicsJoint = newJoint;
  117040. },
  117041. enumerable: true,
  117042. configurable: true
  117043. });
  117044. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  117045. /**
  117046. * Sets the physics plugin
  117047. */
  117048. set: function (physicsPlugin) {
  117049. this._physicsPlugin = physicsPlugin;
  117050. },
  117051. enumerable: true,
  117052. configurable: true
  117053. });
  117054. /**
  117055. * Execute a function that is physics-plugin specific.
  117056. * @param {Function} func the function that will be executed.
  117057. * It accepts two parameters: the physics world and the physics joint
  117058. */
  117059. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  117060. func(this._physicsPlugin.world, this._physicsJoint);
  117061. };
  117062. //TODO check if the native joints are the same
  117063. //Joint Types
  117064. /**
  117065. * Distance-Joint type
  117066. */
  117067. PhysicsJoint.DistanceJoint = 0;
  117068. /**
  117069. * Hinge-Joint type
  117070. */
  117071. PhysicsJoint.HingeJoint = 1;
  117072. /**
  117073. * Ball-and-Socket joint type
  117074. */
  117075. PhysicsJoint.BallAndSocketJoint = 2;
  117076. /**
  117077. * Wheel-Joint type
  117078. */
  117079. PhysicsJoint.WheelJoint = 3;
  117080. /**
  117081. * Slider-Joint type
  117082. */
  117083. PhysicsJoint.SliderJoint = 4;
  117084. //OIMO
  117085. /**
  117086. * Prismatic-Joint type
  117087. */
  117088. PhysicsJoint.PrismaticJoint = 5;
  117089. //
  117090. /**
  117091. * Universal-Joint type
  117092. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  117093. */
  117094. PhysicsJoint.UniversalJoint = 6;
  117095. /**
  117096. * Hinge-Joint 2 type
  117097. */
  117098. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  117099. //Cannon
  117100. /**
  117101. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  117102. */
  117103. PhysicsJoint.PointToPointJoint = 8;
  117104. //Cannon only at the moment
  117105. /**
  117106. * Spring-Joint type
  117107. */
  117108. PhysicsJoint.SpringJoint = 9;
  117109. /**
  117110. * Lock-Joint type
  117111. */
  117112. PhysicsJoint.LockJoint = 10;
  117113. return PhysicsJoint;
  117114. }());
  117115. /**
  117116. * A class representing a physics distance joint
  117117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117118. */
  117119. var DistanceJoint = /** @class */ (function (_super) {
  117120. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  117121. /**
  117122. *
  117123. * @param jointData The data for the Distance-Joint
  117124. */
  117125. function DistanceJoint(jointData) {
  117126. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  117127. }
  117128. /**
  117129. * Update the predefined distance.
  117130. * @param maxDistance The maximum preferred distance
  117131. * @param minDistance The minimum preferred distance
  117132. */
  117133. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  117134. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  117135. };
  117136. return DistanceJoint;
  117137. }(PhysicsJoint));
  117138. /**
  117139. * Represents a Motor-Enabled Joint
  117140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117141. */
  117142. var MotorEnabledJoint = /** @class */ (function (_super) {
  117143. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  117144. /**
  117145. * Initializes the Motor-Enabled Joint
  117146. * @param type The type of the joint
  117147. * @param jointData The physica joint data for the joint
  117148. */
  117149. function MotorEnabledJoint(type, jointData) {
  117150. return _super.call(this, type, jointData) || this;
  117151. }
  117152. /**
  117153. * Set the motor values.
  117154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117155. * @param force the force to apply
  117156. * @param maxForce max force for this motor.
  117157. */
  117158. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  117159. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  117160. };
  117161. /**
  117162. * Set the motor's limits.
  117163. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117164. * @param upperLimit The upper limit of the motor
  117165. * @param lowerLimit The lower limit of the motor
  117166. */
  117167. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  117168. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  117169. };
  117170. return MotorEnabledJoint;
  117171. }(PhysicsJoint));
  117172. /**
  117173. * This class represents a single physics Hinge-Joint
  117174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117175. */
  117176. var HingeJoint = /** @class */ (function (_super) {
  117177. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  117178. /**
  117179. * Initializes the Hinge-Joint
  117180. * @param jointData The joint data for the Hinge-Joint
  117181. */
  117182. function HingeJoint(jointData) {
  117183. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  117184. }
  117185. /**
  117186. * Set the motor values.
  117187. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117188. * @param {number} force the force to apply
  117189. * @param {number} maxForce max force for this motor.
  117190. */
  117191. HingeJoint.prototype.setMotor = function (force, maxForce) {
  117192. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  117193. };
  117194. /**
  117195. * Set the motor's limits.
  117196. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117197. * @param upperLimit The upper limit of the motor
  117198. * @param lowerLimit The lower limit of the motor
  117199. */
  117200. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  117201. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  117202. };
  117203. return HingeJoint;
  117204. }(MotorEnabledJoint));
  117205. /**
  117206. * This class represents a dual hinge physics joint (same as wheel joint)
  117207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117208. */
  117209. var Hinge2Joint = /** @class */ (function (_super) {
  117210. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  117211. /**
  117212. * Initializes the Hinge2-Joint
  117213. * @param jointData The joint data for the Hinge2-Joint
  117214. */
  117215. function Hinge2Joint(jointData) {
  117216. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  117217. }
  117218. /**
  117219. * Set the motor values.
  117220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117221. * @param {number} targetSpeed the speed the motor is to reach
  117222. * @param {number} maxForce max force for this motor.
  117223. * @param {motorIndex} the motor's index, 0 or 1.
  117224. */
  117225. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  117226. if (motorIndex === void 0) { motorIndex = 0; }
  117227. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  117228. };
  117229. /**
  117230. * Set the motor limits.
  117231. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117232. * @param {number} upperLimit the upper limit
  117233. * @param {number} lowerLimit lower limit
  117234. * @param {motorIndex} the motor's index, 0 or 1.
  117235. */
  117236. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  117237. if (motorIndex === void 0) { motorIndex = 0; }
  117238. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  117239. };
  117240. return Hinge2Joint;
  117241. }(MotorEnabledJoint));
  117242. /***/ }),
  117243. /***/ "./Physics/physicsRaycastResult.ts":
  117244. /*!*****************************************!*\
  117245. !*** ./Physics/physicsRaycastResult.ts ***!
  117246. \*****************************************/
  117247. /*! exports provided: PhysicsRaycastResult */
  117248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117249. "use strict";
  117250. __webpack_require__.r(__webpack_exports__);
  117251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRaycastResult", function() { return PhysicsRaycastResult; });
  117252. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117253. /**
  117254. * Holds the data for the raycast result
  117255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117256. */
  117257. var PhysicsRaycastResult = /** @class */ (function () {
  117258. function PhysicsRaycastResult() {
  117259. this._hasHit = false;
  117260. this._hitDistance = 0;
  117261. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117262. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117263. this._rayFromWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117264. this._rayToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117265. }
  117266. Object.defineProperty(PhysicsRaycastResult.prototype, "hasHit", {
  117267. /**
  117268. * Gets if there was a hit
  117269. */
  117270. get: function () {
  117271. return this._hasHit;
  117272. },
  117273. enumerable: true,
  117274. configurable: true
  117275. });
  117276. Object.defineProperty(PhysicsRaycastResult.prototype, "hitDistance", {
  117277. /**
  117278. * Gets the distance from the hit
  117279. */
  117280. get: function () {
  117281. return this._hitDistance;
  117282. },
  117283. enumerable: true,
  117284. configurable: true
  117285. });
  117286. Object.defineProperty(PhysicsRaycastResult.prototype, "hitNormalWorld", {
  117287. /**
  117288. * Gets the hit normal/direction in the world
  117289. */
  117290. get: function () {
  117291. return this._hitNormalWorld;
  117292. },
  117293. enumerable: true,
  117294. configurable: true
  117295. });
  117296. Object.defineProperty(PhysicsRaycastResult.prototype, "hitPointWorld", {
  117297. /**
  117298. * Gets the hit point in the world
  117299. */
  117300. get: function () {
  117301. return this._hitPointWorld;
  117302. },
  117303. enumerable: true,
  117304. configurable: true
  117305. });
  117306. Object.defineProperty(PhysicsRaycastResult.prototype, "rayFromWorld", {
  117307. /**
  117308. * Gets the ray "start point" of the ray in the world
  117309. */
  117310. get: function () {
  117311. return this._rayFromWorld;
  117312. },
  117313. enumerable: true,
  117314. configurable: true
  117315. });
  117316. Object.defineProperty(PhysicsRaycastResult.prototype, "rayToWorld", {
  117317. /**
  117318. * Gets the ray "end point" of the ray in the world
  117319. */
  117320. get: function () {
  117321. return this._rayToWorld;
  117322. },
  117323. enumerable: true,
  117324. configurable: true
  117325. });
  117326. /**
  117327. * Sets the hit data (normal & point in world space)
  117328. * @param hitNormalWorld defines the normal in world space
  117329. * @param hitPointWorld defines the point in world space
  117330. */
  117331. PhysicsRaycastResult.prototype.setHitData = function (hitNormalWorld, hitPointWorld) {
  117332. this._hasHit = true;
  117333. this._hitNormalWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z);
  117334. this._hitPointWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitPointWorld.x, hitPointWorld.y, hitPointWorld.z);
  117335. };
  117336. /**
  117337. * Sets the distance from the start point to the hit point
  117338. * @param distance
  117339. */
  117340. PhysicsRaycastResult.prototype.setHitDistance = function (distance) {
  117341. this._hitDistance = distance;
  117342. };
  117343. /**
  117344. * Calculates the distance manually
  117345. */
  117346. PhysicsRaycastResult.prototype.calculateHitDistance = function () {
  117347. this._hitDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._rayFromWorld, this._hitPointWorld);
  117348. };
  117349. /**
  117350. * Resets all the values to default
  117351. * @param from The from point on world space
  117352. * @param to The to point on world space
  117353. */
  117354. PhysicsRaycastResult.prototype.reset = function (from, to) {
  117355. if (from === void 0) { from = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  117356. if (to === void 0) { to = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  117357. this._rayFromWorld = from;
  117358. this._rayToWorld = to;
  117359. this._hasHit = false;
  117360. this._hitDistance = 0;
  117361. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117362. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117363. };
  117364. return PhysicsRaycastResult;
  117365. }());
  117366. /***/ }),
  117367. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  117368. /*!****************************************************************************!*\
  117369. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  117370. \****************************************************************************/
  117371. /*! exports provided: DefaultRenderingPipeline */
  117372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117373. "use strict";
  117374. __webpack_require__.r(__webpack_exports__);
  117375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  117376. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117377. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  117378. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  117379. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117380. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  117381. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  117382. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  117383. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  117384. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  117385. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  117386. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  117387. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  117388. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117389. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  117390. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  117391. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  117392. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  117393. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  117394. /**
  117395. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  117396. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117397. */
  117398. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  117399. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  117400. /**
  117401. * @constructor
  117402. * @param name - The rendering pipeline name (default: "")
  117403. * @param hdr - If high dynamic range textures should be used (default: true)
  117404. * @param scene - The scene linked to this pipeline (default: the last created scene)
  117405. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  117406. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  117407. */
  117408. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  117409. if (name === void 0) { name = ""; }
  117410. if (hdr === void 0) { hdr = true; }
  117411. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  117412. if (automaticBuild === void 0) { automaticBuild = true; }
  117413. var _this = _super.call(this, scene.getEngine(), name) || this;
  117414. _this._camerasToBeAttached = [];
  117415. /**
  117416. * ID of the sharpen post process,
  117417. */
  117418. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  117419. /**
  117420. * @ignore
  117421. * ID of the image processing post process;
  117422. */
  117423. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  117424. /**
  117425. * @ignore
  117426. * ID of the Fast Approximate Anti-Aliasing post process;
  117427. */
  117428. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  117429. /**
  117430. * ID of the chromatic aberration post process,
  117431. */
  117432. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  117433. /**
  117434. * ID of the grain post process
  117435. */
  117436. _this.GrainPostProcessId = "GrainPostProcessEffect";
  117437. /**
  117438. * Glow post process which adds a glow to emissive areas of the image
  117439. */
  117440. _this._glowLayer = null;
  117441. /**
  117442. * Animations which can be used to tweak settings over a period of time
  117443. */
  117444. _this.animations = [];
  117445. _this._imageProcessingConfigurationObserver = null;
  117446. // Values
  117447. _this._sharpenEnabled = false;
  117448. _this._bloomEnabled = false;
  117449. _this._depthOfFieldEnabled = false;
  117450. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  117451. _this._fxaaEnabled = false;
  117452. _this._imageProcessingEnabled = true;
  117453. _this._bloomScale = 0.5;
  117454. _this._chromaticAberrationEnabled = false;
  117455. _this._grainEnabled = false;
  117456. _this._buildAllowed = true;
  117457. _this._resizeObserver = null;
  117458. _this._hardwareScaleLevel = 1.0;
  117459. _this._bloomKernel = 64;
  117460. /**
  117461. * Specifies the weight of the bloom in the final rendering
  117462. */
  117463. _this._bloomWeight = 0.15;
  117464. /**
  117465. * Specifies the luma threshold for the area that will be blurred by the bloom
  117466. */
  117467. _this._bloomThreshold = 0.9;
  117468. _this._samples = 1;
  117469. _this._hasCleared = false;
  117470. _this._prevPostProcess = null;
  117471. _this._prevPrevPostProcess = null;
  117472. _this._depthOfFieldSceneObserver = null;
  117473. _this._cameras = cameras || scene.cameras;
  117474. _this._cameras = _this._cameras.slice();
  117475. _this._camerasToBeAttached = _this._cameras.slice();
  117476. _this._buildAllowed = automaticBuild;
  117477. // Initialize
  117478. _this._scene = scene;
  117479. var caps = _this._scene.getEngine().getCaps();
  117480. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  117481. // Misc
  117482. if (_this._hdr) {
  117483. if (caps.textureHalfFloatRender) {
  117484. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  117485. }
  117486. else if (caps.textureFloatRender) {
  117487. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  117488. }
  117489. }
  117490. else {
  117491. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  117492. }
  117493. // Attach
  117494. scene.postProcessRenderPipelineManager.addPipeline(_this);
  117495. var engine = _this._scene.getEngine();
  117496. // Create post processes before hand so they can be modified before enabled.
  117497. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  117498. _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);
  117499. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  117500. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  117501. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  117502. _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);
  117503. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  117504. _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);
  117505. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  117506. _this._resizeObserver = engine.onResizeObservable.add(function () {
  117507. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  117508. _this.bloomKernel = _this.bloomKernel;
  117509. });
  117510. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  117511. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  117512. });
  117513. _this._buildPipeline();
  117514. return _this;
  117515. }
  117516. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  117517. /**
  117518. * Gets active scene
  117519. */
  117520. get: function () {
  117521. return this._scene;
  117522. },
  117523. enumerable: true,
  117524. configurable: true
  117525. });
  117526. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  117527. get: function () {
  117528. return this._sharpenEnabled;
  117529. },
  117530. /**
  117531. * Enable or disable the sharpen process from the pipeline
  117532. */
  117533. set: function (enabled) {
  117534. if (this._sharpenEnabled === enabled) {
  117535. return;
  117536. }
  117537. this._sharpenEnabled = enabled;
  117538. this._buildPipeline();
  117539. },
  117540. enumerable: true,
  117541. configurable: true
  117542. });
  117543. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  117544. /**
  117545. * Specifies the size of the bloom blur kernel, relative to the final output size
  117546. */
  117547. get: function () {
  117548. return this._bloomKernel;
  117549. },
  117550. set: function (value) {
  117551. this._bloomKernel = value;
  117552. this.bloom.kernel = value / this._hardwareScaleLevel;
  117553. },
  117554. enumerable: true,
  117555. configurable: true
  117556. });
  117557. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  117558. get: function () {
  117559. return this._bloomWeight;
  117560. },
  117561. /**
  117562. * The strength of the bloom.
  117563. */
  117564. set: function (value) {
  117565. if (this._bloomWeight === value) {
  117566. return;
  117567. }
  117568. this.bloom.weight = value;
  117569. this._bloomWeight = value;
  117570. },
  117571. enumerable: true,
  117572. configurable: true
  117573. });
  117574. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  117575. get: function () {
  117576. return this._bloomThreshold;
  117577. },
  117578. /**
  117579. * The strength of the bloom.
  117580. */
  117581. set: function (value) {
  117582. if (this._bloomThreshold === value) {
  117583. return;
  117584. }
  117585. this.bloom.threshold = value;
  117586. this._bloomThreshold = value;
  117587. },
  117588. enumerable: true,
  117589. configurable: true
  117590. });
  117591. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  117592. get: function () {
  117593. return this._bloomScale;
  117594. },
  117595. /**
  117596. * The scale of the bloom, lower value will provide better performance.
  117597. */
  117598. set: function (value) {
  117599. if (this._bloomScale === value) {
  117600. return;
  117601. }
  117602. this._bloomScale = value;
  117603. // recreate bloom and dispose old as this setting is not dynamic
  117604. this._rebuildBloom();
  117605. this._buildPipeline();
  117606. },
  117607. enumerable: true,
  117608. configurable: true
  117609. });
  117610. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  117611. get: function () {
  117612. return this._bloomEnabled;
  117613. },
  117614. /**
  117615. * Enable or disable the bloom from the pipeline
  117616. */
  117617. set: function (enabled) {
  117618. if (this._bloomEnabled === enabled) {
  117619. return;
  117620. }
  117621. this._bloomEnabled = enabled;
  117622. this._buildPipeline();
  117623. },
  117624. enumerable: true,
  117625. configurable: true
  117626. });
  117627. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  117628. // recreate bloom and dispose old as this setting is not dynamic
  117629. var oldBloom = this.bloom;
  117630. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  117631. this.bloom.threshold = oldBloom.threshold;
  117632. for (var i = 0; i < this._cameras.length; i++) {
  117633. oldBloom.disposeEffects(this._cameras[i]);
  117634. }
  117635. };
  117636. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  117637. /**
  117638. * If the depth of field is enabled.
  117639. */
  117640. get: function () {
  117641. return this._depthOfFieldEnabled;
  117642. },
  117643. set: function (enabled) {
  117644. if (this._depthOfFieldEnabled === enabled) {
  117645. return;
  117646. }
  117647. this._depthOfFieldEnabled = enabled;
  117648. this._buildPipeline();
  117649. },
  117650. enumerable: true,
  117651. configurable: true
  117652. });
  117653. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  117654. /**
  117655. * Blur level of the depth of field effect. (Higher blur will effect performance)
  117656. */
  117657. get: function () {
  117658. return this._depthOfFieldBlurLevel;
  117659. },
  117660. set: function (value) {
  117661. if (this._depthOfFieldBlurLevel === value) {
  117662. return;
  117663. }
  117664. this._depthOfFieldBlurLevel = value;
  117665. // recreate dof and dispose old as this setting is not dynamic
  117666. var oldDof = this.depthOfField;
  117667. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  117668. this.depthOfField.focalLength = oldDof.focalLength;
  117669. this.depthOfField.focusDistance = oldDof.focusDistance;
  117670. this.depthOfField.fStop = oldDof.fStop;
  117671. this.depthOfField.lensSize = oldDof.lensSize;
  117672. for (var i = 0; i < this._cameras.length; i++) {
  117673. oldDof.disposeEffects(this._cameras[i]);
  117674. }
  117675. this._buildPipeline();
  117676. },
  117677. enumerable: true,
  117678. configurable: true
  117679. });
  117680. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  117681. get: function () {
  117682. return this._fxaaEnabled;
  117683. },
  117684. /**
  117685. * If the anti aliasing is enabled.
  117686. */
  117687. set: function (enabled) {
  117688. if (this._fxaaEnabled === enabled) {
  117689. return;
  117690. }
  117691. this._fxaaEnabled = enabled;
  117692. this._buildPipeline();
  117693. },
  117694. enumerable: true,
  117695. configurable: true
  117696. });
  117697. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  117698. get: function () {
  117699. return this._samples;
  117700. },
  117701. /**
  117702. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  117703. */
  117704. set: function (sampleCount) {
  117705. if (this._samples === sampleCount) {
  117706. return;
  117707. }
  117708. this._samples = sampleCount;
  117709. this._buildPipeline();
  117710. },
  117711. enumerable: true,
  117712. configurable: true
  117713. });
  117714. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  117715. get: function () {
  117716. return this._imageProcessingEnabled;
  117717. },
  117718. /**
  117719. * If image processing is enabled.
  117720. */
  117721. set: function (enabled) {
  117722. if (this._imageProcessingEnabled === enabled) {
  117723. return;
  117724. }
  117725. this._imageProcessingEnabled = enabled;
  117726. this._buildPipeline();
  117727. },
  117728. enumerable: true,
  117729. configurable: true
  117730. });
  117731. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  117732. get: function () {
  117733. return this._glowLayer != null;
  117734. },
  117735. /**
  117736. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  117737. */
  117738. set: function (enabled) {
  117739. if (enabled && !this._glowLayer) {
  117740. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  117741. }
  117742. else if (!enabled && this._glowLayer) {
  117743. this._glowLayer.dispose();
  117744. this._glowLayer = null;
  117745. }
  117746. },
  117747. enumerable: true,
  117748. configurable: true
  117749. });
  117750. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  117751. get: function () {
  117752. return this._chromaticAberrationEnabled;
  117753. },
  117754. /**
  117755. * Enable or disable the chromaticAberration process from the pipeline
  117756. */
  117757. set: function (enabled) {
  117758. if (this._chromaticAberrationEnabled === enabled) {
  117759. return;
  117760. }
  117761. this._chromaticAberrationEnabled = enabled;
  117762. this._buildPipeline();
  117763. },
  117764. enumerable: true,
  117765. configurable: true
  117766. });
  117767. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  117768. get: function () {
  117769. return this._grainEnabled;
  117770. },
  117771. /**
  117772. * Enable or disable the grain process from the pipeline
  117773. */
  117774. set: function (enabled) {
  117775. if (this._grainEnabled === enabled) {
  117776. return;
  117777. }
  117778. this._grainEnabled = enabled;
  117779. this._buildPipeline();
  117780. },
  117781. enumerable: true,
  117782. configurable: true
  117783. });
  117784. /**
  117785. * Get the class name
  117786. * @returns "DefaultRenderingPipeline"
  117787. */
  117788. DefaultRenderingPipeline.prototype.getClassName = function () {
  117789. return "DefaultRenderingPipeline";
  117790. };
  117791. /**
  117792. * Force the compilation of the entire pipeline.
  117793. */
  117794. DefaultRenderingPipeline.prototype.prepare = function () {
  117795. var previousState = this._buildAllowed;
  117796. this._buildAllowed = true;
  117797. this._buildPipeline();
  117798. this._buildAllowed = previousState;
  117799. };
  117800. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  117801. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  117802. if (this._hasCleared) {
  117803. postProcess.autoClear = false;
  117804. }
  117805. else {
  117806. postProcess.autoClear = true;
  117807. this._scene.autoClear = false;
  117808. this._hasCleared = true;
  117809. }
  117810. if (!skipTextureSharing) {
  117811. if (this._prevPrevPostProcess) {
  117812. postProcess.shareOutputWith(this._prevPrevPostProcess);
  117813. }
  117814. else {
  117815. postProcess.useOwnOutput();
  117816. }
  117817. if (this._prevPostProcess) {
  117818. this._prevPrevPostProcess = this._prevPostProcess;
  117819. }
  117820. this._prevPostProcess = postProcess;
  117821. }
  117822. };
  117823. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  117824. var _this = this;
  117825. if (!this._buildAllowed) {
  117826. return;
  117827. }
  117828. this._scene.autoClear = true;
  117829. var engine = this._scene.getEngine();
  117830. this._disposePostProcesses();
  117831. if (this._cameras !== null) {
  117832. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  117833. // get back cameras to be used to reattach pipeline
  117834. this._cameras = this._camerasToBeAttached.slice();
  117835. }
  117836. this._reset();
  117837. this._prevPostProcess = null;
  117838. this._prevPrevPostProcess = null;
  117839. this._hasCleared = false;
  117840. if (this.depthOfFieldEnabled) {
  117841. // Multi camera suport
  117842. if (this._cameras.length > 1) {
  117843. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  117844. var camera = _a[_i];
  117845. var depthRenderer = this._scene.enableDepthRenderer(camera);
  117846. depthRenderer.useOnlyInActiveCamera = true;
  117847. }
  117848. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  117849. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  117850. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  117851. }
  117852. });
  117853. }
  117854. else {
  117855. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  117856. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  117857. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  117858. }
  117859. if (!this.depthOfField._isReady()) {
  117860. this.depthOfField._updateEffects();
  117861. }
  117862. this.addEffect(this.depthOfField);
  117863. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  117864. }
  117865. else {
  117866. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  117867. }
  117868. if (this.bloomEnabled) {
  117869. if (!this.bloom._isReady()) {
  117870. this.bloom._updateEffects();
  117871. }
  117872. this.addEffect(this.bloom);
  117873. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  117874. }
  117875. if (this._imageProcessingEnabled) {
  117876. 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);
  117877. if (this._hdr) {
  117878. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  117879. this._setAutoClearAndTextureSharing(this.imageProcessing);
  117880. }
  117881. else {
  117882. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  117883. }
  117884. }
  117885. if (this.sharpenEnabled) {
  117886. if (!this.sharpen.isReady()) {
  117887. this.sharpen.updateEffect();
  117888. }
  117889. this.addEffect(this._sharpenEffect);
  117890. this._setAutoClearAndTextureSharing(this.sharpen);
  117891. }
  117892. if (this.grainEnabled) {
  117893. if (!this.grain.isReady()) {
  117894. this.grain.updateEffect();
  117895. }
  117896. this.addEffect(this._grainEffect);
  117897. this._setAutoClearAndTextureSharing(this.grain);
  117898. }
  117899. if (this.chromaticAberrationEnabled) {
  117900. if (!this.chromaticAberration.isReady()) {
  117901. this.chromaticAberration.updateEffect();
  117902. }
  117903. this.addEffect(this._chromaticAberrationEffect);
  117904. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  117905. }
  117906. if (this.fxaaEnabled) {
  117907. 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);
  117908. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  117909. this._setAutoClearAndTextureSharing(this.fxaa, true);
  117910. }
  117911. if (this._cameras !== null) {
  117912. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  117913. }
  117914. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  117915. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  117916. }
  117917. };
  117918. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  117919. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  117920. for (var i = 0; i < this._cameras.length; i++) {
  117921. var camera = this._cameras[i];
  117922. if (this.imageProcessing) {
  117923. this.imageProcessing.dispose(camera);
  117924. }
  117925. if (this.fxaa) {
  117926. this.fxaa.dispose(camera);
  117927. }
  117928. // These are created in the constructor and should not be disposed on every pipeline change
  117929. if (disposeNonRecreated) {
  117930. if (this.sharpen) {
  117931. this.sharpen.dispose(camera);
  117932. }
  117933. if (this.depthOfField) {
  117934. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  117935. this.depthOfField.disposeEffects(camera);
  117936. }
  117937. if (this.bloom) {
  117938. this.bloom.disposeEffects(camera);
  117939. }
  117940. if (this.chromaticAberration) {
  117941. this.chromaticAberration.dispose(camera);
  117942. }
  117943. if (this.grain) {
  117944. this.grain.dispose(camera);
  117945. }
  117946. if (this._glowLayer) {
  117947. this._glowLayer.dispose();
  117948. }
  117949. }
  117950. }
  117951. this.imageProcessing = null;
  117952. this.fxaa = null;
  117953. if (disposeNonRecreated) {
  117954. this.sharpen = null;
  117955. this._sharpenEffect = null;
  117956. this.depthOfField = null;
  117957. this.bloom = null;
  117958. this.chromaticAberration = null;
  117959. this._chromaticAberrationEffect = null;
  117960. this.grain = null;
  117961. this._grainEffect = null;
  117962. this._glowLayer = null;
  117963. }
  117964. };
  117965. /**
  117966. * Adds a camera to the pipeline
  117967. * @param camera the camera to be added
  117968. */
  117969. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  117970. this._camerasToBeAttached.push(camera);
  117971. this._buildPipeline();
  117972. };
  117973. /**
  117974. * Removes a camera from the pipeline
  117975. * @param camera the camera to remove
  117976. */
  117977. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  117978. var index = this._camerasToBeAttached.indexOf(camera);
  117979. this._camerasToBeAttached.splice(index, 1);
  117980. this._buildPipeline();
  117981. };
  117982. /**
  117983. * Dispose of the pipeline and stop all post processes
  117984. */
  117985. DefaultRenderingPipeline.prototype.dispose = function () {
  117986. this._disposePostProcesses(true);
  117987. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  117988. this._scene.autoClear = true;
  117989. if (this._resizeObserver) {
  117990. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  117991. this._resizeObserver = null;
  117992. }
  117993. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  117994. _super.prototype.dispose.call(this);
  117995. };
  117996. /**
  117997. * Serialize the rendering pipeline (Used when exporting)
  117998. * @returns the serialized object
  117999. */
  118000. DefaultRenderingPipeline.prototype.serialize = function () {
  118001. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  118002. serializationObject.customType = "DefaultRenderingPipeline";
  118003. return serializationObject;
  118004. };
  118005. /**
  118006. * Parse the serialized pipeline
  118007. * @param source Source pipeline.
  118008. * @param scene The scene to load the pipeline to.
  118009. * @param rootUrl The URL of the serialized pipeline.
  118010. * @returns An instantiated pipeline from the serialized object.
  118011. */
  118012. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  118013. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  118014. };
  118015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118017. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  118018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118020. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  118021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118023. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  118024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118026. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  118027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118029. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  118030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118032. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  118033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118035. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  118036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118038. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  118039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118041. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  118042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118044. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  118045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118047. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  118048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118050. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  118051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118053. ], DefaultRenderingPipeline.prototype, "samples", null);
  118054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118056. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  118057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118059. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  118060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118062. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  118063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118065. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  118066. return DefaultRenderingPipeline;
  118067. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  118068. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  118069. /***/ }),
  118070. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  118071. /*!*********************************************************!*\
  118072. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  118073. \*********************************************************/
  118074. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  118075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118076. "use strict";
  118077. __webpack_require__.r(__webpack_exports__);
  118078. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  118079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  118080. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  118081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  118082. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  118083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  118084. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  118085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  118086. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  118087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  118088. /***/ }),
  118089. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  118090. /*!*************************************************************************!*\
  118091. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  118092. \*************************************************************************/
  118093. /*! exports provided: LensRenderingPipeline */
  118094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118095. "use strict";
  118096. __webpack_require__.r(__webpack_exports__);
  118097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  118098. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118099. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118100. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  118101. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  118102. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  118103. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118104. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  118105. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  118106. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  118107. /**
  118108. * BABYLON.JS Chromatic Aberration GLSL Shader
  118109. * Author: Olivier Guyot
  118110. * Separates very slightly R, G and B colors on the edges of the screen
  118111. * Inspired by Francois Tarlier & Martins Upitis
  118112. */
  118113. var LensRenderingPipeline = /** @class */ (function (_super) {
  118114. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  118115. /**
  118116. * @constructor
  118117. *
  118118. * Effect parameters are as follow:
  118119. * {
  118120. * chromatic_aberration: number; // from 0 to x (1 for realism)
  118121. * edge_blur: number; // from 0 to x (1 for realism)
  118122. * distortion: number; // from 0 to x (1 for realism)
  118123. * grain_amount: number; // from 0 to 1
  118124. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  118125. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  118126. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  118127. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  118128. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  118129. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  118130. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  118131. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  118132. * }
  118133. * Note: if an effect parameter is unset, effect is disabled
  118134. *
  118135. * @param name The rendering pipeline name
  118136. * @param parameters - An object containing all parameters (see above)
  118137. * @param scene The scene linked to this pipeline
  118138. * @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)
  118139. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118140. */
  118141. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  118142. if (ratio === void 0) { ratio = 1.0; }
  118143. var _this = _super.call(this, scene.getEngine(), name) || this;
  118144. // Lens effects can be of the following:
  118145. // - chromatic aberration (slight shift of RGB colors)
  118146. // - blur on the edge of the lens
  118147. // - lens distortion
  118148. // - depth-of-field blur & highlights enhancing
  118149. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  118150. // - grain effect (noise or custom texture)
  118151. // Two additional texture samplers are needed:
  118152. // - depth map (for depth-of-field)
  118153. // - grain texture
  118154. /**
  118155. * @ignore
  118156. * The chromatic aberration PostProcess id in the pipeline
  118157. */
  118158. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  118159. /**
  118160. * @ignore
  118161. * The highlights enhancing PostProcess id in the pipeline
  118162. */
  118163. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  118164. /**
  118165. * @ignore
  118166. * The depth-of-field PostProcess id in the pipeline
  118167. */
  118168. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  118169. _this._pentagonBokehIsEnabled = false;
  118170. _this._scene = scene;
  118171. // Fetch texture samplers
  118172. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  118173. if (parameters.grain_texture) {
  118174. _this._grainTexture = parameters.grain_texture;
  118175. }
  118176. else {
  118177. _this._createGrainTexture();
  118178. }
  118179. // save parameters
  118180. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  118181. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  118182. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  118183. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  118184. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  118185. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  118186. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  118187. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  118188. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  118189. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  118190. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  118191. // Create effects
  118192. _this._createChromaticAberrationPostProcess(ratio);
  118193. _this._createHighlightsPostProcess(ratio);
  118194. _this._createDepthOfFieldPostProcess(ratio / 4);
  118195. // Set up pipeline
  118196. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  118197. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  118198. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  118199. if (_this._highlightsGain === -1) {
  118200. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  118201. }
  118202. // Finish
  118203. scene.postProcessRenderPipelineManager.addPipeline(_this);
  118204. if (cameras) {
  118205. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  118206. }
  118207. return _this;
  118208. }
  118209. /**
  118210. * Get the class name
  118211. * @returns "LensRenderingPipeline"
  118212. */
  118213. LensRenderingPipeline.prototype.getClassName = function () {
  118214. return "LensRenderingPipeline";
  118215. };
  118216. Object.defineProperty(LensRenderingPipeline.prototype, "scene", {
  118217. // Properties
  118218. /**
  118219. * Gets associated scene
  118220. */
  118221. get: function () {
  118222. return this._scene;
  118223. },
  118224. enumerable: true,
  118225. configurable: true
  118226. });
  118227. Object.defineProperty(LensRenderingPipeline.prototype, "edgeBlur", {
  118228. /**
  118229. * Gets or sets the edge blur
  118230. */
  118231. get: function () {
  118232. return this._edgeBlur;
  118233. },
  118234. set: function (value) {
  118235. this.setEdgeBlur(value);
  118236. },
  118237. enumerable: true,
  118238. configurable: true
  118239. });
  118240. Object.defineProperty(LensRenderingPipeline.prototype, "grainAmount", {
  118241. /**
  118242. * Gets or sets the grain amount
  118243. */
  118244. get: function () {
  118245. return this._grainAmount;
  118246. },
  118247. set: function (value) {
  118248. this.setGrainAmount(value);
  118249. },
  118250. enumerable: true,
  118251. configurable: true
  118252. });
  118253. Object.defineProperty(LensRenderingPipeline.prototype, "chromaticAberration", {
  118254. /**
  118255. * Gets or sets the chromatic aberration amount
  118256. */
  118257. get: function () {
  118258. return this._chromaticAberration;
  118259. },
  118260. set: function (value) {
  118261. this.setChromaticAberration(value);
  118262. },
  118263. enumerable: true,
  118264. configurable: true
  118265. });
  118266. Object.defineProperty(LensRenderingPipeline.prototype, "dofAperture", {
  118267. /**
  118268. * Gets or sets the depth of field aperture
  118269. */
  118270. get: function () {
  118271. return this._dofAperture;
  118272. },
  118273. set: function (value) {
  118274. this.setAperture(value);
  118275. },
  118276. enumerable: true,
  118277. configurable: true
  118278. });
  118279. Object.defineProperty(LensRenderingPipeline.prototype, "edgeDistortion", {
  118280. /**
  118281. * Gets or sets the edge distortion
  118282. */
  118283. get: function () {
  118284. return this._distortion;
  118285. },
  118286. set: function (value) {
  118287. this.setEdgeDistortion(value);
  118288. },
  118289. enumerable: true,
  118290. configurable: true
  118291. });
  118292. Object.defineProperty(LensRenderingPipeline.prototype, "dofDistortion", {
  118293. /**
  118294. * Gets or sets the depth of field distortion
  118295. */
  118296. get: function () {
  118297. return this._dofDistance;
  118298. },
  118299. set: function (value) {
  118300. this.setFocusDistance(value);
  118301. },
  118302. enumerable: true,
  118303. configurable: true
  118304. });
  118305. Object.defineProperty(LensRenderingPipeline.prototype, "darkenOutOfFocus", {
  118306. /**
  118307. * Gets or sets the darken out of focus amount
  118308. */
  118309. get: function () {
  118310. return this._dofDarken;
  118311. },
  118312. set: function (value) {
  118313. this.setDarkenOutOfFocus(value);
  118314. },
  118315. enumerable: true,
  118316. configurable: true
  118317. });
  118318. Object.defineProperty(LensRenderingPipeline.prototype, "blurNoise", {
  118319. /**
  118320. * Gets or sets a boolean indicating if blur noise is enabled
  118321. */
  118322. get: function () {
  118323. return this._blurNoise;
  118324. },
  118325. set: function (value) {
  118326. this._blurNoise = value;
  118327. },
  118328. enumerable: true,
  118329. configurable: true
  118330. });
  118331. Object.defineProperty(LensRenderingPipeline.prototype, "pentagonBokeh", {
  118332. /**
  118333. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  118334. */
  118335. get: function () {
  118336. return this._pentagonBokehIsEnabled;
  118337. },
  118338. set: function (value) {
  118339. if (value) {
  118340. this.enablePentagonBokeh();
  118341. }
  118342. else {
  118343. this.disablePentagonBokeh();
  118344. }
  118345. },
  118346. enumerable: true,
  118347. configurable: true
  118348. });
  118349. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsGain", {
  118350. /**
  118351. * Gets or sets the highlight grain amount
  118352. */
  118353. get: function () {
  118354. return this._highlightsGain;
  118355. },
  118356. set: function (value) {
  118357. this.setHighlightsGain(value);
  118358. },
  118359. enumerable: true,
  118360. configurable: true
  118361. });
  118362. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsThreshold", {
  118363. /**
  118364. * Gets or sets the highlight threshold
  118365. */
  118366. get: function () {
  118367. return this._highlightsThreshold;
  118368. },
  118369. set: function (value) {
  118370. this.setHighlightsThreshold(value);
  118371. },
  118372. enumerable: true,
  118373. configurable: true
  118374. });
  118375. // public methods (self explanatory)
  118376. /**
  118377. * Sets the amount of blur at the edges
  118378. * @param amount blur amount
  118379. */
  118380. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  118381. /**
  118382. * Sets edge blur to 0
  118383. */
  118384. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  118385. /**
  118386. * Sets the amout of grain
  118387. * @param amount Amount of grain
  118388. */
  118389. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  118390. /**
  118391. * Set grain amount to 0
  118392. */
  118393. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  118394. /**
  118395. * Sets the chromatic aberration amount
  118396. * @param amount amount of chromatic aberration
  118397. */
  118398. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  118399. /**
  118400. * Sets chromatic aberration amount to 0
  118401. */
  118402. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  118403. /**
  118404. * Sets the EdgeDistortion amount
  118405. * @param amount amount of EdgeDistortion
  118406. */
  118407. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  118408. /**
  118409. * Sets edge distortion to 0
  118410. */
  118411. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  118412. /**
  118413. * Sets the FocusDistance amount
  118414. * @param amount amount of FocusDistance
  118415. */
  118416. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  118417. /**
  118418. * Disables depth of field
  118419. */
  118420. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  118421. /**
  118422. * Sets the Aperture amount
  118423. * @param amount amount of Aperture
  118424. */
  118425. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  118426. /**
  118427. * Sets the DarkenOutOfFocus amount
  118428. * @param amount amount of DarkenOutOfFocus
  118429. */
  118430. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  118431. /**
  118432. * Creates a pentagon bokeh effect
  118433. */
  118434. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  118435. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  118436. this._pentagonBokehIsEnabled = true;
  118437. };
  118438. /**
  118439. * Disables the pentagon bokeh effect
  118440. */
  118441. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  118442. this._pentagonBokehIsEnabled = false;
  118443. this._highlightsPostProcess.updateEffect();
  118444. };
  118445. /**
  118446. * Enables noise blur
  118447. */
  118448. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  118449. /**
  118450. * Disables noise blur
  118451. */
  118452. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  118453. /**
  118454. * Sets the HighlightsGain amount
  118455. * @param amount amount of HighlightsGain
  118456. */
  118457. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  118458. this._highlightsGain = amount;
  118459. };
  118460. /**
  118461. * Sets the HighlightsThreshold amount
  118462. * @param amount amount of HighlightsThreshold
  118463. */
  118464. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  118465. if (this._highlightsGain === -1) {
  118466. this._highlightsGain = 1.0;
  118467. }
  118468. this._highlightsThreshold = amount;
  118469. };
  118470. /**
  118471. * Disables highlights
  118472. */
  118473. LensRenderingPipeline.prototype.disableHighlights = function () {
  118474. this._highlightsGain = -1;
  118475. };
  118476. /**
  118477. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  118478. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  118479. */
  118480. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  118481. if (disableDepthRender === void 0) { disableDepthRender = false; }
  118482. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  118483. this._chromaticAberrationPostProcess = null;
  118484. this._highlightsPostProcess = null;
  118485. this._depthOfFieldPostProcess = null;
  118486. this._grainTexture.dispose();
  118487. if (disableDepthRender) {
  118488. this._scene.disableDepthRenderer();
  118489. }
  118490. };
  118491. // colors shifting and distortion
  118492. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  118493. var _this = this;
  118494. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  118495. [], // samplers
  118496. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  118497. this._chromaticAberrationPostProcess.onApply = function (effect) {
  118498. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  118499. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  118500. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  118501. effect.setFloat('radialIntensity', 1);
  118502. effect.setFloat2('direction', 17, 17);
  118503. effect.setFloat2('centerPosition', 0.5, 0.5);
  118504. };
  118505. };
  118506. // highlights enhancing
  118507. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  118508. var _this = this;
  118509. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  118510. [], // samplers
  118511. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  118512. this._highlightsPostProcess.onApply = function (effect) {
  118513. effect.setFloat('gain', _this._highlightsGain);
  118514. effect.setFloat('threshold', _this._highlightsThreshold);
  118515. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  118516. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  118517. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  118518. };
  118519. };
  118520. // colors shifting and distortion
  118521. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  118522. var _this = this;
  118523. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  118524. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  118525. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  118526. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  118527. this._depthOfFieldPostProcess.onApply = function (effect) {
  118528. effect.setTexture("depthSampler", _this._depthTexture);
  118529. effect.setTexture("grainSampler", _this._grainTexture);
  118530. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  118531. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  118532. effect.setFloat('grain_amount', _this._grainAmount);
  118533. effect.setBool('blur_noise', _this._blurNoise);
  118534. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  118535. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  118536. effect.setFloat('distortion', _this._distortion);
  118537. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  118538. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  118539. effect.setFloat('aperture', _this._dofAperture);
  118540. effect.setFloat('darken', _this._dofDarken);
  118541. effect.setFloat('edge_blur', _this._edgeBlur);
  118542. effect.setBool('highlights', (_this._highlightsGain !== -1));
  118543. if (_this._scene.activeCamera) {
  118544. effect.setFloat('near', _this._scene.activeCamera.minZ);
  118545. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  118546. }
  118547. };
  118548. };
  118549. // creates a black and white random noise texture, 512x512
  118550. LensRenderingPipeline.prototype._createGrainTexture = function () {
  118551. var size = 512;
  118552. 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);
  118553. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  118554. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  118555. var context = this._grainTexture.getContext();
  118556. var rand = function (min, max) {
  118557. return Math.random() * (max - min) + min;
  118558. };
  118559. var value;
  118560. for (var x = 0; x < size; x++) {
  118561. for (var y = 0; y < size; y++) {
  118562. value = Math.floor(rand(0.42, 0.58) * 255);
  118563. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  118564. context.fillRect(x, y, 1, 1);
  118565. }
  118566. }
  118567. this._grainTexture.update(false);
  118568. };
  118569. return LensRenderingPipeline;
  118570. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  118571. /***/ }),
  118572. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  118573. /*!**************************************************************************!*\
  118574. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  118575. \**************************************************************************/
  118576. /*! exports provided: SSAO2RenderingPipeline */
  118577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118578. "use strict";
  118579. __webpack_require__.r(__webpack_exports__);
  118580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  118581. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118582. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  118583. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  118584. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  118585. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118586. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  118587. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  118588. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  118589. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118590. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  118591. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  118592. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  118593. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  118594. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  118595. /**
  118596. * Render pipeline to produce ssao effect
  118597. */
  118598. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  118599. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  118600. /**
  118601. * @constructor
  118602. * @param name The rendering pipeline name
  118603. * @param scene The scene linked to this pipeline
  118604. * @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 }
  118605. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118606. */
  118607. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  118608. var _this = _super.call(this, scene.getEngine(), name) || this;
  118609. // Members
  118610. /**
  118611. * @ignore
  118612. * The PassPostProcess id in the pipeline that contains the original scene color
  118613. */
  118614. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  118615. /**
  118616. * @ignore
  118617. * The SSAO PostProcess id in the pipeline
  118618. */
  118619. _this.SSAORenderEffect = "SSAORenderEffect";
  118620. /**
  118621. * @ignore
  118622. * The horizontal blur PostProcess id in the pipeline
  118623. */
  118624. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  118625. /**
  118626. * @ignore
  118627. * The vertical blur PostProcess id in the pipeline
  118628. */
  118629. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  118630. /**
  118631. * @ignore
  118632. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118633. */
  118634. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  118635. /**
  118636. * The output strength of the SSAO post-process. Default value is 1.0.
  118637. */
  118638. _this.totalStrength = 1.0;
  118639. /**
  118640. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  118641. */
  118642. _this.maxZ = 100.0;
  118643. /**
  118644. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  118645. */
  118646. _this.minZAspect = 0.2;
  118647. _this._samples = 8;
  118648. _this._textureSamples = 1;
  118649. _this._expensiveBlur = true;
  118650. /**
  118651. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  118652. */
  118653. _this.radius = 2.0;
  118654. /**
  118655. * The base color of the SSAO post-process
  118656. * The final result is "base + ssao" between [0, 1]
  118657. */
  118658. _this.base = 0;
  118659. _this._firstUpdate = true;
  118660. _this._bits = new Uint32Array(1);
  118661. _this._scene = scene;
  118662. _this._ratio = ratio;
  118663. if (!_this.isSupported) {
  118664. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  118665. return _this;
  118666. }
  118667. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  118668. var blurRatio = _this._ratio.blurRatio || ratio;
  118669. // Set up assets
  118670. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  118671. _this._createRandomTexture();
  118672. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  118673. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  118674. _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);
  118675. _this._originalColorPostProcess.samples = _this.textureSamples;
  118676. _this._createSSAOPostProcess(1.0);
  118677. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  118678. _this._createSSAOCombinePostProcess(blurRatio);
  118679. // Set up pipeline
  118680. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  118681. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  118682. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  118683. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  118684. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  118685. // Finish
  118686. scene.postProcessRenderPipelineManager.addPipeline(_this);
  118687. if (cameras) {
  118688. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  118689. }
  118690. return _this;
  118691. }
  118692. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  118693. get: function () {
  118694. return this._samples;
  118695. },
  118696. /**
  118697. * Number of samples used for the SSAO calculations. Default value is 8
  118698. */
  118699. set: function (n) {
  118700. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  118701. this._samples = n;
  118702. this._sampleSphere = this._generateHemisphere();
  118703. this._firstUpdate = true;
  118704. },
  118705. enumerable: true,
  118706. configurable: true
  118707. });
  118708. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  118709. get: function () {
  118710. return this._textureSamples;
  118711. },
  118712. /**
  118713. * Number of samples to use for antialiasing
  118714. */
  118715. set: function (n) {
  118716. this._textureSamples = n;
  118717. this._originalColorPostProcess.samples = n;
  118718. this._blurHPostProcess.samples = n;
  118719. this._blurVPostProcess.samples = n;
  118720. this._ssaoPostProcess.samples = n;
  118721. this._ssaoCombinePostProcess.samples = n;
  118722. },
  118723. enumerable: true,
  118724. configurable: true
  118725. });
  118726. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  118727. get: function () {
  118728. return this._expensiveBlur;
  118729. },
  118730. /**
  118731. * If bilateral blur should be used
  118732. */
  118733. set: function (b) {
  118734. 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"]);
  118735. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  118736. this._expensiveBlur = b;
  118737. this._firstUpdate = true;
  118738. },
  118739. enumerable: true,
  118740. configurable: true
  118741. });
  118742. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  118743. /**
  118744. * Support test.
  118745. */
  118746. get: function () {
  118747. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  118748. if (!engine) {
  118749. return false;
  118750. }
  118751. return engine.getCaps().drawBuffersExtension;
  118752. },
  118753. enumerable: true,
  118754. configurable: true
  118755. });
  118756. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  118757. /**
  118758. * Gets active scene
  118759. */
  118760. get: function () {
  118761. return this._scene;
  118762. },
  118763. enumerable: true,
  118764. configurable: true
  118765. });
  118766. // Public Methods
  118767. /**
  118768. * Get the class name
  118769. * @returns "SSAO2RenderingPipeline"
  118770. */
  118771. SSAO2RenderingPipeline.prototype.getClassName = function () {
  118772. return "SSAO2RenderingPipeline";
  118773. };
  118774. /**
  118775. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118776. */
  118777. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  118778. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  118779. for (var i = 0; i < this._scene.cameras.length; i++) {
  118780. var camera = this._scene.cameras[i];
  118781. this._originalColorPostProcess.dispose(camera);
  118782. this._ssaoPostProcess.dispose(camera);
  118783. this._blurHPostProcess.dispose(camera);
  118784. this._blurVPostProcess.dispose(camera);
  118785. this._ssaoCombinePostProcess.dispose(camera);
  118786. }
  118787. this._randomTexture.dispose();
  118788. if (disableGeometryBufferRenderer) {
  118789. this._scene.disableGeometryBufferRenderer();
  118790. }
  118791. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  118792. _super.prototype.dispose.call(this);
  118793. };
  118794. // Private Methods
  118795. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  118796. var _this = this;
  118797. this._samplerOffsets = [];
  118798. var expensive = this.expensiveBlur;
  118799. for (var i = -8; i < 8; i++) {
  118800. this._samplerOffsets.push(i * 2 + 0.5);
  118801. }
  118802. 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");
  118803. this._blurHPostProcess.onApply = function (effect) {
  118804. if (!_this._scene.activeCamera) {
  118805. return;
  118806. }
  118807. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  118808. effect.setFloat("near", _this._scene.activeCamera.minZ);
  118809. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  118810. effect.setFloat("radius", _this.radius);
  118811. effect.setTexture("depthSampler", _this._depthTexture);
  118812. if (_this._firstUpdate) {
  118813. effect.setArray("samplerOffsets", _this._samplerOffsets);
  118814. }
  118815. };
  118816. 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");
  118817. this._blurVPostProcess.onApply = function (effect) {
  118818. if (!_this._scene.activeCamera) {
  118819. return;
  118820. }
  118821. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  118822. effect.setFloat("near", _this._scene.activeCamera.minZ);
  118823. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  118824. effect.setFloat("radius", _this.radius);
  118825. effect.setTexture("depthSampler", _this._depthTexture);
  118826. if (_this._firstUpdate) {
  118827. effect.setArray("samplerOffsets", _this._samplerOffsets);
  118828. _this._firstUpdate = false;
  118829. }
  118830. };
  118831. this._blurHPostProcess.samples = this.textureSamples;
  118832. this._blurVPostProcess.samples = this.textureSamples;
  118833. };
  118834. /** @hidden */
  118835. SSAO2RenderingPipeline.prototype._rebuild = function () {
  118836. this._firstUpdate = true;
  118837. _super.prototype._rebuild.call(this);
  118838. };
  118839. //Van der Corput radical inverse
  118840. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  118841. this._bits[0] = i;
  118842. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  118843. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  118844. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  118845. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  118846. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  118847. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  118848. };
  118849. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  118850. return [i / n, this._radicalInverse_VdC(i)];
  118851. };
  118852. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  118853. var phi = v * 2.0 * Math.PI;
  118854. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  118855. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  118856. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  118857. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  118858. };
  118859. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  118860. var numSamples = this.samples;
  118861. var result = [];
  118862. var vector;
  118863. var i = 0;
  118864. while (i < numSamples) {
  118865. if (numSamples < 16) {
  118866. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  118867. }
  118868. else {
  118869. var rand = this._hammersley(i, numSamples);
  118870. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  118871. }
  118872. result.push(vector.x, vector.y, vector.z);
  118873. i++;
  118874. }
  118875. return result;
  118876. };
  118877. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  118878. var _this = this;
  118879. var numSamples = this.samples;
  118880. this._sampleSphere = this._generateHemisphere();
  118881. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  118882. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  118883. "base", "range", "projection", "near", "far", "texelSize",
  118884. "xViewport", "yViewport", "maxZ", "minZAspect"
  118885. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  118886. this._ssaoPostProcess.onApply = function (effect) {
  118887. if (_this._firstUpdate) {
  118888. effect.setArray3("sampleSphere", _this._sampleSphere);
  118889. effect.setFloat("randTextureTiles", 32.0);
  118890. }
  118891. if (!_this._scene.activeCamera) {
  118892. return;
  118893. }
  118894. effect.setFloat("samplesFactor", 1 / _this.samples);
  118895. effect.setFloat("totalStrength", _this.totalStrength);
  118896. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  118897. effect.setFloat("radius", _this.radius);
  118898. effect.setFloat("maxZ", _this.maxZ);
  118899. effect.setFloat("minZAspect", _this.minZAspect);
  118900. effect.setFloat("base", _this.base);
  118901. effect.setFloat("near", _this._scene.activeCamera.minZ);
  118902. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  118903. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  118904. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  118905. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  118906. effect.setTexture("textureSampler", _this._depthTexture);
  118907. effect.setTexture("normalSampler", _this._normalTexture);
  118908. effect.setTexture("randomSampler", _this._randomTexture);
  118909. };
  118910. this._ssaoPostProcess.samples = this.textureSamples;
  118911. };
  118912. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  118913. var _this = this;
  118914. 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);
  118915. this._ssaoCombinePostProcess.onApply = function (effect) {
  118916. var viewport = _this._scene.activeCamera.viewport;
  118917. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  118918. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  118919. };
  118920. this._ssaoCombinePostProcess.samples = this.textureSamples;
  118921. };
  118922. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  118923. var size = 128;
  118924. 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);
  118925. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  118926. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  118927. var context = this._randomTexture.getContext();
  118928. var rand = function (min, max) {
  118929. return Math.random() * (max - min) + min;
  118930. };
  118931. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118932. for (var x = 0; x < size; x++) {
  118933. for (var y = 0; y < size; y++) {
  118934. randVector.x = rand(0.0, 1.0);
  118935. randVector.y = rand(0.0, 1.0);
  118936. randVector.z = 0.0;
  118937. randVector.normalize();
  118938. randVector.scaleInPlace(255);
  118939. randVector.x = Math.floor(randVector.x);
  118940. randVector.y = Math.floor(randVector.y);
  118941. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  118942. context.fillRect(x, y, 1, 1);
  118943. }
  118944. }
  118945. this._randomTexture.update(false);
  118946. };
  118947. /**
  118948. * Serialize the rendering pipeline (Used when exporting)
  118949. * @returns the serialized object
  118950. */
  118951. SSAO2RenderingPipeline.prototype.serialize = function () {
  118952. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  118953. serializationObject.customType = "SSAO2RenderingPipeline";
  118954. return serializationObject;
  118955. };
  118956. /**
  118957. * Parse the serialized pipeline
  118958. * @param source Source pipeline.
  118959. * @param scene The scene to load the pipeline to.
  118960. * @param rootUrl The URL of the serialized pipeline.
  118961. * @returns An instantiated pipeline from the serialized object.
  118962. */
  118963. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  118964. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  118965. };
  118966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118968. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  118969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118971. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  118972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118974. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  118975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  118977. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  118978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  118980. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  118981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118983. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  118984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  118986. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  118987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118989. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  118990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118992. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  118993. return SSAO2RenderingPipeline;
  118994. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  118995. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  118996. /***/ }),
  118997. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  118998. /*!*************************************************************************!*\
  118999. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  119000. \*************************************************************************/
  119001. /*! exports provided: SSAORenderingPipeline */
  119002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119003. "use strict";
  119004. __webpack_require__.r(__webpack_exports__);
  119005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  119006. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119007. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  119008. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119009. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  119010. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  119011. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119012. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119013. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  119014. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  119015. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  119016. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  119017. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  119018. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  119019. /**
  119020. * Render pipeline to produce ssao effect
  119021. */
  119022. var SSAORenderingPipeline = /** @class */ (function (_super) {
  119023. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  119024. /**
  119025. * @constructor
  119026. * @param name - The rendering pipeline name
  119027. * @param scene - The scene linked to this pipeline
  119028. * @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 }
  119029. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119030. */
  119031. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  119032. var _this = _super.call(this, scene.getEngine(), name) || this;
  119033. // Members
  119034. /**
  119035. * @ignore
  119036. * The PassPostProcess id in the pipeline that contains the original scene color
  119037. */
  119038. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  119039. /**
  119040. * @ignore
  119041. * The SSAO PostProcess id in the pipeline
  119042. */
  119043. _this.SSAORenderEffect = "SSAORenderEffect";
  119044. /**
  119045. * @ignore
  119046. * The horizontal blur PostProcess id in the pipeline
  119047. */
  119048. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  119049. /**
  119050. * @ignore
  119051. * The vertical blur PostProcess id in the pipeline
  119052. */
  119053. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  119054. /**
  119055. * @ignore
  119056. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119057. */
  119058. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  119059. /**
  119060. * The output strength of the SSAO post-process. Default value is 1.0.
  119061. */
  119062. _this.totalStrength = 1.0;
  119063. /**
  119064. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119065. */
  119066. _this.radius = 0.0001;
  119067. /**
  119068. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119069. * Must not be equal to fallOff and superior to fallOff.
  119070. * Default value is 0.0075
  119071. */
  119072. _this.area = 0.0075;
  119073. /**
  119074. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119075. * Must not be equal to area and inferior to area.
  119076. * Default value is 0.000001
  119077. */
  119078. _this.fallOff = 0.000001;
  119079. /**
  119080. * The base color of the SSAO post-process
  119081. * The final result is "base + ssao" between [0, 1]
  119082. */
  119083. _this.base = 0.5;
  119084. _this._firstUpdate = true;
  119085. _this._scene = scene;
  119086. // Set up assets
  119087. _this._createRandomTexture();
  119088. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  119089. var ssaoRatio = ratio.ssaoRatio || ratio;
  119090. var combineRatio = ratio.combineRatio || ratio;
  119091. _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);
  119092. _this._createSSAOPostProcess(ssaoRatio);
  119093. _this._createBlurPostProcess(ssaoRatio);
  119094. _this._createSSAOCombinePostProcess(combineRatio);
  119095. // Set up pipeline
  119096. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  119097. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  119098. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  119099. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  119100. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  119101. // Finish
  119102. scene.postProcessRenderPipelineManager.addPipeline(_this);
  119103. if (cameras) {
  119104. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  119105. }
  119106. return _this;
  119107. }
  119108. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  119109. /**
  119110. * Gets active scene
  119111. */
  119112. get: function () {
  119113. return this._scene;
  119114. },
  119115. enumerable: true,
  119116. configurable: true
  119117. });
  119118. // Public Methods
  119119. /**
  119120. * Get the class name
  119121. * @returns "SSAORenderingPipeline"
  119122. */
  119123. SSAORenderingPipeline.prototype.getClassName = function () {
  119124. return "SSAORenderingPipeline";
  119125. };
  119126. /**
  119127. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119128. */
  119129. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  119130. if (disableDepthRender === void 0) { disableDepthRender = false; }
  119131. for (var i = 0; i < this._scene.cameras.length; i++) {
  119132. var camera = this._scene.cameras[i];
  119133. this._originalColorPostProcess.dispose(camera);
  119134. this._ssaoPostProcess.dispose(camera);
  119135. this._blurHPostProcess.dispose(camera);
  119136. this._blurVPostProcess.dispose(camera);
  119137. this._ssaoCombinePostProcess.dispose(camera);
  119138. }
  119139. this._randomTexture.dispose();
  119140. if (disableDepthRender) {
  119141. this._scene.disableDepthRenderer();
  119142. }
  119143. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  119144. _super.prototype.dispose.call(this);
  119145. };
  119146. // Private Methods
  119147. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  119148. var _this = this;
  119149. var size = 16;
  119150. 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);
  119151. 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);
  119152. this._blurHPostProcess.onActivateObservable.add(function () {
  119153. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  119154. _this._blurHPostProcess.kernel = size * dw;
  119155. });
  119156. this._blurVPostProcess.onActivateObservable.add(function () {
  119157. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  119158. _this._blurVPostProcess.kernel = size * dw;
  119159. });
  119160. };
  119161. /** @hidden */
  119162. SSAORenderingPipeline.prototype._rebuild = function () {
  119163. this._firstUpdate = true;
  119164. _super.prototype._rebuild.call(this);
  119165. };
  119166. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  119167. var _this = this;
  119168. var numSamples = 16;
  119169. var sampleSphere = [
  119170. 0.5381, 0.1856, -0.4319,
  119171. 0.1379, 0.2486, 0.4430,
  119172. 0.3371, 0.5679, -0.0057,
  119173. -0.6999, -0.0451, -0.0019,
  119174. 0.0689, -0.1598, -0.8547,
  119175. 0.0560, 0.0069, -0.1843,
  119176. -0.0146, 0.1402, 0.0762,
  119177. 0.0100, -0.1924, -0.0344,
  119178. -0.3577, -0.5301, -0.4358,
  119179. -0.3169, 0.1063, 0.0158,
  119180. 0.0103, -0.5869, 0.0046,
  119181. -0.0897, -0.4940, 0.3287,
  119182. 0.7119, -0.0154, -0.0918,
  119183. -0.0533, 0.0596, -0.5411,
  119184. 0.0352, -0.0631, 0.5460,
  119185. -0.4776, 0.2847, -0.0271
  119186. ];
  119187. var samplesFactor = 1.0 / numSamples;
  119188. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  119189. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  119190. "area", "fallOff", "base", "range", "viewport"
  119191. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  119192. this._ssaoPostProcess.onApply = function (effect) {
  119193. if (_this._firstUpdate) {
  119194. effect.setArray3("sampleSphere", sampleSphere);
  119195. effect.setFloat("samplesFactor", samplesFactor);
  119196. effect.setFloat("randTextureTiles", 4.0);
  119197. }
  119198. effect.setFloat("totalStrength", _this.totalStrength);
  119199. effect.setFloat("radius", _this.radius);
  119200. effect.setFloat("area", _this.area);
  119201. effect.setFloat("fallOff", _this.fallOff);
  119202. effect.setFloat("base", _this.base);
  119203. effect.setTexture("textureSampler", _this._depthTexture);
  119204. effect.setTexture("randomSampler", _this._randomTexture);
  119205. };
  119206. };
  119207. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  119208. var _this = this;
  119209. 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);
  119210. this._ssaoCombinePostProcess.onApply = function (effect) {
  119211. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  119212. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  119213. };
  119214. };
  119215. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  119216. var size = 512;
  119217. 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);
  119218. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  119219. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  119220. var context = this._randomTexture.getContext();
  119221. var rand = function (min, max) {
  119222. return Math.random() * (max - min) + min;
  119223. };
  119224. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  119225. for (var x = 0; x < size; x++) {
  119226. for (var y = 0; y < size; y++) {
  119227. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  119228. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  119229. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  119230. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  119231. context.fillRect(x, y, 1, 1);
  119232. }
  119233. }
  119234. this._randomTexture.update(false);
  119235. };
  119236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119238. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  119239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119241. ], SSAORenderingPipeline.prototype, "radius", void 0);
  119242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119244. ], SSAORenderingPipeline.prototype, "area", void 0);
  119245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119247. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  119248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119250. ], SSAORenderingPipeline.prototype, "base", void 0);
  119251. return SSAORenderingPipeline;
  119252. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  119253. /***/ }),
  119254. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  119255. /*!*****************************************************************************!*\
  119256. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  119257. \*****************************************************************************/
  119258. /*! exports provided: StandardRenderingPipeline */
  119259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119260. "use strict";
  119261. __webpack_require__.r(__webpack_exports__);
  119262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  119263. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119264. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  119265. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  119266. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  119267. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  119268. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119269. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  119270. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119271. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119272. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  119273. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  119274. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  119275. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  119276. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  119277. /**
  119278. * Standard rendering pipeline
  119279. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119280. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119281. */
  119282. var StandardRenderingPipeline = /** @class */ (function (_super) {
  119283. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  119284. /**
  119285. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119286. * @constructor
  119287. * @param name The rendering pipeline name
  119288. * @param scene The scene linked to this pipeline
  119289. * @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)
  119290. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119291. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119292. */
  119293. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  119294. if (originalPostProcess === void 0) { originalPostProcess = null; }
  119295. var _this = _super.call(this, scene.getEngine(), name) || this;
  119296. /**
  119297. * Post-process used to down scale an image x4
  119298. */
  119299. _this.downSampleX4PostProcess = null;
  119300. /**
  119301. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119302. */
  119303. _this.brightPassPostProcess = null;
  119304. /**
  119305. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119306. */
  119307. _this.blurHPostProcesses = [];
  119308. /**
  119309. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119310. */
  119311. _this.blurVPostProcesses = [];
  119312. /**
  119313. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119314. */
  119315. _this.textureAdderPostProcess = null;
  119316. /**
  119317. * Post-process used to create volumetric lighting effect
  119318. */
  119319. _this.volumetricLightPostProcess = null;
  119320. /**
  119321. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119322. */
  119323. _this.volumetricLightSmoothXPostProcess = null;
  119324. /**
  119325. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119326. */
  119327. _this.volumetricLightSmoothYPostProcess = null;
  119328. /**
  119329. * Post-process used to merge the volumetric light effect and the real scene color
  119330. */
  119331. _this.volumetricLightMergePostProces = null;
  119332. /**
  119333. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119334. */
  119335. _this.volumetricLightFinalPostProcess = null;
  119336. /**
  119337. * Base post-process used to calculate the average luminance of the final image for HDR
  119338. */
  119339. _this.luminancePostProcess = null;
  119340. /**
  119341. * Post-processes used to create down sample post-processes in order to get
  119342. * the average luminance of the final image for HDR
  119343. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119344. */
  119345. _this.luminanceDownSamplePostProcesses = [];
  119346. /**
  119347. * Post-process used to create a HDR effect (light adaptation)
  119348. */
  119349. _this.hdrPostProcess = null;
  119350. /**
  119351. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119352. */
  119353. _this.textureAdderFinalPostProcess = null;
  119354. /**
  119355. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119356. */
  119357. _this.lensFlareFinalPostProcess = null;
  119358. /**
  119359. * Post-process used to merge the final HDR post-process and the real scene color
  119360. */
  119361. _this.hdrFinalPostProcess = null;
  119362. /**
  119363. * Post-process used to create a lens flare effect
  119364. */
  119365. _this.lensFlarePostProcess = null;
  119366. /**
  119367. * Post-process that merges the result of the lens flare post-process and the real scene color
  119368. */
  119369. _this.lensFlareComposePostProcess = null;
  119370. /**
  119371. * Post-process used to create a motion blur effect
  119372. */
  119373. _this.motionBlurPostProcess = null;
  119374. /**
  119375. * Post-process used to create a depth of field effect
  119376. */
  119377. _this.depthOfFieldPostProcess = null;
  119378. /**
  119379. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119380. */
  119381. _this.fxaaPostProcess = null;
  119382. // Values
  119383. /**
  119384. * Represents the brightness threshold in order to configure the illuminated surfaces
  119385. */
  119386. _this.brightThreshold = 1.0;
  119387. /**
  119388. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119389. */
  119390. _this.blurWidth = 512.0;
  119391. /**
  119392. * Sets if the blur for highlighted surfaces must be only horizontal
  119393. */
  119394. _this.horizontalBlur = false;
  119395. /**
  119396. * Sets the overall exposure used by the pipeline
  119397. */
  119398. _this.exposure = 1.0;
  119399. /**
  119400. * Texture used typically to simulate "dirty" on camera lens
  119401. */
  119402. _this.lensTexture = null;
  119403. /**
  119404. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119405. */
  119406. _this.volumetricLightCoefficient = 0.2;
  119407. /**
  119408. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119409. */
  119410. _this.volumetricLightPower = 4.0;
  119411. /**
  119412. * Used the set the blur intensity to smooth the volumetric lights
  119413. */
  119414. _this.volumetricLightBlurScale = 64.0;
  119415. /**
  119416. * Light (spot or directional) used to generate the volumetric lights rays
  119417. * The source light must have a shadow generate so the pipeline can get its
  119418. * depth map
  119419. */
  119420. _this.sourceLight = null;
  119421. /**
  119422. * For eye adaptation, represents the minimum luminance the eye can see
  119423. */
  119424. _this.hdrMinimumLuminance = 1.0;
  119425. /**
  119426. * For eye adaptation, represents the decrease luminance speed
  119427. */
  119428. _this.hdrDecreaseRate = 0.5;
  119429. /**
  119430. * For eye adaptation, represents the increase luminance speed
  119431. */
  119432. _this.hdrIncreaseRate = 0.5;
  119433. /**
  119434. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119435. */
  119436. _this.lensColorTexture = null;
  119437. /**
  119438. * The overall strengh for the lens flare effect
  119439. */
  119440. _this.lensFlareStrength = 20.0;
  119441. /**
  119442. * Dispersion coefficient for lens flare ghosts
  119443. */
  119444. _this.lensFlareGhostDispersal = 1.4;
  119445. /**
  119446. * Main lens flare halo width
  119447. */
  119448. _this.lensFlareHaloWidth = 0.7;
  119449. /**
  119450. * Based on the lens distortion effect, defines how much the lens flare result
  119451. * is distorted
  119452. */
  119453. _this.lensFlareDistortionStrength = 16.0;
  119454. /**
  119455. * Lens star texture must be used to simulate rays on the flares and is available
  119456. * in the documentation
  119457. */
  119458. _this.lensStarTexture = null;
  119459. /**
  119460. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119461. * flare effect by taking account of the dirt texture
  119462. */
  119463. _this.lensFlareDirtTexture = null;
  119464. /**
  119465. * Represents the focal length for the depth of field effect
  119466. */
  119467. _this.depthOfFieldDistance = 10.0;
  119468. /**
  119469. * Represents the blur intensity for the blurred part of the depth of field effect
  119470. */
  119471. _this.depthOfFieldBlurWidth = 64.0;
  119472. /**
  119473. * For motion blur, defines how much the image is blurred by the movement
  119474. */
  119475. _this.motionStrength = 1.0;
  119476. /**
  119477. * List of animations for the pipeline (IAnimatable implementation)
  119478. */
  119479. _this.animations = [];
  119480. _this._currentDepthOfFieldSource = null;
  119481. _this._hdrCurrentLuminance = 1.0;
  119482. // Getters and setters
  119483. _this._bloomEnabled = false;
  119484. _this._depthOfFieldEnabled = false;
  119485. _this._vlsEnabled = false;
  119486. _this._lensFlareEnabled = false;
  119487. _this._hdrEnabled = false;
  119488. _this._motionBlurEnabled = false;
  119489. _this._fxaaEnabled = false;
  119490. _this._motionBlurSamples = 64.0;
  119491. _this._volumetricLightStepsCount = 50.0;
  119492. _this._samples = 1;
  119493. _this._cameras = cameras || [];
  119494. // Initialize
  119495. _this._scene = scene;
  119496. _this._basePostProcess = originalPostProcess;
  119497. _this._ratio = ratio;
  119498. // Misc
  119499. _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;
  119500. // Finish
  119501. scene.postProcessRenderPipelineManager.addPipeline(_this);
  119502. _this._buildPipeline();
  119503. return _this;
  119504. }
  119505. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  119506. /**
  119507. * @ignore
  119508. * Specifies if the bloom pipeline is enabled
  119509. */
  119510. get: function () {
  119511. return this._bloomEnabled;
  119512. },
  119513. set: function (enabled) {
  119514. if (this._bloomEnabled === enabled) {
  119515. return;
  119516. }
  119517. this._bloomEnabled = enabled;
  119518. this._buildPipeline();
  119519. },
  119520. enumerable: true,
  119521. configurable: true
  119522. });
  119523. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  119524. /**
  119525. * @ignore
  119526. * Specifies if the depth of field pipeline is enabed
  119527. */
  119528. get: function () {
  119529. return this._depthOfFieldEnabled;
  119530. },
  119531. set: function (enabled) {
  119532. if (this._depthOfFieldEnabled === enabled) {
  119533. return;
  119534. }
  119535. this._depthOfFieldEnabled = enabled;
  119536. this._buildPipeline();
  119537. },
  119538. enumerable: true,
  119539. configurable: true
  119540. });
  119541. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  119542. /**
  119543. * @ignore
  119544. * Specifies if the lens flare pipeline is enabed
  119545. */
  119546. get: function () {
  119547. return this._lensFlareEnabled;
  119548. },
  119549. set: function (enabled) {
  119550. if (this._lensFlareEnabled === enabled) {
  119551. return;
  119552. }
  119553. this._lensFlareEnabled = enabled;
  119554. this._buildPipeline();
  119555. },
  119556. enumerable: true,
  119557. configurable: true
  119558. });
  119559. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  119560. /**
  119561. * @ignore
  119562. * Specifies if the HDR pipeline is enabled
  119563. */
  119564. get: function () {
  119565. return this._hdrEnabled;
  119566. },
  119567. set: function (enabled) {
  119568. if (this._hdrEnabled === enabled) {
  119569. return;
  119570. }
  119571. this._hdrEnabled = enabled;
  119572. this._buildPipeline();
  119573. },
  119574. enumerable: true,
  119575. configurable: true
  119576. });
  119577. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  119578. /**
  119579. * @ignore
  119580. * Specifies if the volumetric lights scattering effect is enabled
  119581. */
  119582. get: function () {
  119583. return this._vlsEnabled;
  119584. },
  119585. set: function (enabled) {
  119586. if (this._vlsEnabled === enabled) {
  119587. return;
  119588. }
  119589. if (enabled) {
  119590. var geometry = this._scene.enableGeometryBufferRenderer();
  119591. if (!geometry) {
  119592. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  119593. return;
  119594. }
  119595. }
  119596. this._vlsEnabled = enabled;
  119597. this._buildPipeline();
  119598. },
  119599. enumerable: true,
  119600. configurable: true
  119601. });
  119602. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  119603. /**
  119604. * @ignore
  119605. * Specifies if the motion blur effect is enabled
  119606. */
  119607. get: function () {
  119608. return this._motionBlurEnabled;
  119609. },
  119610. set: function (enabled) {
  119611. if (this._motionBlurEnabled === enabled) {
  119612. return;
  119613. }
  119614. this._motionBlurEnabled = enabled;
  119615. this._buildPipeline();
  119616. },
  119617. enumerable: true,
  119618. configurable: true
  119619. });
  119620. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  119621. /**
  119622. * Specifies if anti-aliasing is enabled
  119623. */
  119624. get: function () {
  119625. return this._fxaaEnabled;
  119626. },
  119627. set: function (enabled) {
  119628. if (this._fxaaEnabled === enabled) {
  119629. return;
  119630. }
  119631. this._fxaaEnabled = enabled;
  119632. this._buildPipeline();
  119633. },
  119634. enumerable: true,
  119635. configurable: true
  119636. });
  119637. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  119638. /**
  119639. * Specifies the number of steps used to calculate the volumetric lights
  119640. * Typically in interval [50, 200]
  119641. */
  119642. get: function () {
  119643. return this._volumetricLightStepsCount;
  119644. },
  119645. set: function (count) {
  119646. if (this.volumetricLightPostProcess) {
  119647. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  119648. }
  119649. this._volumetricLightStepsCount = count;
  119650. },
  119651. enumerable: true,
  119652. configurable: true
  119653. });
  119654. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  119655. /**
  119656. * Specifies the number of samples used for the motion blur effect
  119657. * Typically in interval [16, 64]
  119658. */
  119659. get: function () {
  119660. return this._motionBlurSamples;
  119661. },
  119662. set: function (samples) {
  119663. if (this.motionBlurPostProcess) {
  119664. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  119665. }
  119666. this._motionBlurSamples = samples;
  119667. },
  119668. enumerable: true,
  119669. configurable: true
  119670. });
  119671. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  119672. /**
  119673. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119674. */
  119675. get: function () {
  119676. return this._samples;
  119677. },
  119678. set: function (sampleCount) {
  119679. if (this._samples === sampleCount) {
  119680. return;
  119681. }
  119682. this._samples = sampleCount;
  119683. this._buildPipeline();
  119684. },
  119685. enumerable: true,
  119686. configurable: true
  119687. });
  119688. StandardRenderingPipeline.prototype._buildPipeline = function () {
  119689. var _this = this;
  119690. var ratio = this._ratio;
  119691. var scene = this._scene;
  119692. this._disposePostProcesses();
  119693. this._reset();
  119694. // Create pass post-process
  119695. if (!this._basePostProcess) {
  119696. 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);
  119697. this.originalPostProcess.onApply = function () {
  119698. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  119699. };
  119700. }
  119701. else {
  119702. this.originalPostProcess = this._basePostProcess;
  119703. }
  119704. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  119705. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  119706. }
  119707. this._currentDepthOfFieldSource = this.originalPostProcess;
  119708. if (this._bloomEnabled) {
  119709. // Create down sample X4 post-process
  119710. this._createDownSampleX4PostProcess(scene, ratio / 2);
  119711. // Create bright pass post-process
  119712. this._createBrightPassPostProcess(scene, ratio / 2);
  119713. // Create gaussian blur post-processes (down sampling blurs)
  119714. this._createBlurPostProcesses(scene, ratio / 4, 1);
  119715. // Create texture adder post-process
  119716. this._createTextureAdderPostProcess(scene, ratio);
  119717. // Create depth-of-field source post-process
  119718. 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);
  119719. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  119720. }
  119721. if (this._vlsEnabled) {
  119722. // Create volumetric light
  119723. this._createVolumetricLightPostProcess(scene, ratio);
  119724. // Create volumetric light final post-process
  119725. 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);
  119726. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  119727. }
  119728. if (this._lensFlareEnabled) {
  119729. // Create lens flare post-process
  119730. this._createLensFlarePostProcess(scene, ratio);
  119731. // Create depth-of-field source post-process post lens-flare and disable it now
  119732. 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);
  119733. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  119734. }
  119735. if (this._hdrEnabled) {
  119736. // Create luminance
  119737. this._createLuminancePostProcesses(scene, this._floatTextureType);
  119738. // Create HDR
  119739. this._createHdrPostProcess(scene, ratio);
  119740. // Create depth-of-field source post-process post hdr and disable it now
  119741. 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);
  119742. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  119743. }
  119744. if (this._depthOfFieldEnabled) {
  119745. // Create gaussian blur used by depth-of-field
  119746. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  119747. // Create depth-of-field post-process
  119748. this._createDepthOfFieldPostProcess(scene, ratio);
  119749. }
  119750. if (this._motionBlurEnabled) {
  119751. // Create motion blur post-process
  119752. this._createMotionBlurPostProcess(scene, ratio);
  119753. }
  119754. if (this._fxaaEnabled) {
  119755. // Create fxaa post-process
  119756. 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);
  119757. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  119758. }
  119759. if (this._cameras !== null) {
  119760. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  119761. }
  119762. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  119763. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  119764. }
  119765. };
  119766. // Down Sample X4 Post-Processs
  119767. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  119768. var _this = this;
  119769. var downSampleX4Offsets = new Array(32);
  119770. 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);
  119771. this.downSampleX4PostProcess.onApply = function (effect) {
  119772. var id = 0;
  119773. var width = _this.downSampleX4PostProcess.width;
  119774. var height = _this.downSampleX4PostProcess.height;
  119775. for (var i = -2; i < 2; i++) {
  119776. for (var j = -2; j < 2; j++) {
  119777. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  119778. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  119779. id += 2;
  119780. }
  119781. }
  119782. effect.setArray2("dsOffsets", downSampleX4Offsets);
  119783. };
  119784. // Add to pipeline
  119785. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  119786. };
  119787. // Brightpass Post-Process
  119788. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  119789. var _this = this;
  119790. var brightOffsets = new Array(8);
  119791. 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);
  119792. this.brightPassPostProcess.onApply = function (effect) {
  119793. var sU = (1.0 / _this.brightPassPostProcess.width);
  119794. var sV = (1.0 / _this.brightPassPostProcess.height);
  119795. brightOffsets[0] = -0.5 * sU;
  119796. brightOffsets[1] = 0.5 * sV;
  119797. brightOffsets[2] = 0.5 * sU;
  119798. brightOffsets[3] = 0.5 * sV;
  119799. brightOffsets[4] = -0.5 * sU;
  119800. brightOffsets[5] = -0.5 * sV;
  119801. brightOffsets[6] = 0.5 * sU;
  119802. brightOffsets[7] = -0.5 * sV;
  119803. effect.setArray2("dsOffsets", brightOffsets);
  119804. effect.setFloat("brightThreshold", _this.brightThreshold);
  119805. };
  119806. // Add to pipeline
  119807. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  119808. };
  119809. // Create blur H&V post-processes
  119810. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  119811. var _this = this;
  119812. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  119813. var engine = scene.getEngine();
  119814. 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);
  119815. 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);
  119816. blurX.onActivateObservable.add(function () {
  119817. var dw = blurX.width / engine.getRenderWidth();
  119818. blurX.kernel = _this[blurWidthKey] * dw;
  119819. });
  119820. blurY.onActivateObservable.add(function () {
  119821. var dw = blurY.height / engine.getRenderHeight();
  119822. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  119823. });
  119824. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  119825. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  119826. this.blurHPostProcesses.push(blurX);
  119827. this.blurVPostProcesses.push(blurY);
  119828. };
  119829. // Create texture adder post-process
  119830. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  119831. var _this = this;
  119832. 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);
  119833. this.textureAdderPostProcess.onApply = function (effect) {
  119834. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  119835. effect.setTexture("lensSampler", _this.lensTexture);
  119836. effect.setFloat("exposure", _this.exposure);
  119837. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  119838. };
  119839. // Add to pipeline
  119840. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  119841. };
  119842. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  119843. var _this = this;
  119844. var geometryRenderer = scene.enableGeometryBufferRenderer();
  119845. geometryRenderer.enablePosition = true;
  119846. var geometry = geometryRenderer.getGBuffer();
  119847. // Base post-process
  119848. 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));
  119849. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  119850. this.volumetricLightPostProcess.onApply = function (effect) {
  119851. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  119852. var generator = _this.sourceLight.getShadowGenerator();
  119853. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  119854. effect.setTexture("positionSampler", geometry.textures[2]);
  119855. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  119856. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  119857. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  119858. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  119859. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  119860. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  119861. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  119862. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  119863. effect.setVector2("depthValues", depthValues);
  119864. }
  119865. };
  119866. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  119867. // Smooth
  119868. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  119869. // Merge
  119870. 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");
  119871. this.volumetricLightMergePostProces.onApply = function (effect) {
  119872. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  119873. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  119874. };
  119875. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  119876. };
  119877. // Create luminance
  119878. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  119879. var _this = this;
  119880. // Create luminance
  119881. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  119882. 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);
  119883. var offsets = [];
  119884. this.luminancePostProcess.onApply = function (effect) {
  119885. var sU = (1.0 / _this.luminancePostProcess.width);
  119886. var sV = (1.0 / _this.luminancePostProcess.height);
  119887. offsets[0] = -0.5 * sU;
  119888. offsets[1] = 0.5 * sV;
  119889. offsets[2] = 0.5 * sU;
  119890. offsets[3] = 0.5 * sV;
  119891. offsets[4] = -0.5 * sU;
  119892. offsets[5] = -0.5 * sV;
  119893. offsets[6] = 0.5 * sU;
  119894. offsets[7] = -0.5 * sV;
  119895. effect.setArray2("lumOffsets", offsets);
  119896. };
  119897. // Add to pipeline
  119898. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  119899. // Create down sample luminance
  119900. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  119901. var size = Math.pow(3, i);
  119902. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  119903. if (i === 0) {
  119904. defines += "#define FINAL_DOWN_SAMPLER";
  119905. }
  119906. 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);
  119907. this.luminanceDownSamplePostProcesses.push(postProcess);
  119908. }
  119909. // Create callbacks and add effects
  119910. var lastLuminance = this.luminancePostProcess;
  119911. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  119912. var downSampleOffsets = new Array(18);
  119913. pp.onApply = function (effect) {
  119914. if (!lastLuminance) {
  119915. return;
  119916. }
  119917. var id = 0;
  119918. for (var x = -1; x < 2; x++) {
  119919. for (var y = -1; y < 2; y++) {
  119920. downSampleOffsets[id] = x / lastLuminance.width;
  119921. downSampleOffsets[id + 1] = y / lastLuminance.height;
  119922. id += 2;
  119923. }
  119924. }
  119925. effect.setArray2("dsOffsets", downSampleOffsets);
  119926. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  119927. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  119928. lastLuminance = _this.luminancePostProcess;
  119929. }
  119930. else {
  119931. lastLuminance = pp;
  119932. }
  119933. };
  119934. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  119935. pp.onAfterRender = function () {
  119936. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  119937. 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);
  119938. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  119939. };
  119940. }
  119941. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  119942. });
  119943. };
  119944. // Create HDR post-process
  119945. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  119946. var _this = this;
  119947. 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);
  119948. var outputLiminance = 1;
  119949. var time = 0;
  119950. var lastTime = 0;
  119951. this.hdrPostProcess.onApply = function (effect) {
  119952. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  119953. time += scene.getEngine().getDeltaTime();
  119954. if (outputLiminance < 0) {
  119955. outputLiminance = _this._hdrCurrentLuminance;
  119956. }
  119957. else {
  119958. var dt = (lastTime - time) / 1000.0;
  119959. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  119960. outputLiminance += _this.hdrDecreaseRate * dt;
  119961. }
  119962. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  119963. outputLiminance -= _this.hdrIncreaseRate * dt;
  119964. }
  119965. else {
  119966. outputLiminance = _this._hdrCurrentLuminance;
  119967. }
  119968. }
  119969. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  119970. effect.setFloat("averageLuminance", outputLiminance);
  119971. lastTime = time;
  119972. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  119973. };
  119974. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  119975. };
  119976. // Create lens flare post-process
  119977. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  119978. var _this = this;
  119979. 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);
  119980. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  119981. this._createBlurPostProcesses(scene, ratio / 4, 2);
  119982. 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);
  119983. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  119984. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  119985. // Lens flare
  119986. this.lensFlarePostProcess.onApply = function (effect) {
  119987. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  119988. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  119989. effect.setFloat("strength", _this.lensFlareStrength);
  119990. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  119991. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  119992. // Shift
  119993. resolution.x = _this.lensFlarePostProcess.width;
  119994. resolution.y = _this.lensFlarePostProcess.height;
  119995. effect.setVector2("resolution", resolution);
  119996. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  119997. };
  119998. // Compose
  119999. 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);
  120000. 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);
  120001. this.lensFlareComposePostProcess.onApply = function (effect) {
  120002. if (!_this._scene.activeCamera) {
  120003. return;
  120004. }
  120005. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  120006. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  120007. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  120008. // Lens start rotation matrix
  120009. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  120010. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  120011. 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));
  120012. camRot *= 4.0;
  120013. 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);
  120014. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  120015. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  120016. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  120017. };
  120018. };
  120019. // Create depth-of-field post-process
  120020. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  120021. var _this = this;
  120022. 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);
  120023. this.depthOfFieldPostProcess.onApply = function (effect) {
  120024. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  120025. effect.setTexture("depthSampler", _this._getDepthTexture());
  120026. effect.setFloat("distance", _this.depthOfFieldDistance);
  120027. };
  120028. // Add to pipeline
  120029. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  120030. };
  120031. // Create motion blur post-process
  120032. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  120033. var _this = this;
  120034. 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);
  120035. var motionScale = 0;
  120036. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  120037. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  120038. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  120039. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  120040. this.motionBlurPostProcess.onApply = function (effect) {
  120041. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  120042. viewProjection.invertToRef(invViewProjection);
  120043. effect.setMatrix("inverseViewProjection", invViewProjection);
  120044. effect.setMatrix("prevViewProjection", prevViewProjection);
  120045. prevViewProjection = viewProjection;
  120046. screenSize.x = _this.motionBlurPostProcess.width;
  120047. screenSize.y = _this.motionBlurPostProcess.height;
  120048. effect.setVector2("screenSize", screenSize);
  120049. motionScale = scene.getEngine().getFps() / 60.0;
  120050. effect.setFloat("motionScale", motionScale);
  120051. effect.setFloat("motionStrength", _this.motionStrength);
  120052. effect.setTexture("depthSampler", _this._getDepthTexture());
  120053. };
  120054. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  120055. };
  120056. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  120057. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  120058. var renderer = this._scene.enableGeometryBufferRenderer();
  120059. return renderer.getGBuffer().textures[0];
  120060. }
  120061. return this._scene.enableDepthRenderer().getDepthMap();
  120062. };
  120063. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  120064. for (var i = 0; i < this._cameras.length; i++) {
  120065. var camera = this._cameras[i];
  120066. if (this.originalPostProcess) {
  120067. this.originalPostProcess.dispose(camera);
  120068. }
  120069. if (this.downSampleX4PostProcess) {
  120070. this.downSampleX4PostProcess.dispose(camera);
  120071. }
  120072. if (this.brightPassPostProcess) {
  120073. this.brightPassPostProcess.dispose(camera);
  120074. }
  120075. if (this.textureAdderPostProcess) {
  120076. this.textureAdderPostProcess.dispose(camera);
  120077. }
  120078. if (this.textureAdderFinalPostProcess) {
  120079. this.textureAdderFinalPostProcess.dispose(camera);
  120080. }
  120081. if (this.volumetricLightPostProcess) {
  120082. this.volumetricLightPostProcess.dispose(camera);
  120083. }
  120084. if (this.volumetricLightSmoothXPostProcess) {
  120085. this.volumetricLightSmoothXPostProcess.dispose(camera);
  120086. }
  120087. if (this.volumetricLightSmoothYPostProcess) {
  120088. this.volumetricLightSmoothYPostProcess.dispose(camera);
  120089. }
  120090. if (this.volumetricLightMergePostProces) {
  120091. this.volumetricLightMergePostProces.dispose(camera);
  120092. }
  120093. if (this.volumetricLightFinalPostProcess) {
  120094. this.volumetricLightFinalPostProcess.dispose(camera);
  120095. }
  120096. if (this.lensFlarePostProcess) {
  120097. this.lensFlarePostProcess.dispose(camera);
  120098. }
  120099. if (this.lensFlareComposePostProcess) {
  120100. this.lensFlareComposePostProcess.dispose(camera);
  120101. }
  120102. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  120103. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  120104. }
  120105. if (this.luminancePostProcess) {
  120106. this.luminancePostProcess.dispose(camera);
  120107. }
  120108. if (this.hdrPostProcess) {
  120109. this.hdrPostProcess.dispose(camera);
  120110. }
  120111. if (this.hdrFinalPostProcess) {
  120112. this.hdrFinalPostProcess.dispose(camera);
  120113. }
  120114. if (this.depthOfFieldPostProcess) {
  120115. this.depthOfFieldPostProcess.dispose(camera);
  120116. }
  120117. if (this.motionBlurPostProcess) {
  120118. this.motionBlurPostProcess.dispose(camera);
  120119. }
  120120. if (this.fxaaPostProcess) {
  120121. this.fxaaPostProcess.dispose(camera);
  120122. }
  120123. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  120124. this.blurHPostProcesses[j].dispose(camera);
  120125. }
  120126. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  120127. this.blurVPostProcesses[j].dispose(camera);
  120128. }
  120129. }
  120130. this.originalPostProcess = null;
  120131. this.downSampleX4PostProcess = null;
  120132. this.brightPassPostProcess = null;
  120133. this.textureAdderPostProcess = null;
  120134. this.textureAdderFinalPostProcess = null;
  120135. this.volumetricLightPostProcess = null;
  120136. this.volumetricLightSmoothXPostProcess = null;
  120137. this.volumetricLightSmoothYPostProcess = null;
  120138. this.volumetricLightMergePostProces = null;
  120139. this.volumetricLightFinalPostProcess = null;
  120140. this.lensFlarePostProcess = null;
  120141. this.lensFlareComposePostProcess = null;
  120142. this.luminancePostProcess = null;
  120143. this.hdrPostProcess = null;
  120144. this.hdrFinalPostProcess = null;
  120145. this.depthOfFieldPostProcess = null;
  120146. this.motionBlurPostProcess = null;
  120147. this.fxaaPostProcess = null;
  120148. this.luminanceDownSamplePostProcesses = [];
  120149. this.blurHPostProcesses = [];
  120150. this.blurVPostProcesses = [];
  120151. };
  120152. /**
  120153. * Dispose of the pipeline and stop all post processes
  120154. */
  120155. StandardRenderingPipeline.prototype.dispose = function () {
  120156. this._disposePostProcesses();
  120157. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  120158. _super.prototype.dispose.call(this);
  120159. };
  120160. /**
  120161. * Serialize the rendering pipeline (Used when exporting)
  120162. * @returns the serialized object
  120163. */
  120164. StandardRenderingPipeline.prototype.serialize = function () {
  120165. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  120166. if (this.sourceLight) {
  120167. serializationObject.sourceLightId = this.sourceLight.id;
  120168. }
  120169. serializationObject.customType = "StandardRenderingPipeline";
  120170. return serializationObject;
  120171. };
  120172. /**
  120173. * Parse the serialized pipeline
  120174. * @param source Source pipeline.
  120175. * @param scene The scene to load the pipeline to.
  120176. * @param rootUrl The URL of the serialized pipeline.
  120177. * @returns An instantiated pipeline from the serialized object.
  120178. */
  120179. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  120180. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  120181. if (source.sourceLightId) {
  120182. p.sourceLight = scene.getLightByID(source.sourceLightId);
  120183. }
  120184. return p;
  120185. };
  120186. /**
  120187. * Luminance steps
  120188. */
  120189. StandardRenderingPipeline.LuminanceSteps = 6;
  120190. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120191. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120192. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  120193. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120194. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120195. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  120196. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120197. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120198. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  120199. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120200. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120201. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  120202. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120203. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  120204. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  120205. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120206. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120207. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  120208. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120210. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  120211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120213. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  120214. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120215. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120216. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  120217. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120218. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120219. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  120220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120222. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  120223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  120225. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  120226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120228. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  120229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120231. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  120232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120234. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  120235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120237. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  120238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  120240. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  120241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  120243. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  120244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120246. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  120247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120249. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  120250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120252. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  120253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120255. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  120256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120258. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  120259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120261. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  120262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120264. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  120265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120267. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  120268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120270. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  120271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120273. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  120274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120276. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  120277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120279. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  120280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120282. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  120283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120285. ], StandardRenderingPipeline.prototype, "samples", null);
  120286. return StandardRenderingPipeline;
  120287. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  120288. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  120289. /***/ }),
  120290. /***/ "./PostProcesses/RenderPipeline/index.ts":
  120291. /*!***********************************************!*\
  120292. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  120293. \***********************************************/
  120294. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  120295. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120296. "use strict";
  120297. __webpack_require__.r(__webpack_exports__);
  120298. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  120299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  120300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  120301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  120302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  120303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  120304. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  120306. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  120308. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  120309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  120310. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  120311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  120312. /***/ }),
  120313. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  120314. /*!*****************************************************************!*\
  120315. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  120316. \*****************************************************************/
  120317. /*! exports provided: PostProcessRenderEffect */
  120318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120319. "use strict";
  120320. __webpack_require__.r(__webpack_exports__);
  120321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  120322. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  120323. /**
  120324. * This represents a set of one or more post processes in Babylon.
  120325. * A post process can be used to apply a shader to a texture after it is rendered.
  120326. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120327. */
  120328. var PostProcessRenderEffect = /** @class */ (function () {
  120329. /**
  120330. * Instantiates a post process render effect.
  120331. * A post process can be used to apply a shader to a texture after it is rendered.
  120332. * @param engine The engine the effect is tied to
  120333. * @param name The name of the effect
  120334. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  120335. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  120336. */
  120337. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  120338. this._name = name;
  120339. this._singleInstance = singleInstance || true;
  120340. this._getPostProcesses = getPostProcesses;
  120341. this._cameras = {};
  120342. this._indicesForCamera = {};
  120343. this._postProcesses = {};
  120344. }
  120345. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  120346. /**
  120347. * Checks if all the post processes in the effect are supported.
  120348. */
  120349. get: function () {
  120350. for (var index in this._postProcesses) {
  120351. if (this._postProcesses.hasOwnProperty(index)) {
  120352. var pps = this._postProcesses[index];
  120353. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  120354. if (!pps[ppIndex].isSupported) {
  120355. return false;
  120356. }
  120357. }
  120358. }
  120359. }
  120360. return true;
  120361. },
  120362. enumerable: true,
  120363. configurable: true
  120364. });
  120365. /**
  120366. * Updates the current state of the effect
  120367. * @hidden
  120368. */
  120369. PostProcessRenderEffect.prototype._update = function () {
  120370. };
  120371. /**
  120372. * Attaches the effect on cameras
  120373. * @param cameras The camera to attach to.
  120374. * @hidden
  120375. */
  120376. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  120377. var _this = this;
  120378. var cameraKey;
  120379. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  120380. if (!cams) {
  120381. return;
  120382. }
  120383. for (var i = 0; i < cams.length; i++) {
  120384. var camera = cams[i];
  120385. var cameraName = camera.name;
  120386. if (this._singleInstance) {
  120387. cameraKey = 0;
  120388. }
  120389. else {
  120390. cameraKey = cameraName;
  120391. }
  120392. if (!this._postProcesses[cameraKey]) {
  120393. var postProcess = this._getPostProcesses();
  120394. if (postProcess) {
  120395. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  120396. }
  120397. }
  120398. if (!this._indicesForCamera[cameraName]) {
  120399. this._indicesForCamera[cameraName] = [];
  120400. }
  120401. this._postProcesses[cameraKey].forEach(function (postProcess) {
  120402. var index = camera.attachPostProcess(postProcess);
  120403. _this._indicesForCamera[cameraName].push(index);
  120404. });
  120405. if (!this._cameras[cameraName]) {
  120406. this._cameras[cameraName] = camera;
  120407. }
  120408. }
  120409. };
  120410. /**
  120411. * Detatches the effect on cameras
  120412. * @param cameras The camera to detatch from.
  120413. * @hidden
  120414. */
  120415. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  120416. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  120417. if (!cams) {
  120418. return;
  120419. }
  120420. for (var i = 0; i < cams.length; i++) {
  120421. var camera = cams[i];
  120422. var cameraName = camera.name;
  120423. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  120424. if (postProcesses) {
  120425. postProcesses.forEach(function (postProcess) {
  120426. camera.detachPostProcess(postProcess);
  120427. });
  120428. }
  120429. if (this._cameras[cameraName]) {
  120430. this._cameras[cameraName] = null;
  120431. }
  120432. }
  120433. };
  120434. /**
  120435. * Enables the effect on given cameras
  120436. * @param cameras The camera to enable.
  120437. * @hidden
  120438. */
  120439. PostProcessRenderEffect.prototype._enable = function (cameras) {
  120440. var _this = this;
  120441. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  120442. if (!cams) {
  120443. return;
  120444. }
  120445. for (var i = 0; i < cams.length; i++) {
  120446. var camera = cams[i];
  120447. var cameraName = camera.name;
  120448. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  120449. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  120450. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  120451. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  120452. });
  120453. }
  120454. }
  120455. }
  120456. };
  120457. /**
  120458. * Disables the effect on the given cameras
  120459. * @param cameras The camera to disable.
  120460. * @hidden
  120461. */
  120462. PostProcessRenderEffect.prototype._disable = function (cameras) {
  120463. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  120464. if (!cams) {
  120465. return;
  120466. }
  120467. for (var i = 0; i < cams.length; i++) {
  120468. var camera = cams[i];
  120469. var cameraName = camera.name;
  120470. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  120471. camera.detachPostProcess(postProcess);
  120472. });
  120473. }
  120474. };
  120475. /**
  120476. * Gets a list of the post processes contained in the effect.
  120477. * @param camera The camera to get the post processes on.
  120478. * @returns The list of the post processes in the effect.
  120479. */
  120480. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  120481. if (this._singleInstance) {
  120482. return this._postProcesses[0];
  120483. }
  120484. else {
  120485. if (!camera) {
  120486. return null;
  120487. }
  120488. return this._postProcesses[camera.name];
  120489. }
  120490. };
  120491. return PostProcessRenderEffect;
  120492. }());
  120493. /***/ }),
  120494. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  120495. /*!*******************************************************************!*\
  120496. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  120497. \*******************************************************************/
  120498. /*! exports provided: PostProcessRenderPipeline */
  120499. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120500. "use strict";
  120501. __webpack_require__.r(__webpack_exports__);
  120502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  120503. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120504. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  120505. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  120506. /**
  120507. * PostProcessRenderPipeline
  120508. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120509. */
  120510. var PostProcessRenderPipeline = /** @class */ (function () {
  120511. /**
  120512. * Initializes a PostProcessRenderPipeline
  120513. * @param engine engine to add the pipeline to
  120514. * @param name name of the pipeline
  120515. */
  120516. function PostProcessRenderPipeline(engine, name) {
  120517. this.engine = engine;
  120518. this._name = name;
  120519. this._renderEffects = {};
  120520. this._renderEffectsForIsolatedPass = new Array();
  120521. this._cameras = [];
  120522. }
  120523. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  120524. /**
  120525. * Gets pipeline name
  120526. */
  120527. get: function () {
  120528. return this._name;
  120529. },
  120530. enumerable: true,
  120531. configurable: true
  120532. });
  120533. /**
  120534. * Gets the class name
  120535. * @returns "PostProcessRenderPipeline"
  120536. */
  120537. PostProcessRenderPipeline.prototype.getClassName = function () {
  120538. return "PostProcessRenderPipeline";
  120539. };
  120540. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  120541. /**
  120542. * If all the render effects in the pipeline are supported
  120543. */
  120544. get: function () {
  120545. for (var renderEffectName in this._renderEffects) {
  120546. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  120547. if (!this._renderEffects[renderEffectName].isSupported) {
  120548. return false;
  120549. }
  120550. }
  120551. }
  120552. return true;
  120553. },
  120554. enumerable: true,
  120555. configurable: true
  120556. });
  120557. /**
  120558. * Adds an effect to the pipeline
  120559. * @param renderEffect the effect to add
  120560. */
  120561. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  120562. this._renderEffects[renderEffect._name] = renderEffect;
  120563. };
  120564. // private
  120565. /** @hidden */
  120566. PostProcessRenderPipeline.prototype._rebuild = function () {
  120567. };
  120568. /** @hidden */
  120569. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  120570. var renderEffects = this._renderEffects[renderEffectName];
  120571. if (!renderEffects) {
  120572. return;
  120573. }
  120574. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  120575. };
  120576. /** @hidden */
  120577. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  120578. var renderEffects = this._renderEffects[renderEffectName];
  120579. if (!renderEffects) {
  120580. return;
  120581. }
  120582. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  120583. };
  120584. /** @hidden */
  120585. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  120586. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  120587. if (!cams) {
  120588. return;
  120589. }
  120590. var indicesToDelete = [];
  120591. var i;
  120592. for (i = 0; i < cams.length; i++) {
  120593. var camera = cams[i];
  120594. var cameraName = camera.name;
  120595. if (this._cameras.indexOf(camera) === -1) {
  120596. this._cameras[cameraName] = camera;
  120597. }
  120598. else if (unique) {
  120599. indicesToDelete.push(i);
  120600. }
  120601. }
  120602. for (i = 0; i < indicesToDelete.length; i++) {
  120603. cameras.splice(indicesToDelete[i], 1);
  120604. }
  120605. for (var renderEffectName in this._renderEffects) {
  120606. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  120607. this._renderEffects[renderEffectName]._attachCameras(cams);
  120608. }
  120609. }
  120610. };
  120611. /** @hidden */
  120612. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  120613. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  120614. if (!cams) {
  120615. return;
  120616. }
  120617. for (var renderEffectName in this._renderEffects) {
  120618. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  120619. this._renderEffects[renderEffectName]._detachCameras(cams);
  120620. }
  120621. }
  120622. for (var i = 0; i < cams.length; i++) {
  120623. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  120624. }
  120625. };
  120626. /** @hidden */
  120627. PostProcessRenderPipeline.prototype._update = function () {
  120628. for (var renderEffectName in this._renderEffects) {
  120629. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  120630. this._renderEffects[renderEffectName]._update();
  120631. }
  120632. }
  120633. for (var i = 0; i < this._cameras.length; i++) {
  120634. var cameraName = this._cameras[i].name;
  120635. if (this._renderEffectsForIsolatedPass[cameraName]) {
  120636. this._renderEffectsForIsolatedPass[cameraName]._update();
  120637. }
  120638. }
  120639. };
  120640. /** @hidden */
  120641. PostProcessRenderPipeline.prototype._reset = function () {
  120642. this._renderEffects = {};
  120643. this._renderEffectsForIsolatedPass = new Array();
  120644. };
  120645. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  120646. // 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)
  120647. var effectKeys = Object.keys(this._renderEffects);
  120648. if (this.engine.webGLVersion === 1) {
  120649. return false;
  120650. }
  120651. if (effectKeys.length > 0) {
  120652. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  120653. if (postProcesses) {
  120654. postProcesses[0].samples = sampleCount;
  120655. }
  120656. }
  120657. return true;
  120658. };
  120659. /**
  120660. * Disposes of the pipeline
  120661. */
  120662. PostProcessRenderPipeline.prototype.dispose = function () {
  120663. // Must be implemented by children
  120664. };
  120665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120667. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  120668. return PostProcessRenderPipeline;
  120669. }());
  120670. /***/ }),
  120671. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  120672. /*!**************************************************************************!*\
  120673. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  120674. \**************************************************************************/
  120675. /*! exports provided: PostProcessRenderPipelineManager */
  120676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120677. "use strict";
  120678. __webpack_require__.r(__webpack_exports__);
  120679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  120680. /**
  120681. * PostProcessRenderPipelineManager class
  120682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120683. */
  120684. var PostProcessRenderPipelineManager = /** @class */ (function () {
  120685. /**
  120686. * Initializes a PostProcessRenderPipelineManager
  120687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120688. */
  120689. function PostProcessRenderPipelineManager() {
  120690. this._renderPipelines = {};
  120691. }
  120692. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  120693. /**
  120694. * Gets the list of supported render pipelines
  120695. */
  120696. get: function () {
  120697. var result = [];
  120698. for (var renderPipelineName in this._renderPipelines) {
  120699. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  120700. var pipeline = this._renderPipelines[renderPipelineName];
  120701. if (pipeline.isSupported) {
  120702. result.push(pipeline);
  120703. }
  120704. }
  120705. }
  120706. return result;
  120707. },
  120708. enumerable: true,
  120709. configurable: true
  120710. });
  120711. /**
  120712. * Adds a pipeline to the manager
  120713. * @param renderPipeline The pipeline to add
  120714. */
  120715. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  120716. this._renderPipelines[renderPipeline._name] = renderPipeline;
  120717. };
  120718. /**
  120719. * Attaches a camera to the pipeline
  120720. * @param renderPipelineName The name of the pipeline to attach to
  120721. * @param cameras the camera to attach
  120722. * @param unique if the camera can be attached multiple times to the pipeline
  120723. */
  120724. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  120725. if (unique === void 0) { unique = false; }
  120726. var renderPipeline = this._renderPipelines[renderPipelineName];
  120727. if (!renderPipeline) {
  120728. return;
  120729. }
  120730. renderPipeline._attachCameras(cameras, unique);
  120731. };
  120732. /**
  120733. * Detaches a camera from the pipeline
  120734. * @param renderPipelineName The name of the pipeline to detach from
  120735. * @param cameras the camera to detach
  120736. */
  120737. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  120738. var renderPipeline = this._renderPipelines[renderPipelineName];
  120739. if (!renderPipeline) {
  120740. return;
  120741. }
  120742. renderPipeline._detachCameras(cameras);
  120743. };
  120744. /**
  120745. * Enables an effect by name on a pipeline
  120746. * @param renderPipelineName the name of the pipeline to enable the effect in
  120747. * @param renderEffectName the name of the effect to enable
  120748. * @param cameras the cameras that the effect should be enabled on
  120749. */
  120750. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  120751. var renderPipeline = this._renderPipelines[renderPipelineName];
  120752. if (!renderPipeline) {
  120753. return;
  120754. }
  120755. renderPipeline._enableEffect(renderEffectName, cameras);
  120756. };
  120757. /**
  120758. * Disables an effect by name on a pipeline
  120759. * @param renderPipelineName the name of the pipeline to disable the effect in
  120760. * @param renderEffectName the name of the effect to disable
  120761. * @param cameras the cameras that the effect should be disabled on
  120762. */
  120763. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  120764. var renderPipeline = this._renderPipelines[renderPipelineName];
  120765. if (!renderPipeline) {
  120766. return;
  120767. }
  120768. renderPipeline._disableEffect(renderEffectName, cameras);
  120769. };
  120770. /**
  120771. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  120772. */
  120773. PostProcessRenderPipelineManager.prototype.update = function () {
  120774. for (var renderPipelineName in this._renderPipelines) {
  120775. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  120776. var pipeline = this._renderPipelines[renderPipelineName];
  120777. if (!pipeline.isSupported) {
  120778. pipeline.dispose();
  120779. delete this._renderPipelines[renderPipelineName];
  120780. }
  120781. else {
  120782. pipeline._update();
  120783. }
  120784. }
  120785. }
  120786. };
  120787. /** @hidden */
  120788. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  120789. for (var renderPipelineName in this._renderPipelines) {
  120790. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  120791. var pipeline = this._renderPipelines[renderPipelineName];
  120792. pipeline._rebuild();
  120793. }
  120794. }
  120795. };
  120796. /**
  120797. * Disposes of the manager and pipelines
  120798. */
  120799. PostProcessRenderPipelineManager.prototype.dispose = function () {
  120800. for (var renderPipelineName in this._renderPipelines) {
  120801. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  120802. var pipeline = this._renderPipelines[renderPipelineName];
  120803. pipeline.dispose();
  120804. }
  120805. }
  120806. };
  120807. return PostProcessRenderPipelineManager;
  120808. }());
  120809. /***/ }),
  120810. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  120811. /*!****************************************************************************************!*\
  120812. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  120813. \****************************************************************************************/
  120814. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  120815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120816. "use strict";
  120817. __webpack_require__.r(__webpack_exports__);
  120818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  120819. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  120820. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  120821. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  120822. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  120823. get: function () {
  120824. if (!this._postProcessRenderPipelineManager) {
  120825. // Register the G Buffer component to the scene.
  120826. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  120827. if (!component) {
  120828. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  120829. this._addComponent(component);
  120830. }
  120831. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  120832. }
  120833. return this._postProcessRenderPipelineManager;
  120834. },
  120835. enumerable: true,
  120836. configurable: true
  120837. });
  120838. /**
  120839. * Defines the Render Pipeline scene component responsible to rendering pipelines
  120840. */
  120841. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  120842. /**
  120843. * Creates a new instance of the component for the given scene
  120844. * @param scene Defines the scene to register the component in
  120845. */
  120846. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  120847. /**
  120848. * The component name helpfull to identify the component in the list of scene components.
  120849. */
  120850. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  120851. this.scene = scene;
  120852. }
  120853. /**
  120854. * Registers the component in a given scene
  120855. */
  120856. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  120857. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  120858. };
  120859. /**
  120860. * Rebuilds the elements related to this component in case of
  120861. * context lost for instance.
  120862. */
  120863. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  120864. if (this.scene._postProcessRenderPipelineManager) {
  120865. this.scene._postProcessRenderPipelineManager._rebuild();
  120866. }
  120867. };
  120868. /**
  120869. * Disposes the component and the associated ressources
  120870. */
  120871. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  120872. if (this.scene._postProcessRenderPipelineManager) {
  120873. this.scene._postProcessRenderPipelineManager.dispose();
  120874. }
  120875. };
  120876. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  120877. if (this.scene._postProcessRenderPipelineManager) {
  120878. this.scene._postProcessRenderPipelineManager.update();
  120879. }
  120880. };
  120881. return PostProcessRenderPipelineManagerSceneComponent;
  120882. }());
  120883. /***/ }),
  120884. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  120885. /*!**********************************************!*\
  120886. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  120887. \**********************************************/
  120888. /*! exports provided: AnaglyphPostProcess */
  120889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120890. "use strict";
  120891. __webpack_require__.r(__webpack_exports__);
  120892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  120893. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120894. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120895. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  120896. /**
  120897. * Postprocess used to generate anaglyphic rendering
  120898. */
  120899. var AnaglyphPostProcess = /** @class */ (function (_super) {
  120900. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  120901. /**
  120902. * Creates a new AnaglyphPostProcess
  120903. * @param name defines postprocess name
  120904. * @param options defines creation options or target ratio scale
  120905. * @param rigCameras defines cameras using this postprocess
  120906. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  120907. * @param engine defines hosting engine
  120908. * @param reusable defines if the postprocess will be reused multiple times per frame
  120909. */
  120910. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  120911. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  120912. _this._passedProcess = rigCameras[0]._rigPostProcess;
  120913. _this.onApplyObservable.add(function (effect) {
  120914. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  120915. });
  120916. return _this;
  120917. }
  120918. return AnaglyphPostProcess;
  120919. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  120920. /***/ }),
  120921. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  120922. /*!***************************************************!*\
  120923. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  120924. \***************************************************/
  120925. /*! exports provided: BlackAndWhitePostProcess */
  120926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120927. "use strict";
  120928. __webpack_require__.r(__webpack_exports__);
  120929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  120930. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120931. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120932. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  120933. /**
  120934. * Post process used to render in black and white
  120935. */
  120936. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  120937. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  120938. /**
  120939. * Creates a black and white post process
  120940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  120941. * @param name The name of the effect.
  120942. * @param options The required width/height ratio to downsize to before computing the render pass.
  120943. * @param camera The camera to apply the render pass to.
  120944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120945. * @param engine The engine which the post process will be applied. (default: current engine)
  120946. * @param reusable If the post process can be reused on the same frame. (default: false)
  120947. */
  120948. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  120949. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  120950. /**
  120951. * Linear about to convert he result to black and white (default: 1)
  120952. */
  120953. _this.degree = 1;
  120954. _this.onApplyObservable.add(function (effect) {
  120955. effect.setFloat("degree", _this.degree);
  120956. });
  120957. return _this;
  120958. }
  120959. return BlackAndWhitePostProcess;
  120960. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  120961. /***/ }),
  120962. /***/ "./PostProcesses/bloomEffect.ts":
  120963. /*!**************************************!*\
  120964. !*** ./PostProcesses/bloomEffect.ts ***!
  120965. \**************************************/
  120966. /*! exports provided: BloomEffect */
  120967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120968. "use strict";
  120969. __webpack_require__.r(__webpack_exports__);
  120970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  120971. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120972. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120973. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  120974. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  120975. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  120976. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120977. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120978. /**
  120979. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  120980. */
  120981. var BloomEffect = /** @class */ (function (_super) {
  120982. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  120983. /**
  120984. * Creates a new instance of @see BloomEffect
  120985. * @param scene The scene the effect belongs to.
  120986. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  120987. * @param bloomKernel The size of the kernel to be used when applying the blur.
  120988. * @param bloomWeight The the strength of bloom.
  120989. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120990. * @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)
  120991. */
  120992. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  120993. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  120994. if (blockCompilation === void 0) { blockCompilation = false; }
  120995. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  120996. return _this._effects;
  120997. }, true) || this;
  120998. _this.bloomScale = bloomScale;
  120999. /**
  121000. * @hidden Internal
  121001. */
  121002. _this._effects = [];
  121003. _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);
  121004. _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);
  121005. _this._blurX.alwaysForcePOT = true;
  121006. _this._blurX.autoClear = false;
  121007. _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);
  121008. _this._blurY.alwaysForcePOT = true;
  121009. _this._blurY.autoClear = false;
  121010. _this.kernel = bloomKernel;
  121011. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  121012. _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);
  121013. _this._merge.autoClear = false;
  121014. _this._effects.push(_this._merge);
  121015. return _this;
  121016. }
  121017. Object.defineProperty(BloomEffect.prototype, "threshold", {
  121018. /**
  121019. * The luminance threshold to find bright areas of the image to bloom.
  121020. */
  121021. get: function () {
  121022. return this._downscale.threshold;
  121023. },
  121024. set: function (value) {
  121025. this._downscale.threshold = value;
  121026. },
  121027. enumerable: true,
  121028. configurable: true
  121029. });
  121030. Object.defineProperty(BloomEffect.prototype, "weight", {
  121031. /**
  121032. * The strength of the bloom.
  121033. */
  121034. get: function () {
  121035. return this._merge.weight;
  121036. },
  121037. set: function (value) {
  121038. this._merge.weight = value;
  121039. },
  121040. enumerable: true,
  121041. configurable: true
  121042. });
  121043. Object.defineProperty(BloomEffect.prototype, "kernel", {
  121044. /**
  121045. * Specifies the size of the bloom blur kernel, relative to the final output size
  121046. */
  121047. get: function () {
  121048. return this._blurX.kernel / this.bloomScale;
  121049. },
  121050. set: function (value) {
  121051. this._blurX.kernel = value * this.bloomScale;
  121052. this._blurY.kernel = value * this.bloomScale;
  121053. },
  121054. enumerable: true,
  121055. configurable: true
  121056. });
  121057. /**
  121058. * Disposes each of the internal effects for a given camera.
  121059. * @param camera The camera to dispose the effect on.
  121060. */
  121061. BloomEffect.prototype.disposeEffects = function (camera) {
  121062. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121063. this._effects[effectIndex].dispose(camera);
  121064. }
  121065. };
  121066. /**
  121067. * @hidden Internal
  121068. */
  121069. BloomEffect.prototype._updateEffects = function () {
  121070. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121071. this._effects[effectIndex].updateEffect();
  121072. }
  121073. };
  121074. /**
  121075. * Internal
  121076. * @returns if all the contained post processes are ready.
  121077. * @hidden
  121078. */
  121079. BloomEffect.prototype._isReady = function () {
  121080. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121081. if (!this._effects[effectIndex].isReady()) {
  121082. return false;
  121083. }
  121084. }
  121085. return true;
  121086. };
  121087. return BloomEffect;
  121088. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  121089. /***/ }),
  121090. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  121091. /*!************************************************!*\
  121092. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  121093. \************************************************/
  121094. /*! exports provided: BloomMergePostProcess */
  121095. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121096. "use strict";
  121097. __webpack_require__.r(__webpack_exports__);
  121098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  121099. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121100. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121101. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121102. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  121103. /**
  121104. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121105. */
  121106. var BloomMergePostProcess = /** @class */ (function (_super) {
  121107. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  121108. /**
  121109. * Creates a new instance of @see BloomMergePostProcess
  121110. * @param name The name of the effect.
  121111. * @param originalFromInput Post process which's input will be used for the merge.
  121112. * @param blurred Blurred highlights post process which's output will be used.
  121113. * @param weight Weight of the bloom to be added to the original input.
  121114. * @param options The required width/height ratio to downsize to before computing the render pass.
  121115. * @param camera The camera to apply the render pass to.
  121116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121117. * @param engine The engine which the post process will be applied. (default: current engine)
  121118. * @param reusable If the post process can be reused on the same frame. (default: false)
  121119. * @param textureType Type of textures used when performing the post process. (default: 0)
  121120. * @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)
  121121. */
  121122. function BloomMergePostProcess(name, originalFromInput, blurred,
  121123. /** Weight of the bloom to be added to the original input. */
  121124. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121125. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121126. if (blockCompilation === void 0) { blockCompilation = false; }
  121127. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  121128. _this.weight = weight;
  121129. _this.onApplyObservable.add(function (effect) {
  121130. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  121131. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  121132. effect.setFloat("bloomWeight", _this.weight);
  121133. });
  121134. if (!blockCompilation) {
  121135. _this.updateEffect();
  121136. }
  121137. return _this;
  121138. }
  121139. return BloomMergePostProcess;
  121140. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121141. /***/ }),
  121142. /***/ "./PostProcesses/blurPostProcess.ts":
  121143. /*!******************************************!*\
  121144. !*** ./PostProcesses/blurPostProcess.ts ***!
  121145. \******************************************/
  121146. /*! exports provided: BlurPostProcess */
  121147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121148. "use strict";
  121149. __webpack_require__.r(__webpack_exports__);
  121150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  121151. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121152. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121153. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121154. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121155. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  121156. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  121157. /**
  121158. * The Blur Post Process which blurs an image based on a kernel and direction.
  121159. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  121160. */
  121161. var BlurPostProcess = /** @class */ (function (_super) {
  121162. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  121163. /**
  121164. * Creates a new instance BlurPostProcess
  121165. * @param name The name of the effect.
  121166. * @param direction The direction in which to blur the image.
  121167. * @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.
  121168. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  121169. * @param camera The camera to apply the render pass to.
  121170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121171. * @param engine The engine which the post process will be applied. (default: current engine)
  121172. * @param reusable If the post process can be reused on the same frame. (default: false)
  121173. * @param textureType Type of textures used when performing the post process. (default: 0)
  121174. * @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)
  121175. */
  121176. function BlurPostProcess(name,
  121177. /** The direction in which to blur the image. */
  121178. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  121179. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  121180. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121181. if (defines === void 0) { defines = ""; }
  121182. if (blockCompilation === void 0) { blockCompilation = false; }
  121183. 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;
  121184. _this.direction = direction;
  121185. _this.blockCompilation = blockCompilation;
  121186. _this._packedFloat = false;
  121187. _this._staticDefines = "";
  121188. _this._staticDefines = defines;
  121189. _this.onApplyObservable.add(function (effect) {
  121190. if (_this._outputTexture) {
  121191. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  121192. }
  121193. else {
  121194. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  121195. }
  121196. });
  121197. _this.kernel = kernel;
  121198. return _this;
  121199. }
  121200. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  121201. /**
  121202. * Gets the length in pixels of the blur sample region
  121203. */
  121204. get: function () {
  121205. return this._idealKernel;
  121206. },
  121207. /**
  121208. * Sets the length in pixels of the blur sample region
  121209. */
  121210. set: function (v) {
  121211. if (this._idealKernel === v) {
  121212. return;
  121213. }
  121214. v = Math.max(v, 1);
  121215. this._idealKernel = v;
  121216. this._kernel = this._nearestBestKernel(v);
  121217. if (!this.blockCompilation) {
  121218. this._updateParameters();
  121219. }
  121220. },
  121221. enumerable: true,
  121222. configurable: true
  121223. });
  121224. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  121225. /**
  121226. * Gets wether or not the blur is unpacking/repacking floats
  121227. */
  121228. get: function () {
  121229. return this._packedFloat;
  121230. },
  121231. /**
  121232. * Sets wether or not the blur needs to unpack/repack floats
  121233. */
  121234. set: function (v) {
  121235. if (this._packedFloat === v) {
  121236. return;
  121237. }
  121238. this._packedFloat = v;
  121239. if (!this.blockCompilation) {
  121240. this._updateParameters();
  121241. }
  121242. },
  121243. enumerable: true,
  121244. configurable: true
  121245. });
  121246. /**
  121247. * Updates the effect with the current post process compile time values and recompiles the shader.
  121248. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  121249. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  121250. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  121251. * @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
  121252. * @param onCompiled Called when the shader has been compiled.
  121253. * @param onError Called if there is an error when compiling a shader.
  121254. */
  121255. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  121256. if (defines === void 0) { defines = null; }
  121257. if (uniforms === void 0) { uniforms = null; }
  121258. if (samplers === void 0) { samplers = null; }
  121259. this._updateParameters(onCompiled, onError);
  121260. };
  121261. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  121262. // Generate sampling offsets and weights
  121263. var N = this._kernel;
  121264. var centerIndex = (N - 1) / 2;
  121265. // Generate Gaussian sampling weights over kernel
  121266. var offsets = [];
  121267. var weights = [];
  121268. var totalWeight = 0;
  121269. for (var i = 0; i < N; i++) {
  121270. var u = i / (N - 1);
  121271. var w = this._gaussianWeight(u * 2.0 - 1);
  121272. offsets[i] = (i - centerIndex);
  121273. weights[i] = w;
  121274. totalWeight += w;
  121275. }
  121276. // Normalize weights
  121277. for (var i = 0; i < weights.length; i++) {
  121278. weights[i] /= totalWeight;
  121279. }
  121280. // Optimize: combine samples to take advantage of hardware linear sampling
  121281. // Walk from left to center, combining pairs (symmetrically)
  121282. var linearSamplingWeights = [];
  121283. var linearSamplingOffsets = [];
  121284. var linearSamplingMap = [];
  121285. for (var i = 0; i <= centerIndex; i += 2) {
  121286. var j = Math.min(i + 1, Math.floor(centerIndex));
  121287. var singleCenterSample = i === j;
  121288. if (singleCenterSample) {
  121289. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  121290. }
  121291. else {
  121292. var sharedCell = j === centerIndex;
  121293. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  121294. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  121295. if (offsetLinear === 0) {
  121296. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  121297. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  121298. }
  121299. else {
  121300. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  121301. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  121302. }
  121303. }
  121304. }
  121305. for (var i = 0; i < linearSamplingMap.length; i++) {
  121306. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  121307. linearSamplingWeights[i] = linearSamplingMap[i].w;
  121308. }
  121309. // Replace with optimized
  121310. offsets = linearSamplingOffsets;
  121311. weights = linearSamplingWeights;
  121312. // Generate shaders
  121313. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  121314. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  121315. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  121316. var defines = "";
  121317. defines += this._staticDefines;
  121318. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  121319. if (this._staticDefines.indexOf("DOF") != -1) {
  121320. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  121321. varyingCount--;
  121322. }
  121323. for (var i = 0; i < varyingCount; i++) {
  121324. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  121325. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  121326. }
  121327. var depCount = 0;
  121328. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  121329. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  121330. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  121331. depCount++;
  121332. }
  121333. if (this.packedFloat) {
  121334. defines += "#define PACKEDFLOAT 1";
  121335. }
  121336. this.blockCompilation = false;
  121337. _super.prototype.updateEffect.call(this, defines, null, null, {
  121338. varyingCount: varyingCount,
  121339. depCount: depCount
  121340. }, onCompiled, onError);
  121341. };
  121342. /**
  121343. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  121344. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  121345. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  121346. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  121347. * The gaps between physical kernels are compensated for in the weighting of the samples
  121348. * @param idealKernel Ideal blur kernel.
  121349. * @return Nearest best kernel.
  121350. */
  121351. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  121352. var v = Math.round(idealKernel);
  121353. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  121354. var k = _a[_i];
  121355. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  121356. return Math.max(k, 3);
  121357. }
  121358. }
  121359. return Math.max(v, 3);
  121360. };
  121361. /**
  121362. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  121363. * @param x The point on the Gaussian distribution to sample.
  121364. * @return the value of the Gaussian function at x.
  121365. */
  121366. BlurPostProcess.prototype._gaussianWeight = function (x) {
  121367. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  121368. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  121369. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  121370. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  121371. // truncated at around 1.3% of peak strength.
  121372. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  121373. var sigma = (1 / 3);
  121374. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  121375. var exponent = -((x * x) / (2.0 * sigma * sigma));
  121376. var weight = (1.0 / denominator) * Math.exp(exponent);
  121377. return weight;
  121378. };
  121379. /**
  121380. * Generates a string that can be used as a floating point number in GLSL.
  121381. * @param x Value to print.
  121382. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  121383. * @return GLSL float string.
  121384. */
  121385. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  121386. if (decimalFigures === void 0) { decimalFigures = 8; }
  121387. return x.toFixed(decimalFigures).replace(/0+$/, '');
  121388. };
  121389. return BlurPostProcess;
  121390. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121391. /***/ }),
  121392. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  121393. /*!*********************************************************!*\
  121394. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  121395. \*********************************************************/
  121396. /*! exports provided: ChromaticAberrationPostProcess */
  121397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121398. "use strict";
  121399. __webpack_require__.r(__webpack_exports__);
  121400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  121401. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121402. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121403. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121404. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121405. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  121406. /**
  121407. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  121408. */
  121409. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  121410. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  121411. /**
  121412. * Creates a new instance ChromaticAberrationPostProcess
  121413. * @param name The name of the effect.
  121414. * @param screenWidth The width of the screen to apply the effect on.
  121415. * @param screenHeight The height of the screen to apply the effect on.
  121416. * @param options The required width/height ratio to downsize to before computing the render pass.
  121417. * @param camera The camera to apply the render pass to.
  121418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121419. * @param engine The engine which the post process will be applied. (default: current engine)
  121420. * @param reusable If the post process can be reused on the same frame. (default: false)
  121421. * @param textureType Type of textures used when performing the post process. (default: 0)
  121422. * @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)
  121423. */
  121424. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121425. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121426. if (blockCompilation === void 0) { blockCompilation = false; }
  121427. 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;
  121428. /**
  121429. * The amount of seperation of rgb channels (default: 30)
  121430. */
  121431. _this.aberrationAmount = 30;
  121432. /**
  121433. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  121434. */
  121435. _this.radialIntensity = 0;
  121436. /**
  121437. * 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))
  121438. */
  121439. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  121440. /**
  121441. * 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))
  121442. */
  121443. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  121444. _this.onApplyObservable.add(function (effect) {
  121445. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  121446. effect.setFloat('screen_width', screenWidth);
  121447. effect.setFloat('screen_height', screenHeight);
  121448. effect.setFloat('radialIntensity', _this.radialIntensity);
  121449. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  121450. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  121451. });
  121452. return _this;
  121453. }
  121454. return ChromaticAberrationPostProcess;
  121455. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  121456. /***/ }),
  121457. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  121458. /*!*******************************************************!*\
  121459. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  121460. \*******************************************************/
  121461. /*! exports provided: CircleOfConfusionPostProcess */
  121462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121463. "use strict";
  121464. __webpack_require__.r(__webpack_exports__);
  121465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  121466. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121467. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121468. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  121469. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121470. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  121471. /**
  121472. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  121473. */
  121474. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  121475. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  121476. /**
  121477. * Creates a new instance CircleOfConfusionPostProcess
  121478. * @param name The name of the effect.
  121479. * @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.
  121480. * @param options The required width/height ratio to downsize to before computing the render pass.
  121481. * @param camera The camera to apply the render pass to.
  121482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121483. * @param engine The engine which the post process will be applied. (default: current engine)
  121484. * @param reusable If the post process can be reused on the same frame. (default: false)
  121485. * @param textureType Type of textures used when performing the post process. (default: 0)
  121486. * @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)
  121487. */
  121488. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121489. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121490. if (blockCompilation === void 0) { blockCompilation = false; }
  121491. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  121492. /**
  121493. * 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.
  121494. */
  121495. _this.lensSize = 50;
  121496. /**
  121497. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121498. */
  121499. _this.fStop = 1.4;
  121500. /**
  121501. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121502. */
  121503. _this.focusDistance = 2000;
  121504. /**
  121505. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  121506. */
  121507. _this.focalLength = 50;
  121508. _this._depthTexture = null;
  121509. _this._depthTexture = depthTexture;
  121510. _this.onApplyObservable.add(function (effect) {
  121511. if (!_this._depthTexture) {
  121512. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  121513. return;
  121514. }
  121515. effect.setTexture("depthSampler", _this._depthTexture);
  121516. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  121517. var aperture = _this.lensSize / _this.fStop;
  121518. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  121519. effect.setFloat('focusDistance', _this.focusDistance);
  121520. effect.setFloat('cocPrecalculation', cocPrecalculation);
  121521. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  121522. });
  121523. return _this;
  121524. }
  121525. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  121526. /**
  121527. * 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.
  121528. */
  121529. set: function (value) {
  121530. this._depthTexture = value;
  121531. },
  121532. enumerable: true,
  121533. configurable: true
  121534. });
  121535. return CircleOfConfusionPostProcess;
  121536. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121537. /***/ }),
  121538. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  121539. /*!*****************************************************!*\
  121540. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  121541. \*****************************************************/
  121542. /*! exports provided: ColorCorrectionPostProcess */
  121543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121544. "use strict";
  121545. __webpack_require__.r(__webpack_exports__);
  121546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  121547. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121548. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121549. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121550. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  121551. /**
  121552. *
  121553. * This post-process allows the modification of rendered colors by using
  121554. * a 'look-up table' (LUT). This effect is also called Color Grading.
  121555. *
  121556. * The object needs to be provided an url to a texture containing the color
  121557. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  121558. * Use an image editing software to tweak the LUT to match your needs.
  121559. *
  121560. * For an example of a color LUT, see here:
  121561. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  121562. * For explanations on color grading, see here:
  121563. * @see http://udn.epicgames.com/Three/ColorGrading.html
  121564. *
  121565. */
  121566. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  121567. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  121568. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  121569. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  121570. _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);
  121571. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  121572. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  121573. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  121574. _this.onApply = function (effect) {
  121575. effect.setTexture("colorTable", _this._colorTableTexture);
  121576. };
  121577. return _this;
  121578. }
  121579. return ColorCorrectionPostProcess;
  121580. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121581. /***/ }),
  121582. /***/ "./PostProcesses/convolutionPostProcess.ts":
  121583. /*!*************************************************!*\
  121584. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  121585. \*************************************************/
  121586. /*! exports provided: ConvolutionPostProcess */
  121587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121588. "use strict";
  121589. __webpack_require__.r(__webpack_exports__);
  121590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  121591. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121592. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121593. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121594. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  121595. /**
  121596. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  121597. * input texture to perform effects such as edge detection or sharpening
  121598. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121599. */
  121600. var ConvolutionPostProcess = /** @class */ (function (_super) {
  121601. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  121602. /**
  121603. * Creates a new instance ConvolutionPostProcess
  121604. * @param name The name of the effect.
  121605. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  121606. * @param options The required width/height ratio to downsize to before computing the render pass.
  121607. * @param camera The camera to apply the render pass to.
  121608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121609. * @param engine The engine which the post process will be applied. (default: current engine)
  121610. * @param reusable If the post process can be reused on the same frame. (default: false)
  121611. * @param textureType Type of textures used when performing the post process. (default: 0)
  121612. */
  121613. function ConvolutionPostProcess(name,
  121614. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  121615. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  121616. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121617. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  121618. _this.kernel = kernel;
  121619. _this.onApply = function (effect) {
  121620. effect.setFloat2("screenSize", _this.width, _this.height);
  121621. effect.setArray("kernel", _this.kernel);
  121622. };
  121623. return _this;
  121624. }
  121625. // Statics
  121626. /**
  121627. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121628. */
  121629. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  121630. /**
  121631. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121632. */
  121633. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  121634. /**
  121635. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121636. */
  121637. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  121638. /**
  121639. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121640. */
  121641. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  121642. /**
  121643. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121644. */
  121645. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  121646. /**
  121647. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121648. */
  121649. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  121650. return ConvolutionPostProcess;
  121651. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121652. /***/ }),
  121653. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  121654. /*!******************************************************!*\
  121655. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  121656. \******************************************************/
  121657. /*! exports provided: DepthOfFieldBlurPostProcess */
  121658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121659. "use strict";
  121660. __webpack_require__.r(__webpack_exports__);
  121661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  121662. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121663. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121664. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  121665. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121666. /**
  121667. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  121668. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  121669. * based on samples that have a large difference in distance than the center pixel.
  121670. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121671. */
  121672. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  121673. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  121674. /**
  121675. * Creates a new instance CircleOfConfusionPostProcess
  121676. * @param name The name of the effect.
  121677. * @param scene The scene the effect belongs to.
  121678. * @param direction The direction the blur should be applied.
  121679. * @param kernel The size of the kernel used to blur.
  121680. * @param options The required width/height ratio to downsize to before computing the render pass.
  121681. * @param camera The camera to apply the render pass to.
  121682. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  121683. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  121684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121685. * @param engine The engine which the post process will be applied. (default: current engine)
  121686. * @param reusable If the post process can be reused on the same frame. (default: false)
  121687. * @param textureType Type of textures used when performing the post process. (default: 0)
  121688. * @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)
  121689. */
  121690. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  121691. if (imageToBlur === void 0) { imageToBlur = null; }
  121692. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  121693. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121694. if (blockCompilation === void 0) { blockCompilation = false; }
  121695. 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;
  121696. _this.direction = direction;
  121697. _this.onApplyObservable.add(function (effect) {
  121698. if (imageToBlur != null) {
  121699. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  121700. }
  121701. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  121702. if (scene.activeCamera) {
  121703. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  121704. }
  121705. });
  121706. return _this;
  121707. }
  121708. return DepthOfFieldBlurPostProcess;
  121709. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  121710. /***/ }),
  121711. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  121712. /*!*********************************************!*\
  121713. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  121714. \*********************************************/
  121715. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  121716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121717. "use strict";
  121718. __webpack_require__.r(__webpack_exports__);
  121719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  121720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  121721. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121722. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121723. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121724. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  121725. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  121726. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  121727. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  121728. /**
  121729. * Specifies the level of max blur that should be applied when using the depth of field effect
  121730. */
  121731. var DepthOfFieldEffectBlurLevel;
  121732. (function (DepthOfFieldEffectBlurLevel) {
  121733. /**
  121734. * Subtle blur
  121735. */
  121736. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  121737. /**
  121738. * Medium blur
  121739. */
  121740. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  121741. /**
  121742. * Large blur
  121743. */
  121744. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  121745. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  121746. /**
  121747. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  121748. */
  121749. var DepthOfFieldEffect = /** @class */ (function (_super) {
  121750. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  121751. /**
  121752. * Creates a new instance DepthOfFieldEffect
  121753. * @param scene The scene the effect belongs to.
  121754. * @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.
  121755. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121756. * @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)
  121757. */
  121758. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  121759. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  121760. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  121761. if (blockCompilation === void 0) { blockCompilation = false; }
  121762. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  121763. return _this._effects;
  121764. }, true) || this;
  121765. /**
  121766. * @hidden Internal post processes in depth of field effect
  121767. */
  121768. _this._effects = [];
  121769. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  121770. _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);
  121771. // 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)
  121772. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  121773. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121774. _this._depthOfFieldBlurY = [];
  121775. _this._depthOfFieldBlurX = [];
  121776. var blurCount = 1;
  121777. var kernelSize = 15;
  121778. switch (blurLevel) {
  121779. case DepthOfFieldEffectBlurLevel.High: {
  121780. blurCount = 3;
  121781. kernelSize = 51;
  121782. break;
  121783. }
  121784. case DepthOfFieldEffectBlurLevel.Medium: {
  121785. blurCount = 2;
  121786. kernelSize = 31;
  121787. break;
  121788. }
  121789. default: {
  121790. kernelSize = 15;
  121791. blurCount = 1;
  121792. break;
  121793. }
  121794. }
  121795. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  121796. var ratio = 1.0;
  121797. for (var i = 0; i < blurCount; i++) {
  121798. 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);
  121799. blurY.autoClear = false;
  121800. ratio = 0.75 / Math.pow(2, i);
  121801. 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);
  121802. blurX.autoClear = false;
  121803. _this._depthOfFieldBlurY.push(blurY);
  121804. _this._depthOfFieldBlurX.push(blurX);
  121805. }
  121806. // Set all post processes on the effect.
  121807. _this._effects = [_this._circleOfConfusion];
  121808. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  121809. _this._effects.push(_this._depthOfFieldBlurY[i]);
  121810. _this._effects.push(_this._depthOfFieldBlurX[i]);
  121811. }
  121812. // Merge blurred images with original image based on circleOfConfusion
  121813. _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);
  121814. _this._dofMerge.autoClear = false;
  121815. _this._effects.push(_this._dofMerge);
  121816. return _this;
  121817. }
  121818. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  121819. get: function () {
  121820. return this._circleOfConfusion.focalLength;
  121821. },
  121822. /**
  121823. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  121824. */
  121825. set: function (value) {
  121826. this._circleOfConfusion.focalLength = value;
  121827. },
  121828. enumerable: true,
  121829. configurable: true
  121830. });
  121831. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  121832. get: function () {
  121833. return this._circleOfConfusion.fStop;
  121834. },
  121835. /**
  121836. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121837. */
  121838. set: function (value) {
  121839. this._circleOfConfusion.fStop = value;
  121840. },
  121841. enumerable: true,
  121842. configurable: true
  121843. });
  121844. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  121845. get: function () {
  121846. return this._circleOfConfusion.focusDistance;
  121847. },
  121848. /**
  121849. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121850. */
  121851. set: function (value) {
  121852. this._circleOfConfusion.focusDistance = value;
  121853. },
  121854. enumerable: true,
  121855. configurable: true
  121856. });
  121857. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  121858. get: function () {
  121859. return this._circleOfConfusion.lensSize;
  121860. },
  121861. /**
  121862. * 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.
  121863. */
  121864. set: function (value) {
  121865. this._circleOfConfusion.lensSize = value;
  121866. },
  121867. enumerable: true,
  121868. configurable: true
  121869. });
  121870. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  121871. /**
  121872. * 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.
  121873. */
  121874. set: function (value) {
  121875. this._circleOfConfusion.depthTexture = value;
  121876. },
  121877. enumerable: true,
  121878. configurable: true
  121879. });
  121880. /**
  121881. * Disposes each of the internal effects for a given camera.
  121882. * @param camera The camera to dispose the effect on.
  121883. */
  121884. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  121885. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121886. this._effects[effectIndex].dispose(camera);
  121887. }
  121888. };
  121889. /**
  121890. * @hidden Internal
  121891. */
  121892. DepthOfFieldEffect.prototype._updateEffects = function () {
  121893. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121894. this._effects[effectIndex].updateEffect();
  121895. }
  121896. };
  121897. /**
  121898. * Internal
  121899. * @returns if all the contained post processes are ready.
  121900. * @hidden
  121901. */
  121902. DepthOfFieldEffect.prototype._isReady = function () {
  121903. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121904. if (!this._effects[effectIndex].isReady()) {
  121905. return false;
  121906. }
  121907. }
  121908. return true;
  121909. };
  121910. return DepthOfFieldEffect;
  121911. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  121912. /***/ }),
  121913. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  121914. /*!*******************************************************!*\
  121915. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  121916. \*******************************************************/
  121917. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  121918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121919. "use strict";
  121920. __webpack_require__.r(__webpack_exports__);
  121921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  121922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  121923. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121924. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121925. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121926. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  121927. /**
  121928. * Options to be set when merging outputs from the default pipeline.
  121929. */
  121930. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  121931. function DepthOfFieldMergePostProcessOptions() {
  121932. }
  121933. return DepthOfFieldMergePostProcessOptions;
  121934. }());
  121935. /**
  121936. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121937. */
  121938. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  121939. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  121940. /**
  121941. * Creates a new instance of DepthOfFieldMergePostProcess
  121942. * @param name The name of the effect.
  121943. * @param originalFromInput Post process which's input will be used for the merge.
  121944. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  121945. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  121946. * @param options The required width/height ratio to downsize to before computing the render pass.
  121947. * @param camera The camera to apply the render pass to.
  121948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121949. * @param engine The engine which the post process will be applied. (default: current engine)
  121950. * @param reusable If the post process can be reused on the same frame. (default: false)
  121951. * @param textureType Type of textures used when performing the post process. (default: 0)
  121952. * @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)
  121953. */
  121954. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121955. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121956. if (blockCompilation === void 0) { blockCompilation = false; }
  121957. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  121958. _this.blurSteps = blurSteps;
  121959. _this.onApplyObservable.add(function (effect) {
  121960. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  121961. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  121962. blurSteps.forEach(function (step, index) {
  121963. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  121964. });
  121965. });
  121966. if (!blockCompilation) {
  121967. _this.updateEffect();
  121968. }
  121969. return _this;
  121970. }
  121971. /**
  121972. * Updates the effect with the current post process compile time values and recompiles the shader.
  121973. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  121974. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  121975. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  121976. * @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
  121977. * @param onCompiled Called when the shader has been compiled.
  121978. * @param onError Called if there is an error when compiling a shader.
  121979. */
  121980. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  121981. if (defines === void 0) { defines = null; }
  121982. if (uniforms === void 0) { uniforms = null; }
  121983. if (samplers === void 0) { samplers = null; }
  121984. if (!defines) {
  121985. defines = "";
  121986. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  121987. }
  121988. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  121989. };
  121990. return DepthOfFieldMergePostProcess;
  121991. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121992. /***/ }),
  121993. /***/ "./PostProcesses/displayPassPostProcess.ts":
  121994. /*!*************************************************!*\
  121995. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  121996. \*************************************************/
  121997. /*! exports provided: DisplayPassPostProcess */
  121998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121999. "use strict";
  122000. __webpack_require__.r(__webpack_exports__);
  122001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  122002. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122003. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122004. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  122005. /**
  122006. * DisplayPassPostProcess which produces an output the same as it's input
  122007. */
  122008. var DisplayPassPostProcess = /** @class */ (function (_super) {
  122009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  122010. /**
  122011. * Creates the DisplayPassPostProcess
  122012. * @param name The name of the effect.
  122013. * @param options The required width/height ratio to downsize to before computing the render pass.
  122014. * @param camera The camera to apply the render pass to.
  122015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122016. * @param engine The engine which the post process will be applied. (default: current engine)
  122017. * @param reusable If the post process can be reused on the same frame. (default: false)
  122018. */
  122019. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  122020. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  122021. }
  122022. return DisplayPassPostProcess;
  122023. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122024. /***/ }),
  122025. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  122026. /*!*******************************************************!*\
  122027. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  122028. \*******************************************************/
  122029. /*! exports provided: ExtractHighlightsPostProcess */
  122030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122031. "use strict";
  122032. __webpack_require__.r(__webpack_exports__);
  122033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  122034. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122035. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122037. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122038. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  122039. /**
  122040. * 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.
  122041. */
  122042. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  122043. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  122044. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122045. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122046. if (blockCompilation === void 0) { blockCompilation = false; }
  122047. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  122048. /**
  122049. * The luminance threshold, pixels below this value will be set to black.
  122050. */
  122051. _this.threshold = 0.9;
  122052. /** @hidden */
  122053. _this._exposure = 1;
  122054. /**
  122055. * Post process which has the input texture to be used when performing highlight extraction
  122056. * @hidden
  122057. */
  122058. _this._inputPostProcess = null;
  122059. _this.onApplyObservable.add(function (effect) {
  122060. if (_this._inputPostProcess) {
  122061. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  122062. }
  122063. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  122064. effect.setFloat('exposure', _this._exposure);
  122065. });
  122066. return _this;
  122067. }
  122068. return ExtractHighlightsPostProcess;
  122069. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122070. /***/ }),
  122071. /***/ "./PostProcesses/filterPostProcess.ts":
  122072. /*!********************************************!*\
  122073. !*** ./PostProcesses/filterPostProcess.ts ***!
  122074. \********************************************/
  122075. /*! exports provided: FilterPostProcess */
  122076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122077. "use strict";
  122078. __webpack_require__.r(__webpack_exports__);
  122079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  122080. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122081. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122082. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  122083. /**
  122084. * Applies a kernel filter to the image
  122085. */
  122086. var FilterPostProcess = /** @class */ (function (_super) {
  122087. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  122088. /**
  122089. *
  122090. * @param name The name of the effect.
  122091. * @param kernelMatrix The matrix to be applied to the image
  122092. * @param options The required width/height ratio to downsize to before computing the render pass.
  122093. * @param camera The camera to apply the render pass to.
  122094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122095. * @param engine The engine which the post process will be applied. (default: current engine)
  122096. * @param reusable If the post process can be reused on the same frame. (default: false)
  122097. */
  122098. function FilterPostProcess(name,
  122099. /** The matrix to be applied to the image */
  122100. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  122101. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  122102. _this.kernelMatrix = kernelMatrix;
  122103. _this.onApply = function (effect) {
  122104. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  122105. };
  122106. return _this;
  122107. }
  122108. return FilterPostProcess;
  122109. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122110. /***/ }),
  122111. /***/ "./PostProcesses/fxaaPostProcess.ts":
  122112. /*!******************************************!*\
  122113. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  122114. \******************************************/
  122115. /*! exports provided: FxaaPostProcess */
  122116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122117. "use strict";
  122118. __webpack_require__.r(__webpack_exports__);
  122119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  122120. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122121. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122122. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122123. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122124. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  122125. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  122126. /**
  122127. * Fxaa post process
  122128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  122129. */
  122130. var FxaaPostProcess = /** @class */ (function (_super) {
  122131. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  122132. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  122133. if (camera === void 0) { camera = null; }
  122134. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122135. 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;
  122136. var defines = _this._getDefines();
  122137. _this.updateEffect(defines);
  122138. _this.onApplyObservable.add(function (effect) {
  122139. var texelSize = _this.texelSize;
  122140. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  122141. });
  122142. return _this;
  122143. }
  122144. FxaaPostProcess.prototype._getDefines = function () {
  122145. var engine = this.getEngine();
  122146. if (!engine) {
  122147. return null;
  122148. }
  122149. var glInfo = engine.getGlInfo();
  122150. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  122151. return "#define MALI 1\n";
  122152. }
  122153. return null;
  122154. };
  122155. return FxaaPostProcess;
  122156. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  122157. /***/ }),
  122158. /***/ "./PostProcesses/grainPostProcess.ts":
  122159. /*!*******************************************!*\
  122160. !*** ./PostProcesses/grainPostProcess.ts ***!
  122161. \*******************************************/
  122162. /*! exports provided: GrainPostProcess */
  122163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122164. "use strict";
  122165. __webpack_require__.r(__webpack_exports__);
  122166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  122167. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122168. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122169. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122170. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  122171. /**
  122172. * The GrainPostProcess adds noise to the image at mid luminance levels
  122173. */
  122174. var GrainPostProcess = /** @class */ (function (_super) {
  122175. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  122176. /**
  122177. * Creates a new instance of @see GrainPostProcess
  122178. * @param name The name of the effect.
  122179. * @param options The required width/height ratio to downsize to before computing the render pass.
  122180. * @param camera The camera to apply the render pass to.
  122181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122182. * @param engine The engine which the post process will be applied. (default: current engine)
  122183. * @param reusable If the post process can be reused on the same frame. (default: false)
  122184. * @param textureType Type of textures used when performing the post process. (default: 0)
  122185. * @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)
  122186. */
  122187. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122188. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122189. if (blockCompilation === void 0) { blockCompilation = false; }
  122190. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  122191. /**
  122192. * The intensity of the grain added (default: 30)
  122193. */
  122194. _this.intensity = 30;
  122195. /**
  122196. * If the grain should be randomized on every frame
  122197. */
  122198. _this.animated = false;
  122199. _this.onApplyObservable.add(function (effect) {
  122200. effect.setFloat('intensity', _this.intensity);
  122201. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  122202. });
  122203. return _this;
  122204. }
  122205. return GrainPostProcess;
  122206. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122207. /***/ }),
  122208. /***/ "./PostProcesses/highlightsPostProcess.ts":
  122209. /*!************************************************!*\
  122210. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  122211. \************************************************/
  122212. /*! exports provided: HighlightsPostProcess */
  122213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122214. "use strict";
  122215. __webpack_require__.r(__webpack_exports__);
  122216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  122217. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122218. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122219. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122220. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  122221. /**
  122222. * Extracts highlights from the image
  122223. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122224. */
  122225. var HighlightsPostProcess = /** @class */ (function (_super) {
  122226. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  122227. /**
  122228. * Extracts highlights from the image
  122229. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122230. * @param name The name of the effect.
  122231. * @param options The required width/height ratio to downsize to before computing the render pass.
  122232. * @param camera The camera to apply the render pass to.
  122233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122234. * @param engine The engine which the post process will be applied. (default: current engine)
  122235. * @param reusable If the post process can be reused on the same frame. (default: false)
  122236. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  122237. */
  122238. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  122239. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122240. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  122241. }
  122242. return HighlightsPostProcess;
  122243. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122244. /***/ }),
  122245. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  122246. /*!*****************************************************!*\
  122247. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  122248. \*****************************************************/
  122249. /*! exports provided: ImageProcessingPostProcess */
  122250. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122251. "use strict";
  122252. __webpack_require__.r(__webpack_exports__);
  122253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  122254. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122255. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  122256. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  122257. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122258. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  122259. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122260. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  122261. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  122262. /**
  122263. * ImageProcessingPostProcess
  122264. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  122265. */
  122266. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  122267. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  122268. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  122269. if (camera === void 0) { camera = null; }
  122270. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122271. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  122272. _this._fromLinearSpace = true;
  122273. /**
  122274. * Defines cache preventing GC.
  122275. */
  122276. _this._defines = {
  122277. IMAGEPROCESSING: false,
  122278. VIGNETTE: false,
  122279. VIGNETTEBLENDMODEMULTIPLY: false,
  122280. VIGNETTEBLENDMODEOPAQUE: false,
  122281. TONEMAPPING: false,
  122282. TONEMAPPING_ACES: false,
  122283. CONTRAST: false,
  122284. COLORCURVES: false,
  122285. COLORGRADING: false,
  122286. COLORGRADING3D: false,
  122287. FROMLINEARSPACE: false,
  122288. SAMPLER3DGREENDEPTH: false,
  122289. SAMPLER3DBGRMAP: false,
  122290. IMAGEPROCESSINGPOSTPROCESS: false,
  122291. EXPOSURE: false,
  122292. };
  122293. // Setup the configuration as forced by the constructor. This would then not force the
  122294. // scene materials output in linear space and let untouched the default forward pass.
  122295. if (imageProcessingConfiguration) {
  122296. imageProcessingConfiguration.applyByPostProcess = true;
  122297. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  122298. // This will cause the shader to be compiled
  122299. _this.fromLinearSpace = false;
  122300. }
  122301. // Setup the default processing configuration to the scene.
  122302. else {
  122303. _this._attachImageProcessingConfiguration(null, true);
  122304. _this.imageProcessingConfiguration.applyByPostProcess = true;
  122305. }
  122306. _this.onApply = function (effect) {
  122307. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  122308. };
  122309. return _this;
  122310. }
  122311. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  122312. /**
  122313. * Gets the image processing configuration used either in this material.
  122314. */
  122315. get: function () {
  122316. return this._imageProcessingConfiguration;
  122317. },
  122318. /**
  122319. * Sets the Default image processing configuration used either in the this material.
  122320. *
  122321. * If sets to null, the scene one is in use.
  122322. */
  122323. set: function (value) {
  122324. this._attachImageProcessingConfiguration(value);
  122325. },
  122326. enumerable: true,
  122327. configurable: true
  122328. });
  122329. /**
  122330. * Attaches a new image processing configuration to the PBR Material.
  122331. * @param configuration
  122332. */
  122333. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  122334. var _this = this;
  122335. if (doNotBuild === void 0) { doNotBuild = false; }
  122336. if (configuration === this._imageProcessingConfiguration) {
  122337. return;
  122338. }
  122339. // Detaches observer.
  122340. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  122341. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  122342. }
  122343. // Pick the scene configuration if needed.
  122344. if (!configuration) {
  122345. var scene = null;
  122346. var engine = this.getEngine();
  122347. var camera = this.getCamera();
  122348. if (camera) {
  122349. scene = camera.getScene();
  122350. }
  122351. else if (engine && engine.scenes) {
  122352. var scenes = engine.scenes;
  122353. scene = scenes[scenes.length - 1];
  122354. }
  122355. else {
  122356. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  122357. }
  122358. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  122359. }
  122360. else {
  122361. this._imageProcessingConfiguration = configuration;
  122362. }
  122363. // Attaches observer.
  122364. if (this._imageProcessingConfiguration) {
  122365. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  122366. _this._updateParameters();
  122367. });
  122368. }
  122369. // Ensure the effect will be rebuilt.
  122370. if (!doNotBuild) {
  122371. this._updateParameters();
  122372. }
  122373. };
  122374. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  122375. /**
  122376. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122377. */
  122378. get: function () {
  122379. return this.imageProcessingConfiguration.colorCurves;
  122380. },
  122381. /**
  122382. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122383. */
  122384. set: function (value) {
  122385. this.imageProcessingConfiguration.colorCurves = value;
  122386. },
  122387. enumerable: true,
  122388. configurable: true
  122389. });
  122390. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  122391. /**
  122392. * Gets wether the color curves effect is enabled.
  122393. */
  122394. get: function () {
  122395. return this.imageProcessingConfiguration.colorCurvesEnabled;
  122396. },
  122397. /**
  122398. * Sets wether the color curves effect is enabled.
  122399. */
  122400. set: function (value) {
  122401. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  122402. },
  122403. enumerable: true,
  122404. configurable: true
  122405. });
  122406. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  122407. /**
  122408. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122409. */
  122410. get: function () {
  122411. return this.imageProcessingConfiguration.colorGradingTexture;
  122412. },
  122413. /**
  122414. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122415. */
  122416. set: function (value) {
  122417. this.imageProcessingConfiguration.colorGradingTexture = value;
  122418. },
  122419. enumerable: true,
  122420. configurable: true
  122421. });
  122422. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  122423. /**
  122424. * Gets wether the color grading effect is enabled.
  122425. */
  122426. get: function () {
  122427. return this.imageProcessingConfiguration.colorGradingEnabled;
  122428. },
  122429. /**
  122430. * Gets wether the color grading effect is enabled.
  122431. */
  122432. set: function (value) {
  122433. this.imageProcessingConfiguration.colorGradingEnabled = value;
  122434. },
  122435. enumerable: true,
  122436. configurable: true
  122437. });
  122438. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  122439. /**
  122440. * Gets exposure used in the effect.
  122441. */
  122442. get: function () {
  122443. return this.imageProcessingConfiguration.exposure;
  122444. },
  122445. /**
  122446. * Sets exposure used in the effect.
  122447. */
  122448. set: function (value) {
  122449. this.imageProcessingConfiguration.exposure = value;
  122450. },
  122451. enumerable: true,
  122452. configurable: true
  122453. });
  122454. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  122455. /**
  122456. * Gets wether tonemapping is enabled or not.
  122457. */
  122458. get: function () {
  122459. return this._imageProcessingConfiguration.toneMappingEnabled;
  122460. },
  122461. /**
  122462. * Sets wether tonemapping is enabled or not
  122463. */
  122464. set: function (value) {
  122465. this._imageProcessingConfiguration.toneMappingEnabled = value;
  122466. },
  122467. enumerable: true,
  122468. configurable: true
  122469. });
  122470. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  122471. /**
  122472. * Gets the type of tone mapping effect.
  122473. */
  122474. get: function () {
  122475. return this._imageProcessingConfiguration.toneMappingType;
  122476. },
  122477. /**
  122478. * Sets the type of tone mapping effect.
  122479. */
  122480. set: function (value) {
  122481. this._imageProcessingConfiguration.toneMappingType = value;
  122482. },
  122483. enumerable: true,
  122484. configurable: true
  122485. });
  122486. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  122487. /**
  122488. * Gets contrast used in the effect.
  122489. */
  122490. get: function () {
  122491. return this.imageProcessingConfiguration.contrast;
  122492. },
  122493. /**
  122494. * Sets contrast used in the effect.
  122495. */
  122496. set: function (value) {
  122497. this.imageProcessingConfiguration.contrast = value;
  122498. },
  122499. enumerable: true,
  122500. configurable: true
  122501. });
  122502. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  122503. /**
  122504. * Gets Vignette stretch size.
  122505. */
  122506. get: function () {
  122507. return this.imageProcessingConfiguration.vignetteStretch;
  122508. },
  122509. /**
  122510. * Sets Vignette stretch size.
  122511. */
  122512. set: function (value) {
  122513. this.imageProcessingConfiguration.vignetteStretch = value;
  122514. },
  122515. enumerable: true,
  122516. configurable: true
  122517. });
  122518. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  122519. /**
  122520. * Gets Vignette centre X Offset.
  122521. */
  122522. get: function () {
  122523. return this.imageProcessingConfiguration.vignetteCentreX;
  122524. },
  122525. /**
  122526. * Sets Vignette centre X Offset.
  122527. */
  122528. set: function (value) {
  122529. this.imageProcessingConfiguration.vignetteCentreX = value;
  122530. },
  122531. enumerable: true,
  122532. configurable: true
  122533. });
  122534. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  122535. /**
  122536. * Gets Vignette centre Y Offset.
  122537. */
  122538. get: function () {
  122539. return this.imageProcessingConfiguration.vignetteCentreY;
  122540. },
  122541. /**
  122542. * Sets Vignette centre Y Offset.
  122543. */
  122544. set: function (value) {
  122545. this.imageProcessingConfiguration.vignetteCentreY = value;
  122546. },
  122547. enumerable: true,
  122548. configurable: true
  122549. });
  122550. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  122551. /**
  122552. * Gets Vignette weight or intensity of the vignette effect.
  122553. */
  122554. get: function () {
  122555. return this.imageProcessingConfiguration.vignetteWeight;
  122556. },
  122557. /**
  122558. * Sets Vignette weight or intensity of the vignette effect.
  122559. */
  122560. set: function (value) {
  122561. this.imageProcessingConfiguration.vignetteWeight = value;
  122562. },
  122563. enumerable: true,
  122564. configurable: true
  122565. });
  122566. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  122567. /**
  122568. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122569. * if vignetteEnabled is set to true.
  122570. */
  122571. get: function () {
  122572. return this.imageProcessingConfiguration.vignetteColor;
  122573. },
  122574. /**
  122575. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122576. * if vignetteEnabled is set to true.
  122577. */
  122578. set: function (value) {
  122579. this.imageProcessingConfiguration.vignetteColor = value;
  122580. },
  122581. enumerable: true,
  122582. configurable: true
  122583. });
  122584. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  122585. /**
  122586. * Gets Camera field of view used by the Vignette effect.
  122587. */
  122588. get: function () {
  122589. return this.imageProcessingConfiguration.vignetteCameraFov;
  122590. },
  122591. /**
  122592. * Sets Camera field of view used by the Vignette effect.
  122593. */
  122594. set: function (value) {
  122595. this.imageProcessingConfiguration.vignetteCameraFov = value;
  122596. },
  122597. enumerable: true,
  122598. configurable: true
  122599. });
  122600. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  122601. /**
  122602. * Gets the vignette blend mode allowing different kind of effect.
  122603. */
  122604. get: function () {
  122605. return this.imageProcessingConfiguration.vignetteBlendMode;
  122606. },
  122607. /**
  122608. * Sets the vignette blend mode allowing different kind of effect.
  122609. */
  122610. set: function (value) {
  122611. this.imageProcessingConfiguration.vignetteBlendMode = value;
  122612. },
  122613. enumerable: true,
  122614. configurable: true
  122615. });
  122616. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  122617. /**
  122618. * Gets wether the vignette effect is enabled.
  122619. */
  122620. get: function () {
  122621. return this.imageProcessingConfiguration.vignetteEnabled;
  122622. },
  122623. /**
  122624. * Sets wether the vignette effect is enabled.
  122625. */
  122626. set: function (value) {
  122627. this.imageProcessingConfiguration.vignetteEnabled = value;
  122628. },
  122629. enumerable: true,
  122630. configurable: true
  122631. });
  122632. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  122633. /**
  122634. * Gets wether the input of the processing is in Gamma or Linear Space.
  122635. */
  122636. get: function () {
  122637. return this._fromLinearSpace;
  122638. },
  122639. /**
  122640. * Sets wether the input of the processing is in Gamma or Linear Space.
  122641. */
  122642. set: function (value) {
  122643. if (this._fromLinearSpace === value) {
  122644. return;
  122645. }
  122646. this._fromLinearSpace = value;
  122647. this._updateParameters();
  122648. },
  122649. enumerable: true,
  122650. configurable: true
  122651. });
  122652. /**
  122653. * "ImageProcessingPostProcess"
  122654. * @returns "ImageProcessingPostProcess"
  122655. */
  122656. ImageProcessingPostProcess.prototype.getClassName = function () {
  122657. return "ImageProcessingPostProcess";
  122658. };
  122659. ImageProcessingPostProcess.prototype._updateParameters = function () {
  122660. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  122661. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  122662. var defines = "";
  122663. for (var define in this._defines) {
  122664. if (this._defines[define]) {
  122665. defines += "#define " + define + ";\r\n";
  122666. }
  122667. }
  122668. var samplers = ["textureSampler"];
  122669. var uniforms = ["scale"];
  122670. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  122671. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  122672. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  122673. }
  122674. this.updateEffect(defines, uniforms, samplers);
  122675. };
  122676. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  122677. _super.prototype.dispose.call(this, camera);
  122678. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  122679. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  122680. }
  122681. if (this._imageProcessingConfiguration) {
  122682. this.imageProcessingConfiguration.applyByPostProcess = false;
  122683. }
  122684. };
  122685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122687. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  122688. return ImageProcessingPostProcess;
  122689. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  122690. /***/ }),
  122691. /***/ "./PostProcesses/index.ts":
  122692. /*!********************************!*\
  122693. !*** ./PostProcesses/index.ts ***!
  122694. \********************************/
  122695. /*! 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, VRMultiviewToSingleview, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  122696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122697. "use strict";
  122698. __webpack_require__.r(__webpack_exports__);
  122699. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  122700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  122701. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  122702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  122703. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  122704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  122705. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  122706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  122707. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  122708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  122709. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  122710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  122711. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  122712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  122713. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  122714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  122715. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  122716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  122717. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  122718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  122719. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  122720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  122721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  122722. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  122723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  122724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  122725. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  122726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  122727. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  122728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  122729. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  122730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  122731. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  122732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  122733. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  122734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  122735. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  122736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  122737. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  122738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  122739. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  122740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  122741. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  122742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  122743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  122744. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  122746. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  122747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  122748. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  122749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  122750. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  122751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  122752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  122753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  122754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  122755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  122756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  122757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  122758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  122759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  122760. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  122761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  122762. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  122763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  122764. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  122765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  122766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  122767. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  122768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  122769. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  122770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  122771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleview", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRMultiviewToSingleview"]; });
  122772. /***/ }),
  122773. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  122774. /*!************************************************!*\
  122775. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  122776. \************************************************/
  122777. /*! exports provided: MotionBlurPostProcess */
  122778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122779. "use strict";
  122780. __webpack_require__.r(__webpack_exports__);
  122781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  122782. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122783. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  122784. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122785. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122786. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122787. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  122788. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animatable */ "./Animations/animatable.ts");
  122789. /* harmony import */ var _Rendering_geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  122790. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  122791. /**
  122792. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  122793. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  122794. * As an example, all you have to do is to create the post-process:
  122795. * var mb = new BABYLON.MotionBlurPostProcess(
  122796. * 'mb', // The name of the effect.
  122797. * scene, // The scene containing the objects to blur according to their velocity.
  122798. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  122799. * camera // The camera to apply the render pass to.
  122800. * );
  122801. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  122802. */
  122803. var MotionBlurPostProcess = /** @class */ (function (_super) {
  122804. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  122805. /**
  122806. * Creates a new instance MotionBlurPostProcess
  122807. * @param name The name of the effect.
  122808. * @param scene The scene containing the objects to blur according to their velocity.
  122809. * @param options The required width/height ratio to downsize to before computing the render pass.
  122810. * @param camera The camera to apply the render pass to.
  122811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122812. * @param engine The engine which the post process will be applied. (default: current engine)
  122813. * @param reusable If the post process can be reused on the same frame. (default: false)
  122814. * @param textureType Type of textures used when performing the post process. (default: 0)
  122815. * @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)
  122816. */
  122817. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122818. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122819. if (blockCompilation === void 0) { blockCompilation = false; }
  122820. 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;
  122821. /**
  122822. * Defines how much the image is blurred by the movement. Default value is equal to 1
  122823. */
  122824. _this.motionStrength = 1;
  122825. _this._motionBlurSamples = 32;
  122826. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  122827. if (!_this._geometryBufferRenderer) {
  122828. // Geometry buffer renderer is not supported. So, work as a passthrough.
  122829. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  122830. _this.updateEffect();
  122831. }
  122832. else {
  122833. // Geometry buffer renderer is supported.
  122834. _this._geometryBufferRenderer.enableVelocity = true;
  122835. _this.onApply = function (effect) {
  122836. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  122837. effect.setFloat("motionScale", scene.getAnimationRatio());
  122838. effect.setFloat("motionStrength", _this.motionStrength);
  122839. if (_this._geometryBufferRenderer) {
  122840. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  122841. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  122842. }
  122843. };
  122844. }
  122845. return _this;
  122846. }
  122847. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  122848. /**
  122849. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  122850. */
  122851. get: function () {
  122852. return this._motionBlurSamples;
  122853. },
  122854. /**
  122855. * Sets the number of iterations to be used for motion blur quality
  122856. */
  122857. set: function (samples) {
  122858. this._motionBlurSamples = samples;
  122859. if (this._geometryBufferRenderer) {
  122860. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  122861. }
  122862. },
  122863. enumerable: true,
  122864. configurable: true
  122865. });
  122866. /**
  122867. * Disposes the post process.
  122868. * @param camera The camera to dispose the post process on.
  122869. */
  122870. MotionBlurPostProcess.prototype.dispose = function (camera) {
  122871. if (this._geometryBufferRenderer) {
  122872. // Clear previous transformation matrices dictionary used to compute objects velocities
  122873. this._geometryBufferRenderer._previousTransformationMatrices = {};
  122874. }
  122875. _super.prototype.dispose.call(this, camera);
  122876. };
  122877. return MotionBlurPostProcess;
  122878. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  122879. /***/ }),
  122880. /***/ "./PostProcesses/passPostProcess.ts":
  122881. /*!******************************************!*\
  122882. !*** ./PostProcesses/passPostProcess.ts ***!
  122883. \******************************************/
  122884. /*! exports provided: PassPostProcess, PassCubePostProcess */
  122885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122886. "use strict";
  122887. __webpack_require__.r(__webpack_exports__);
  122888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  122889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  122890. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122891. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122892. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122893. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  122894. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  122895. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  122896. /**
  122897. * PassPostProcess which produces an output the same as it's input
  122898. */
  122899. var PassPostProcess = /** @class */ (function (_super) {
  122900. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  122901. /**
  122902. * Creates the PassPostProcess
  122903. * @param name The name of the effect.
  122904. * @param options The required width/height ratio to downsize to before computing the render pass.
  122905. * @param camera The camera to apply the render pass to.
  122906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122907. * @param engine The engine which the post process will be applied. (default: current engine)
  122908. * @param reusable If the post process can be reused on the same frame. (default: false)
  122909. * @param textureType The type of texture to be used when performing the post processing.
  122910. * @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)
  122911. */
  122912. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122913. if (camera === void 0) { camera = null; }
  122914. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122915. if (blockCompilation === void 0) { blockCompilation = false; }
  122916. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  122917. }
  122918. return PassPostProcess;
  122919. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  122920. /**
  122921. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  122922. */
  122923. var PassCubePostProcess = /** @class */ (function (_super) {
  122924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  122925. /**
  122926. * Creates the PassCubePostProcess
  122927. * @param name The name of the effect.
  122928. * @param options The required width/height ratio to downsize to before computing the render pass.
  122929. * @param camera The camera to apply the render pass to.
  122930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122931. * @param engine The engine which the post process will be applied. (default: current engine)
  122932. * @param reusable If the post process can be reused on the same frame. (default: false)
  122933. * @param textureType The type of texture to be used when performing the post processing.
  122934. * @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)
  122935. */
  122936. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122937. if (camera === void 0) { camera = null; }
  122938. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122939. if (blockCompilation === void 0) { blockCompilation = false; }
  122940. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  122941. _this._face = 0;
  122942. return _this;
  122943. }
  122944. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  122945. /**
  122946. * Gets or sets the cube face to display.
  122947. * * 0 is +X
  122948. * * 1 is -X
  122949. * * 2 is +Y
  122950. * * 3 is -Y
  122951. * * 4 is +Z
  122952. * * 5 is -Z
  122953. */
  122954. get: function () {
  122955. return this._face;
  122956. },
  122957. set: function (value) {
  122958. if (value < 0 || value > 5) {
  122959. return;
  122960. }
  122961. this._face = value;
  122962. switch (this._face) {
  122963. case 0:
  122964. this.updateEffect("#define POSITIVEX");
  122965. break;
  122966. case 1:
  122967. this.updateEffect("#define NEGATIVEX");
  122968. break;
  122969. case 2:
  122970. this.updateEffect("#define POSITIVEY");
  122971. break;
  122972. case 3:
  122973. this.updateEffect("#define NEGATIVEY");
  122974. break;
  122975. case 4:
  122976. this.updateEffect("#define POSITIVEZ");
  122977. break;
  122978. case 5:
  122979. this.updateEffect("#define NEGATIVEZ");
  122980. break;
  122981. }
  122982. },
  122983. enumerable: true,
  122984. configurable: true
  122985. });
  122986. return PassCubePostProcess;
  122987. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  122988. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  122989. 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);
  122990. };
  122991. /***/ }),
  122992. /***/ "./PostProcesses/postProcess.ts":
  122993. /*!**************************************!*\
  122994. !*** ./PostProcesses/postProcess.ts ***!
  122995. \**************************************/
  122996. /*! exports provided: PostProcess */
  122997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122998. "use strict";
  122999. __webpack_require__.r(__webpack_exports__);
  123000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  123001. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  123002. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  123003. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  123004. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123005. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123006. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  123007. /**
  123008. * PostProcess can be used to apply a shader to a texture after it has been rendered
  123009. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123010. */
  123011. var PostProcess = /** @class */ (function () {
  123012. /**
  123013. * Creates a new instance PostProcess
  123014. * @param name The name of the PostProcess.
  123015. * @param fragmentUrl The url of the fragment shader to be used.
  123016. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  123017. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  123018. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  123019. * @param camera The camera to apply the render pass to.
  123020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123021. * @param engine The engine which the post process will be applied. (default: current engine)
  123022. * @param reusable If the post process can be reused on the same frame. (default: false)
  123023. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  123024. * @param textureType Type of textures used when performing the post process. (default: 0)
  123025. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  123026. * @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
  123027. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  123028. */
  123029. function PostProcess(
  123030. /** Name of the PostProcess. */
  123031. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  123032. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  123033. if (defines === void 0) { defines = null; }
  123034. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123035. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  123036. if (blockCompilation === void 0) { blockCompilation = false; }
  123037. this.name = name;
  123038. /**
  123039. * Width of the texture to apply the post process on
  123040. */
  123041. this.width = -1;
  123042. /**
  123043. * Height of the texture to apply the post process on
  123044. */
  123045. this.height = -1;
  123046. /**
  123047. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  123048. * @hidden
  123049. */
  123050. this._outputTexture = null;
  123051. /**
  123052. * If the buffer needs to be cleared before applying the post process. (default: true)
  123053. * Should be set to false if shader will overwrite all previous pixels.
  123054. */
  123055. this.autoClear = true;
  123056. /**
  123057. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  123058. */
  123059. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  123060. /**
  123061. * Animations to be used for the post processing
  123062. */
  123063. this.animations = new Array();
  123064. /**
  123065. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  123066. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  123067. */
  123068. this.enablePixelPerfectMode = false;
  123069. /**
  123070. * Force the postprocess to be applied without taking in account viewport
  123071. */
  123072. this.forceFullscreenViewport = true;
  123073. /**
  123074. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  123075. *
  123076. * | Value | Type | Description |
  123077. * | ----- | ----------------------------------- | ----------- |
  123078. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  123079. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  123080. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  123081. *
  123082. */
  123083. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  123084. /**
  123085. * Force textures to be a power of two (default: false)
  123086. */
  123087. this.alwaysForcePOT = false;
  123088. this._samples = 1;
  123089. /**
  123090. * Modify the scale of the post process to be the same as the viewport (default: false)
  123091. */
  123092. this.adaptScaleToCurrentViewport = false;
  123093. this._reusable = false;
  123094. /**
  123095. * Smart array of input and output textures for the post process.
  123096. * @hidden
  123097. */
  123098. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  123099. /**
  123100. * The index in _textures that corresponds to the output texture.
  123101. * @hidden
  123102. */
  123103. this._currentRenderTextureInd = 0;
  123104. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  123105. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  123106. // Events
  123107. /**
  123108. * An event triggered when the postprocess is activated.
  123109. */
  123110. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123111. /**
  123112. * An event triggered when the postprocess changes its size.
  123113. */
  123114. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123115. /**
  123116. * An event triggered when the postprocess applies its effect.
  123117. */
  123118. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123119. /**
  123120. * An event triggered before rendering the postprocess
  123121. */
  123122. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123123. /**
  123124. * An event triggered after rendering the postprocess
  123125. */
  123126. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123127. if (camera != null) {
  123128. this._camera = camera;
  123129. this._scene = camera.getScene();
  123130. camera.attachPostProcess(this);
  123131. this._engine = this._scene.getEngine();
  123132. this._scene.postProcesses.push(this);
  123133. this.uniqueId = this._scene.getUniqueId();
  123134. }
  123135. else if (engine) {
  123136. this._engine = engine;
  123137. this._engine.postProcesses.push(this);
  123138. }
  123139. this._options = options;
  123140. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  123141. this._reusable = reusable || false;
  123142. this._textureType = textureType;
  123143. this._samplers = samplers || [];
  123144. this._samplers.push("textureSampler");
  123145. this._fragmentUrl = fragmentUrl;
  123146. this._vertexUrl = vertexUrl;
  123147. this._parameters = parameters || [];
  123148. this._parameters.push("scale");
  123149. this._indexParameters = indexParameters;
  123150. if (!blockCompilation) {
  123151. this.updateEffect(defines);
  123152. }
  123153. }
  123154. Object.defineProperty(PostProcess.prototype, "samples", {
  123155. /**
  123156. * Number of sample textures (default: 1)
  123157. */
  123158. get: function () {
  123159. return this._samples;
  123160. },
  123161. set: function (n) {
  123162. var _this = this;
  123163. this._samples = n;
  123164. this._textures.forEach(function (texture) {
  123165. if (texture.samples !== _this._samples) {
  123166. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  123167. }
  123168. });
  123169. },
  123170. enumerable: true,
  123171. configurable: true
  123172. });
  123173. /**
  123174. * Returns the fragment url or shader name used in the post process.
  123175. * @returns the fragment url or name in the shader store.
  123176. */
  123177. PostProcess.prototype.getEffectName = function () {
  123178. return this._fragmentUrl;
  123179. };
  123180. Object.defineProperty(PostProcess.prototype, "onActivate", {
  123181. /**
  123182. * A function that is added to the onActivateObservable
  123183. */
  123184. set: function (callback) {
  123185. if (this._onActivateObserver) {
  123186. this.onActivateObservable.remove(this._onActivateObserver);
  123187. }
  123188. if (callback) {
  123189. this._onActivateObserver = this.onActivateObservable.add(callback);
  123190. }
  123191. },
  123192. enumerable: true,
  123193. configurable: true
  123194. });
  123195. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  123196. /**
  123197. * A function that is added to the onSizeChangedObservable
  123198. */
  123199. set: function (callback) {
  123200. if (this._onSizeChangedObserver) {
  123201. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  123202. }
  123203. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  123204. },
  123205. enumerable: true,
  123206. configurable: true
  123207. });
  123208. Object.defineProperty(PostProcess.prototype, "onApply", {
  123209. /**
  123210. * A function that is added to the onApplyObservable
  123211. */
  123212. set: function (callback) {
  123213. if (this._onApplyObserver) {
  123214. this.onApplyObservable.remove(this._onApplyObserver);
  123215. }
  123216. this._onApplyObserver = this.onApplyObservable.add(callback);
  123217. },
  123218. enumerable: true,
  123219. configurable: true
  123220. });
  123221. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  123222. /**
  123223. * A function that is added to the onBeforeRenderObservable
  123224. */
  123225. set: function (callback) {
  123226. if (this._onBeforeRenderObserver) {
  123227. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  123228. }
  123229. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  123230. },
  123231. enumerable: true,
  123232. configurable: true
  123233. });
  123234. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  123235. /**
  123236. * A function that is added to the onAfterRenderObservable
  123237. */
  123238. set: function (callback) {
  123239. if (this._onAfterRenderObserver) {
  123240. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  123241. }
  123242. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  123243. },
  123244. enumerable: true,
  123245. configurable: true
  123246. });
  123247. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  123248. /**
  123249. * 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
  123250. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  123251. */
  123252. get: function () {
  123253. return this._textures.data[this._currentRenderTextureInd];
  123254. },
  123255. set: function (value) {
  123256. this._forcedOutputTexture = value;
  123257. },
  123258. enumerable: true,
  123259. configurable: true
  123260. });
  123261. /**
  123262. * Gets the camera which post process is applied to.
  123263. * @returns The camera the post process is applied to.
  123264. */
  123265. PostProcess.prototype.getCamera = function () {
  123266. return this._camera;
  123267. };
  123268. Object.defineProperty(PostProcess.prototype, "texelSize", {
  123269. /**
  123270. * Gets the texel size of the postprocess.
  123271. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  123272. */
  123273. get: function () {
  123274. if (this._shareOutputWithPostProcess) {
  123275. return this._shareOutputWithPostProcess.texelSize;
  123276. }
  123277. if (this._forcedOutputTexture) {
  123278. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  123279. }
  123280. return this._texelSize;
  123281. },
  123282. enumerable: true,
  123283. configurable: true
  123284. });
  123285. /**
  123286. * Gets a string idenfifying the name of the class
  123287. * @returns "PostProcess" string
  123288. */
  123289. PostProcess.prototype.getClassName = function () {
  123290. return "PostProcess";
  123291. };
  123292. /**
  123293. * Gets the engine which this post process belongs to.
  123294. * @returns The engine the post process was enabled with.
  123295. */
  123296. PostProcess.prototype.getEngine = function () {
  123297. return this._engine;
  123298. };
  123299. /**
  123300. * The effect that is created when initializing the post process.
  123301. * @returns The created effect corrisponding the the postprocess.
  123302. */
  123303. PostProcess.prototype.getEffect = function () {
  123304. return this._effect;
  123305. };
  123306. /**
  123307. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  123308. * @param postProcess The post process to share the output with.
  123309. * @returns This post process.
  123310. */
  123311. PostProcess.prototype.shareOutputWith = function (postProcess) {
  123312. this._disposeTextures();
  123313. this._shareOutputWithPostProcess = postProcess;
  123314. return this;
  123315. };
  123316. /**
  123317. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  123318. * This should be called if the post process that shares output with this post process is disabled/disposed.
  123319. */
  123320. PostProcess.prototype.useOwnOutput = function () {
  123321. if (this._textures.length == 0) {
  123322. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  123323. }
  123324. this._shareOutputWithPostProcess = null;
  123325. };
  123326. /**
  123327. * Updates the effect with the current post process compile time values and recompiles the shader.
  123328. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  123329. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  123330. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  123331. * @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
  123332. * @param onCompiled Called when the shader has been compiled.
  123333. * @param onError Called if there is an error when compiling a shader.
  123334. */
  123335. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  123336. if (defines === void 0) { defines = null; }
  123337. if (uniforms === void 0) { uniforms = null; }
  123338. if (samplers === void 0) { samplers = null; }
  123339. 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);
  123340. };
  123341. /**
  123342. * The post process is reusable if it can be used multiple times within one frame.
  123343. * @returns If the post process is reusable
  123344. */
  123345. PostProcess.prototype.isReusable = function () {
  123346. return this._reusable;
  123347. };
  123348. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  123349. PostProcess.prototype.markTextureDirty = function () {
  123350. this.width = -1;
  123351. };
  123352. /**
  123353. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  123354. * 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.
  123355. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  123356. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  123357. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  123358. * @returns The target texture that was bound to be written to.
  123359. */
  123360. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  123361. var _this = this;
  123362. if (sourceTexture === void 0) { sourceTexture = null; }
  123363. camera = camera || this._camera;
  123364. var scene = camera.getScene();
  123365. var engine = scene.getEngine();
  123366. var maxSize = engine.getCaps().maxTextureSize;
  123367. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  123368. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  123369. // 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
  123370. var webVRCamera = camera.parent;
  123371. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  123372. requiredWidth /= 2;
  123373. }
  123374. var desiredWidth = (this._options.width || requiredWidth);
  123375. var desiredHeight = this._options.height || requiredHeight;
  123376. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  123377. if (this.adaptScaleToCurrentViewport) {
  123378. var currentViewport = engine.currentViewport;
  123379. if (currentViewport) {
  123380. desiredWidth *= currentViewport.width;
  123381. desiredHeight *= currentViewport.height;
  123382. }
  123383. }
  123384. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  123385. if (!this._options.width) {
  123386. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  123387. }
  123388. if (!this._options.height) {
  123389. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  123390. }
  123391. }
  123392. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  123393. if (this._textures.length > 0) {
  123394. for (var i = 0; i < this._textures.length; i++) {
  123395. this._engine._releaseTexture(this._textures.data[i]);
  123396. }
  123397. this._textures.reset();
  123398. }
  123399. this.width = desiredWidth;
  123400. this.height = desiredHeight;
  123401. var textureSize = { width: this.width, height: this.height };
  123402. var textureOptions = {
  123403. generateMipMaps: false,
  123404. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  123405. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  123406. samplingMode: this.renderTargetSamplingMode,
  123407. type: this._textureType
  123408. };
  123409. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  123410. if (this._reusable) {
  123411. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  123412. }
  123413. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  123414. this.onSizeChangedObservable.notifyObservers(this);
  123415. }
  123416. this._textures.forEach(function (texture) {
  123417. if (texture.samples !== _this.samples) {
  123418. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  123419. }
  123420. });
  123421. }
  123422. var target;
  123423. if (this._shareOutputWithPostProcess) {
  123424. target = this._shareOutputWithPostProcess.inputTexture;
  123425. }
  123426. else if (this._forcedOutputTexture) {
  123427. target = this._forcedOutputTexture;
  123428. this.width = this._forcedOutputTexture.width;
  123429. this.height = this._forcedOutputTexture.height;
  123430. }
  123431. else {
  123432. target = this.inputTexture;
  123433. }
  123434. // Bind the input of this post process to be used as the output of the previous post process.
  123435. if (this.enablePixelPerfectMode) {
  123436. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  123437. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  123438. }
  123439. else {
  123440. this._scaleRatio.copyFromFloats(1, 1);
  123441. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  123442. }
  123443. this.onActivateObservable.notifyObservers(camera);
  123444. // Clear
  123445. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  123446. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  123447. }
  123448. if (this._reusable) {
  123449. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  123450. }
  123451. return target;
  123452. };
  123453. Object.defineProperty(PostProcess.prototype, "isSupported", {
  123454. /**
  123455. * If the post process is supported.
  123456. */
  123457. get: function () {
  123458. return this._effect.isSupported;
  123459. },
  123460. enumerable: true,
  123461. configurable: true
  123462. });
  123463. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  123464. /**
  123465. * The aspect ratio of the output texture.
  123466. */
  123467. get: function () {
  123468. if (this._shareOutputWithPostProcess) {
  123469. return this._shareOutputWithPostProcess.aspectRatio;
  123470. }
  123471. if (this._forcedOutputTexture) {
  123472. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  123473. }
  123474. return this.width / this.height;
  123475. },
  123476. enumerable: true,
  123477. configurable: true
  123478. });
  123479. /**
  123480. * Get a value indicating if the post-process is ready to be used
  123481. * @returns true if the post-process is ready (shader is compiled)
  123482. */
  123483. PostProcess.prototype.isReady = function () {
  123484. return this._effect && this._effect.isReady();
  123485. };
  123486. /**
  123487. * Binds all textures and uniforms to the shader, this will be run on every pass.
  123488. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  123489. */
  123490. PostProcess.prototype.apply = function () {
  123491. // Check
  123492. if (!this._effect || !this._effect.isReady()) {
  123493. return null;
  123494. }
  123495. // States
  123496. this._engine.enableEffect(this._effect);
  123497. this._engine.setState(false);
  123498. this._engine.setDepthBuffer(false);
  123499. this._engine.setDepthWrite(false);
  123500. // Alpha
  123501. this._engine.setAlphaMode(this.alphaMode);
  123502. if (this.alphaConstants) {
  123503. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  123504. }
  123505. // Bind the output texture of the preivous post process as the input to this post process.
  123506. var source;
  123507. if (this._shareOutputWithPostProcess) {
  123508. source = this._shareOutputWithPostProcess.inputTexture;
  123509. }
  123510. else if (this._forcedOutputTexture) {
  123511. source = this._forcedOutputTexture;
  123512. }
  123513. else {
  123514. source = this.inputTexture;
  123515. }
  123516. this._effect._bindTexture("textureSampler", source);
  123517. // Parameters
  123518. this._effect.setVector2("scale", this._scaleRatio);
  123519. this.onApplyObservable.notifyObservers(this._effect);
  123520. return this._effect;
  123521. };
  123522. PostProcess.prototype._disposeTextures = function () {
  123523. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  123524. return;
  123525. }
  123526. if (this._textures.length > 0) {
  123527. for (var i = 0; i < this._textures.length; i++) {
  123528. this._engine._releaseTexture(this._textures.data[i]);
  123529. }
  123530. }
  123531. this._textures.dispose();
  123532. };
  123533. /**
  123534. * Disposes the post process.
  123535. * @param camera The camera to dispose the post process on.
  123536. */
  123537. PostProcess.prototype.dispose = function (camera) {
  123538. camera = camera || this._camera;
  123539. this._disposeTextures();
  123540. if (this._scene) {
  123541. var index_1 = this._scene.postProcesses.indexOf(this);
  123542. if (index_1 !== -1) {
  123543. this._scene.postProcesses.splice(index_1, 1);
  123544. }
  123545. }
  123546. else {
  123547. var index_2 = this._engine.postProcesses.indexOf(this);
  123548. if (index_2 !== -1) {
  123549. this._engine.postProcesses.splice(index_2, 1);
  123550. }
  123551. }
  123552. if (!camera) {
  123553. return;
  123554. }
  123555. camera.detachPostProcess(this);
  123556. var index = camera._postProcesses.indexOf(this);
  123557. if (index === 0 && camera._postProcesses.length > 0) {
  123558. var firstPostProcess = this._camera._getFirstPostProcess();
  123559. if (firstPostProcess) {
  123560. firstPostProcess.markTextureDirty();
  123561. }
  123562. }
  123563. this.onActivateObservable.clear();
  123564. this.onAfterRenderObservable.clear();
  123565. this.onApplyObservable.clear();
  123566. this.onBeforeRenderObservable.clear();
  123567. this.onSizeChangedObservable.clear();
  123568. };
  123569. return PostProcess;
  123570. }());
  123571. /***/ }),
  123572. /***/ "./PostProcesses/postProcessManager.ts":
  123573. /*!*********************************************!*\
  123574. !*** ./PostProcesses/postProcessManager.ts ***!
  123575. \*********************************************/
  123576. /*! exports provided: PostProcessManager */
  123577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123578. "use strict";
  123579. __webpack_require__.r(__webpack_exports__);
  123580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  123581. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  123582. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  123583. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123584. /**
  123585. * PostProcessManager is used to manage one or more post processes or post process pipelines
  123586. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123587. */
  123588. var PostProcessManager = /** @class */ (function () {
  123589. /**
  123590. * Creates a new instance PostProcess
  123591. * @param scene The scene that the post process is associated with.
  123592. */
  123593. function PostProcessManager(scene) {
  123594. this._vertexBuffers = {};
  123595. this._scene = scene;
  123596. }
  123597. PostProcessManager.prototype._prepareBuffers = function () {
  123598. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  123599. return;
  123600. }
  123601. // VBO
  123602. var vertices = [];
  123603. vertices.push(1, 1);
  123604. vertices.push(-1, 1);
  123605. vertices.push(-1, -1);
  123606. vertices.push(1, -1);
  123607. 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);
  123608. this._buildIndexBuffer();
  123609. };
  123610. PostProcessManager.prototype._buildIndexBuffer = function () {
  123611. // Indices
  123612. var indices = [];
  123613. indices.push(0);
  123614. indices.push(1);
  123615. indices.push(2);
  123616. indices.push(0);
  123617. indices.push(2);
  123618. indices.push(3);
  123619. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  123620. };
  123621. /**
  123622. * Rebuilds the vertex buffers of the manager.
  123623. * @hidden
  123624. */
  123625. PostProcessManager.prototype._rebuild = function () {
  123626. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  123627. if (!vb) {
  123628. return;
  123629. }
  123630. vb._rebuild();
  123631. this._buildIndexBuffer();
  123632. };
  123633. // Methods
  123634. /**
  123635. * Prepares a frame to be run through a post process.
  123636. * @param sourceTexture The input texture to the post procesess. (default: null)
  123637. * @param postProcesses An array of post processes to be run. (default: null)
  123638. * @returns True if the post processes were able to be run.
  123639. * @hidden
  123640. */
  123641. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  123642. if (sourceTexture === void 0) { sourceTexture = null; }
  123643. if (postProcesses === void 0) { postProcesses = null; }
  123644. var camera = this._scene.activeCamera;
  123645. if (!camera) {
  123646. return false;
  123647. }
  123648. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  123649. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  123650. return false;
  123651. }
  123652. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  123653. return true;
  123654. };
  123655. /**
  123656. * Manually render a set of post processes to a texture.
  123657. * @param postProcesses An array of post processes to be run.
  123658. * @param targetTexture The target texture to render to.
  123659. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  123660. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  123661. * @param lodLevel defines which lod of the texture to render to
  123662. */
  123663. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  123664. if (targetTexture === void 0) { targetTexture = null; }
  123665. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  123666. if (faceIndex === void 0) { faceIndex = 0; }
  123667. if (lodLevel === void 0) { lodLevel = 0; }
  123668. var engine = this._scene.getEngine();
  123669. for (var index = 0; index < postProcesses.length; index++) {
  123670. if (index < postProcesses.length - 1) {
  123671. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  123672. }
  123673. else {
  123674. if (targetTexture) {
  123675. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  123676. }
  123677. else {
  123678. engine.restoreDefaultFramebuffer();
  123679. }
  123680. }
  123681. var pp = postProcesses[index];
  123682. var effect = pp.apply();
  123683. if (effect) {
  123684. pp.onBeforeRenderObservable.notifyObservers(effect);
  123685. // VBOs
  123686. this._prepareBuffers();
  123687. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  123688. // Draw order
  123689. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  123690. pp.onAfterRenderObservable.notifyObservers(effect);
  123691. }
  123692. }
  123693. // Restore depth buffer
  123694. engine.setDepthBuffer(true);
  123695. engine.setDepthWrite(true);
  123696. };
  123697. /**
  123698. * Finalize the result of the output of the postprocesses.
  123699. * @param doNotPresent If true the result will not be displayed to the screen.
  123700. * @param targetTexture The target texture to render to.
  123701. * @param faceIndex The index of the face to bind the target texture to.
  123702. * @param postProcesses The array of post processes to render.
  123703. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  123704. * @hidden
  123705. */
  123706. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  123707. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  123708. var camera = this._scene.activeCamera;
  123709. if (!camera) {
  123710. return;
  123711. }
  123712. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  123713. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  123714. return;
  123715. }
  123716. var engine = this._scene.getEngine();
  123717. for (var index = 0, len = postProcesses.length; index < len; index++) {
  123718. var pp = postProcesses[index];
  123719. if (index < len - 1) {
  123720. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  123721. }
  123722. else {
  123723. if (targetTexture) {
  123724. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  123725. pp._outputTexture = targetTexture;
  123726. }
  123727. else {
  123728. engine.restoreDefaultFramebuffer();
  123729. pp._outputTexture = null;
  123730. }
  123731. }
  123732. if (doNotPresent) {
  123733. break;
  123734. }
  123735. var effect = pp.apply();
  123736. if (effect) {
  123737. pp.onBeforeRenderObservable.notifyObservers(effect);
  123738. // VBOs
  123739. this._prepareBuffers();
  123740. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  123741. // Draw order
  123742. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  123743. pp.onAfterRenderObservable.notifyObservers(effect);
  123744. }
  123745. }
  123746. // Restore states
  123747. engine.setDepthBuffer(true);
  123748. engine.setDepthWrite(true);
  123749. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  123750. };
  123751. /**
  123752. * Disposes of the post process manager.
  123753. */
  123754. PostProcessManager.prototype.dispose = function () {
  123755. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  123756. if (buffer) {
  123757. buffer.dispose();
  123758. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  123759. }
  123760. if (this._indexBuffer) {
  123761. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  123762. this._indexBuffer = null;
  123763. }
  123764. };
  123765. return PostProcessManager;
  123766. }());
  123767. /***/ }),
  123768. /***/ "./PostProcesses/refractionPostProcess.ts":
  123769. /*!************************************************!*\
  123770. !*** ./PostProcesses/refractionPostProcess.ts ***!
  123771. \************************************************/
  123772. /*! exports provided: RefractionPostProcess */
  123773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123774. "use strict";
  123775. __webpack_require__.r(__webpack_exports__);
  123776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  123777. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123778. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123779. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123780. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  123781. /**
  123782. * Post process which applies a refractin texture
  123783. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123784. */
  123785. var RefractionPostProcess = /** @class */ (function (_super) {
  123786. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  123787. /**
  123788. * Initializes the RefractionPostProcess
  123789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123790. * @param name The name of the effect.
  123791. * @param refractionTextureUrl Url of the refraction texture to use
  123792. * @param color the base color of the refraction (used to taint the rendering)
  123793. * @param depth simulated refraction depth
  123794. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  123795. * @param camera The camera to apply the render pass to.
  123796. * @param options The required width/height ratio to downsize to before computing the render pass.
  123797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123798. * @param engine The engine which the post process will be applied. (default: current engine)
  123799. * @param reusable If the post process can be reused on the same frame. (default: false)
  123800. */
  123801. function RefractionPostProcess(name, refractionTextureUrl,
  123802. /** the base color of the refraction (used to taint the rendering) */
  123803. color,
  123804. /** simulated refraction depth */
  123805. depth,
  123806. /** the coefficient of the base color (0 to remove base color tainting) */
  123807. colorLevel, options, camera, samplingMode, engine, reusable) {
  123808. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  123809. _this.color = color;
  123810. _this.depth = depth;
  123811. _this.colorLevel = colorLevel;
  123812. _this._ownRefractionTexture = true;
  123813. _this.onActivateObservable.add(function (cam) {
  123814. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  123815. });
  123816. _this.onApplyObservable.add(function (effect) {
  123817. effect.setColor3("baseColor", _this.color);
  123818. effect.setFloat("depth", _this.depth);
  123819. effect.setFloat("colorLevel", _this.colorLevel);
  123820. effect.setTexture("refractionSampler", _this._refTexture);
  123821. });
  123822. return _this;
  123823. }
  123824. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  123825. /**
  123826. * Gets or sets the refraction texture
  123827. * Please note that you are responsible for disposing the texture if you set it manually
  123828. */
  123829. get: function () {
  123830. return this._refTexture;
  123831. },
  123832. set: function (value) {
  123833. if (this._refTexture && this._ownRefractionTexture) {
  123834. this._refTexture.dispose();
  123835. }
  123836. this._refTexture = value;
  123837. this._ownRefractionTexture = false;
  123838. },
  123839. enumerable: true,
  123840. configurable: true
  123841. });
  123842. // Methods
  123843. /**
  123844. * Disposes of the post process
  123845. * @param camera Camera to dispose post process on
  123846. */
  123847. RefractionPostProcess.prototype.dispose = function (camera) {
  123848. if (this._refTexture && this._ownRefractionTexture) {
  123849. this._refTexture.dispose();
  123850. this._refTexture = null;
  123851. }
  123852. _super.prototype.dispose.call(this, camera);
  123853. };
  123854. return RefractionPostProcess;
  123855. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123856. /***/ }),
  123857. /***/ "./PostProcesses/sharpenPostProcess.ts":
  123858. /*!*********************************************!*\
  123859. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  123860. \*********************************************/
  123861. /*! exports provided: SharpenPostProcess */
  123862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123863. "use strict";
  123864. __webpack_require__.r(__webpack_exports__);
  123865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  123866. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123867. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123868. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123869. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  123870. /**
  123871. * The SharpenPostProcess applies a sharpen kernel to every pixel
  123872. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123873. */
  123874. var SharpenPostProcess = /** @class */ (function (_super) {
  123875. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  123876. /**
  123877. * Creates a new instance ConvolutionPostProcess
  123878. * @param name The name of the effect.
  123879. * @param options The required width/height ratio to downsize to before computing the render pass.
  123880. * @param camera The camera to apply the render pass to.
  123881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123882. * @param engine The engine which the post process will be applied. (default: current engine)
  123883. * @param reusable If the post process can be reused on the same frame. (default: false)
  123884. * @param textureType Type of textures used when performing the post process. (default: 0)
  123885. * @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)
  123886. */
  123887. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123888. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123889. if (blockCompilation === void 0) { blockCompilation = false; }
  123890. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  123891. /**
  123892. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  123893. */
  123894. _this.colorAmount = 1.0;
  123895. /**
  123896. * How much sharpness should be applied (default: 0.3)
  123897. */
  123898. _this.edgeAmount = 0.3;
  123899. _this.onApply = function (effect) {
  123900. effect.setFloat2("screenSize", _this.width, _this.height);
  123901. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  123902. };
  123903. return _this;
  123904. }
  123905. return SharpenPostProcess;
  123906. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123907. /***/ }),
  123908. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  123909. /*!***********************************************************!*\
  123910. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  123911. \***********************************************************/
  123912. /*! exports provided: StereoscopicInterlacePostProcess */
  123913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123914. "use strict";
  123915. __webpack_require__.r(__webpack_exports__);
  123916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  123917. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123918. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123919. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123920. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  123921. /**
  123922. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  123923. */
  123924. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  123925. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  123926. /**
  123927. * Initializes a StereoscopicInterlacePostProcess
  123928. * @param name The name of the effect.
  123929. * @param rigCameras The rig cameras to be appled to the post process
  123930. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  123931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123932. * @param engine The engine which the post process will be applied. (default: current engine)
  123933. * @param reusable If the post process can be reused on the same frame. (default: false)
  123934. */
  123935. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  123936. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  123937. _this._passedProcess = rigCameras[0]._rigPostProcess;
  123938. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  123939. _this.onSizeChangedObservable.add(function () {
  123940. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  123941. });
  123942. _this.onApplyObservable.add(function (effect) {
  123943. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  123944. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  123945. });
  123946. return _this;
  123947. }
  123948. return StereoscopicInterlacePostProcess;
  123949. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123950. /***/ }),
  123951. /***/ "./PostProcesses/tonemapPostProcess.ts":
  123952. /*!*********************************************!*\
  123953. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  123954. \*********************************************/
  123955. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  123956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123957. "use strict";
  123958. __webpack_require__.r(__webpack_exports__);
  123959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  123960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  123961. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123962. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123963. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123964. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  123965. /** Defines operator used for tonemapping */
  123966. var TonemappingOperator;
  123967. (function (TonemappingOperator) {
  123968. /** Hable */
  123969. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  123970. /** Reinhard */
  123971. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  123972. /** HejiDawson */
  123973. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  123974. /** Photographic */
  123975. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  123976. })(TonemappingOperator || (TonemappingOperator = {}));
  123977. /**
  123978. * Defines a post process to apply tone mapping
  123979. */
  123980. var TonemapPostProcess = /** @class */ (function (_super) {
  123981. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  123982. /**
  123983. * Creates a new TonemapPostProcess
  123984. * @param name defines the name of the postprocess
  123985. * @param _operator defines the operator to use
  123986. * @param exposureAdjustment defines the required exposure adjustement
  123987. * @param camera defines the camera to use (can be null)
  123988. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  123989. * @param engine defines the hosting engine (can be ignore if camera is set)
  123990. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  123991. */
  123992. function TonemapPostProcess(name, _operator,
  123993. /** Defines the required exposure adjustement */
  123994. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  123995. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  123996. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123997. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  123998. _this._operator = _operator;
  123999. _this.exposureAdjustment = exposureAdjustment;
  124000. var defines = "#define ";
  124001. if (_this._operator === TonemappingOperator.Hable) {
  124002. defines += "HABLE_TONEMAPPING";
  124003. }
  124004. else if (_this._operator === TonemappingOperator.Reinhard) {
  124005. defines += "REINHARD_TONEMAPPING";
  124006. }
  124007. else if (_this._operator === TonemappingOperator.HejiDawson) {
  124008. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  124009. }
  124010. else if (_this._operator === TonemappingOperator.Photographic) {
  124011. defines += "PHOTOGRAPHIC_TONEMAPPING";
  124012. }
  124013. //sadly a second call to create the effect.
  124014. _this.updateEffect(defines);
  124015. _this.onApply = function (effect) {
  124016. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  124017. };
  124018. return _this;
  124019. }
  124020. return TonemapPostProcess;
  124021. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  124022. /***/ }),
  124023. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  124024. /*!***************************************************************!*\
  124025. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  124026. \***************************************************************/
  124027. /*! exports provided: VolumetricLightScatteringPostProcess */
  124028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124029. "use strict";
  124030. __webpack_require__.r(__webpack_exports__);
  124031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  124032. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124033. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  124034. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  124035. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124036. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124037. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  124038. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  124039. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124040. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  124041. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124042. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  124043. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124044. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124045. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  124046. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  124047. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  124048. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  124049. /**
  124050. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  124051. */
  124052. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  124053. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  124054. /**
  124055. * @constructor
  124056. * @param name The post-process name
  124057. * @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)
  124058. * @param camera The camera that the post-process will be attached to
  124059. * @param mesh The mesh used to create the light scattering
  124060. * @param samples The post-process quality, default 100
  124061. * @param samplingModeThe post-process filtering mode
  124062. * @param engine The babylon engine
  124063. * @param reusable If the post-process is reusable
  124064. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  124065. */
  124066. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  124067. if (samples === void 0) { samples = 100; }
  124068. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  124069. 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;
  124070. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  124071. /**
  124072. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  124073. */
  124074. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124075. /**
  124076. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  124077. */
  124078. _this.useCustomMeshPosition = false;
  124079. /**
  124080. * If the post-process should inverse the light scattering direction
  124081. */
  124082. _this.invert = true;
  124083. /**
  124084. * Array containing the excluded meshes not rendered in the internal pass
  124085. */
  124086. _this.excludedMeshes = new Array();
  124087. /**
  124088. * Controls the overall intensity of the post-process
  124089. */
  124090. _this.exposure = 0.3;
  124091. /**
  124092. * Dissipates each sample's contribution in range [0, 1]
  124093. */
  124094. _this.decay = 0.96815;
  124095. /**
  124096. * Controls the overall intensity of each sample
  124097. */
  124098. _this.weight = 0.58767;
  124099. /**
  124100. * Controls the density of each sample
  124101. */
  124102. _this.density = 0.926;
  124103. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  124104. engine = scene.getEngine();
  124105. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  124106. // Configure mesh
  124107. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  124108. // Configure
  124109. _this._createPass(scene, ratio.passRatio || ratio);
  124110. _this.onActivate = function (camera) {
  124111. if (!_this.isSupported) {
  124112. _this.dispose(camera);
  124113. }
  124114. _this.onActivate = null;
  124115. };
  124116. _this.onApplyObservable.add(function (effect) {
  124117. _this._updateMeshScreenCoordinates(scene);
  124118. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  124119. effect.setFloat("exposure", _this.exposure);
  124120. effect.setFloat("decay", _this.decay);
  124121. effect.setFloat("weight", _this.weight);
  124122. effect.setFloat("density", _this.density);
  124123. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  124124. });
  124125. return _this;
  124126. }
  124127. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  124128. /**
  124129. * @hidden
  124130. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  124131. */
  124132. get: function () {
  124133. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  124134. return false;
  124135. },
  124136. set: function (useDiffuseColor) {
  124137. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  124138. },
  124139. enumerable: true,
  124140. configurable: true
  124141. });
  124142. /**
  124143. * Returns the string "VolumetricLightScatteringPostProcess"
  124144. * @returns "VolumetricLightScatteringPostProcess"
  124145. */
  124146. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  124147. return "VolumetricLightScatteringPostProcess";
  124148. };
  124149. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  124150. var mesh = subMesh.getMesh();
  124151. // Render this.mesh as default
  124152. if (mesh === this.mesh && mesh.material) {
  124153. return mesh.material.isReady(mesh);
  124154. }
  124155. var defines = [];
  124156. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  124157. var material = subMesh.getMaterial();
  124158. // Alpha test
  124159. if (material) {
  124160. if (material.needAlphaTesting()) {
  124161. defines.push("#define ALPHATEST");
  124162. }
  124163. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  124164. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  124165. defines.push("#define UV1");
  124166. }
  124167. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  124168. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  124169. defines.push("#define UV2");
  124170. }
  124171. }
  124172. // Bones
  124173. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  124174. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  124175. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  124176. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  124177. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  124178. }
  124179. else {
  124180. defines.push("#define NUM_BONE_INFLUENCERS 0");
  124181. }
  124182. // Instances
  124183. if (useInstances) {
  124184. defines.push("#define INSTANCES");
  124185. attribs.push("world0");
  124186. attribs.push("world1");
  124187. attribs.push("world2");
  124188. attribs.push("world3");
  124189. }
  124190. // Get correct effect
  124191. var join = defines.join("\n");
  124192. if (this._cachedDefines !== join) {
  124193. this._cachedDefines = join;
  124194. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  124195. }
  124196. return this._volumetricLightScatteringPass.isReady();
  124197. };
  124198. /**
  124199. * Sets the new light position for light scattering effect
  124200. * @param position The new custom light position
  124201. */
  124202. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  124203. this.customMeshPosition = position;
  124204. };
  124205. /**
  124206. * Returns the light position for light scattering effect
  124207. * @return Vector3 The custom light position
  124208. */
  124209. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  124210. return this.customMeshPosition;
  124211. };
  124212. /**
  124213. * Disposes the internal assets and detaches the post-process from the camera
  124214. */
  124215. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  124216. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  124217. if (rttIndex !== -1) {
  124218. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  124219. }
  124220. this._volumetricLightScatteringRTT.dispose();
  124221. _super.prototype.dispose.call(this, camera);
  124222. };
  124223. /**
  124224. * Returns the render target texture used by the post-process
  124225. * @return the render target texture used by the post-process
  124226. */
  124227. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  124228. return this._volumetricLightScatteringRTT;
  124229. };
  124230. // Private methods
  124231. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  124232. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  124233. return true;
  124234. }
  124235. return false;
  124236. };
  124237. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  124238. var _this = this;
  124239. var engine = scene.getEngine();
  124240. 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);
  124241. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  124242. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  124243. this._volumetricLightScatteringRTT.renderList = null;
  124244. this._volumetricLightScatteringRTT.renderParticles = false;
  124245. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  124246. var camera = this.getCamera();
  124247. if (camera) {
  124248. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  124249. }
  124250. else {
  124251. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  124252. }
  124253. // Custom render function for submeshes
  124254. var renderSubMesh = function (subMesh) {
  124255. var mesh = subMesh.getRenderingMesh();
  124256. if (_this._meshExcluded(mesh)) {
  124257. return;
  124258. }
  124259. var material = subMesh.getMaterial();
  124260. if (!material) {
  124261. return;
  124262. }
  124263. var scene = mesh.getScene();
  124264. var engine = scene.getEngine();
  124265. // Culling
  124266. engine.setState(material.backFaceCulling);
  124267. // Managing instances
  124268. var batch = mesh._getInstancesRenderList(subMesh._id);
  124269. if (batch.mustReturn) {
  124270. return;
  124271. }
  124272. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  124273. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  124274. var effect = _this._volumetricLightScatteringPass;
  124275. if (mesh === _this.mesh) {
  124276. if (subMesh.effect) {
  124277. effect = subMesh.effect;
  124278. }
  124279. else {
  124280. effect = material.getEffect();
  124281. }
  124282. }
  124283. engine.enableEffect(effect);
  124284. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  124285. if (mesh === _this.mesh) {
  124286. material.bind(mesh.getWorldMatrix(), mesh);
  124287. }
  124288. else {
  124289. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  124290. // Alpha test
  124291. if (material && material.needAlphaTesting()) {
  124292. var alphaTexture = material.getAlphaTestTexture();
  124293. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  124294. if (alphaTexture) {
  124295. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  124296. }
  124297. }
  124298. // Bones
  124299. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  124300. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  124301. }
  124302. }
  124303. // Draw
  124304. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  124305. }
  124306. };
  124307. // Render target texture callbacks
  124308. var savedSceneClearColor;
  124309. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  124310. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  124311. savedSceneClearColor = scene.clearColor;
  124312. scene.clearColor = sceneClearColor;
  124313. });
  124314. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  124315. scene.clearColor = savedSceneClearColor;
  124316. });
  124317. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  124318. var engine = scene.getEngine();
  124319. var index;
  124320. if (depthOnlySubMeshes.length) {
  124321. engine.setColorWrite(false);
  124322. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  124323. renderSubMesh(depthOnlySubMeshes.data[index]);
  124324. }
  124325. engine.setColorWrite(true);
  124326. }
  124327. for (index = 0; index < opaqueSubMeshes.length; index++) {
  124328. renderSubMesh(opaqueSubMeshes.data[index]);
  124329. }
  124330. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  124331. renderSubMesh(alphaTestSubMeshes.data[index]);
  124332. }
  124333. if (transparentSubMeshes.length) {
  124334. // Sort sub meshes
  124335. for (index = 0; index < transparentSubMeshes.length; index++) {
  124336. var submesh = transparentSubMeshes.data[index];
  124337. var boundingInfo = submesh.getBoundingInfo();
  124338. if (boundingInfo && scene.activeCamera) {
  124339. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  124340. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  124341. }
  124342. }
  124343. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  124344. sortedArray.sort(function (a, b) {
  124345. // Alpha index first
  124346. if (a._alphaIndex > b._alphaIndex) {
  124347. return 1;
  124348. }
  124349. if (a._alphaIndex < b._alphaIndex) {
  124350. return -1;
  124351. }
  124352. // Then distance to camera
  124353. if (a._distanceToCamera < b._distanceToCamera) {
  124354. return 1;
  124355. }
  124356. if (a._distanceToCamera > b._distanceToCamera) {
  124357. return -1;
  124358. }
  124359. return 0;
  124360. });
  124361. // Render sub meshes
  124362. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  124363. for (index = 0; index < sortedArray.length; index++) {
  124364. renderSubMesh(sortedArray[index]);
  124365. }
  124366. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  124367. }
  124368. };
  124369. };
  124370. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  124371. var transform = scene.getTransformMatrix();
  124372. var meshPosition;
  124373. if (this.useCustomMeshPosition) {
  124374. meshPosition = this.customMeshPosition;
  124375. }
  124376. else if (this.attachedNode) {
  124377. meshPosition = this.attachedNode.position;
  124378. }
  124379. else {
  124380. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  124381. }
  124382. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  124383. this._screenCoordinates.x = pos.x / this._viewPort.width;
  124384. this._screenCoordinates.y = pos.y / this._viewPort.height;
  124385. if (this.invert) {
  124386. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  124387. }
  124388. };
  124389. // Static methods
  124390. /**
  124391. * Creates a default mesh for the Volumeric Light Scattering post-process
  124392. * @param name The mesh name
  124393. * @param scene The scene where to create the mesh
  124394. * @return the default mesh
  124395. */
  124396. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  124397. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  124398. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  124399. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  124400. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  124401. mesh.material = material;
  124402. return mesh;
  124403. };
  124404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  124406. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  124407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124409. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  124410. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124412. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  124413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  124415. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  124416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124418. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  124419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124421. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  124422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124424. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  124425. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124427. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  124428. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124430. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  124431. return VolumetricLightScatteringPostProcess;
  124432. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  124433. /***/ }),
  124434. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  124435. /*!************************************************************!*\
  124436. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  124437. \************************************************************/
  124438. /*! exports provided: VRDistortionCorrectionPostProcess, VRMultiviewToSingleview */
  124439. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124440. "use strict";
  124441. __webpack_require__.r(__webpack_exports__);
  124442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  124443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleview", function() { return VRMultiviewToSingleview; });
  124444. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124445. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124446. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124447. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124448. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  124449. /**
  124450. * VRDistortionCorrectionPostProcess used for mobile VR
  124451. */
  124452. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  124453. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  124454. /**
  124455. * Initializes the VRDistortionCorrectionPostProcess
  124456. * @param name The name of the effect.
  124457. * @param camera The camera to apply the render pass to.
  124458. * @param isRightEye If this is for the right eye distortion
  124459. * @param vrMetrics All the required metrics for the VR camera
  124460. */
  124461. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  124462. var _this = _super.call(this, name, "vrDistortionCorrection", [
  124463. 'LensCenter',
  124464. 'Scale',
  124465. 'ScaleIn',
  124466. 'HmdWarpParam'
  124467. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  124468. _this._isRightEye = isRightEye;
  124469. _this._distortionFactors = vrMetrics.distortionK;
  124470. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  124471. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  124472. _this.adaptScaleToCurrentViewport = true;
  124473. _this.onSizeChangedObservable.add(function () {
  124474. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  124475. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  124476. _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);
  124477. });
  124478. _this.onApplyObservable.add(function (effect) {
  124479. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  124480. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  124481. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  124482. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  124483. });
  124484. return _this;
  124485. }
  124486. return VRDistortionCorrectionPostProcess;
  124487. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  124488. /**
  124489. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  124490. * This will not be used for webXR as it supports displaying texture arrays directly
  124491. */
  124492. var VRMultiviewToSingleview = /** @class */ (function (_super) {
  124493. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRMultiviewToSingleview, _super);
  124494. /**
  124495. * Initializes a VRMultiviewToSingleview
  124496. * @param name name of the post process
  124497. * @param camera camera to be applied to
  124498. * @param scaleFactor scaling factor to the size of the output texture
  124499. */
  124500. function VRMultiviewToSingleview(name, camera, scaleFactor) {
  124501. var _this = _super.call(this, name, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], scaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  124502. _this.onSizeChangedObservable.add(function () {
  124503. });
  124504. _this.onApplyObservable.add(function (effect) {
  124505. if (camera._scene.activeCamera && camera._scene.activeCamera.isLeftCamera) {
  124506. effect.setInt("imageIndex", 0);
  124507. }
  124508. else {
  124509. effect.setInt("imageIndex", 1);
  124510. }
  124511. effect.setTexture("multiviewSampler", camera._multiviewTexture);
  124512. });
  124513. return _this;
  124514. }
  124515. return VRMultiviewToSingleview;
  124516. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  124517. /***/ }),
  124518. /***/ "./Probes/index.ts":
  124519. /*!*************************!*\
  124520. !*** ./Probes/index.ts ***!
  124521. \*************************/
  124522. /*! exports provided: ReflectionProbe */
  124523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124524. "use strict";
  124525. __webpack_require__.r(__webpack_exports__);
  124526. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  124527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  124528. /***/ }),
  124529. /***/ "./Probes/reflectionProbe.ts":
  124530. /*!***********************************!*\
  124531. !*** ./Probes/reflectionProbe.ts ***!
  124532. \***********************************/
  124533. /*! exports provided: ReflectionProbe */
  124534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124535. "use strict";
  124536. __webpack_require__.r(__webpack_exports__);
  124537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  124538. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124539. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  124540. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  124541. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124542. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  124543. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124544. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  124545. if (!this.reflectionProbes) {
  124546. return -1;
  124547. }
  124548. var index = this.reflectionProbes.indexOf(toRemove);
  124549. if (index !== -1) {
  124550. this.reflectionProbes.splice(index, 1);
  124551. }
  124552. return index;
  124553. };
  124554. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  124555. if (!this.reflectionProbes) {
  124556. this.reflectionProbes = [];
  124557. }
  124558. this.reflectionProbes.push(newReflectionProbe);
  124559. };
  124560. /**
  124561. * Class used to generate realtime reflection / refraction cube textures
  124562. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124563. */
  124564. var ReflectionProbe = /** @class */ (function () {
  124565. /**
  124566. * Creates a new reflection probe
  124567. * @param name defines the name of the probe
  124568. * @param size defines the texture resolution (for each face)
  124569. * @param scene defines the hosting scene
  124570. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124571. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124572. */
  124573. function ReflectionProbe(
  124574. /** defines the name of the probe */
  124575. name, size, scene, generateMipMaps, useFloat) {
  124576. if (generateMipMaps === void 0) { generateMipMaps = true; }
  124577. if (useFloat === void 0) { useFloat = false; }
  124578. var _this = this;
  124579. this.name = name;
  124580. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  124581. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124582. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124583. this._invertYAxis = false;
  124584. /** Gets or sets probe position (center of the cube map) */
  124585. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124586. this._scene = scene;
  124587. // Create the scene field if not exist.
  124588. if (!this._scene.reflectionProbes) {
  124589. this._scene.reflectionProbes = new Array();
  124590. }
  124591. this._scene.reflectionProbes.push(this);
  124592. 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);
  124593. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  124594. switch (faceIndex) {
  124595. case 0:
  124596. _this._add.copyFromFloats(1, 0, 0);
  124597. break;
  124598. case 1:
  124599. _this._add.copyFromFloats(-1, 0, 0);
  124600. break;
  124601. case 2:
  124602. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  124603. break;
  124604. case 3:
  124605. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  124606. break;
  124607. case 4:
  124608. _this._add.copyFromFloats(0, 0, 1);
  124609. break;
  124610. case 5:
  124611. _this._add.copyFromFloats(0, 0, -1);
  124612. break;
  124613. }
  124614. if (_this._attachedMesh) {
  124615. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  124616. }
  124617. _this.position.addToRef(_this._add, _this._target);
  124618. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  124619. if (scene.activeCamera) {
  124620. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  124621. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  124622. }
  124623. scene._forcedViewPosition = _this.position;
  124624. });
  124625. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  124626. scene._forcedViewPosition = null;
  124627. scene.updateTransformMatrix(true);
  124628. });
  124629. }
  124630. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  124631. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124632. get: function () {
  124633. return this._renderTargetTexture.samples;
  124634. },
  124635. set: function (value) {
  124636. this._renderTargetTexture.samples = value;
  124637. },
  124638. enumerable: true,
  124639. configurable: true
  124640. });
  124641. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  124642. /** Gets or sets the refresh rate to use (on every frame by default) */
  124643. get: function () {
  124644. return this._renderTargetTexture.refreshRate;
  124645. },
  124646. set: function (value) {
  124647. this._renderTargetTexture.refreshRate = value;
  124648. },
  124649. enumerable: true,
  124650. configurable: true
  124651. });
  124652. /**
  124653. * Gets the hosting scene
  124654. * @returns a Scene
  124655. */
  124656. ReflectionProbe.prototype.getScene = function () {
  124657. return this._scene;
  124658. };
  124659. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  124660. /** Gets the internal CubeTexture used to render to */
  124661. get: function () {
  124662. return this._renderTargetTexture;
  124663. },
  124664. enumerable: true,
  124665. configurable: true
  124666. });
  124667. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  124668. /** Gets the list of meshes to render */
  124669. get: function () {
  124670. return this._renderTargetTexture.renderList;
  124671. },
  124672. enumerable: true,
  124673. configurable: true
  124674. });
  124675. /**
  124676. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124677. * @param mesh defines the mesh to attach to
  124678. */
  124679. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  124680. this._attachedMesh = mesh;
  124681. };
  124682. /**
  124683. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124684. * @param renderingGroupId The rendering group id corresponding to its index
  124685. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124686. */
  124687. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  124688. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  124689. };
  124690. /**
  124691. * Clean all associated resources
  124692. */
  124693. ReflectionProbe.prototype.dispose = function () {
  124694. var index = this._scene.reflectionProbes.indexOf(this);
  124695. if (index !== -1) {
  124696. // Remove from the scene if found
  124697. this._scene.reflectionProbes.splice(index, 1);
  124698. }
  124699. if (this._renderTargetTexture) {
  124700. this._renderTargetTexture.dispose();
  124701. this._renderTargetTexture = null;
  124702. }
  124703. };
  124704. /**
  124705. * Converts the reflection probe information to a readable string for debug purpose.
  124706. * @param fullDetails Supports for multiple levels of logging within scene loading
  124707. * @returns the human readable reflection probe info
  124708. */
  124709. ReflectionProbe.prototype.toString = function (fullDetails) {
  124710. var ret = "Name: " + this.name;
  124711. if (fullDetails) {
  124712. ret += ", position: " + this.position.toString();
  124713. if (this._attachedMesh) {
  124714. ret += ", attached mesh: " + this._attachedMesh.name;
  124715. }
  124716. }
  124717. return ret;
  124718. };
  124719. /**
  124720. * Get the class name of the relfection probe.
  124721. * @returns "ReflectionProbe"
  124722. */
  124723. ReflectionProbe.prototype.getClassName = function () {
  124724. return "ReflectionProbe";
  124725. };
  124726. /**
  124727. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124728. * @returns The JSON representation of the texture
  124729. */
  124730. ReflectionProbe.prototype.serialize = function () {
  124731. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  124732. serializationObject.isReflectionProbe = true;
  124733. return serializationObject;
  124734. };
  124735. /**
  124736. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124737. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124738. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124739. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124740. * @returns The parsed reflection probe if successful
  124741. */
  124742. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  124743. var reflectionProbe = null;
  124744. if (scene.reflectionProbes) {
  124745. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  124746. var rp = scene.reflectionProbes[index];
  124747. if (rp.name === parsedReflectionProbe.name) {
  124748. reflectionProbe = rp;
  124749. break;
  124750. }
  124751. }
  124752. }
  124753. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  124754. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  124755. if (parsedReflectionProbe._attachedMesh) {
  124756. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  124757. }
  124758. return reflectionProbe;
  124759. };
  124760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  124762. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  124763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  124765. ], ReflectionProbe.prototype, "position", void 0);
  124766. return ReflectionProbe;
  124767. }());
  124768. /***/ }),
  124769. /***/ "./Rendering/boundingBoxRenderer.ts":
  124770. /*!******************************************!*\
  124771. !*** ./Rendering/boundingBoxRenderer.ts ***!
  124772. \******************************************/
  124773. /*! exports provided: BoundingBoxRenderer */
  124774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124775. "use strict";
  124776. __webpack_require__.r(__webpack_exports__);
  124777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  124778. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124779. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124780. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  124781. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  124782. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124783. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  124784. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124785. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124786. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  124787. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  124788. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  124789. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  124790. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  124791. get: function () {
  124792. return this._forceShowBoundingBoxes || false;
  124793. },
  124794. set: function (value) {
  124795. this._forceShowBoundingBoxes = value;
  124796. // Lazyly creates a BB renderer if needed.
  124797. if (value) {
  124798. this.getBoundingBoxRenderer();
  124799. }
  124800. },
  124801. enumerable: true,
  124802. configurable: true
  124803. });
  124804. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  124805. if (!this._boundingBoxRenderer) {
  124806. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  124807. }
  124808. return this._boundingBoxRenderer;
  124809. };
  124810. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  124811. get: function () {
  124812. return this._showBoundingBox || false;
  124813. },
  124814. set: function (value) {
  124815. this._showBoundingBox = value;
  124816. // Lazyly creates a BB renderer if needed.
  124817. if (value) {
  124818. this.getScene().getBoundingBoxRenderer();
  124819. }
  124820. },
  124821. enumerable: true,
  124822. configurable: true
  124823. });
  124824. /**
  124825. * Component responsible of rendering the bounding box of the meshes in a scene.
  124826. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  124827. */
  124828. var BoundingBoxRenderer = /** @class */ (function () {
  124829. /**
  124830. * Instantiates a new bounding box renderer in a scene.
  124831. * @param scene the scene the renderer renders in
  124832. */
  124833. function BoundingBoxRenderer(scene) {
  124834. /**
  124835. * The component name helpfull to identify the component in the list of scene components.
  124836. */
  124837. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  124838. /**
  124839. * Color of the bounding box lines placed in front of an object
  124840. */
  124841. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  124842. /**
  124843. * Color of the bounding box lines placed behind an object
  124844. */
  124845. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  124846. /**
  124847. * Defines if the renderer should show the back lines or not
  124848. */
  124849. this.showBackLines = true;
  124850. /**
  124851. * @hidden
  124852. */
  124853. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  124854. this._vertexBuffers = {};
  124855. this.scene = scene;
  124856. scene._addComponent(this);
  124857. }
  124858. /**
  124859. * Registers the component in a given scene
  124860. */
  124861. BoundingBoxRenderer.prototype.register = function () {
  124862. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  124863. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  124864. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  124865. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  124866. };
  124867. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  124868. if (mesh.showSubMeshesBoundingBox) {
  124869. var boundingInfo = subMesh.getBoundingInfo();
  124870. if (boundingInfo !== null && boundingInfo !== undefined) {
  124871. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  124872. this.renderList.push(boundingInfo.boundingBox);
  124873. }
  124874. }
  124875. };
  124876. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  124877. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  124878. var boundingInfo = sourceMesh.getBoundingInfo();
  124879. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  124880. this.renderList.push(boundingInfo.boundingBox);
  124881. }
  124882. };
  124883. BoundingBoxRenderer.prototype._prepareRessources = function () {
  124884. if (this._colorShader) {
  124885. return;
  124886. }
  124887. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  124888. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  124889. uniforms: ["world", "viewProjection", "color"]
  124890. });
  124891. var engine = this.scene.getEngine();
  124892. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  124893. 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);
  124894. this._createIndexBuffer();
  124895. };
  124896. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  124897. var engine = this.scene.getEngine();
  124898. 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]);
  124899. };
  124900. /**
  124901. * Rebuilds the elements related to this component in case of
  124902. * context lost for instance.
  124903. */
  124904. BoundingBoxRenderer.prototype.rebuild = function () {
  124905. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  124906. if (vb) {
  124907. vb._rebuild();
  124908. }
  124909. this._createIndexBuffer();
  124910. };
  124911. /**
  124912. * @hidden
  124913. */
  124914. BoundingBoxRenderer.prototype.reset = function () {
  124915. this.renderList.reset();
  124916. };
  124917. /**
  124918. * Render the bounding boxes of a specific rendering group
  124919. * @param renderingGroupId defines the rendering group to render
  124920. */
  124921. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  124922. if (this.renderList.length === 0) {
  124923. return;
  124924. }
  124925. this._prepareRessources();
  124926. if (!this._colorShader.isReady()) {
  124927. return;
  124928. }
  124929. var engine = this.scene.getEngine();
  124930. engine.setDepthWrite(false);
  124931. this._colorShader._preBind();
  124932. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  124933. var boundingBox = this.renderList.data[boundingBoxIndex];
  124934. if (boundingBox._tag !== renderingGroupId) {
  124935. continue;
  124936. }
  124937. var min = boundingBox.minimum;
  124938. var max = boundingBox.maximum;
  124939. var diff = max.subtract(min);
  124940. var median = min.add(diff.scale(0.5));
  124941. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  124942. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  124943. .multiply(boundingBox.getWorldMatrix());
  124944. // VBOs
  124945. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  124946. if (this.showBackLines) {
  124947. // Back
  124948. engine.setDepthFunctionToGreaterOrEqual();
  124949. this.scene.resetCachedMaterial();
  124950. this._colorShader.setColor4("color", this.backColor.toColor4());
  124951. this._colorShader.bind(worldMatrix);
  124952. // Draw order
  124953. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  124954. }
  124955. // Front
  124956. engine.setDepthFunctionToLess();
  124957. this.scene.resetCachedMaterial();
  124958. this._colorShader.setColor4("color", this.frontColor.toColor4());
  124959. this._colorShader.bind(worldMatrix);
  124960. // Draw order
  124961. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  124962. }
  124963. this._colorShader.unbind();
  124964. engine.setDepthFunctionToLessOrEqual();
  124965. engine.setDepthWrite(true);
  124966. };
  124967. /**
  124968. * In case of occlusion queries, we can render the occlusion bounding box through this method
  124969. * @param mesh Define the mesh to render the occlusion bounding box for
  124970. */
  124971. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  124972. this._prepareRessources();
  124973. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  124974. return;
  124975. }
  124976. var engine = this.scene.getEngine();
  124977. engine.setDepthWrite(false);
  124978. engine.setColorWrite(false);
  124979. this._colorShader._preBind();
  124980. var boundingBox = mesh._boundingInfo.boundingBox;
  124981. var min = boundingBox.minimum;
  124982. var max = boundingBox.maximum;
  124983. var diff = max.subtract(min);
  124984. var median = min.add(diff.scale(0.5));
  124985. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  124986. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  124987. .multiply(boundingBox.getWorldMatrix());
  124988. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  124989. engine.setDepthFunctionToLess();
  124990. this.scene.resetCachedMaterial();
  124991. this._colorShader.bind(worldMatrix);
  124992. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  124993. this._colorShader.unbind();
  124994. engine.setDepthFunctionToLessOrEqual();
  124995. engine.setDepthWrite(true);
  124996. engine.setColorWrite(true);
  124997. };
  124998. /**
  124999. * Dispose and release the resources attached to this renderer.
  125000. */
  125001. BoundingBoxRenderer.prototype.dispose = function () {
  125002. if (!this._colorShader) {
  125003. return;
  125004. }
  125005. this.renderList.dispose();
  125006. this._colorShader.dispose();
  125007. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125008. if (buffer) {
  125009. buffer.dispose();
  125010. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  125011. }
  125012. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  125013. };
  125014. return BoundingBoxRenderer;
  125015. }());
  125016. /***/ }),
  125017. /***/ "./Rendering/depthRenderer.ts":
  125018. /*!************************************!*\
  125019. !*** ./Rendering/depthRenderer.ts ***!
  125020. \************************************/
  125021. /*! exports provided: DepthRenderer */
  125022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125023. "use strict";
  125024. __webpack_require__.r(__webpack_exports__);
  125025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  125026. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125027. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125028. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125029. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  125030. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125031. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125032. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  125033. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  125034. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  125035. /**
  125036. * This represents a depth renderer in Babylon.
  125037. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  125038. */
  125039. var DepthRenderer = /** @class */ (function () {
  125040. /**
  125041. * Instantiates a depth renderer
  125042. * @param scene The scene the renderer belongs to
  125043. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  125044. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  125045. */
  125046. function DepthRenderer(scene, type, camera) {
  125047. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  125048. if (camera === void 0) { camera = null; }
  125049. var _this = this;
  125050. /**
  125051. * Specifiess that the depth renderer will only be used within
  125052. * the camera it is created for.
  125053. * This can help forcing its rendering during the camera processing.
  125054. */
  125055. this.useOnlyInActiveCamera = false;
  125056. this._scene = scene;
  125057. DepthRenderer._SceneComponentInitialization(this._scene);
  125058. this._camera = camera;
  125059. var engine = scene.getEngine();
  125060. // Render target
  125061. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  125062. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  125063. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  125064. this._depthMap.refreshRate = 1;
  125065. this._depthMap.renderParticles = false;
  125066. this._depthMap.renderList = null;
  125067. // Camera to get depth map from to support multiple concurrent cameras
  125068. this._depthMap.activeCamera = this._camera;
  125069. this._depthMap.ignoreCameraViewport = true;
  125070. this._depthMap.useCameraPostProcesses = false;
  125071. // set default depth value to 1.0 (far away)
  125072. this._depthMap.onClearObservable.add(function (engine) {
  125073. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  125074. });
  125075. // Custom render function
  125076. var renderSubMesh = function (subMesh) {
  125077. var mesh = subMesh.getRenderingMesh();
  125078. var scene = _this._scene;
  125079. var engine = scene.getEngine();
  125080. var material = subMesh.getMaterial();
  125081. if (!material) {
  125082. return;
  125083. }
  125084. // Culling and reverse (right handed system)
  125085. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  125086. // Managing instances
  125087. var batch = mesh._getInstancesRenderList(subMesh._id);
  125088. if (batch.mustReturn) {
  125089. return;
  125090. }
  125091. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  125092. var camera = _this._camera || scene.activeCamera;
  125093. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  125094. engine.enableEffect(_this._effect);
  125095. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  125096. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  125097. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  125098. // Alpha test
  125099. if (material && material.needAlphaTesting()) {
  125100. var alphaTexture = material.getAlphaTestTexture();
  125101. if (alphaTexture) {
  125102. _this._effect.setTexture("diffuseSampler", alphaTexture);
  125103. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  125104. }
  125105. }
  125106. // Bones
  125107. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  125108. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  125109. }
  125110. // Draw
  125111. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  125112. }
  125113. };
  125114. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  125115. var index;
  125116. if (depthOnlySubMeshes.length) {
  125117. engine.setColorWrite(false);
  125118. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  125119. renderSubMesh(depthOnlySubMeshes.data[index]);
  125120. }
  125121. engine.setColorWrite(true);
  125122. }
  125123. for (index = 0; index < opaqueSubMeshes.length; index++) {
  125124. renderSubMesh(opaqueSubMeshes.data[index]);
  125125. }
  125126. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  125127. renderSubMesh(alphaTestSubMeshes.data[index]);
  125128. }
  125129. };
  125130. }
  125131. /**
  125132. * Creates the depth rendering effect and checks if the effect is ready.
  125133. * @param subMesh The submesh to be used to render the depth map of
  125134. * @param useInstances If multiple world instances should be used
  125135. * @returns if the depth renderer is ready to render the depth map
  125136. */
  125137. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  125138. var material = subMesh.getMaterial();
  125139. if (material.disableDepthWrite) {
  125140. return false;
  125141. }
  125142. var defines = [];
  125143. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125144. var mesh = subMesh.getMesh();
  125145. // Alpha test
  125146. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  125147. defines.push("#define ALPHATEST");
  125148. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  125149. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  125150. defines.push("#define UV1");
  125151. }
  125152. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  125153. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  125154. defines.push("#define UV2");
  125155. }
  125156. }
  125157. // Bones
  125158. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  125159. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  125160. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  125161. if (mesh.numBoneInfluencers > 4) {
  125162. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  125163. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  125164. }
  125165. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  125166. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  125167. }
  125168. else {
  125169. defines.push("#define NUM_BONE_INFLUENCERS 0");
  125170. }
  125171. // Instances
  125172. if (useInstances) {
  125173. defines.push("#define INSTANCES");
  125174. attribs.push("world0");
  125175. attribs.push("world1");
  125176. attribs.push("world2");
  125177. attribs.push("world3");
  125178. }
  125179. // Get correct effect
  125180. var join = defines.join("\n");
  125181. if (this._cachedDefines !== join) {
  125182. this._cachedDefines = join;
  125183. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  125184. }
  125185. return this._effect.isReady();
  125186. };
  125187. /**
  125188. * Gets the texture which the depth map will be written to.
  125189. * @returns The depth map texture
  125190. */
  125191. DepthRenderer.prototype.getDepthMap = function () {
  125192. return this._depthMap;
  125193. };
  125194. /**
  125195. * Disposes of the depth renderer.
  125196. */
  125197. DepthRenderer.prototype.dispose = function () {
  125198. this._depthMap.dispose();
  125199. };
  125200. /** @hidden */
  125201. DepthRenderer._SceneComponentInitialization = function (_) {
  125202. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  125203. };
  125204. return DepthRenderer;
  125205. }());
  125206. /***/ }),
  125207. /***/ "./Rendering/depthRendererSceneComponent.ts":
  125208. /*!**************************************************!*\
  125209. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  125210. \**************************************************/
  125211. /*! exports provided: DepthRendererSceneComponent */
  125212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125213. "use strict";
  125214. __webpack_require__.r(__webpack_exports__);
  125215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  125216. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125217. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  125218. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125219. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125220. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  125221. camera = camera || this.activeCamera;
  125222. if (!camera) {
  125223. throw "No camera available to enable depth renderer";
  125224. }
  125225. if (!this._depthRenderer) {
  125226. this._depthRenderer = {};
  125227. }
  125228. if (!this._depthRenderer[camera.id]) {
  125229. var textureType = 0;
  125230. if (this.getEngine().getCaps().textureHalfFloatRender) {
  125231. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  125232. }
  125233. else if (this.getEngine().getCaps().textureFloatRender) {
  125234. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  125235. }
  125236. else {
  125237. throw "Depth renderer does not support int texture type";
  125238. }
  125239. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  125240. }
  125241. return this._depthRenderer[camera.id];
  125242. };
  125243. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  125244. camera = camera || this.activeCamera;
  125245. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  125246. return;
  125247. }
  125248. this._depthRenderer[camera.id].dispose();
  125249. delete this._depthRenderer[camera.id];
  125250. };
  125251. /**
  125252. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  125253. * in several rendering techniques.
  125254. */
  125255. var DepthRendererSceneComponent = /** @class */ (function () {
  125256. /**
  125257. * Creates a new instance of the component for the given scene
  125258. * @param scene Defines the scene to register the component in
  125259. */
  125260. function DepthRendererSceneComponent(scene) {
  125261. /**
  125262. * The component name helpfull to identify the component in the list of scene components.
  125263. */
  125264. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  125265. this.scene = scene;
  125266. }
  125267. /**
  125268. * Registers the component in a given scene
  125269. */
  125270. DepthRendererSceneComponent.prototype.register = function () {
  125271. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  125272. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  125273. };
  125274. /**
  125275. * Rebuilds the elements related to this component in case of
  125276. * context lost for instance.
  125277. */
  125278. DepthRendererSceneComponent.prototype.rebuild = function () {
  125279. // Nothing to do for this component
  125280. };
  125281. /**
  125282. * Disposes the component and the associated ressources
  125283. */
  125284. DepthRendererSceneComponent.prototype.dispose = function () {
  125285. for (var key in this.scene._depthRenderer) {
  125286. this.scene._depthRenderer[key].dispose();
  125287. }
  125288. };
  125289. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  125290. if (this.scene._depthRenderer) {
  125291. for (var key in this.scene._depthRenderer) {
  125292. var depthRenderer = this.scene._depthRenderer[key];
  125293. if (!depthRenderer.useOnlyInActiveCamera) {
  125294. renderTargets.push(depthRenderer.getDepthMap());
  125295. }
  125296. }
  125297. }
  125298. };
  125299. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  125300. if (this.scene._depthRenderer) {
  125301. for (var key in this.scene._depthRenderer) {
  125302. var depthRenderer = this.scene._depthRenderer[key];
  125303. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  125304. renderTargets.push(depthRenderer.getDepthMap());
  125305. }
  125306. }
  125307. }
  125308. };
  125309. return DepthRendererSceneComponent;
  125310. }());
  125311. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  125312. // Register the G Buffer component to the scene.
  125313. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  125314. if (!component) {
  125315. component = new DepthRendererSceneComponent(scene);
  125316. scene._addComponent(component);
  125317. }
  125318. };
  125319. /***/ }),
  125320. /***/ "./Rendering/edgesRenderer.ts":
  125321. /*!************************************!*\
  125322. !*** ./Rendering/edgesRenderer.ts ***!
  125323. \************************************/
  125324. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  125325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125326. "use strict";
  125327. __webpack_require__.r(__webpack_exports__);
  125328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  125329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  125330. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125331. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125332. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  125333. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  125334. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125335. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125336. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  125337. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  125338. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125339. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  125340. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  125341. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  125342. if (this._edgesRenderer) {
  125343. this._edgesRenderer.dispose();
  125344. this._edgesRenderer = null;
  125345. }
  125346. return this;
  125347. };
  125348. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  125349. if (epsilon === void 0) { epsilon = 0.95; }
  125350. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  125351. this.disableEdgesRendering();
  125352. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  125353. return this;
  125354. };
  125355. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  125356. get: function () {
  125357. return this._edgesRenderer;
  125358. },
  125359. enumerable: true,
  125360. configurable: true
  125361. });
  125362. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  125363. if (epsilon === void 0) { epsilon = 0.95; }
  125364. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  125365. this.disableEdgesRendering();
  125366. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  125367. return this;
  125368. };
  125369. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  125370. if (epsilon === void 0) { epsilon = 0.95; }
  125371. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  125372. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  125373. return this;
  125374. };
  125375. /**
  125376. * FaceAdjacencies Helper class to generate edges
  125377. */
  125378. var FaceAdjacencies = /** @class */ (function () {
  125379. function FaceAdjacencies() {
  125380. this.edges = new Array();
  125381. this.edgesConnectedCount = 0;
  125382. }
  125383. return FaceAdjacencies;
  125384. }());
  125385. /**
  125386. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  125387. */
  125388. var EdgesRenderer = /** @class */ (function () {
  125389. /**
  125390. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  125391. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  125392. * @param source Mesh used to create edges
  125393. * @param epsilon sum of angles in adjacency to check for edge
  125394. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  125395. * @param generateEdgesLines - should generate Lines or only prepare resources.
  125396. */
  125397. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  125398. if (epsilon === void 0) { epsilon = 0.95; }
  125399. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  125400. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  125401. var _this = this;
  125402. /**
  125403. * Define the size of the edges with an orthographic camera
  125404. */
  125405. this.edgesWidthScalerForOrthographic = 1000.0;
  125406. /**
  125407. * Define the size of the edges with a perspective camera
  125408. */
  125409. this.edgesWidthScalerForPerspective = 50.0;
  125410. this._linesPositions = new Array();
  125411. this._linesNormals = new Array();
  125412. this._linesIndices = new Array();
  125413. this._buffers = {};
  125414. this._checkVerticesInsteadOfIndices = false;
  125415. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  125416. this.isEnabled = true;
  125417. this._source = source;
  125418. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  125419. this._epsilon = epsilon;
  125420. this._prepareRessources();
  125421. if (generateEdgesLines) {
  125422. this._generateEdgesLines();
  125423. }
  125424. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  125425. _this._rebuild();
  125426. });
  125427. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  125428. _this.dispose();
  125429. });
  125430. }
  125431. EdgesRenderer.prototype._prepareRessources = function () {
  125432. if (this._lineShader) {
  125433. return;
  125434. }
  125435. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  125436. attributes: ["position", "normal"],
  125437. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  125438. });
  125439. this._lineShader.disableDepthWrite = true;
  125440. this._lineShader.backFaceCulling = false;
  125441. };
  125442. /** @hidden */
  125443. EdgesRenderer.prototype._rebuild = function () {
  125444. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125445. if (buffer) {
  125446. buffer._rebuild();
  125447. }
  125448. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  125449. if (buffer) {
  125450. buffer._rebuild();
  125451. }
  125452. var scene = this._source.getScene();
  125453. var engine = scene.getEngine();
  125454. this._ib = engine.createIndexBuffer(this._linesIndices);
  125455. };
  125456. /**
  125457. * Releases the required resources for the edges renderer
  125458. */
  125459. EdgesRenderer.prototype.dispose = function () {
  125460. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  125461. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  125462. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125463. if (buffer) {
  125464. buffer.dispose();
  125465. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  125466. }
  125467. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  125468. if (buffer) {
  125469. buffer.dispose();
  125470. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  125471. }
  125472. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  125473. this._lineShader.dispose();
  125474. };
  125475. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  125476. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  125477. return 0;
  125478. }
  125479. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  125480. return 1;
  125481. }
  125482. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  125483. return 2;
  125484. }
  125485. return -1;
  125486. };
  125487. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  125488. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  125489. return 0;
  125490. }
  125491. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  125492. return 1;
  125493. }
  125494. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  125495. return 2;
  125496. }
  125497. return -1;
  125498. };
  125499. /**
  125500. * Checks if the pair of p0 and p1 is en edge
  125501. * @param faceIndex
  125502. * @param edge
  125503. * @param faceNormals
  125504. * @param p0
  125505. * @param p1
  125506. * @private
  125507. */
  125508. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  125509. var needToCreateLine;
  125510. if (edge === undefined) {
  125511. needToCreateLine = true;
  125512. }
  125513. else {
  125514. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  125515. needToCreateLine = dotProduct < this._epsilon;
  125516. }
  125517. if (needToCreateLine) {
  125518. this.createLine(p0, p1, this._linesPositions.length / 3);
  125519. }
  125520. };
  125521. /**
  125522. * push line into the position, normal and index buffer
  125523. * @protected
  125524. */
  125525. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  125526. // Positions
  125527. 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);
  125528. // Normals
  125529. 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);
  125530. // Indices
  125531. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  125532. };
  125533. /**
  125534. * Generates lines edges from adjacencjes
  125535. * @private
  125536. */
  125537. EdgesRenderer.prototype._generateEdgesLines = function () {
  125538. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  125539. var indices = this._source.getIndices();
  125540. if (!indices || !positions) {
  125541. return;
  125542. }
  125543. // First let's find adjacencies
  125544. var adjacencies = new Array();
  125545. var faceNormals = new Array();
  125546. var index;
  125547. var faceAdjacencies;
  125548. // Prepare faces
  125549. for (index = 0; index < indices.length; index += 3) {
  125550. faceAdjacencies = new FaceAdjacencies();
  125551. var p0Index = indices[index];
  125552. var p1Index = indices[index + 1];
  125553. var p2Index = indices[index + 2];
  125554. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  125555. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  125556. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  125557. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  125558. faceNormal.normalize();
  125559. faceNormals.push(faceNormal);
  125560. adjacencies.push(faceAdjacencies);
  125561. }
  125562. // Scan
  125563. for (index = 0; index < adjacencies.length; index++) {
  125564. faceAdjacencies = adjacencies[index];
  125565. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  125566. var otherFaceAdjacencies = adjacencies[otherIndex];
  125567. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  125568. break;
  125569. }
  125570. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  125571. continue;
  125572. }
  125573. var otherP0 = indices[otherIndex * 3];
  125574. var otherP1 = indices[otherIndex * 3 + 1];
  125575. var otherP2 = indices[otherIndex * 3 + 2];
  125576. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  125577. var otherEdgeIndex = 0;
  125578. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  125579. continue;
  125580. }
  125581. switch (edgeIndex) {
  125582. case 0:
  125583. if (this._checkVerticesInsteadOfIndices) {
  125584. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  125585. }
  125586. else {
  125587. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  125588. }
  125589. break;
  125590. case 1:
  125591. if (this._checkVerticesInsteadOfIndices) {
  125592. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  125593. }
  125594. else {
  125595. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  125596. }
  125597. break;
  125598. case 2:
  125599. if (this._checkVerticesInsteadOfIndices) {
  125600. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  125601. }
  125602. else {
  125603. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  125604. }
  125605. break;
  125606. }
  125607. if (otherEdgeIndex === -1) {
  125608. continue;
  125609. }
  125610. faceAdjacencies.edges[edgeIndex] = otherIndex;
  125611. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  125612. faceAdjacencies.edgesConnectedCount++;
  125613. otherFaceAdjacencies.edgesConnectedCount++;
  125614. if (faceAdjacencies.edgesConnectedCount === 3) {
  125615. break;
  125616. }
  125617. }
  125618. }
  125619. }
  125620. // Create lines
  125621. for (index = 0; index < adjacencies.length; index++) {
  125622. // 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
  125623. var current = adjacencies[index];
  125624. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  125625. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  125626. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  125627. }
  125628. // Merge into a single mesh
  125629. var engine = this._source.getScene().getEngine();
  125630. 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);
  125631. 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);
  125632. this._ib = engine.createIndexBuffer(this._linesIndices);
  125633. this._indicesCount = this._linesIndices.length;
  125634. };
  125635. /**
  125636. * Checks wether or not the edges renderer is ready to render.
  125637. * @return true if ready, otherwise false.
  125638. */
  125639. EdgesRenderer.prototype.isReady = function () {
  125640. return this._lineShader.isReady();
  125641. };
  125642. /**
  125643. * Renders the edges of the attached mesh,
  125644. */
  125645. EdgesRenderer.prototype.render = function () {
  125646. var scene = this._source.getScene();
  125647. if (!this.isReady() || !scene.activeCamera) {
  125648. return;
  125649. }
  125650. var engine = scene.getEngine();
  125651. this._lineShader._preBind();
  125652. if (this._source.edgesColor.a !== 1) {
  125653. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  125654. }
  125655. else {
  125656. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  125657. }
  125658. // VBOs
  125659. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  125660. scene.resetCachedMaterial();
  125661. this._lineShader.setColor4("color", this._source.edgesColor);
  125662. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  125663. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  125664. }
  125665. else {
  125666. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  125667. }
  125668. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  125669. this._lineShader.bind(this._source.getWorldMatrix());
  125670. // Draw order
  125671. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  125672. this._lineShader.unbind();
  125673. };
  125674. return EdgesRenderer;
  125675. }());
  125676. /**
  125677. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  125678. */
  125679. var LineEdgesRenderer = /** @class */ (function (_super) {
  125680. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  125681. /**
  125682. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  125683. * @param source LineMesh used to generate edges
  125684. * @param epsilon not important (specified angle for edge detection)
  125685. * @param checkVerticesInsteadOfIndices not important for LineMesh
  125686. */
  125687. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  125688. if (epsilon === void 0) { epsilon = 0.95; }
  125689. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  125690. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  125691. _this._generateEdgesLines();
  125692. return _this;
  125693. }
  125694. /**
  125695. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  125696. */
  125697. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  125698. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  125699. var indices = this._source.getIndices();
  125700. if (!indices || !positions) {
  125701. return;
  125702. }
  125703. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  125704. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  125705. var len = indices.length - 1;
  125706. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  125707. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  125708. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  125709. this.createLine(p0, p1, offset);
  125710. }
  125711. // Merge into a single mesh
  125712. var engine = this._source.getScene().getEngine();
  125713. 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);
  125714. 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);
  125715. this._ib = engine.createIndexBuffer(this._linesIndices);
  125716. this._indicesCount = this._linesIndices.length;
  125717. };
  125718. return LineEdgesRenderer;
  125719. }(EdgesRenderer));
  125720. /***/ }),
  125721. /***/ "./Rendering/geometryBufferRenderer.ts":
  125722. /*!*********************************************!*\
  125723. !*** ./Rendering/geometryBufferRenderer.ts ***!
  125724. \*********************************************/
  125725. /*! exports provided: GeometryBufferRenderer */
  125726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125727. "use strict";
  125728. __webpack_require__.r(__webpack_exports__);
  125729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  125730. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125731. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125732. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125733. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125734. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  125735. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125736. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  125737. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  125738. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  125739. /**
  125740. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  125741. */
  125742. var GeometryBufferRenderer = /** @class */ (function () {
  125743. /**
  125744. * Creates a new G Buffer for the scene
  125745. * @param scene The scene the buffer belongs to
  125746. * @param ratio How big is the buffer related to the main canvas.
  125747. */
  125748. function GeometryBufferRenderer(scene, ratio) {
  125749. if (ratio === void 0) { ratio = 1; }
  125750. /**
  125751. * Dictionary used to store the previous transformation matrices of each rendered mesh
  125752. * in order to compute objects velocities when enableVelocity is set to "true"
  125753. * @hidden
  125754. */
  125755. this._previousTransformationMatrices = {};
  125756. this._enablePosition = false;
  125757. this._enableVelocity = false;
  125758. this._positionIndex = -1;
  125759. this._velocityIndex = -1;
  125760. this._scene = scene;
  125761. this._ratio = ratio;
  125762. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  125763. // Render target
  125764. this._createRenderTargets();
  125765. }
  125766. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  125767. /**
  125768. * Set the render list (meshes to be rendered) used in the G buffer.
  125769. */
  125770. set: function (meshes) {
  125771. this._multiRenderTarget.renderList = meshes;
  125772. },
  125773. enumerable: true,
  125774. configurable: true
  125775. });
  125776. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  125777. /**
  125778. * Gets wether or not G buffer are supported by the running hardware.
  125779. * This requires draw buffer supports
  125780. */
  125781. get: function () {
  125782. return this._multiRenderTarget.isSupported;
  125783. },
  125784. enumerable: true,
  125785. configurable: true
  125786. });
  125787. /**
  125788. * Returns the index of the given texture type in the G-Buffer textures array
  125789. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  125790. * @returns the index of the given texture type in the G-Buffer textures array
  125791. */
  125792. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  125793. switch (textureType) {
  125794. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  125795. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  125796. default: return -1;
  125797. }
  125798. };
  125799. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  125800. /**
  125801. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  125802. */
  125803. get: function () {
  125804. return this._enablePosition;
  125805. },
  125806. /**
  125807. * Sets whether or not objects positions are enabled for the G buffer.
  125808. */
  125809. set: function (enable) {
  125810. this._enablePosition = enable;
  125811. this.dispose();
  125812. this._createRenderTargets();
  125813. },
  125814. enumerable: true,
  125815. configurable: true
  125816. });
  125817. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  125818. /**
  125819. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  125820. */
  125821. get: function () {
  125822. return this._enableVelocity;
  125823. },
  125824. /**
  125825. * Sets wether or not objects velocities are enabled for the G buffer.
  125826. */
  125827. set: function (enable) {
  125828. this._enableVelocity = enable;
  125829. this.dispose();
  125830. this._createRenderTargets();
  125831. },
  125832. enumerable: true,
  125833. configurable: true
  125834. });
  125835. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  125836. /**
  125837. * Gets the scene associated with the buffer.
  125838. */
  125839. get: function () {
  125840. return this._scene;
  125841. },
  125842. enumerable: true,
  125843. configurable: true
  125844. });
  125845. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  125846. /**
  125847. * Gets the ratio used by the buffer during its creation.
  125848. * How big is the buffer related to the main canvas.
  125849. */
  125850. get: function () {
  125851. return this._ratio;
  125852. },
  125853. enumerable: true,
  125854. configurable: true
  125855. });
  125856. /**
  125857. * Checks wether everything is ready to render a submesh to the G buffer.
  125858. * @param subMesh the submesh to check readiness for
  125859. * @param useInstances is the mesh drawn using instance or not
  125860. * @returns true if ready otherwise false
  125861. */
  125862. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  125863. var material = subMesh.getMaterial();
  125864. if (material && material.disableDepthWrite) {
  125865. return false;
  125866. }
  125867. var defines = [];
  125868. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  125869. var mesh = subMesh.getMesh();
  125870. // Alpha test
  125871. if (material && material.needAlphaTesting()) {
  125872. defines.push("#define ALPHATEST");
  125873. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  125874. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  125875. defines.push("#define UV1");
  125876. }
  125877. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  125878. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  125879. defines.push("#define UV2");
  125880. }
  125881. }
  125882. // Buffers
  125883. if (this._enablePosition) {
  125884. defines.push("#define POSITION");
  125885. defines.push("#define POSITION_INDEX " + this._positionIndex);
  125886. }
  125887. if (this._enableVelocity) {
  125888. defines.push("#define VELOCITY");
  125889. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  125890. }
  125891. // Bones
  125892. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  125893. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  125894. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  125895. if (mesh.numBoneInfluencers > 4) {
  125896. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  125897. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  125898. }
  125899. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  125900. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  125901. }
  125902. else {
  125903. defines.push("#define NUM_BONE_INFLUENCERS 0");
  125904. }
  125905. // Instances
  125906. if (useInstances) {
  125907. defines.push("#define INSTANCES");
  125908. attribs.push("world0");
  125909. attribs.push("world1");
  125910. attribs.push("world2");
  125911. attribs.push("world3");
  125912. }
  125913. // Setup textures count
  125914. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  125915. // Get correct effect
  125916. var join = defines.join("\n");
  125917. if (this._cachedDefines !== join) {
  125918. this._cachedDefines = join;
  125919. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  125920. }
  125921. return this._effect.isReady();
  125922. };
  125923. /**
  125924. * Gets the current underlying G Buffer.
  125925. * @returns the buffer
  125926. */
  125927. GeometryBufferRenderer.prototype.getGBuffer = function () {
  125928. return this._multiRenderTarget;
  125929. };
  125930. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  125931. /**
  125932. * Gets the number of samples used to render the buffer (anti aliasing).
  125933. */
  125934. get: function () {
  125935. return this._multiRenderTarget.samples;
  125936. },
  125937. /**
  125938. * Sets the number of samples used to render the buffer (anti aliasing).
  125939. */
  125940. set: function (value) {
  125941. this._multiRenderTarget.samples = value;
  125942. },
  125943. enumerable: true,
  125944. configurable: true
  125945. });
  125946. /**
  125947. * Disposes the renderer and frees up associated resources.
  125948. */
  125949. GeometryBufferRenderer.prototype.dispose = function () {
  125950. this.getGBuffer().dispose();
  125951. };
  125952. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  125953. var _this = this;
  125954. var engine = this._scene.getEngine();
  125955. var count = 2;
  125956. if (this._enablePosition) {
  125957. this._positionIndex = count;
  125958. count++;
  125959. }
  125960. if (this._enableVelocity) {
  125961. this._velocityIndex = count;
  125962. count++;
  125963. }
  125964. 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 });
  125965. if (!this.isSupported) {
  125966. return;
  125967. }
  125968. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  125969. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  125970. this._multiRenderTarget.refreshRate = 1;
  125971. this._multiRenderTarget.renderParticles = false;
  125972. this._multiRenderTarget.renderList = null;
  125973. // set default depth value to 1.0 (far away)
  125974. this._multiRenderTarget.onClearObservable.add(function (engine) {
  125975. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  125976. });
  125977. // Custom render function
  125978. var renderSubMesh = function (subMesh) {
  125979. var mesh = subMesh.getRenderingMesh();
  125980. var scene = _this._scene;
  125981. var engine = scene.getEngine();
  125982. var material = subMesh.getMaterial();
  125983. if (!material) {
  125984. return;
  125985. }
  125986. // Velocity
  125987. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  125988. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  125989. }
  125990. // Culling
  125991. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  125992. // Managing instances
  125993. var batch = mesh._getInstancesRenderList(subMesh._id);
  125994. if (batch.mustReturn) {
  125995. return;
  125996. }
  125997. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  125998. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  125999. engine.enableEffect(_this._effect);
  126000. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  126001. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  126002. _this._effect.setMatrix("view", scene.getViewMatrix());
  126003. // Alpha test
  126004. if (material && material.needAlphaTesting()) {
  126005. var alphaTexture = material.getAlphaTestTexture();
  126006. if (alphaTexture) {
  126007. _this._effect.setTexture("diffuseSampler", alphaTexture);
  126008. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  126009. }
  126010. }
  126011. // Bones
  126012. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  126013. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  126014. }
  126015. // Velocity
  126016. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  126017. // Draw
  126018. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  126019. }
  126020. // Velocity
  126021. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  126022. };
  126023. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  126024. var index;
  126025. if (depthOnlySubMeshes.length) {
  126026. engine.setColorWrite(false);
  126027. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  126028. renderSubMesh(depthOnlySubMeshes.data[index]);
  126029. }
  126030. engine.setColorWrite(true);
  126031. }
  126032. for (index = 0; index < opaqueSubMeshes.length; index++) {
  126033. renderSubMesh(opaqueSubMeshes.data[index]);
  126034. }
  126035. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  126036. renderSubMesh(alphaTestSubMeshes.data[index]);
  126037. }
  126038. };
  126039. };
  126040. /**
  126041. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126042. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126043. */
  126044. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  126045. /**
  126046. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126047. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126048. */
  126049. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  126050. /** @hidden */
  126051. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  126052. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  126053. };
  126054. return GeometryBufferRenderer;
  126055. }());
  126056. /***/ }),
  126057. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  126058. /*!***********************************************************!*\
  126059. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  126060. \***********************************************************/
  126061. /*! exports provided: GeometryBufferRendererSceneComponent */
  126062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126063. "use strict";
  126064. __webpack_require__.r(__webpack_exports__);
  126065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  126066. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126067. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126068. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  126069. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  126070. get: function () {
  126071. this._geometryBufferRenderer;
  126072. },
  126073. set: function (value) {
  126074. if (value && value.isSupported) {
  126075. this._geometryBufferRenderer = value;
  126076. }
  126077. },
  126078. enumerable: true,
  126079. configurable: true
  126080. });
  126081. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  126082. if (ratio === void 0) { ratio = 1; }
  126083. if (this._geometryBufferRenderer) {
  126084. return this._geometryBufferRenderer;
  126085. }
  126086. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  126087. if (!this._geometryBufferRenderer.isSupported) {
  126088. this._geometryBufferRenderer = null;
  126089. }
  126090. return this._geometryBufferRenderer;
  126091. };
  126092. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  126093. if (!this._geometryBufferRenderer) {
  126094. return;
  126095. }
  126096. this._geometryBufferRenderer.dispose();
  126097. this._geometryBufferRenderer = null;
  126098. };
  126099. /**
  126100. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126101. * in several rendering techniques.
  126102. */
  126103. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  126104. /**
  126105. * Creates a new instance of the component for the given scene
  126106. * @param scene Defines the scene to register the component in
  126107. */
  126108. function GeometryBufferRendererSceneComponent(scene) {
  126109. /**
  126110. * The component name helpful to identify the component in the list of scene components.
  126111. */
  126112. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  126113. this.scene = scene;
  126114. }
  126115. /**
  126116. * Registers the component in a given scene
  126117. */
  126118. GeometryBufferRendererSceneComponent.prototype.register = function () {
  126119. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  126120. };
  126121. /**
  126122. * Rebuilds the elements related to this component in case of
  126123. * context lost for instance.
  126124. */
  126125. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  126126. // Nothing to do for this component
  126127. };
  126128. /**
  126129. * Disposes the component and the associated ressources
  126130. */
  126131. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  126132. // Nothing to do for this component
  126133. };
  126134. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  126135. if (this.scene._geometryBufferRenderer) {
  126136. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  126137. }
  126138. };
  126139. return GeometryBufferRendererSceneComponent;
  126140. }());
  126141. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  126142. // Register the G Buffer component to the scene.
  126143. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  126144. if (!component) {
  126145. component = new GeometryBufferRendererSceneComponent(scene);
  126146. scene._addComponent(component);
  126147. }
  126148. };
  126149. /***/ }),
  126150. /***/ "./Rendering/index.ts":
  126151. /*!****************************!*\
  126152. !*** ./Rendering/index.ts ***!
  126153. \****************************/
  126154. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  126155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126156. "use strict";
  126157. __webpack_require__.r(__webpack_exports__);
  126158. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  126159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  126160. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  126161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  126162. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  126163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  126164. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  126165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  126166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  126167. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  126168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  126169. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  126170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  126171. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  126172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  126173. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  126174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  126175. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  126176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  126177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  126178. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  126179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  126180. /***/ }),
  126181. /***/ "./Rendering/outlineRenderer.ts":
  126182. /*!**************************************!*\
  126183. !*** ./Rendering/outlineRenderer.ts ***!
  126184. \**************************************/
  126185. /*! exports provided: OutlineRenderer */
  126186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126187. "use strict";
  126188. __webpack_require__.r(__webpack_exports__);
  126189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  126190. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126191. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126192. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126193. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126194. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126195. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126196. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  126197. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  126198. /**
  126199. * Gets the outline renderer associated with the scene
  126200. * @returns a OutlineRenderer
  126201. */
  126202. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  126203. if (!this._outlineRenderer) {
  126204. this._outlineRenderer = new OutlineRenderer(this);
  126205. }
  126206. return this._outlineRenderer;
  126207. };
  126208. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  126209. get: function () {
  126210. return this._renderOutline;
  126211. },
  126212. set: function (value) {
  126213. if (value) {
  126214. // Lazy Load the component.
  126215. this.getScene().getOutlineRenderer();
  126216. }
  126217. this._renderOutline = value;
  126218. },
  126219. enumerable: true,
  126220. configurable: true
  126221. });
  126222. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  126223. get: function () {
  126224. return this._renderOverlay;
  126225. },
  126226. set: function (value) {
  126227. if (value) {
  126228. // Lazy Load the component.
  126229. this.getScene().getOutlineRenderer();
  126230. }
  126231. this._renderOverlay = value;
  126232. },
  126233. enumerable: true,
  126234. configurable: true
  126235. });
  126236. /**
  126237. * This class is responsible to draw bothe outline/overlay of meshes.
  126238. * It should not be used directly but through the available method on mesh.
  126239. */
  126240. var OutlineRenderer = /** @class */ (function () {
  126241. /**
  126242. * Instantiates a new outline renderer. (There could be only one per scene).
  126243. * @param scene Defines the scene it belongs to
  126244. */
  126245. function OutlineRenderer(scene) {
  126246. /**
  126247. * The name of the component. Each component must have a unique name.
  126248. */
  126249. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  126250. /**
  126251. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126252. */
  126253. this.zOffset = 1;
  126254. this.scene = scene;
  126255. this._engine = scene.getEngine();
  126256. this.scene._addComponent(this);
  126257. }
  126258. /**
  126259. * Register the component to one instance of a scene.
  126260. */
  126261. OutlineRenderer.prototype.register = function () {
  126262. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  126263. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  126264. };
  126265. /**
  126266. * Rebuilds the elements related to this component in case of
  126267. * context lost for instance.
  126268. */
  126269. OutlineRenderer.prototype.rebuild = function () {
  126270. // Nothing to do here.
  126271. };
  126272. /**
  126273. * Disposes the component and the associated ressources.
  126274. */
  126275. OutlineRenderer.prototype.dispose = function () {
  126276. // Nothing to do here.
  126277. };
  126278. /**
  126279. * Renders the outline in the canvas.
  126280. * @param subMesh Defines the sumesh to render
  126281. * @param batch Defines the batch of meshes in case of instances
  126282. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126283. */
  126284. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  126285. var _this = this;
  126286. if (useOverlay === void 0) { useOverlay = false; }
  126287. var scene = this.scene;
  126288. var engine = scene.getEngine();
  126289. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  126290. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  126291. return;
  126292. }
  126293. var mesh = subMesh.getRenderingMesh();
  126294. var material = subMesh.getMaterial();
  126295. if (!material || !scene.activeCamera) {
  126296. return;
  126297. }
  126298. engine.enableEffect(this._effect);
  126299. // Logarithmic depth
  126300. if (material.useLogarithmicDepth) {
  126301. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  126302. }
  126303. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  126304. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  126305. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  126306. // Bones
  126307. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  126308. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  126309. }
  126310. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  126311. // Alpha test
  126312. if (material && material.needAlphaTesting()) {
  126313. var alphaTexture = material.getAlphaTestTexture();
  126314. if (alphaTexture) {
  126315. this._effect.setTexture("diffuseSampler", alphaTexture);
  126316. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  126317. }
  126318. }
  126319. engine.setZOffset(-this.zOffset);
  126320. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  126321. engine.setZOffset(0);
  126322. };
  126323. /**
  126324. * Returns whether or not the outline renderer is ready for a given submesh.
  126325. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126326. * @param subMesh Defines the submesh to check readyness for
  126327. * @param useInstances Defines wheter wee are trying to render instances or not
  126328. * @returns true if ready otherwise false
  126329. */
  126330. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  126331. var defines = [];
  126332. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  126333. var mesh = subMesh.getMesh();
  126334. var material = subMesh.getMaterial();
  126335. if (material) {
  126336. // Alpha test
  126337. if (material.needAlphaTesting()) {
  126338. defines.push("#define ALPHATEST");
  126339. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  126340. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  126341. defines.push("#define UV1");
  126342. }
  126343. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  126344. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  126345. defines.push("#define UV2");
  126346. }
  126347. }
  126348. //Logarithmic depth
  126349. if (material.useLogarithmicDepth) {
  126350. defines.push("#define LOGARITHMICDEPTH");
  126351. }
  126352. }
  126353. // Bones
  126354. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  126355. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  126356. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  126357. if (mesh.numBoneInfluencers > 4) {
  126358. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  126359. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  126360. }
  126361. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  126362. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  126363. }
  126364. else {
  126365. defines.push("#define NUM_BONE_INFLUENCERS 0");
  126366. }
  126367. // Instances
  126368. if (useInstances) {
  126369. defines.push("#define INSTANCES");
  126370. attribs.push("world0");
  126371. attribs.push("world1");
  126372. attribs.push("world2");
  126373. attribs.push("world3");
  126374. }
  126375. // Get correct effect
  126376. var join = defines.join("\n");
  126377. if (this._cachedDefines !== join) {
  126378. this._cachedDefines = join;
  126379. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  126380. }
  126381. return this._effect.isReady();
  126382. };
  126383. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  126384. // Outline - step 1
  126385. this._savedDepthWrite = this._engine.getDepthWrite();
  126386. if (mesh.renderOutline) {
  126387. var material = subMesh.getMaterial();
  126388. if (material && material.needAlphaBlending) {
  126389. this._engine.cacheStencilState();
  126390. // Draw only to stencil buffer for the original mesh
  126391. // The resulting stencil buffer will be used so the outline is not visible inside the mesh when the mesh is transparent
  126392. this._engine.setDepthWrite(false);
  126393. this._engine.setColorWrite(false);
  126394. this._engine.setStencilBuffer(true);
  126395. this._engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].REPLACE);
  126396. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALWAYS);
  126397. this._engine.setStencilMask(OutlineRenderer._StencilReference);
  126398. this._engine.setStencilFunctionReference(OutlineRenderer._StencilReference);
  126399. this.render(subMesh, batch, /* This sets offset to 0 */ true);
  126400. this._engine.setColorWrite(true);
  126401. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].NOTEQUAL);
  126402. }
  126403. // Draw the outline using the above stencil if needed to avoid drawing within the mesh
  126404. this._engine.setDepthWrite(false);
  126405. this.render(subMesh, batch);
  126406. this._engine.setDepthWrite(this._savedDepthWrite);
  126407. if (material && material.needAlphaBlending) {
  126408. this._engine.restoreStencilState();
  126409. }
  126410. }
  126411. };
  126412. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  126413. // Outline - step 2
  126414. if (mesh.renderOutline && this._savedDepthWrite) {
  126415. this._engine.setDepthWrite(true);
  126416. this._engine.setColorWrite(false);
  126417. this.render(subMesh, batch);
  126418. this._engine.setColorWrite(true);
  126419. }
  126420. // Overlay
  126421. if (mesh.renderOverlay) {
  126422. var currentMode = this._engine.getAlphaMode();
  126423. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  126424. this.render(subMesh, batch, true);
  126425. this._engine.setAlphaMode(currentMode);
  126426. }
  126427. };
  126428. /**
  126429. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126430. */
  126431. OutlineRenderer._StencilReference = 0x04;
  126432. return OutlineRenderer;
  126433. }());
  126434. /***/ }),
  126435. /***/ "./Rendering/renderingGroup.ts":
  126436. /*!*************************************!*\
  126437. !*** ./Rendering/renderingGroup.ts ***!
  126438. \*************************************/
  126439. /*! exports provided: RenderingGroup */
  126440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126441. "use strict";
  126442. __webpack_require__.r(__webpack_exports__);
  126443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  126444. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  126445. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126446. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126447. /**
  126448. * This represents the object necessary to create a rendering group.
  126449. * This is exclusively used and created by the rendering manager.
  126450. * To modify the behavior, you use the available helpers in your scene or meshes.
  126451. * @hidden
  126452. */
  126453. var RenderingGroup = /** @class */ (function () {
  126454. /**
  126455. * Creates a new rendering group.
  126456. * @param index The rendering group index
  126457. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  126458. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  126459. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  126460. */
  126461. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  126462. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  126463. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  126464. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  126465. this.index = index;
  126466. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126467. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126468. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126469. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126470. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126471. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126472. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  126473. this._scene = scene;
  126474. this.opaqueSortCompareFn = opaqueSortCompareFn;
  126475. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  126476. this.transparentSortCompareFn = transparentSortCompareFn;
  126477. }
  126478. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  126479. /**
  126480. * Set the opaque sort comparison function.
  126481. * If null the sub meshes will be render in the order they were created
  126482. */
  126483. set: function (value) {
  126484. this._opaqueSortCompareFn = value;
  126485. if (value) {
  126486. this._renderOpaque = this.renderOpaqueSorted;
  126487. }
  126488. else {
  126489. this._renderOpaque = RenderingGroup.renderUnsorted;
  126490. }
  126491. },
  126492. enumerable: true,
  126493. configurable: true
  126494. });
  126495. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  126496. /**
  126497. * Set the alpha test sort comparison function.
  126498. * If null the sub meshes will be render in the order they were created
  126499. */
  126500. set: function (value) {
  126501. this._alphaTestSortCompareFn = value;
  126502. if (value) {
  126503. this._renderAlphaTest = this.renderAlphaTestSorted;
  126504. }
  126505. else {
  126506. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  126507. }
  126508. },
  126509. enumerable: true,
  126510. configurable: true
  126511. });
  126512. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  126513. /**
  126514. * Set the transparent sort comparison function.
  126515. * If null the sub meshes will be render in the order they were created
  126516. */
  126517. set: function (value) {
  126518. if (value) {
  126519. this._transparentSortCompareFn = value;
  126520. }
  126521. else {
  126522. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  126523. }
  126524. this._renderTransparent = this.renderTransparentSorted;
  126525. },
  126526. enumerable: true,
  126527. configurable: true
  126528. });
  126529. /**
  126530. * Render all the sub meshes contained in the group.
  126531. * @param customRenderFunction Used to override the default render behaviour of the group.
  126532. * @returns true if rendered some submeshes.
  126533. */
  126534. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  126535. if (customRenderFunction) {
  126536. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  126537. return;
  126538. }
  126539. var engine = this._scene.getEngine();
  126540. // Depth only
  126541. if (this._depthOnlySubMeshes.length !== 0) {
  126542. engine.setColorWrite(false);
  126543. this._renderAlphaTest(this._depthOnlySubMeshes);
  126544. engine.setColorWrite(true);
  126545. }
  126546. // Opaque
  126547. if (this._opaqueSubMeshes.length !== 0) {
  126548. this._renderOpaque(this._opaqueSubMeshes);
  126549. }
  126550. // Alpha test
  126551. if (this._alphaTestSubMeshes.length !== 0) {
  126552. this._renderAlphaTest(this._alphaTestSubMeshes);
  126553. }
  126554. var stencilState = engine.getStencilBuffer();
  126555. engine.setStencilBuffer(false);
  126556. // Sprites
  126557. if (renderSprites) {
  126558. this._renderSprites();
  126559. }
  126560. // Particles
  126561. if (renderParticles) {
  126562. this._renderParticles(activeMeshes);
  126563. }
  126564. if (this.onBeforeTransparentRendering) {
  126565. this.onBeforeTransparentRendering();
  126566. }
  126567. // Transparent
  126568. if (this._transparentSubMeshes.length !== 0) {
  126569. this._renderTransparent(this._transparentSubMeshes);
  126570. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  126571. }
  126572. // Set back stencil to false in case it changes before the edge renderer.
  126573. engine.setStencilBuffer(false);
  126574. // Edges
  126575. if (this._edgesRenderers.length) {
  126576. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  126577. this._edgesRenderers.data[edgesRendererIndex].render();
  126578. }
  126579. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  126580. }
  126581. // Restore Stencil state.
  126582. engine.setStencilBuffer(stencilState);
  126583. };
  126584. /**
  126585. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  126586. * @param subMeshes The submeshes to render
  126587. */
  126588. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  126589. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  126590. };
  126591. /**
  126592. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  126593. * @param subMeshes The submeshes to render
  126594. */
  126595. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  126596. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  126597. };
  126598. /**
  126599. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  126600. * @param subMeshes The submeshes to render
  126601. */
  126602. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  126603. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  126604. };
  126605. /**
  126606. * Renders the submeshes in a specified order.
  126607. * @param subMeshes The submeshes to sort before render
  126608. * @param sortCompareFn The comparison function use to sort
  126609. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  126610. * @param transparent Specifies to activate blending if true
  126611. */
  126612. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  126613. var subIndex = 0;
  126614. var subMesh;
  126615. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  126616. for (; subIndex < subMeshes.length; subIndex++) {
  126617. subMesh = subMeshes.data[subIndex];
  126618. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  126619. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  126620. }
  126621. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  126622. if (sortCompareFn) {
  126623. sortedArray.sort(sortCompareFn);
  126624. }
  126625. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  126626. subMesh = sortedArray[subIndex];
  126627. if (transparent) {
  126628. var material = subMesh.getMaterial();
  126629. if (material && material.needDepthPrePass) {
  126630. var engine = material.getScene().getEngine();
  126631. engine.setColorWrite(false);
  126632. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  126633. subMesh.render(false);
  126634. engine.setColorWrite(true);
  126635. }
  126636. }
  126637. subMesh.render(transparent);
  126638. }
  126639. };
  126640. /**
  126641. * Renders the submeshes in the order they were dispatched (no sort applied).
  126642. * @param subMeshes The submeshes to render
  126643. */
  126644. RenderingGroup.renderUnsorted = function (subMeshes) {
  126645. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  126646. var submesh = subMeshes.data[subIndex];
  126647. submesh.render(false);
  126648. }
  126649. };
  126650. /**
  126651. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  126652. * are rendered back to front if in the same alpha index.
  126653. *
  126654. * @param a The first submesh
  126655. * @param b The second submesh
  126656. * @returns The result of the comparison
  126657. */
  126658. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  126659. // Alpha index first
  126660. if (a._alphaIndex > b._alphaIndex) {
  126661. return 1;
  126662. }
  126663. if (a._alphaIndex < b._alphaIndex) {
  126664. return -1;
  126665. }
  126666. // Then distance to camera
  126667. return RenderingGroup.backToFrontSortCompare(a, b);
  126668. };
  126669. /**
  126670. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  126671. * are rendered back to front.
  126672. *
  126673. * @param a The first submesh
  126674. * @param b The second submesh
  126675. * @returns The result of the comparison
  126676. */
  126677. RenderingGroup.backToFrontSortCompare = function (a, b) {
  126678. // Then distance to camera
  126679. if (a._distanceToCamera < b._distanceToCamera) {
  126680. return 1;
  126681. }
  126682. if (a._distanceToCamera > b._distanceToCamera) {
  126683. return -1;
  126684. }
  126685. return 0;
  126686. };
  126687. /**
  126688. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  126689. * are rendered front to back (prevent overdraw).
  126690. *
  126691. * @param a The first submesh
  126692. * @param b The second submesh
  126693. * @returns The result of the comparison
  126694. */
  126695. RenderingGroup.frontToBackSortCompare = function (a, b) {
  126696. // Then distance to camera
  126697. if (a._distanceToCamera < b._distanceToCamera) {
  126698. return -1;
  126699. }
  126700. if (a._distanceToCamera > b._distanceToCamera) {
  126701. return 1;
  126702. }
  126703. return 0;
  126704. };
  126705. /**
  126706. * Resets the different lists of submeshes to prepare a new frame.
  126707. */
  126708. RenderingGroup.prototype.prepare = function () {
  126709. this._opaqueSubMeshes.reset();
  126710. this._transparentSubMeshes.reset();
  126711. this._alphaTestSubMeshes.reset();
  126712. this._depthOnlySubMeshes.reset();
  126713. this._particleSystems.reset();
  126714. this._spriteManagers.reset();
  126715. this._edgesRenderers.reset();
  126716. };
  126717. RenderingGroup.prototype.dispose = function () {
  126718. this._opaqueSubMeshes.dispose();
  126719. this._transparentSubMeshes.dispose();
  126720. this._alphaTestSubMeshes.dispose();
  126721. this._depthOnlySubMeshes.dispose();
  126722. this._particleSystems.dispose();
  126723. this._spriteManagers.dispose();
  126724. this._edgesRenderers.dispose();
  126725. };
  126726. /**
  126727. * Inserts the submesh in its correct queue depending on its material.
  126728. * @param subMesh The submesh to dispatch
  126729. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  126730. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  126731. */
  126732. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  126733. // Get mesh and materials if not provided
  126734. if (mesh === undefined) {
  126735. mesh = subMesh.getMesh();
  126736. }
  126737. if (material === undefined) {
  126738. material = subMesh.getMaterial();
  126739. }
  126740. if (material === null || material === undefined) {
  126741. return;
  126742. }
  126743. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  126744. this._transparentSubMeshes.push(subMesh);
  126745. }
  126746. else if (material.needAlphaTesting()) { // Alpha test
  126747. if (material.needDepthPrePass) {
  126748. this._depthOnlySubMeshes.push(subMesh);
  126749. }
  126750. this._alphaTestSubMeshes.push(subMesh);
  126751. }
  126752. else {
  126753. if (material.needDepthPrePass) {
  126754. this._depthOnlySubMeshes.push(subMesh);
  126755. }
  126756. this._opaqueSubMeshes.push(subMesh); // Opaque
  126757. }
  126758. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  126759. this._edgesRenderers.push(mesh._edgesRenderer);
  126760. }
  126761. };
  126762. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  126763. this._spriteManagers.push(spriteManager);
  126764. };
  126765. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  126766. this._particleSystems.push(particleSystem);
  126767. };
  126768. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  126769. if (this._particleSystems.length === 0) {
  126770. return;
  126771. }
  126772. // Particles
  126773. var activeCamera = this._scene.activeCamera;
  126774. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  126775. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  126776. var particleSystem = this._particleSystems.data[particleIndex];
  126777. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  126778. continue;
  126779. }
  126780. var emitter = particleSystem.emitter;
  126781. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  126782. this._scene._activeParticles.addCount(particleSystem.render(), false);
  126783. }
  126784. }
  126785. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  126786. };
  126787. RenderingGroup.prototype._renderSprites = function () {
  126788. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  126789. return;
  126790. }
  126791. // Sprites
  126792. var activeCamera = this._scene.activeCamera;
  126793. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  126794. for (var id = 0; id < this._spriteManagers.length; id++) {
  126795. var spriteManager = this._spriteManagers.data[id];
  126796. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  126797. spriteManager.render();
  126798. }
  126799. }
  126800. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  126801. };
  126802. return RenderingGroup;
  126803. }());
  126804. /***/ }),
  126805. /***/ "./Rendering/renderingManager.ts":
  126806. /*!***************************************!*\
  126807. !*** ./Rendering/renderingManager.ts ***!
  126808. \***************************************/
  126809. /*! exports provided: RenderingGroupInfo, RenderingManager */
  126810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126811. "use strict";
  126812. __webpack_require__.r(__webpack_exports__);
  126813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  126814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  126815. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  126816. /**
  126817. * This class is used by the onRenderingGroupObservable
  126818. */
  126819. var RenderingGroupInfo = /** @class */ (function () {
  126820. function RenderingGroupInfo() {
  126821. }
  126822. return RenderingGroupInfo;
  126823. }());
  126824. /**
  126825. * This is the manager responsible of all the rendering for meshes sprites and particles.
  126826. * It is enable to manage the different groups as well as the different necessary sort functions.
  126827. * This should not be used directly aside of the few static configurations
  126828. */
  126829. var RenderingManager = /** @class */ (function () {
  126830. /**
  126831. * Instantiates a new rendering group for a particular scene
  126832. * @param scene Defines the scene the groups belongs to
  126833. */
  126834. function RenderingManager(scene) {
  126835. /**
  126836. * @hidden
  126837. */
  126838. this._useSceneAutoClearSetup = false;
  126839. this._renderingGroups = new Array();
  126840. this._autoClearDepthStencil = {};
  126841. this._customOpaqueSortCompareFn = {};
  126842. this._customAlphaTestSortCompareFn = {};
  126843. this._customTransparentSortCompareFn = {};
  126844. this._renderingGroupInfo = new RenderingGroupInfo();
  126845. this._scene = scene;
  126846. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  126847. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  126848. }
  126849. }
  126850. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  126851. if (depth === void 0) { depth = true; }
  126852. if (stencil === void 0) { stencil = true; }
  126853. if (this._depthStencilBufferAlreadyCleaned) {
  126854. return;
  126855. }
  126856. this._scene.getEngine().clear(null, false, depth, stencil);
  126857. this._depthStencilBufferAlreadyCleaned = true;
  126858. };
  126859. /**
  126860. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  126861. * @hidden
  126862. */
  126863. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  126864. // Update the observable context (not null as it only goes away on dispose)
  126865. var info = this._renderingGroupInfo;
  126866. info.scene = this._scene;
  126867. info.camera = this._scene.activeCamera;
  126868. // Dispatch sprites
  126869. if (this._scene.spriteManagers && renderSprites) {
  126870. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  126871. var manager = this._scene.spriteManagers[index];
  126872. this.dispatchSprites(manager);
  126873. }
  126874. }
  126875. // Render
  126876. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  126877. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  126878. var renderingGroup = this._renderingGroups[index];
  126879. if (!renderingGroup) {
  126880. continue;
  126881. }
  126882. var renderingGroupMask = Math.pow(2, index);
  126883. info.renderingGroupId = index;
  126884. // Before Observable
  126885. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  126886. // Clear depth/stencil if needed
  126887. if (RenderingManager.AUTOCLEAR) {
  126888. var autoClear = this._useSceneAutoClearSetup ?
  126889. this._scene.getAutoClearDepthStencilSetup(index) :
  126890. this._autoClearDepthStencil[index];
  126891. if (autoClear && autoClear.autoClear) {
  126892. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  126893. }
  126894. }
  126895. // Render
  126896. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  126897. var step = _a[_i];
  126898. step.action(index);
  126899. }
  126900. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  126901. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  126902. var step = _c[_b];
  126903. step.action(index);
  126904. }
  126905. // After Observable
  126906. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  126907. }
  126908. };
  126909. /**
  126910. * Resets the different information of the group to prepare a new frame
  126911. * @hidden
  126912. */
  126913. RenderingManager.prototype.reset = function () {
  126914. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  126915. var renderingGroup = this._renderingGroups[index];
  126916. if (renderingGroup) {
  126917. renderingGroup.prepare();
  126918. }
  126919. }
  126920. };
  126921. /**
  126922. * Dispose and release the group and its associated resources.
  126923. * @hidden
  126924. */
  126925. RenderingManager.prototype.dispose = function () {
  126926. this.freeRenderingGroups();
  126927. this._renderingGroups.length = 0;
  126928. this._renderingGroupInfo = null;
  126929. };
  126930. /**
  126931. * Clear the info related to rendering groups preventing retention points during dispose.
  126932. */
  126933. RenderingManager.prototype.freeRenderingGroups = function () {
  126934. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  126935. var renderingGroup = this._renderingGroups[index];
  126936. if (renderingGroup) {
  126937. renderingGroup.dispose();
  126938. }
  126939. }
  126940. };
  126941. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  126942. if (this._renderingGroups[renderingGroupId] === undefined) {
  126943. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  126944. }
  126945. };
  126946. /**
  126947. * Add a sprite manager to the rendering manager in order to render it this frame.
  126948. * @param spriteManager Define the sprite manager to render
  126949. */
  126950. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  126951. var renderingGroupId = spriteManager.renderingGroupId || 0;
  126952. this._prepareRenderingGroup(renderingGroupId);
  126953. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  126954. };
  126955. /**
  126956. * Add a particle system to the rendering manager in order to render it this frame.
  126957. * @param particleSystem Define the particle system to render
  126958. */
  126959. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  126960. var renderingGroupId = particleSystem.renderingGroupId || 0;
  126961. this._prepareRenderingGroup(renderingGroupId);
  126962. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  126963. };
  126964. /**
  126965. * Add a submesh to the manager in order to render it this frame
  126966. * @param subMesh The submesh to dispatch
  126967. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  126968. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  126969. */
  126970. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  126971. if (mesh === undefined) {
  126972. mesh = subMesh.getMesh();
  126973. }
  126974. var renderingGroupId = mesh.renderingGroupId || 0;
  126975. this._prepareRenderingGroup(renderingGroupId);
  126976. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  126977. };
  126978. /**
  126979. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  126980. * This allowed control for front to back rendering or reversly depending of the special needs.
  126981. *
  126982. * @param renderingGroupId The rendering group id corresponding to its index
  126983. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  126984. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  126985. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  126986. */
  126987. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  126988. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  126989. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  126990. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  126991. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  126992. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  126993. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  126994. if (this._renderingGroups[renderingGroupId]) {
  126995. var group = this._renderingGroups[renderingGroupId];
  126996. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  126997. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  126998. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  126999. }
  127000. };
  127001. /**
  127002. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  127003. *
  127004. * @param renderingGroupId The rendering group id corresponding to its index
  127005. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  127006. * @param depth Automatically clears depth between groups if true and autoClear is true.
  127007. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  127008. */
  127009. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  127010. if (depth === void 0) { depth = true; }
  127011. if (stencil === void 0) { stencil = true; }
  127012. this._autoClearDepthStencil[renderingGroupId] = {
  127013. autoClear: autoClearDepthStencil,
  127014. depth: depth,
  127015. stencil: stencil
  127016. };
  127017. };
  127018. /**
  127019. * Gets the current auto clear configuration for one rendering group of the rendering
  127020. * manager.
  127021. * @param index the rendering group index to get the information for
  127022. * @returns The auto clear setup for the requested rendering group
  127023. */
  127024. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  127025. return this._autoClearDepthStencil[index];
  127026. };
  127027. /**
  127028. * The max id used for rendering groups (not included)
  127029. */
  127030. RenderingManager.MAX_RENDERINGGROUPS = 4;
  127031. /**
  127032. * The min id used for rendering groups (included)
  127033. */
  127034. RenderingManager.MIN_RENDERINGGROUPS = 0;
  127035. /**
  127036. * Used to globally prevent autoclearing scenes.
  127037. */
  127038. RenderingManager.AUTOCLEAR = true;
  127039. return RenderingManager;
  127040. }());
  127041. /***/ }),
  127042. /***/ "./Rendering/utilityLayerRenderer.ts":
  127043. /*!*******************************************!*\
  127044. !*** ./Rendering/utilityLayerRenderer.ts ***!
  127045. \*******************************************/
  127046. /*! exports provided: UtilityLayerRenderer */
  127047. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127048. "use strict";
  127049. __webpack_require__.r(__webpack_exports__);
  127050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  127051. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  127053. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  127054. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  127055. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  127056. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127057. /**
  127058. * Renders a layer on top of an existing scene
  127059. */
  127060. var UtilityLayerRenderer = /** @class */ (function () {
  127061. /**
  127062. * Instantiates a UtilityLayerRenderer
  127063. * @param originalScene the original scene that will be rendered on top of
  127064. * @param handleEvents boolean indicating if the utility layer should handle events
  127065. */
  127066. function UtilityLayerRenderer(
  127067. /** the original scene that will be rendered on top of */
  127068. originalScene, handleEvents) {
  127069. if (handleEvents === void 0) { handleEvents = true; }
  127070. var _this = this;
  127071. this.originalScene = originalScene;
  127072. this._pointerCaptures = {};
  127073. this._lastPointerEvents = {};
  127074. /**
  127075. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127076. */
  127077. this.pickUtilitySceneFirst = true;
  127078. /**
  127079. * If the utility layer should automatically be rendered on top of existing scene
  127080. */
  127081. this.shouldRender = true;
  127082. /**
  127083. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127084. */
  127085. this.onlyCheckPointerDownEvents = true;
  127086. /**
  127087. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127088. */
  127089. this.processAllEvents = false;
  127090. /**
  127091. * Observable raised when the pointer move from the utility layer scene to the main scene
  127092. */
  127093. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  127094. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  127095. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  127096. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  127097. this.utilityLayerScene._allowPostProcessClearColor = false;
  127098. originalScene.getEngine().scenes.pop();
  127099. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  127100. this.utilityLayerScene.detachControl();
  127101. if (handleEvents) {
  127102. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  127103. if (!_this.utilityLayerScene.activeCamera) {
  127104. return;
  127105. }
  127106. if (!_this.processAllEvents) {
  127107. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  127108. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  127109. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  127110. return;
  127111. }
  127112. }
  127113. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  127114. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  127115. var pointerEvent = (prePointerInfo.event);
  127116. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  127117. _this._pointerCaptures[pointerEvent.pointerId] = false;
  127118. return;
  127119. }
  127120. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  127121. if (!prePointerInfo.ray && utilityScenePick) {
  127122. prePointerInfo.ray = utilityScenePick.ray;
  127123. }
  127124. // always fire the prepointer oversvable
  127125. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  127126. // allow every non pointer down event to flow to the utility layer
  127127. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  127128. if (!prePointerInfo.skipOnPointerObservable) {
  127129. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  127130. }
  127131. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  127132. _this._pointerCaptures[pointerEvent.pointerId] = false;
  127133. }
  127134. return;
  127135. }
  127136. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  127137. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  127138. if (utilityScenePick && utilityScenePick.hit) {
  127139. if (!prePointerInfo.skipOnPointerObservable) {
  127140. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  127141. }
  127142. prePointerInfo.skipOnPointerObservable = true;
  127143. }
  127144. }
  127145. else {
  127146. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  127147. var pointerEvent_1 = (prePointerInfo.event);
  127148. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  127149. if (originalScenePick && utilityScenePick) {
  127150. // No pick in utility scene
  127151. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  127152. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  127153. // We touched an utility mesh present in the main scene
  127154. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  127155. prePointerInfo.skipOnPointerObservable = true;
  127156. }
  127157. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  127158. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  127159. }
  127160. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  127161. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  127162. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  127163. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  127164. }
  127165. }
  127166. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  127167. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  127168. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  127169. // If a previous utility layer set this, do not unset this
  127170. if (!prePointerInfo.skipOnPointerObservable) {
  127171. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  127172. }
  127173. }
  127174. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  127175. // We have a pick in both scenes but main is closer than utility
  127176. // We touched an utility mesh present in the main scene
  127177. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  127178. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  127179. prePointerInfo.skipOnPointerObservable = true;
  127180. }
  127181. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  127182. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  127183. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  127184. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  127185. }
  127186. }
  127187. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  127188. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  127189. }
  127190. }
  127191. }
  127192. });
  127193. // As a newly added utility layer will be rendered over the screen last, it's pointer events should be processed first
  127194. if (this._originalPointerObserver) {
  127195. originalScene.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver);
  127196. }
  127197. }
  127198. // Render directly on top of existing scene without clearing
  127199. this.utilityLayerScene.autoClear = false;
  127200. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  127201. if (_this.shouldRender) {
  127202. _this.render();
  127203. }
  127204. });
  127205. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  127206. _this.dispose();
  127207. });
  127208. this._updateCamera();
  127209. }
  127210. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  127211. /**
  127212. * 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)
  127213. */
  127214. get: function () {
  127215. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  127216. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  127217. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  127218. UtilityLayerRenderer._DefaultUtilityLayer = null;
  127219. });
  127220. }
  127221. return UtilityLayerRenderer._DefaultUtilityLayer;
  127222. },
  127223. enumerable: true,
  127224. configurable: true
  127225. });
  127226. Object.defineProperty(UtilityLayerRenderer, "DefaultGizmoUtilityLayer", {
  127227. /**
  127228. * 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)
  127229. */
  127230. get: function () {
  127231. if (UtilityLayerRenderer._DefaultGizmoUtilityLayer == null) {
  127232. UtilityLayerRenderer._DefaultGizmoUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  127233. var light = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]("light1", new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 1, 0), UtilityLayerRenderer._DefaultGizmoUtilityLayer.utilityLayerScene);
  127234. light.intensity = 2;
  127235. light.groundColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].Gray();
  127236. UtilityLayerRenderer._DefaultGizmoUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  127237. UtilityLayerRenderer._DefaultGizmoUtilityLayer = null;
  127238. });
  127239. }
  127240. return UtilityLayerRenderer._DefaultGizmoUtilityLayer;
  127241. },
  127242. enumerable: true,
  127243. configurable: true
  127244. });
  127245. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  127246. /**
  127247. * 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)
  127248. */
  127249. get: function () {
  127250. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  127251. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  127252. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  127253. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  127254. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  127255. });
  127256. }
  127257. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  127258. },
  127259. enumerable: true,
  127260. configurable: true
  127261. });
  127262. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  127263. if (!prePointerInfo.skipOnPointerObservable) {
  127264. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  127265. this._lastPointerEvents[pointerEvent.pointerId] = true;
  127266. }
  127267. };
  127268. /**
  127269. * Renders the utility layers scene on top of the original scene
  127270. */
  127271. UtilityLayerRenderer.prototype.render = function () {
  127272. this._updateCamera();
  127273. if (this.utilityLayerScene.activeCamera) {
  127274. // Set the camera's scene to utility layers scene
  127275. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  127276. var camera = this.utilityLayerScene.activeCamera;
  127277. camera._scene = this.utilityLayerScene;
  127278. if (camera.leftCamera) {
  127279. camera.leftCamera._scene = this.utilityLayerScene;
  127280. }
  127281. if (camera.rightCamera) {
  127282. camera.rightCamera._scene = this.utilityLayerScene;
  127283. }
  127284. this.utilityLayerScene.render(false);
  127285. // Reset camera's scene back to original
  127286. camera._scene = oldScene;
  127287. if (camera.leftCamera) {
  127288. camera.leftCamera._scene = oldScene;
  127289. }
  127290. if (camera.rightCamera) {
  127291. camera.rightCamera._scene = oldScene;
  127292. }
  127293. }
  127294. };
  127295. /**
  127296. * Disposes of the renderer
  127297. */
  127298. UtilityLayerRenderer.prototype.dispose = function () {
  127299. this.onPointerOutObservable.clear();
  127300. if (this._afterRenderObserver) {
  127301. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  127302. }
  127303. if (this._sceneDisposeObserver) {
  127304. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  127305. }
  127306. if (this._originalPointerObserver) {
  127307. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  127308. }
  127309. this.utilityLayerScene.dispose();
  127310. };
  127311. UtilityLayerRenderer.prototype._updateCamera = function () {
  127312. if (this.originalScene.activeCameras.length > 1) {
  127313. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  127314. }
  127315. else {
  127316. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  127317. }
  127318. };
  127319. UtilityLayerRenderer._DefaultGizmoUtilityLayer = null;
  127320. UtilityLayerRenderer._DefaultUtilityLayer = null;
  127321. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  127322. return UtilityLayerRenderer;
  127323. }());
  127324. /***/ }),
  127325. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  127326. /*!*****************************************************************!*\
  127327. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  127328. \*****************************************************************/
  127329. /*! exports provided: backgroundFragmentDeclaration */
  127330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127331. "use strict";
  127332. __webpack_require__.r(__webpack_exports__);
  127333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  127334. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127335. var name = 'backgroundFragmentDeclaration';
  127336. 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";
  127337. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127338. /** @hidden */
  127339. var backgroundFragmentDeclaration = { name: name, shader: shader };
  127340. /***/ }),
  127341. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  127342. /*!************************************************************!*\
  127343. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  127344. \************************************************************/
  127345. /*! exports provided: backgroundUboDeclaration */
  127346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127347. "use strict";
  127348. __webpack_require__.r(__webpack_exports__);
  127349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  127350. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127351. var name = 'backgroundUboDeclaration';
  127352. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";
  127353. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127354. /** @hidden */
  127355. var backgroundUboDeclaration = { name: name, shader: shader };
  127356. /***/ }),
  127357. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  127358. /*!***************************************************************!*\
  127359. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  127360. \***************************************************************/
  127361. /*! exports provided: backgroundVertexDeclaration */
  127362. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127363. "use strict";
  127364. __webpack_require__.r(__webpack_exports__);
  127365. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  127366. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127367. var name = 'backgroundVertexDeclaration';
  127368. 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";
  127369. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127370. /** @hidden */
  127371. var backgroundVertexDeclaration = { name: name, shader: shader };
  127372. /***/ }),
  127373. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  127374. /*!****************************************************!*\
  127375. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  127376. \****************************************************/
  127377. /*! exports provided: bonesDeclaration */
  127378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127379. "use strict";
  127380. __webpack_require__.r(__webpack_exports__);
  127381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  127382. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127383. var name = 'bonesDeclaration';
  127384. 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";
  127385. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127386. /** @hidden */
  127387. var bonesDeclaration = { name: name, shader: shader };
  127388. /***/ }),
  127389. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  127390. /*!***********************************************!*\
  127391. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  127392. \***********************************************/
  127393. /*! exports provided: bonesVertex */
  127394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127395. "use strict";
  127396. __webpack_require__.r(__webpack_exports__);
  127397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  127398. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127399. var name = 'bonesVertex';
  127400. 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";
  127401. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127402. /** @hidden */
  127403. var bonesVertex = { name: name, shader: shader };
  127404. /***/ }),
  127405. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  127406. /*!************************************************!*\
  127407. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  127408. \************************************************/
  127409. /*! exports provided: bumpFragment */
  127410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127411. "use strict";
  127412. __webpack_require__.r(__webpack_exports__);
  127413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  127414. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127415. var name = 'bumpFragment';
  127416. var shader = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else\nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#elif defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW,vPositionW,vMainUV1,vec2(1.,1.));\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#else\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif\n#endif";
  127417. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127418. /** @hidden */
  127419. var bumpFragment = { name: name, shader: shader };
  127420. /***/ }),
  127421. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  127422. /*!*********************************************************!*\
  127423. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  127424. \*********************************************************/
  127425. /*! exports provided: bumpFragmentFunctions */
  127426. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127427. "use strict";
  127428. __webpack_require__.r(__webpack_exports__);
  127429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  127430. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127431. var name = 'bumpFragmentFunctions';
  127432. var shader = "#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv,sampler2D textureSampler,float scale)\n{\nvec3 map=texture2D(textureSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(scale,scale,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=tangentSpaceParams.x;\nbitangent*=tangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\n#endif\n#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nreturn perturbNormal(cotangentFrame,uv,bumpSampler,vBumpInfos.y);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\nreturn cotangent_frame(normal,p,uv,vTangentSpaceParams);\n}\n#endif\n#if defined(BUMP) && defined(PARALLAX)\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif";
  127433. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127434. /** @hidden */
  127435. var bumpFragmentFunctions = { name: name, shader: shader };
  127436. /***/ }),
  127437. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  127438. /*!**********************************************!*\
  127439. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  127440. \**********************************************/
  127441. /*! exports provided: bumpVertex */
  127442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127443. "use strict";
  127444. __webpack_require__.r(__webpack_exports__);
  127445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  127446. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127447. var name = 'bumpVertex';
  127448. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";
  127449. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127450. /** @hidden */
  127451. var bumpVertex = { name: name, shader: shader };
  127452. /***/ }),
  127453. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  127454. /*!*********************************************************!*\
  127455. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  127456. \*********************************************************/
  127457. /*! exports provided: bumpVertexDeclaration */
  127458. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127459. "use strict";
  127460. __webpack_require__.r(__webpack_exports__);
  127461. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  127462. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127463. var name = 'bumpVertexDeclaration';
  127464. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  127465. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127466. /** @hidden */
  127467. var bumpVertexDeclaration = { name: name, shader: shader };
  127468. /***/ }),
  127469. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  127470. /*!*****************************************************!*\
  127471. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  127472. \*****************************************************/
  127473. /*! exports provided: clipPlaneFragment */
  127474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127475. "use strict";
  127476. __webpack_require__.r(__webpack_exports__);
  127477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  127478. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127479. var name = 'clipPlaneFragment';
  127480. 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";
  127481. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127482. /** @hidden */
  127483. var clipPlaneFragment = { name: name, shader: shader };
  127484. /***/ }),
  127485. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  127486. /*!****************************************************************!*\
  127487. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  127488. \****************************************************************/
  127489. /*! exports provided: clipPlaneFragmentDeclaration */
  127490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127491. "use strict";
  127492. __webpack_require__.r(__webpack_exports__);
  127493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  127494. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127495. var name = 'clipPlaneFragmentDeclaration';
  127496. 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";
  127497. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127498. /** @hidden */
  127499. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  127500. /***/ }),
  127501. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  127502. /*!*****************************************************************!*\
  127503. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  127504. \*****************************************************************/
  127505. /*! exports provided: clipPlaneFragmentDeclaration2 */
  127506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127507. "use strict";
  127508. __webpack_require__.r(__webpack_exports__);
  127509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  127510. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127511. var name = 'clipPlaneFragmentDeclaration2';
  127512. 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";
  127513. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127514. /** @hidden */
  127515. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  127516. /***/ }),
  127517. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  127518. /*!***************************************************!*\
  127519. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  127520. \***************************************************/
  127521. /*! exports provided: clipPlaneVertex */
  127522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127523. "use strict";
  127524. __webpack_require__.r(__webpack_exports__);
  127525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  127526. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127527. var name = 'clipPlaneVertex';
  127528. 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";
  127529. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127530. /** @hidden */
  127531. var clipPlaneVertex = { name: name, shader: shader };
  127532. /***/ }),
  127533. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  127534. /*!**************************************************************!*\
  127535. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  127536. \**************************************************************/
  127537. /*! exports provided: clipPlaneVertexDeclaration */
  127538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127539. "use strict";
  127540. __webpack_require__.r(__webpack_exports__);
  127541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  127542. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127543. var name = 'clipPlaneVertexDeclaration';
  127544. 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";
  127545. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127546. /** @hidden */
  127547. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  127548. /***/ }),
  127549. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  127550. /*!***************************************************************!*\
  127551. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  127552. \***************************************************************/
  127553. /*! exports provided: clipPlaneVertexDeclaration2 */
  127554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127555. "use strict";
  127556. __webpack_require__.r(__webpack_exports__);
  127557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  127558. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127559. var name = 'clipPlaneVertexDeclaration2';
  127560. 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";
  127561. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127562. /** @hidden */
  127563. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  127564. /***/ }),
  127565. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  127566. /*!**************************************************************!*\
  127567. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  127568. \**************************************************************/
  127569. /*! exports provided: defaultFragmentDeclaration */
  127570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127571. "use strict";
  127572. __webpack_require__.r(__webpack_exports__);
  127573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  127574. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127575. var name = 'defaultFragmentDeclaration';
  127576. var shader = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#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";
  127577. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127578. /** @hidden */
  127579. var defaultFragmentDeclaration = { name: name, shader: shader };
  127580. /***/ }),
  127581. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  127582. /*!*********************************************************!*\
  127583. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  127584. \*********************************************************/
  127585. /*! exports provided: defaultUboDeclaration */
  127586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127587. "use strict";
  127588. __webpack_require__.r(__webpack_exports__);
  127589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  127590. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127591. var name = 'defaultUboDeclaration';
  127592. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nfloat visibility;\nvec4 vDiffuseColor;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};\n";
  127593. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127594. /** @hidden */
  127595. var defaultUboDeclaration = { name: name, shader: shader };
  127596. /***/ }),
  127597. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  127598. /*!************************************************************!*\
  127599. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  127600. \************************************************************/
  127601. /*! exports provided: defaultVertexDeclaration */
  127602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127603. "use strict";
  127604. __webpack_require__.r(__webpack_exports__);
  127605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  127606. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127607. var name = 'defaultVertexDeclaration';
  127608. 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";
  127609. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127610. /** @hidden */
  127611. var defaultVertexDeclaration = { name: name, shader: shader };
  127612. /***/ }),
  127613. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  127614. /*!************************************************!*\
  127615. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  127616. \************************************************/
  127617. /*! exports provided: depthPrePass */
  127618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127619. "use strict";
  127620. __webpack_require__.r(__webpack_exports__);
  127621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  127622. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127623. var name = 'depthPrePass';
  127624. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  127625. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127626. /** @hidden */
  127627. var depthPrePass = { name: name, shader: shader };
  127628. /***/ }),
  127629. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  127630. /*!***********************************************!*\
  127631. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  127632. \***********************************************/
  127633. /*! exports provided: fogFragment */
  127634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127635. "use strict";
  127636. __webpack_require__.r(__webpack_exports__);
  127637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  127638. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127639. var name = 'fogFragment';
  127640. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  127641. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127642. /** @hidden */
  127643. var fogFragment = { name: name, shader: shader };
  127644. /***/ }),
  127645. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  127646. /*!**********************************************************!*\
  127647. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  127648. \**********************************************************/
  127649. /*! exports provided: fogFragmentDeclaration */
  127650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127651. "use strict";
  127652. __webpack_require__.r(__webpack_exports__);
  127653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  127654. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127655. var name = 'fogFragmentDeclaration';
  127656. 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";
  127657. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127658. /** @hidden */
  127659. var fogFragmentDeclaration = { name: name, shader: shader };
  127660. /***/ }),
  127661. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  127662. /*!*********************************************!*\
  127663. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  127664. \*********************************************/
  127665. /*! exports provided: fogVertex */
  127666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127667. "use strict";
  127668. __webpack_require__.r(__webpack_exports__);
  127669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  127670. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127671. var name = 'fogVertex';
  127672. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  127673. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127674. /** @hidden */
  127675. var fogVertex = { name: name, shader: shader };
  127676. /***/ }),
  127677. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  127678. /*!********************************************************!*\
  127679. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  127680. \********************************************************/
  127681. /*! exports provided: fogVertexDeclaration */
  127682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127683. "use strict";
  127684. __webpack_require__.r(__webpack_exports__);
  127685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  127686. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127687. var name = 'fogVertexDeclaration';
  127688. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  127689. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127690. /** @hidden */
  127691. var fogVertexDeclaration = { name: name, shader: shader };
  127692. /***/ }),
  127693. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  127694. /*!***************************************************!*\
  127695. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  127696. \***************************************************/
  127697. /*! exports provided: fresnelFunction */
  127698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127699. "use strict";
  127700. __webpack_require__.r(__webpack_exports__);
  127701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  127702. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127703. var name = 'fresnelFunction';
  127704. 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";
  127705. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127706. /** @hidden */
  127707. var fresnelFunction = { name: name, shader: shader };
  127708. /***/ }),
  127709. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  127710. /*!******************************************************!*\
  127711. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  127712. \******************************************************/
  127713. /*! exports provided: harmonicsFunctions */
  127714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127715. "use strict";
  127716. __webpack_require__.r(__webpack_exports__);
  127717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  127718. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127719. var name = 'harmonicsFunctions';
  127720. 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";
  127721. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127722. /** @hidden */
  127723. var harmonicsFunctions = { name: name, shader: shader };
  127724. /***/ }),
  127725. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  127726. /*!***************************************************!*\
  127727. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  127728. \***************************************************/
  127729. /*! exports provided: helperFunctions */
  127730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127731. "use strict";
  127732. __webpack_require__.r(__webpack_exports__);
  127733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  127734. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127735. var name = 'helperFunctions';
  127736. var shader = "const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}";
  127737. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127738. /** @hidden */
  127739. var helperFunctions = { name: name, shader: shader };
  127740. /***/ }),
  127741. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  127742. /*!**************************************************************!*\
  127743. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  127744. \**************************************************************/
  127745. /*! exports provided: imageProcessingDeclaration */
  127746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127747. "use strict";
  127748. __webpack_require__.r(__webpack_exports__);
  127749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  127750. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127751. var name = 'imageProcessingDeclaration';
  127752. 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";
  127753. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127754. /** @hidden */
  127755. var imageProcessingDeclaration = { name: name, shader: shader };
  127756. /***/ }),
  127757. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  127758. /*!************************************************************!*\
  127759. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  127760. \************************************************************/
  127761. /*! exports provided: imageProcessingFunctions */
  127762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127763. "use strict";
  127764. __webpack_require__.r(__webpack_exports__);
  127765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  127766. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127767. var name = 'imageProcessingFunctions';
  127768. var shader = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x;\n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=saturate(color);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=saturate(result.rgb);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  127769. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127770. /** @hidden */
  127771. var imageProcessingFunctions = { name: name, shader: shader };
  127772. /***/ }),
  127773. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  127774. /*!********************************************************!*\
  127775. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  127776. \********************************************************/
  127777. /*! exports provided: instancesDeclaration */
  127778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127779. "use strict";
  127780. __webpack_require__.r(__webpack_exports__);
  127781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  127782. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127783. var name = 'instancesDeclaration';
  127784. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  127785. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127786. /** @hidden */
  127787. var instancesDeclaration = { name: name, shader: shader };
  127788. /***/ }),
  127789. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  127790. /*!***************************************************!*\
  127791. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  127792. \***************************************************/
  127793. /*! exports provided: instancesVertex */
  127794. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127795. "use strict";
  127796. __webpack_require__.r(__webpack_exports__);
  127797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  127798. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127799. var name = 'instancesVertex';
  127800. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  127801. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127802. /** @hidden */
  127803. var instancesVertex = { name: name, shader: shader };
  127804. /***/ }),
  127805. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  127806. /*!******************************************************!*\
  127807. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  127808. \******************************************************/
  127809. /*! exports provided: kernelBlurFragment */
  127810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127811. "use strict";
  127812. __webpack_require__.r(__webpack_exports__);
  127813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  127814. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127815. var name = 'kernelBlurFragment';
  127816. 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";
  127817. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127818. /** @hidden */
  127819. var kernelBlurFragment = { name: name, shader: shader };
  127820. /***/ }),
  127821. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  127822. /*!*******************************************************!*\
  127823. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  127824. \*******************************************************/
  127825. /*! exports provided: kernelBlurFragment2 */
  127826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127827. "use strict";
  127828. __webpack_require__.r(__webpack_exports__);
  127829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  127830. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127831. var name = 'kernelBlurFragment2';
  127832. 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";
  127833. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127834. /** @hidden */
  127835. var kernelBlurFragment2 = { name: name, shader: shader };
  127836. /***/ }),
  127837. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  127838. /*!****************************************************************!*\
  127839. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  127840. \****************************************************************/
  127841. /*! exports provided: kernelBlurVaryingDeclaration */
  127842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127843. "use strict";
  127844. __webpack_require__.r(__webpack_exports__);
  127845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  127846. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127847. var name = 'kernelBlurVaryingDeclaration';
  127848. var shader = "varying vec2 sampleCoord{X};";
  127849. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127850. /** @hidden */
  127851. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  127852. /***/ }),
  127853. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  127854. /*!****************************************************!*\
  127855. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  127856. \****************************************************/
  127857. /*! exports provided: kernelBlurVertex */
  127858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127859. "use strict";
  127860. __webpack_require__.r(__webpack_exports__);
  127861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  127862. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127863. var name = 'kernelBlurVertex';
  127864. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  127865. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127866. /** @hidden */
  127867. var kernelBlurVertex = { name: name, shader: shader };
  127868. /***/ }),
  127869. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  127870. /*!*************************************************!*\
  127871. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  127872. \*************************************************/
  127873. /*! exports provided: lightFragment */
  127874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127875. "use strict";
  127876. __webpack_require__.r(__webpack_exports__);
  127877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  127878. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127879. var name = 'lightFragment';
  127880. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\n\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicTangent,anisotropicBitangent,anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\n\npreInfo.roughness=sheenIntensity;\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef CLEARCOAT\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearCoatRoughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearCoatNormalW,clearCoatAARoughnessFactors.x,clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatLightingAbsorption(clearCoatNdotVRefract,preInfo.L,clearCoatNormalW,clearCoatColor,clearCoatThickness,clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\n\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif";
  127881. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127882. /** @hidden */
  127883. var lightFragment = { name: name, shader: shader };
  127884. /***/ }),
  127885. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  127886. /*!************************************************************!*\
  127887. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  127888. \************************************************************/
  127889. /*! exports provided: lightFragmentDeclaration */
  127890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127891. "use strict";
  127892. __webpack_require__.r(__webpack_exports__);
  127893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  127894. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127895. var name = 'lightFragmentDeclaration';
  127896. 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";
  127897. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127898. /** @hidden */
  127899. var lightFragmentDeclaration = { name: name, shader: shader };
  127900. /***/ }),
  127901. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  127902. /*!*******************************************************!*\
  127903. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  127904. \*******************************************************/
  127905. /*! exports provided: lightUboDeclaration */
  127906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127907. "use strict";
  127908. __webpack_require__.r(__webpack_exports__);
  127909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  127910. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127911. var name = 'lightUboDeclaration';
  127912. 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";
  127913. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127914. /** @hidden */
  127915. var lightUboDeclaration = { name: name, shader: shader };
  127916. /***/ }),
  127917. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  127918. /*!***********************************************************!*\
  127919. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  127920. \***********************************************************/
  127921. /*! exports provided: lightsFragmentFunctions */
  127922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127923. "use strict";
  127924. __webpack_require__.r(__webpack_exports__);
  127925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  127926. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127927. var name = 'lightsFragmentFunctions';
  127928. 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}";
  127929. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127930. /** @hidden */
  127931. var lightsFragmentFunctions = { name: name, shader: shader };
  127932. /***/ }),
  127933. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  127934. /*!*******************************************************!*\
  127935. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  127936. \*******************************************************/
  127937. /*! exports provided: logDepthDeclaration */
  127938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127939. "use strict";
  127940. __webpack_require__.r(__webpack_exports__);
  127941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  127942. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127943. var name = 'logDepthDeclaration';
  127944. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  127945. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127946. /** @hidden */
  127947. var logDepthDeclaration = { name: name, shader: shader };
  127948. /***/ }),
  127949. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  127950. /*!****************************************************!*\
  127951. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  127952. \****************************************************/
  127953. /*! exports provided: logDepthFragment */
  127954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127955. "use strict";
  127956. __webpack_require__.r(__webpack_exports__);
  127957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  127958. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127959. var name = 'logDepthFragment';
  127960. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  127961. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127962. /** @hidden */
  127963. var logDepthFragment = { name: name, shader: shader };
  127964. /***/ }),
  127965. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  127966. /*!**************************************************!*\
  127967. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  127968. \**************************************************/
  127969. /*! exports provided: logDepthVertex */
  127970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127971. "use strict";
  127972. __webpack_require__.r(__webpack_exports__);
  127973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  127974. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127975. var name = 'logDepthVertex';
  127976. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  127977. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127978. /** @hidden */
  127979. var logDepthVertex = { name: name, shader: shader };
  127980. /***/ }),
  127981. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  127982. /*!******************************************************!*\
  127983. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  127984. \******************************************************/
  127985. /*! exports provided: morphTargetsVertex */
  127986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127987. "use strict";
  127988. __webpack_require__.r(__webpack_exports__);
  127989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  127990. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127991. var name = 'morphTargetsVertex';
  127992. 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";
  127993. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127994. /** @hidden */
  127995. var morphTargetsVertex = { name: name, shader: shader };
  127996. /***/ }),
  127997. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  127998. /*!*****************************************************************!*\
  127999. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  128000. \*****************************************************************/
  128001. /*! exports provided: morphTargetsVertexDeclaration */
  128002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128003. "use strict";
  128004. __webpack_require__.r(__webpack_exports__);
  128005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  128006. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128007. var name = 'morphTargetsVertexDeclaration';
  128008. 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";
  128009. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128010. /** @hidden */
  128011. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  128012. /***/ }),
  128013. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  128014. /*!***********************************************************************!*\
  128015. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  128016. \***********************************************************************/
  128017. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  128018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128019. "use strict";
  128020. __webpack_require__.r(__webpack_exports__);
  128021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  128022. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128023. var name = 'morphTargetsVertexGlobalDeclaration';
  128024. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  128025. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128026. /** @hidden */
  128027. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  128028. /***/ }),
  128029. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  128030. /*!**********************************************************!*\
  128031. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  128032. \**********************************************************/
  128033. /*! exports provided: mrtFragmentDeclaration */
  128034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128035. "use strict";
  128036. __webpack_require__.r(__webpack_exports__);
  128037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  128038. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128039. var name = 'mrtFragmentDeclaration';
  128040. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  128041. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128042. /** @hidden */
  128043. var mrtFragmentDeclaration = { name: name, shader: shader };
  128044. /***/ }),
  128045. /***/ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts":
  128046. /*!****************************************************!*\
  128047. !*** ./Shaders/ShadersInclude/pbrBRDFFunctions.ts ***!
  128048. \****************************************************/
  128049. /*! exports provided: pbrBRDFFunctions */
  128050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128051. "use strict";
  128052. __webpack_require__.r(__webpack_exports__);
  128053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrBRDFFunctions", function() { return pbrBRDFFunctions; });
  128054. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128055. var name = 'pbrBRDFFunctions';
  128056. var shader = "\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n\n\n\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness,sampler2D brdfSampler) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec4 brdfLookup=texture2D(brdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(REFLECTION)\n\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\n\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\n\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n\n\n\n\n#ifdef BRDF_V_HEIGHT_CORRELATED\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n#endif\n#ifdef SHEEN\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n#endif\n\n\n\n\n\n\n\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n";
  128057. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128058. /** @hidden */
  128059. var pbrBRDFFunctions = { name: name, shader: shader };
  128060. /***/ }),
  128061. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  128062. /*!********************************************!*\
  128063. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  128064. \********************************************/
  128065. /*! exports provided: pbrDebug */
  128066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128067. "use strict";
  128068. __webpack_require__.r(__webpack_exports__);
  128069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  128070. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128071. var name = 'pbrDebug';
  128072. var shader = "#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w<vDebugMode.x) {\nreturn;\n}\n\n#if DEBUGMODE == 1\ngl_FragColor.rgb=vPositionW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 2 && defined(NORMAL)\ngl_FragColor.rgb=vNormalW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 3 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 4 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 5\n\ngl_FragColor.rgb=normalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 6 && defined(MAINUV1)\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\n#elif DEBUGMODE == 7 && defined(MAINUV2)\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\n#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 10 && defined(CLEARCOAT)\n\ngl_FragColor.rgb=clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 12 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicTangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 13 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicBitangent;\n#define DEBUGMODE_NORMALIZE\n\n#elif DEBUGMODE == 20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE == 21 && defined(AMBIENT)\ngl_FragColor.rgb=ambientOcclusionColorMap.rgb;\n#elif DEBUGMODE == 22 && defined(OPACITY)\ngl_FragColor.rgb=opacityMap.rgb;\n#elif DEBUGMODE == 23 && defined(EMISSIVE)\ngl_FragColor.rgb=emissiveColorTex.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 24 && defined(LIGHTMAP)\ngl_FragColor.rgb=lightmapColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=clearCoatMapData.rgb;\n#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearCoatTintMapData.rgb;\n#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\ngl_FragColor.rgb=sheenMapData.rgb;\n#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\ngl_FragColor.rgb=anisotropyMapData.rgb;\n\n#elif DEBUGMODE == 40 && defined(REFRACTION)\n\ngl_FragColor.rgb=environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 41 && defined(REFLECTION)\ngl_FragColor.rgb=environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=environmentClearCoatRadiance;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 53 && defined(SHEEN)\ngl_FragColor.rgb=sheenBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 54 && defined(REFLECTION)\ngl_FragColor.rgb=environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 61\ngl_FragColor.rgb=specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 62\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 65 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 66 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatRoughness);\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatNdotV);\n\n#elif DEBUGMODE == 70 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 71 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 72 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 73 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 74 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 75 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 76 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 77\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#endif";
  128073. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128074. /** @hidden */
  128075. var pbrDebug = { name: name, shader: shader };
  128076. /***/ }),
  128077. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts":
  128078. /*!*********************************************************************!*\
  128079. !*** ./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts ***!
  128080. \*********************************************************************/
  128081. /*! exports provided: pbrDirectLightingFalloffFunctions */
  128082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128083. "use strict";
  128084. __webpack_require__.r(__webpack_exports__);
  128085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFalloffFunctions", function() { return pbrDirectLightingFalloffFunctions; });
  128086. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128087. var name = 'pbrDirectLightingFalloffFunctions';
  128088. var shader = "float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/maxEps(lightDistanceSquared);\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=saturate(1.0-factor*factor);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}";
  128089. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128090. /** @hidden */
  128091. var pbrDirectLightingFalloffFunctions = { name: name, shader: shader };
  128092. /***/ }),
  128093. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts":
  128094. /*!**************************************************************!*\
  128095. !*** ./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts ***!
  128096. \**************************************************************/
  128097. /*! exports provided: pbrDirectLightingFunctions */
  128098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128099. "use strict";
  128100. __webpack_require__.r(__webpack_exports__);
  128101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFunctions", function() { return pbrDirectLightingFunctions; });
  128102. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128103. var name = 'pbrDirectLightingFunctions';
  128104. var shader = "#define CLEARCOATREFLECTANCE90 1.0\n\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\n\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat visibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat visibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat visibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*visibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n\nvec3 fresnel=reflectance0;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\nvec3 sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";
  128105. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128106. /** @hidden */
  128107. var pbrDirectLightingFunctions = { name: name, shader: shader };
  128108. /***/ }),
  128109. /***/ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts":
  128110. /*!*******************************************************************!*\
  128111. !*** ./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts ***!
  128112. \*******************************************************************/
  128113. /*! exports provided: pbrDirectLightingSetupFunctions */
  128114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128115. "use strict";
  128116. __webpack_require__.r(__webpack_exports__);
  128117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingSetupFunctions", function() { return pbrDirectLightingSetupFunctions; });
  128118. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128119. var name = 'pbrDirectLightingSetupFunctions';
  128120. var shader = "\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.NdotL=saturateEps(dot(N,result.L));\nresult.VdotH=saturate(dot(V,result.H));\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.NdotL=saturateEps(dot(N,result.L));\nresult.VdotH=saturate(dot(V,result.H));\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";
  128121. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128122. /** @hidden */
  128123. var pbrDirectLightingSetupFunctions = { name: name, shader: shader };
  128124. /***/ }),
  128125. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  128126. /*!**********************************************************!*\
  128127. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  128128. \**********************************************************/
  128129. /*! exports provided: pbrFragmentDeclaration */
  128130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128131. "use strict";
  128132. __webpack_require__.r(__webpack_exports__);
  128133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  128134. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128135. var name = 'pbrFragmentDeclaration';
  128136. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif";
  128137. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128138. /** @hidden */
  128139. var pbrFragmentDeclaration = { name: name, shader: shader };
  128140. /***/ }),
  128141. /***/ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts":
  128142. /*!***************************************************************!*\
  128143. !*** ./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts ***!
  128144. \***************************************************************/
  128145. /*! exports provided: pbrFragmentExtraDeclaration */
  128146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128147. "use strict";
  128148. __webpack_require__.r(__webpack_exports__);
  128149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentExtraDeclaration", function() { return pbrFragmentExtraDeclaration; });
  128150. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128151. var name = 'pbrFragmentExtraDeclaration';
  128152. var shader = "uniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif";
  128153. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128154. /** @hidden */
  128155. var pbrFragmentExtraDeclaration = { name: name, shader: shader };
  128156. /***/ }),
  128157. /***/ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts":
  128158. /*!******************************************************************!*\
  128159. !*** ./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts ***!
  128160. \******************************************************************/
  128161. /*! exports provided: pbrFragmentSamplersDeclaration */
  128162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128163. "use strict";
  128164. __webpack_require__.r(__webpack_exports__);
  128165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentSamplersDeclaration", function() { return pbrFragmentSamplersDeclaration; });
  128166. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128167. var name = 'pbrFragmentSamplersDeclaration';
  128168. var shader = "#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\n#ifdef 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#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif";
  128169. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128170. /** @hidden */
  128171. var pbrFragmentSamplersDeclaration = { name: name, shader: shader };
  128172. /***/ }),
  128173. /***/ "./Shaders/ShadersInclude/pbrHelperFunctions.ts":
  128174. /*!******************************************************!*\
  128175. !*** ./Shaders/ShadersInclude/pbrHelperFunctions.ts ***!
  128176. \******************************************************/
  128177. /*! exports provided: pbrHelperFunctions */
  128178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128179. "use strict";
  128180. __webpack_require__.r(__webpack_exports__);
  128181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrHelperFunctions", function() { return pbrHelperFunctions; });
  128182. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128183. var name = 'pbrHelperFunctions';
  128184. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\n\n\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n\n\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\n\n\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n#endif\n#ifdef CLEARCOAT\n\n\n\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn exp(alpha*-(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n\n\n\n\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif";
  128185. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128186. /** @hidden */
  128187. var pbrHelperFunctions = { name: name, shader: shader };
  128188. /***/ }),
  128189. /***/ "./Shaders/ShadersInclude/pbrIBLFunctions.ts":
  128190. /*!***************************************************!*\
  128191. !*** ./Shaders/ShadersInclude/pbrIBLFunctions.ts ***!
  128192. \***************************************************/
  128193. /*! exports provided: pbrIBLFunctions */
  128194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128195. "use strict";
  128196. __webpack_require__.r(__webpack_exports__);
  128197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrIBLFunctions", function() { return pbrIBLFunctions; });
  128198. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128199. var name = 'pbrIBLFunctions';
  128200. var shader = "#if defined(REFLECTION) || defined(REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,normal));\nreturn square(temp);\n}\n#endif\n\n\n\n\n#if defined(LODINREFLECTIONALPHA) || defined(LODINREFRACTIONALPHA)\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif";
  128201. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128202. /** @hidden */
  128203. var pbrIBLFunctions = { name: name, shader: shader };
  128204. /***/ }),
  128205. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  128206. /*!*****************************************************!*\
  128207. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  128208. \*****************************************************/
  128209. /*! exports provided: pbrUboDeclaration */
  128210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128211. "use strict";
  128212. __webpack_require__.r(__webpack_exports__);
  128213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  128214. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128215. var name = 'pbrUboDeclaration';
  128216. 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 float pointSize;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";
  128217. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128218. /** @hidden */
  128219. var pbrUboDeclaration = { name: name, shader: shader };
  128220. /***/ }),
  128221. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  128222. /*!********************************************************!*\
  128223. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  128224. \********************************************************/
  128225. /*! exports provided: pbrVertexDeclaration */
  128226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128227. "use strict";
  128228. __webpack_require__.r(__webpack_exports__);
  128229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  128230. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128231. var name = 'pbrVertexDeclaration';
  128232. var shader = "uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n";
  128233. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128234. /** @hidden */
  128235. var pbrVertexDeclaration = { name: name, shader: shader };
  128236. /***/ }),
  128237. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  128238. /*!****************************************************!*\
  128239. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  128240. \****************************************************/
  128241. /*! exports provided: pointCloudVertex */
  128242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128243. "use strict";
  128244. __webpack_require__.r(__webpack_exports__);
  128245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  128246. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128247. var name = 'pointCloudVertex';
  128248. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  128249. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128250. /** @hidden */
  128251. var pointCloudVertex = { name: name, shader: shader };
  128252. /***/ }),
  128253. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  128254. /*!******************************************************!*\
  128255. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  128256. \******************************************************/
  128257. /*! exports provided: reflectionFunction */
  128258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128259. "use strict";
  128260. __webpack_require__.r(__webpack_exports__);
  128261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  128262. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128263. var name = 'reflectionFunction';
  128264. 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}";
  128265. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128266. /** @hidden */
  128267. var reflectionFunction = { name: name, shader: shader };
  128268. /***/ }),
  128269. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  128270. /*!************************************************************!*\
  128271. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  128272. \************************************************************/
  128273. /*! exports provided: shadowsFragmentFunctions */
  128274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128275. "use strict";
  128276. __webpack_require__.r(__webpack_exports__);
  128277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  128278. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128279. var name = 'shadowsFragmentFunctions';
  128280. 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 computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#endif\n#endif\n";
  128281. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128282. /** @hidden */
  128283. var shadowsFragmentFunctions = { name: name, shader: shader };
  128284. /***/ }),
  128285. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  128286. /*!*************************************************!*\
  128287. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  128288. \*************************************************/
  128289. /*! exports provided: shadowsVertex */
  128290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128291. "use strict";
  128292. __webpack_require__.r(__webpack_exports__);
  128293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  128294. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128295. var name = 'shadowsVertex';
  128296. 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";
  128297. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128298. /** @hidden */
  128299. var shadowsVertex = { name: name, shader: shader };
  128300. /***/ }),
  128301. /***/ "./Shaders/anaglyph.fragment.ts":
  128302. /*!**************************************!*\
  128303. !*** ./Shaders/anaglyph.fragment.ts ***!
  128304. \**************************************/
  128305. /*! exports provided: anaglyphPixelShader */
  128306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128307. "use strict";
  128308. __webpack_require__.r(__webpack_exports__);
  128309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  128310. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128311. var name = 'anaglyphPixelShader';
  128312. 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}";
  128313. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128314. /** @hidden */
  128315. var anaglyphPixelShader = { name: name, shader: shader };
  128316. /***/ }),
  128317. /***/ "./Shaders/background.fragment.ts":
  128318. /*!****************************************!*\
  128319. !*** ./Shaders/background.fragment.ts ***!
  128320. \****************************************/
  128321. /*! exports provided: backgroundPixelShader */
  128322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128323. "use strict";
  128324. __webpack_require__.r(__webpack_exports__);
  128325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  128326. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128327. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  128328. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  128329. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  128330. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128331. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  128332. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  128333. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128334. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  128335. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  128336. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128337. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  128338. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  128339. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128340. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  128341. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  128342. var name = 'backgroundPixelShader';
  128343. var shader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n";
  128344. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128345. /** @hidden */
  128346. var backgroundPixelShader = { name: name, shader: shader };
  128347. /***/ }),
  128348. /***/ "./Shaders/background.vertex.ts":
  128349. /*!**************************************!*\
  128350. !*** ./Shaders/background.vertex.ts ***!
  128351. \**************************************/
  128352. /*! exports provided: backgroundVertexShader */
  128353. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128354. "use strict";
  128355. __webpack_require__.r(__webpack_exports__);
  128356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  128357. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128358. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  128359. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  128360. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128361. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128362. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128363. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  128364. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  128365. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  128366. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  128367. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128368. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128369. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  128370. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  128371. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  128372. var name = 'backgroundVertexShader';
  128373. var shader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(position,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  128374. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128375. /** @hidden */
  128376. var backgroundVertexShader = { name: name, shader: shader };
  128377. /***/ }),
  128378. /***/ "./Shaders/blackAndWhite.fragment.ts":
  128379. /*!*******************************************!*\
  128380. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  128381. \*******************************************/
  128382. /*! exports provided: blackAndWhitePixelShader */
  128383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128384. "use strict";
  128385. __webpack_require__.r(__webpack_exports__);
  128386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  128387. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128388. var name = 'blackAndWhitePixelShader';
  128389. 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}";
  128390. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128391. /** @hidden */
  128392. var blackAndWhitePixelShader = { name: name, shader: shader };
  128393. /***/ }),
  128394. /***/ "./Shaders/bloomMerge.fragment.ts":
  128395. /*!****************************************!*\
  128396. !*** ./Shaders/bloomMerge.fragment.ts ***!
  128397. \****************************************/
  128398. /*! exports provided: bloomMergePixelShader */
  128399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128400. "use strict";
  128401. __webpack_require__.r(__webpack_exports__);
  128402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  128403. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128404. var name = 'bloomMergePixelShader';
  128405. 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";
  128406. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128407. /** @hidden */
  128408. var bloomMergePixelShader = { name: name, shader: shader };
  128409. /***/ }),
  128410. /***/ "./Shaders/chromaticAberration.fragment.ts":
  128411. /*!*************************************************!*\
  128412. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  128413. \*************************************************/
  128414. /*! exports provided: chromaticAberrationPixelShader */
  128415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128416. "use strict";
  128417. __webpack_require__.r(__webpack_exports__);
  128418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  128419. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128420. var name = 'chromaticAberrationPixelShader';
  128421. 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}";
  128422. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128423. /** @hidden */
  128424. var chromaticAberrationPixelShader = { name: name, shader: shader };
  128425. /***/ }),
  128426. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  128427. /*!***********************************************!*\
  128428. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  128429. \***********************************************/
  128430. /*! exports provided: circleOfConfusionPixelShader */
  128431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128432. "use strict";
  128433. __webpack_require__.r(__webpack_exports__);
  128434. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  128435. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128436. var name = 'circleOfConfusionPixelShader';
  128437. 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";
  128438. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128439. /** @hidden */
  128440. var circleOfConfusionPixelShader = { name: name, shader: shader };
  128441. /***/ }),
  128442. /***/ "./Shaders/color.fragment.ts":
  128443. /*!***********************************!*\
  128444. !*** ./Shaders/color.fragment.ts ***!
  128445. \***********************************/
  128446. /*! exports provided: colorPixelShader */
  128447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128448. "use strict";
  128449. __webpack_require__.r(__webpack_exports__);
  128450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  128451. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128452. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  128453. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128454. var name = 'colorPixelShader';
  128455. var shader = "#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\n#include<clipPlaneFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";
  128456. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128457. /** @hidden */
  128458. var colorPixelShader = { name: name, shader: shader };
  128459. /***/ }),
  128460. /***/ "./Shaders/color.vertex.ts":
  128461. /*!*********************************!*\
  128462. !*** ./Shaders/color.vertex.ts ***!
  128463. \*********************************/
  128464. /*! exports provided: colorVertexShader */
  128465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128466. "use strict";
  128467. __webpack_require__.r(__webpack_exports__);
  128468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  128469. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128470. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128471. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  128472. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128473. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128474. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128475. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  128476. var name = 'colorVertexShader';
  128477. var shader = "\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<clipPlaneVertexDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\n#include<clipPlaneVertex>\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";
  128478. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128479. /** @hidden */
  128480. var colorVertexShader = { name: name, shader: shader };
  128481. /***/ }),
  128482. /***/ "./Shaders/colorCorrection.fragment.ts":
  128483. /*!*********************************************!*\
  128484. !*** ./Shaders/colorCorrection.fragment.ts ***!
  128485. \*********************************************/
  128486. /*! exports provided: colorCorrectionPixelShader */
  128487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128488. "use strict";
  128489. __webpack_require__.r(__webpack_exports__);
  128490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  128491. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128492. var name = 'colorCorrectionPixelShader';
  128493. 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}";
  128494. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128495. /** @hidden */
  128496. var colorCorrectionPixelShader = { name: name, shader: shader };
  128497. /***/ }),
  128498. /***/ "./Shaders/convolution.fragment.ts":
  128499. /*!*****************************************!*\
  128500. !*** ./Shaders/convolution.fragment.ts ***!
  128501. \*****************************************/
  128502. /*! exports provided: convolutionPixelShader */
  128503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128504. "use strict";
  128505. __webpack_require__.r(__webpack_exports__);
  128506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  128507. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128508. var name = 'convolutionPixelShader';
  128509. 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}";
  128510. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128511. /** @hidden */
  128512. var convolutionPixelShader = { name: name, shader: shader };
  128513. /***/ }),
  128514. /***/ "./Shaders/default.fragment.ts":
  128515. /*!*************************************!*\
  128516. !*** ./Shaders/default.fragment.ts ***!
  128517. \*************************************/
  128518. /*! exports provided: defaultPixelShader */
  128519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128520. "use strict";
  128521. __webpack_require__.r(__webpack_exports__);
  128522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  128523. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128524. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  128525. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  128526. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128527. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  128528. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  128529. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  128530. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  128531. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  128532. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  128533. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128534. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128535. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  128536. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  128537. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  128538. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  128539. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128540. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  128541. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  128542. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  128543. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  128544. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  128545. var name = 'defaultPixelShader';
  128546. var shader = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\ncolor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n";
  128547. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128548. /** @hidden */
  128549. var defaultPixelShader = { name: name, shader: shader };
  128550. /***/ }),
  128551. /***/ "./Shaders/default.vertex.ts":
  128552. /*!***********************************!*\
  128553. !*** ./Shaders/default.vertex.ts ***!
  128554. \***********************************/
  128555. /*! exports provided: defaultVertexShader */
  128556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128557. "use strict";
  128558. __webpack_require__.r(__webpack_exports__);
  128559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  128560. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128561. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  128562. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  128563. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128564. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128565. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128566. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  128567. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  128568. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  128569. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  128570. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  128571. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  128572. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  128573. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  128574. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  128575. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128576. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128577. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  128578. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  128579. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  128580. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  128581. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  128582. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  128583. var name = 'defaultVertexShader';
  128584. 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>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(positionUpdated,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 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";
  128585. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128586. /** @hidden */
  128587. var defaultVertexShader = { name: name, shader: shader };
  128588. /***/ }),
  128589. /***/ "./Shaders/depth.fragment.ts":
  128590. /*!***********************************!*\
  128591. !*** ./Shaders/depth.fragment.ts ***!
  128592. \***********************************/
  128593. /*! exports provided: depthPixelShader */
  128594. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128595. "use strict";
  128596. __webpack_require__.r(__webpack_exports__);
  128597. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  128598. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128599. var name = 'depthPixelShader';
  128600. 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}";
  128601. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128602. /** @hidden */
  128603. var depthPixelShader = { name: name, shader: shader };
  128604. /***/ }),
  128605. /***/ "./Shaders/depth.vertex.ts":
  128606. /*!*********************************!*\
  128607. !*** ./Shaders/depth.vertex.ts ***!
  128608. \*********************************/
  128609. /*! exports provided: depthVertexShader */
  128610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128611. "use strict";
  128612. __webpack_require__.r(__webpack_exports__);
  128613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  128614. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128615. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128616. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128617. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128618. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128619. var name = 'depthVertexShader';
  128620. 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}";
  128621. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128622. /** @hidden */
  128623. var depthVertexShader = { name: name, shader: shader };
  128624. /***/ }),
  128625. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  128626. /*!******************************************!*\
  128627. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  128628. \******************************************/
  128629. /*! exports provided: depthBoxBlurPixelShader */
  128630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128631. "use strict";
  128632. __webpack_require__.r(__webpack_exports__);
  128633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  128634. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128635. var name = 'depthBoxBlurPixelShader';
  128636. 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}";
  128637. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128638. /** @hidden */
  128639. var depthBoxBlurPixelShader = { name: name, shader: shader };
  128640. /***/ }),
  128641. /***/ "./Shaders/depthOfField.fragment.ts":
  128642. /*!******************************************!*\
  128643. !*** ./Shaders/depthOfField.fragment.ts ***!
  128644. \******************************************/
  128645. /*! exports provided: depthOfFieldPixelShader */
  128646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128647. "use strict";
  128648. __webpack_require__.r(__webpack_exports__);
  128649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  128650. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128651. var name = 'depthOfFieldPixelShader';
  128652. 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";
  128653. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128654. /** @hidden */
  128655. var depthOfFieldPixelShader = { name: name, shader: shader };
  128656. /***/ }),
  128657. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  128658. /*!***********************************************!*\
  128659. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  128660. \***********************************************/
  128661. /*! exports provided: depthOfFieldMergePixelShader */
  128662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128663. "use strict";
  128664. __webpack_require__.r(__webpack_exports__);
  128665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  128666. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128667. var name = 'depthOfFieldMergePixelShader';
  128668. 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";
  128669. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128670. /** @hidden */
  128671. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  128672. /***/ }),
  128673. /***/ "./Shaders/displayPass.fragment.ts":
  128674. /*!*****************************************!*\
  128675. !*** ./Shaders/displayPass.fragment.ts ***!
  128676. \*****************************************/
  128677. /*! exports provided: displayPassPixelShader */
  128678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128679. "use strict";
  128680. __webpack_require__.r(__webpack_exports__);
  128681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  128682. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128683. var name = 'displayPassPixelShader';
  128684. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  128685. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128686. /** @hidden */
  128687. var displayPassPixelShader = { name: name, shader: shader };
  128688. /***/ }),
  128689. /***/ "./Shaders/extractHighlights.fragment.ts":
  128690. /*!***********************************************!*\
  128691. !*** ./Shaders/extractHighlights.fragment.ts ***!
  128692. \***********************************************/
  128693. /*! exports provided: extractHighlightsPixelShader */
  128694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128695. "use strict";
  128696. __webpack_require__.r(__webpack_exports__);
  128697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  128698. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128699. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128700. var name = 'extractHighlightsPixelShader';
  128701. 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}";
  128702. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128703. /** @hidden */
  128704. var extractHighlightsPixelShader = { name: name, shader: shader };
  128705. /***/ }),
  128706. /***/ "./Shaders/filter.fragment.ts":
  128707. /*!************************************!*\
  128708. !*** ./Shaders/filter.fragment.ts ***!
  128709. \************************************/
  128710. /*! exports provided: filterPixelShader */
  128711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128712. "use strict";
  128713. __webpack_require__.r(__webpack_exports__);
  128714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  128715. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128716. var name = 'filterPixelShader';
  128717. 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}";
  128718. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128719. /** @hidden */
  128720. var filterPixelShader = { name: name, shader: shader };
  128721. /***/ }),
  128722. /***/ "./Shaders/fxaa.fragment.ts":
  128723. /*!**********************************!*\
  128724. !*** ./Shaders/fxaa.fragment.ts ***!
  128725. \**********************************/
  128726. /*! exports provided: fxaaPixelShader */
  128727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128728. "use strict";
  128729. __webpack_require__.r(__webpack_exports__);
  128730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  128731. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128732. var name = 'fxaaPixelShader';
  128733. 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}";
  128734. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128735. /** @hidden */
  128736. var fxaaPixelShader = { name: name, shader: shader };
  128737. /***/ }),
  128738. /***/ "./Shaders/fxaa.vertex.ts":
  128739. /*!********************************!*\
  128740. !*** ./Shaders/fxaa.vertex.ts ***!
  128741. \********************************/
  128742. /*! exports provided: fxaaVertexShader */
  128743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128744. "use strict";
  128745. __webpack_require__.r(__webpack_exports__);
  128746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  128747. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128748. var name = 'fxaaVertexShader';
  128749. 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}";
  128750. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128751. /** @hidden */
  128752. var fxaaVertexShader = { name: name, shader: shader };
  128753. /***/ }),
  128754. /***/ "./Shaders/geometry.fragment.ts":
  128755. /*!**************************************!*\
  128756. !*** ./Shaders/geometry.fragment.ts ***!
  128757. \**************************************/
  128758. /*! exports provided: geometryPixelShader */
  128759. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128760. "use strict";
  128761. __webpack_require__.r(__webpack_exports__);
  128762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  128763. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128764. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  128765. var name = 'geometryPixelShader';
  128766. 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}";
  128767. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128768. /** @hidden */
  128769. var geometryPixelShader = { name: name, shader: shader };
  128770. /***/ }),
  128771. /***/ "./Shaders/geometry.vertex.ts":
  128772. /*!************************************!*\
  128773. !*** ./Shaders/geometry.vertex.ts ***!
  128774. \************************************/
  128775. /*! exports provided: geometryVertexShader */
  128776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128777. "use strict";
  128778. __webpack_require__.r(__webpack_exports__);
  128779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  128780. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128781. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128782. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128783. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128784. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128785. var name = 'geometryVertexShader';
  128786. 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}";
  128787. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128788. /** @hidden */
  128789. var geometryVertexShader = { name: name, shader: shader };
  128790. /***/ }),
  128791. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  128792. /*!*************************************************!*\
  128793. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  128794. \*************************************************/
  128795. /*! exports provided: glowBlurPostProcessPixelShader */
  128796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128797. "use strict";
  128798. __webpack_require__.r(__webpack_exports__);
  128799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  128800. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128801. var name = 'glowBlurPostProcessPixelShader';
  128802. 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}";
  128803. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128804. /** @hidden */
  128805. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  128806. /***/ }),
  128807. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  128808. /*!***********************************************!*\
  128809. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  128810. \***********************************************/
  128811. /*! exports provided: glowMapGenerationPixelShader */
  128812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128813. "use strict";
  128814. __webpack_require__.r(__webpack_exports__);
  128815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  128816. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128817. var name = 'glowMapGenerationPixelShader';
  128818. 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}";
  128819. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128820. /** @hidden */
  128821. var glowMapGenerationPixelShader = { name: name, shader: shader };
  128822. /***/ }),
  128823. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  128824. /*!*********************************************!*\
  128825. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  128826. \*********************************************/
  128827. /*! exports provided: glowMapGenerationVertexShader */
  128828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128829. "use strict";
  128830. __webpack_require__.r(__webpack_exports__);
  128831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  128832. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128833. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128834. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  128835. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  128836. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128837. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  128838. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128839. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128840. var name = 'glowMapGenerationVertexShader';
  128841. 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}";
  128842. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128843. /** @hidden */
  128844. var glowMapGenerationVertexShader = { name: name, shader: shader };
  128845. /***/ }),
  128846. /***/ "./Shaders/glowMapMerge.fragment.ts":
  128847. /*!******************************************!*\
  128848. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  128849. \******************************************/
  128850. /*! exports provided: glowMapMergePixelShader */
  128851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128852. "use strict";
  128853. __webpack_require__.r(__webpack_exports__);
  128854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  128855. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128856. var name = 'glowMapMergePixelShader';
  128857. 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}";
  128858. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128859. /** @hidden */
  128860. var glowMapMergePixelShader = { name: name, shader: shader };
  128861. /***/ }),
  128862. /***/ "./Shaders/glowMapMerge.vertex.ts":
  128863. /*!****************************************!*\
  128864. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  128865. \****************************************/
  128866. /*! exports provided: glowMapMergeVertexShader */
  128867. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128868. "use strict";
  128869. __webpack_require__.r(__webpack_exports__);
  128870. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  128871. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128872. var name = 'glowMapMergeVertexShader';
  128873. 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}";
  128874. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128875. /** @hidden */
  128876. var glowMapMergeVertexShader = { name: name, shader: shader };
  128877. /***/ }),
  128878. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  128879. /*!************************************************!*\
  128880. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  128881. \************************************************/
  128882. /*! exports provided: gpuRenderParticlesPixelShader */
  128883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128884. "use strict";
  128885. __webpack_require__.r(__webpack_exports__);
  128886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  128887. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128888. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  128889. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128890. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128891. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128892. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128893. var name = 'gpuRenderParticlesPixelShader';
  128894. 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";
  128895. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128896. /** @hidden */
  128897. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  128898. /***/ }),
  128899. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  128900. /*!**********************************************!*\
  128901. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  128902. \**********************************************/
  128903. /*! exports provided: gpuRenderParticlesVertexShader */
  128904. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128905. "use strict";
  128906. __webpack_require__.r(__webpack_exports__);
  128907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  128908. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128909. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  128910. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  128911. var name = 'gpuRenderParticlesVertexShader';
  128912. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\nuniform vec3 worldOffset;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn (position+worldOffset)+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn (position+worldOffset)+alignedCorner;\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=(position+worldOffset)-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=(position+worldOffset)-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";
  128913. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128914. /** @hidden */
  128915. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  128916. /***/ }),
  128917. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  128918. /*!************************************************!*\
  128919. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  128920. \************************************************/
  128921. /*! exports provided: gpuUpdateParticlesPixelShader */
  128922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128923. "use strict";
  128924. __webpack_require__.r(__webpack_exports__);
  128925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  128926. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128927. var name = 'gpuUpdateParticlesPixelShader';
  128928. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  128929. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128930. /** @hidden */
  128931. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  128932. /***/ }),
  128933. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  128934. /*!**********************************************!*\
  128935. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  128936. \**********************************************/
  128937. /*! exports provided: gpuUpdateParticlesVertexShader */
  128938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128939. "use strict";
  128940. __webpack_require__.r(__webpack_exports__);
  128941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  128942. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128943. var name = 'gpuUpdateParticlesVertexShader';
  128944. 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}";
  128945. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128946. /** @hidden */
  128947. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  128948. /***/ }),
  128949. /***/ "./Shaders/grain.fragment.ts":
  128950. /*!***********************************!*\
  128951. !*** ./Shaders/grain.fragment.ts ***!
  128952. \***********************************/
  128953. /*! exports provided: grainPixelShader */
  128954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128955. "use strict";
  128956. __webpack_require__.r(__webpack_exports__);
  128957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  128958. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128959. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128960. var name = 'grainPixelShader';
  128961. 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}";
  128962. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128963. /** @hidden */
  128964. var grainPixelShader = { name: name, shader: shader };
  128965. /***/ }),
  128966. /***/ "./Shaders/highlights.fragment.ts":
  128967. /*!****************************************!*\
  128968. !*** ./Shaders/highlights.fragment.ts ***!
  128969. \****************************************/
  128970. /*! exports provided: highlightsPixelShader */
  128971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128972. "use strict";
  128973. __webpack_require__.r(__webpack_exports__);
  128974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  128975. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128976. var name = 'highlightsPixelShader';
  128977. 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}";
  128978. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128979. /** @hidden */
  128980. var highlightsPixelShader = { name: name, shader: shader };
  128981. /***/ }),
  128982. /***/ "./Shaders/imageProcessing.fragment.ts":
  128983. /*!*********************************************!*\
  128984. !*** ./Shaders/imageProcessing.fragment.ts ***!
  128985. \*********************************************/
  128986. /*! exports provided: imageProcessingPixelShader */
  128987. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128988. "use strict";
  128989. __webpack_require__.r(__webpack_exports__);
  128990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  128991. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128992. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128993. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128994. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128995. var name = 'imageProcessingPixelShader';
  128996. 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}";
  128997. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128998. /** @hidden */
  128999. var imageProcessingPixelShader = { name: name, shader: shader };
  129000. /***/ }),
  129001. /***/ "./Shaders/kernelBlur.fragment.ts":
  129002. /*!****************************************!*\
  129003. !*** ./Shaders/kernelBlur.fragment.ts ***!
  129004. \****************************************/
  129005. /*! exports provided: kernelBlurPixelShader */
  129006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129007. "use strict";
  129008. __webpack_require__.r(__webpack_exports__);
  129009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  129010. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129011. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  129012. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  129013. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  129014. var name = 'kernelBlurPixelShader';
  129015. 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}";
  129016. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129017. /** @hidden */
  129018. var kernelBlurPixelShader = { name: name, shader: shader };
  129019. /***/ }),
  129020. /***/ "./Shaders/kernelBlur.vertex.ts":
  129021. /*!**************************************!*\
  129022. !*** ./Shaders/kernelBlur.vertex.ts ***!
  129023. \**************************************/
  129024. /*! exports provided: kernelBlurVertexShader */
  129025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129026. "use strict";
  129027. __webpack_require__.r(__webpack_exports__);
  129028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  129029. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129030. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  129031. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  129032. var name = 'kernelBlurVertexShader';
  129033. 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}";
  129034. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129035. /** @hidden */
  129036. var kernelBlurVertexShader = { name: name, shader: shader };
  129037. /***/ }),
  129038. /***/ "./Shaders/layer.fragment.ts":
  129039. /*!***********************************!*\
  129040. !*** ./Shaders/layer.fragment.ts ***!
  129041. \***********************************/
  129042. /*! exports provided: layerPixelShader */
  129043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129044. "use strict";
  129045. __webpack_require__.r(__webpack_exports__);
  129046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  129047. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129048. var name = 'layerPixelShader';
  129049. 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}";
  129050. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129051. /** @hidden */
  129052. var layerPixelShader = { name: name, shader: shader };
  129053. /***/ }),
  129054. /***/ "./Shaders/layer.vertex.ts":
  129055. /*!*********************************!*\
  129056. !*** ./Shaders/layer.vertex.ts ***!
  129057. \*********************************/
  129058. /*! exports provided: layerVertexShader */
  129059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129060. "use strict";
  129061. __webpack_require__.r(__webpack_exports__);
  129062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  129063. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129064. var name = 'layerVertexShader';
  129065. 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}";
  129066. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129067. /** @hidden */
  129068. var layerVertexShader = { name: name, shader: shader };
  129069. /***/ }),
  129070. /***/ "./Shaders/lensFlare.fragment.ts":
  129071. /*!***************************************!*\
  129072. !*** ./Shaders/lensFlare.fragment.ts ***!
  129073. \***************************************/
  129074. /*! exports provided: lensFlarePixelShader */
  129075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129076. "use strict";
  129077. __webpack_require__.r(__webpack_exports__);
  129078. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  129079. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129080. var name = 'lensFlarePixelShader';
  129081. 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}";
  129082. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129083. /** @hidden */
  129084. var lensFlarePixelShader = { name: name, shader: shader };
  129085. /***/ }),
  129086. /***/ "./Shaders/lensFlare.vertex.ts":
  129087. /*!*************************************!*\
  129088. !*** ./Shaders/lensFlare.vertex.ts ***!
  129089. \*************************************/
  129090. /*! exports provided: lensFlareVertexShader */
  129091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129092. "use strict";
  129093. __webpack_require__.r(__webpack_exports__);
  129094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  129095. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129096. var name = 'lensFlareVertexShader';
  129097. 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}";
  129098. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129099. /** @hidden */
  129100. var lensFlareVertexShader = { name: name, shader: shader };
  129101. /***/ }),
  129102. /***/ "./Shaders/lensHighlights.fragment.ts":
  129103. /*!********************************************!*\
  129104. !*** ./Shaders/lensHighlights.fragment.ts ***!
  129105. \********************************************/
  129106. /*! exports provided: lensHighlightsPixelShader */
  129107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129108. "use strict";
  129109. __webpack_require__.r(__webpack_exports__);
  129110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  129111. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129112. var name = 'lensHighlightsPixelShader';
  129113. 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}";
  129114. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129115. /** @hidden */
  129116. var lensHighlightsPixelShader = { name: name, shader: shader };
  129117. /***/ }),
  129118. /***/ "./Shaders/line.fragment.ts":
  129119. /*!**********************************!*\
  129120. !*** ./Shaders/line.fragment.ts ***!
  129121. \**********************************/
  129122. /*! exports provided: linePixelShader */
  129123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129124. "use strict";
  129125. __webpack_require__.r(__webpack_exports__);
  129126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  129127. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129128. var name = 'linePixelShader';
  129129. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  129130. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129131. /** @hidden */
  129132. var linePixelShader = { name: name, shader: shader };
  129133. /***/ }),
  129134. /***/ "./Shaders/line.vertex.ts":
  129135. /*!********************************!*\
  129136. !*** ./Shaders/line.vertex.ts ***!
  129137. \********************************/
  129138. /*! exports provided: lineVertexShader */
  129139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129140. "use strict";
  129141. __webpack_require__.r(__webpack_exports__);
  129142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  129143. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129144. var name = 'lineVertexShader';
  129145. 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}";
  129146. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129147. /** @hidden */
  129148. var lineVertexShader = { name: name, shader: shader };
  129149. /***/ }),
  129150. /***/ "./Shaders/motionBlur.fragment.ts":
  129151. /*!****************************************!*\
  129152. !*** ./Shaders/motionBlur.fragment.ts ***!
  129153. \****************************************/
  129154. /*! exports provided: motionBlurPixelShader */
  129155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129156. "use strict";
  129157. __webpack_require__.r(__webpack_exports__);
  129158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  129159. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129160. var name = 'motionBlurPixelShader';
  129161. 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";
  129162. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129163. /** @hidden */
  129164. var motionBlurPixelShader = { name: name, shader: shader };
  129165. /***/ }),
  129166. /***/ "./Shaders/noise.fragment.ts":
  129167. /*!***********************************!*\
  129168. !*** ./Shaders/noise.fragment.ts ***!
  129169. \***********************************/
  129170. /*! exports provided: noisePixelShader */
  129171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129172. "use strict";
  129173. __webpack_require__.r(__webpack_exports__);
  129174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  129175. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129176. var name = 'noisePixelShader';
  129177. 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";
  129178. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129179. /** @hidden */
  129180. var noisePixelShader = { name: name, shader: shader };
  129181. /***/ }),
  129182. /***/ "./Shaders/outline.fragment.ts":
  129183. /*!*************************************!*\
  129184. !*** ./Shaders/outline.fragment.ts ***!
  129185. \*************************************/
  129186. /*! exports provided: outlinePixelShader */
  129187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129188. "use strict";
  129189. __webpack_require__.r(__webpack_exports__);
  129190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  129191. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129192. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129193. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  129194. var name = 'outlinePixelShader';
  129195. 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}";
  129196. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129197. /** @hidden */
  129198. var outlinePixelShader = { name: name, shader: shader };
  129199. /***/ }),
  129200. /***/ "./Shaders/outline.vertex.ts":
  129201. /*!***********************************!*\
  129202. !*** ./Shaders/outline.vertex.ts ***!
  129203. \***********************************/
  129204. /*! exports provided: outlineVertexShader */
  129205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129206. "use strict";
  129207. __webpack_require__.r(__webpack_exports__);
  129208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  129209. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129210. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129211. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129212. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129213. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129214. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129215. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  129216. var name = 'outlineVertexShader';
  129217. 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";
  129218. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129219. /** @hidden */
  129220. var outlineVertexShader = { name: name, shader: shader };
  129221. /***/ }),
  129222. /***/ "./Shaders/particles.fragment.ts":
  129223. /*!***************************************!*\
  129224. !*** ./Shaders/particles.fragment.ts ***!
  129225. \***************************************/
  129226. /*! exports provided: particlesPixelShader */
  129227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129228. "use strict";
  129229. __webpack_require__.r(__webpack_exports__);
  129230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  129231. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129232. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129233. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129234. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129235. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129236. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129237. var name = 'particlesPixelShader';
  129238. 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}";
  129239. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129240. /** @hidden */
  129241. var particlesPixelShader = { name: name, shader: shader };
  129242. /***/ }),
  129243. /***/ "./Shaders/particles.vertex.ts":
  129244. /*!*************************************!*\
  129245. !*** ./Shaders/particles.vertex.ts ***!
  129246. \*************************************/
  129247. /*! exports provided: particlesVertexShader */
  129248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129249. "use strict";
  129250. __webpack_require__.r(__webpack_exports__);
  129251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  129252. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129253. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129254. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129255. var name = 'particlesVertexShader';
  129256. 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}";
  129257. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129258. /** @hidden */
  129259. var particlesVertexShader = { name: name, shader: shader };
  129260. /***/ }),
  129261. /***/ "./Shaders/pass.fragment.ts":
  129262. /*!**********************************!*\
  129263. !*** ./Shaders/pass.fragment.ts ***!
  129264. \**********************************/
  129265. /*! exports provided: passPixelShader */
  129266. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129267. "use strict";
  129268. __webpack_require__.r(__webpack_exports__);
  129269. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  129270. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129271. var name = 'passPixelShader';
  129272. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  129273. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129274. /** @hidden */
  129275. var passPixelShader = { name: name, shader: shader };
  129276. /***/ }),
  129277. /***/ "./Shaders/passCube.fragment.ts":
  129278. /*!**************************************!*\
  129279. !*** ./Shaders/passCube.fragment.ts ***!
  129280. \**************************************/
  129281. /*! exports provided: passCubePixelShader */
  129282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129283. "use strict";
  129284. __webpack_require__.r(__webpack_exports__);
  129285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  129286. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129287. var name = 'passCubePixelShader';
  129288. 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}";
  129289. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129290. /** @hidden */
  129291. var passCubePixelShader = { name: name, shader: shader };
  129292. /***/ }),
  129293. /***/ "./Shaders/pbr.fragment.ts":
  129294. /*!*********************************!*\
  129295. !*** ./Shaders/pbr.fragment.ts ***!
  129296. \*********************************/
  129297. /*! exports provided: pbrPixelShader */
  129298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129299. "use strict";
  129300. __webpack_require__.r(__webpack_exports__);
  129301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  129302. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129303. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  129304. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  129305. /* harmony import */ var _ShadersInclude_pbrFragmentExtraDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentExtraDeclaration */ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts");
  129306. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129307. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129308. /* harmony import */ var _ShadersInclude_pbrFragmentSamplersDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentSamplersDeclaration */ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts");
  129309. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129310. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129311. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129312. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  129313. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129314. /* harmony import */ var _ShadersInclude_pbrHelperFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrHelperFunctions */ "./Shaders/ShadersInclude/pbrHelperFunctions.ts");
  129315. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129316. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  129317. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  129318. /* harmony import */ var _ShadersInclude_pbrDirectLightingSetupFunctions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingSetupFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts");
  129319. /* harmony import */ var _ShadersInclude_pbrDirectLightingFalloffFunctions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFalloffFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts");
  129320. /* harmony import */ var _ShadersInclude_pbrBRDFFunctions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/pbrBRDFFunctions */ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts");
  129321. /* harmony import */ var _ShadersInclude_pbrDirectLightingFunctions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts");
  129322. /* harmony import */ var _ShadersInclude_pbrIBLFunctions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/pbrIBLFunctions */ "./Shaders/ShadersInclude/pbrIBLFunctions.ts");
  129323. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  129324. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  129325. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129326. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  129327. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  129328. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  129329. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  129330. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  129331. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  129332. var name = 'pbrPixelShader';
  129333. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#include<__decl__pbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<pbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n\n#include<helperFunctions>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<bumpFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n\nvoid main(void) {\n#include<clipPlaneFragment>\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#ifdef CLEARCOAT\n\nvec3 clearCoatNormalW=normalW;\n#endif\n#include<bumpFragment>\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n#ifdef REFLECTANCE\n\n\n\n\n\nsurfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\n\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=saturate(microSurface);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\n\nfloat NdotV=absEps(NdotVUnclamped);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\n\nalphaG+=AARoughnessFactors.y;\n#endif\n#ifdef ANISOTROPIC\nfloat anisotropy=vAnisotropy.b;\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\n#ifdef ANISOTROPIC_TEXTURE\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\nanisotropy*=anisotropyMapData.b;\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\n#endif\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\nvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\nvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\nvec3 anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG);\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=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\n#ifdef SHEEN\nfloat sheenIntensity=vSheenColor.a;\n#ifdef SHEEN_TEXTURE\nvec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset)*vSheenInfos.y;\nsheenIntensity*=sheenMapData.a;\n#endif\n#ifdef SHEEN_LINKWITHALBEDO\nfloat sheenFactor=pow5(1.0-sheenIntensity);\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\nfloat sheenRoughness=sheenIntensity;\n\nsurfaceAlbedo.rgb*=sheenFactor;\n#else\nvec3 sheenColor=vSheenColor.rgb;\n#ifdef SHEEN_TEXTURE\nsheenColor.rgb*=toLinearSpace(sheenMapData.rgb);\n#endif\nfloat sheenRoughness=roughness;\n\nsheenIntensity*=(1.-reflectance);\n\nsheenColor*=sheenIntensity;\n#endif\n\n#if defined(REFLECTION)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\n\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\n\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG,NdotVUnclamped);\n#else\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nsheenReflectionLOD=sheenReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nenvironmentSheenRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,sheenReflectionLOD);\n#else\nfloat lodSheenReflectionNormalized=saturate(sheenReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodSheenReflectionNormalizedDoubled=lodSheenReflectionNormalized*2.0;\nvec4 environmentSheenMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodSheenReflectionNormalizedDoubled<1.0){\nenvironmentSheenRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSheenMid,\nlodSheenReflectionNormalizedDoubled\n);\n}else{\nenvironmentSheenRadiance=mix(\nenvironmentSheenMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodSheenReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentSheenRadiance.rgb=fromRGBD(environmentSheenRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentSheenRadiance.rgb=toLinearSpace(environmentSheenRadiance.rgb);\n#endif\n\nenvironmentSheenRadiance.rgb*=vReflectionInfos.x;\nenvironmentSheenRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#ifdef CLEARCOAT\n\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\nclearCoatIntensity*=clearCoatMapData.x;\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\nclearCoatThickness*=clearCoatTintMapData.a;\n#endif\nclearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\n#endif\n\n\n\n\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\nspecularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset).xyz*2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBN,vClearCoatBumpUV+uvOffset,clearCoatBumpSampler,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\n#endif\n\nvec2 clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\n\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\n\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\n\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\n\nclearCoatAlphaG+=clearCoatAARoughnessFactors.y;\n#endif\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nclearCoatReflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\n#else\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\n#endif\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG,clearCoatNdotVUnclamped);\n#else\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nclearCoatReflectionLOD=clearCoatReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nfloat requestedClearCoatReflectionLOD=clearCoatReflectionLOD;\nenvironmentClearCoatRadiance=sampleReflectionLod(reflectionSampler,clearCoatReflectionCoords,requestedClearCoatReflectionLOD);\n#else\nfloat lodClearCoatReflectionNormalized=saturate(clearCoatReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodClearCoatReflectionNormalizedDoubled=lodClearCoatReflectionNormalized*2.0;\nvec4 environmentClearCoatMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodClearCoatReflectionNormalizedDoubled<1.0){\nenvironmentClearCoatRadiance=mix(\nsampleReflection(reflectionSamplerHigh,clearCoatReflectionCoords),\nenvironmentClearCoatMid,\nlodClearCoatReflectionNormalizedDoubled\n);\n}else{\nenvironmentClearCoatRadiance=mix(\nenvironmentClearCoatMid,\nsampleReflection(reflectionSamplerLow,clearCoatReflectionCoords),\nlodClearCoatReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentClearCoatRadiance.rgb=fromRGBD(environmentClearCoatRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentClearCoatRadiance.rgb=toLinearSpace(environmentClearCoatRadiance.rgb);\n#endif\n#ifdef CLEARCOAT_TINT\n\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\n\nfloat clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\nvec3 absorption=vec3(0.);\n#endif\n\nenvironmentClearCoatRadiance.rgb*=vReflectionInfos.x;\nenvironmentClearCoatRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#if defined(ENVIRONMENTBRDF)\n\nvec3 environmentBrdf=getBRDFLookup(NdotV,roughness,environmentBrdfSampler);\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef SHEEN\nvec3 sheenBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\n\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(specularEnvironmentR0,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#if defined(SHEEN) && defined(REFLECTION)\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\nsheenEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nsheenEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#endif\n\n#ifdef CLEARCOAT\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness,environmentBrdfSampler);\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\n\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatAbsorption(clearCoatNdotVRefract,clearCoatNdotVRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#ifdef REFLECTION\nenvironmentIrradiance*=absorption;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=absorption;\n#endif\nspecularEnvironmentReflectance*=absorption;\n#endif\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\nfloat conservationFactor=(1.-fresnelIBLClearCoat);\n#ifdef REFLECTION\nenvironmentIrradiance*=conservationFactor;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\nspecularEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\n\n#ifdef 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=saturate(maxChannel*mixedAlbedo);\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#ifndef METALLICWORKFLOW\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\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#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\n\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=energyConservationFactor;\n#endif\n\n#ifdef REFLECTION\nvec3 finalClearCoatRadiance=environmentClearCoatRadiance.rgb;\nfinalClearCoatRadiance*=clearCoatEnvironmentReflectance;\n\nvec3 finalClearCoatRadianceScaled=finalClearCoatRadiance*vLightingIntensity.z;\n#endif\n#ifdef REFRACTION\nfinalRefraction*=(conservationFactor*conservationFactor);\n#ifdef CLEARCOAT_TINT\nfinalRefraction*=absorption;\n#endif\n#endif\n#endif\n\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n\n\n\n\n\n#ifdef REFLECTION\nvec3 finalSheenRadiance=environmentSheenRadiance.rgb;\nfinalSheenRadiance*=sheenEnvironmentReflectance;\n\nvec3 finalSheenRadianceScaled=finalSheenRadiance*vLightingIntensity.z;\n#endif\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\n#endif\n#endif\n#endif\n\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nvAmbientColor*ambientOcclusionColor +\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef CLEARCOAT\n\n\nfinalClearCoatScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#ifdef CLEARCOAT\n\n\nfinalClearCoatRadianceScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenRadianceScaled +\n#endif\n#endif\n#ifdef 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\nfinalColor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n#include<pbrDebug>\n}\n";
  129334. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129335. /** @hidden */
  129336. var pbrPixelShader = { name: name, shader: shader };
  129337. /***/ }),
  129338. /***/ "./Shaders/pbr.vertex.ts":
  129339. /*!*******************************!*\
  129340. !*** ./Shaders/pbr.vertex.ts ***!
  129341. \*******************************/
  129342. /*! exports provided: pbrVertexShader */
  129343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129344. "use strict";
  129345. __webpack_require__.r(__webpack_exports__);
  129346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  129347. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129348. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  129349. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  129350. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129351. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129352. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129353. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  129354. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  129355. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129356. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  129357. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129358. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129359. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  129360. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  129361. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129362. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  129363. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129364. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129365. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  129366. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129367. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  129368. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  129369. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  129370. var name = 'pbrVertexShader';
  129371. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatTintUV;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nvarying vec2 vSheenUV;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nvarying vec2 vAnisotropyUV;\n#endif\n#endif\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(positionUpdated,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#endif\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nif (vClearCoatInfos.x == 0.)\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nif (vClearCoatBumpInfos.x == 0.)\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nif (vClearCoatTintInfos.x == 0.)\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nif (vSheenInfos.x == 0.)\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nif (vAnisotropyInfos.x == 0.)\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n}";
  129372. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129373. /** @hidden */
  129374. var pbrVertexShader = { name: name, shader: shader };
  129375. /***/ }),
  129376. /***/ "./Shaders/postprocess.vertex.ts":
  129377. /*!***************************************!*\
  129378. !*** ./Shaders/postprocess.vertex.ts ***!
  129379. \***************************************/
  129380. /*! exports provided: postprocessVertexShader */
  129381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129382. "use strict";
  129383. __webpack_require__.r(__webpack_exports__);
  129384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  129385. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129386. var name = 'postprocessVertexShader';
  129387. 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}";
  129388. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129389. /** @hidden */
  129390. var postprocessVertexShader = { name: name, shader: shader };
  129391. /***/ }),
  129392. /***/ "./Shaders/procedural.vertex.ts":
  129393. /*!**************************************!*\
  129394. !*** ./Shaders/procedural.vertex.ts ***!
  129395. \**************************************/
  129396. /*! exports provided: proceduralVertexShader */
  129397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129398. "use strict";
  129399. __webpack_require__.r(__webpack_exports__);
  129400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  129401. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129402. var name = 'proceduralVertexShader';
  129403. 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}";
  129404. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129405. /** @hidden */
  129406. var proceduralVertexShader = { name: name, shader: shader };
  129407. /***/ }),
  129408. /***/ "./Shaders/refraction.fragment.ts":
  129409. /*!****************************************!*\
  129410. !*** ./Shaders/refraction.fragment.ts ***!
  129411. \****************************************/
  129412. /*! exports provided: refractionPixelShader */
  129413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129414. "use strict";
  129415. __webpack_require__.r(__webpack_exports__);
  129416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  129417. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129418. var name = 'refractionPixelShader';
  129419. 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}";
  129420. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129421. /** @hidden */
  129422. var refractionPixelShader = { name: name, shader: shader };
  129423. /***/ }),
  129424. /***/ "./Shaders/rgbdDecode.fragment.ts":
  129425. /*!****************************************!*\
  129426. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  129427. \****************************************/
  129428. /*! exports provided: rgbdDecodePixelShader */
  129429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129430. "use strict";
  129431. __webpack_require__.r(__webpack_exports__);
  129432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  129433. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129434. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129435. var name = 'rgbdDecodePixelShader';
  129436. 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}";
  129437. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129438. /** @hidden */
  129439. var rgbdDecodePixelShader = { name: name, shader: shader };
  129440. /***/ }),
  129441. /***/ "./Shaders/rgbdEncode.fragment.ts":
  129442. /*!****************************************!*\
  129443. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  129444. \****************************************/
  129445. /*! exports provided: rgbdEncodePixelShader */
  129446. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129447. "use strict";
  129448. __webpack_require__.r(__webpack_exports__);
  129449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  129450. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129451. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129452. var name = 'rgbdEncodePixelShader';
  129453. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  129454. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129455. /** @hidden */
  129456. var rgbdEncodePixelShader = { name: name, shader: shader };
  129457. /***/ }),
  129458. /***/ "./Shaders/shadowMap.fragment.ts":
  129459. /*!***************************************!*\
  129460. !*** ./Shaders/shadowMap.fragment.ts ***!
  129461. \***************************************/
  129462. /*! exports provided: shadowMapPixelShader */
  129463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129464. "use strict";
  129465. __webpack_require__.r(__webpack_exports__);
  129466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  129467. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129468. var name = 'shadowMapPixelShader';
  129469. 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}";
  129470. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129471. /** @hidden */
  129472. var shadowMapPixelShader = { name: name, shader: shader };
  129473. /***/ }),
  129474. /***/ "./Shaders/shadowMap.vertex.ts":
  129475. /*!*************************************!*\
  129476. !*** ./Shaders/shadowMap.vertex.ts ***!
  129477. \*************************************/
  129478. /*! exports provided: shadowMapVertexShader */
  129479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129480. "use strict";
  129481. __webpack_require__.r(__webpack_exports__);
  129482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  129483. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129484. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129485. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  129486. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  129487. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129488. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129489. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  129490. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129491. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129492. var name = 'shadowMapVertexShader';
  129493. 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}";
  129494. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129495. /** @hidden */
  129496. var shadowMapVertexShader = { name: name, shader: shader };
  129497. /***/ }),
  129498. /***/ "./Shaders/sharpen.fragment.ts":
  129499. /*!*************************************!*\
  129500. !*** ./Shaders/sharpen.fragment.ts ***!
  129501. \*************************************/
  129502. /*! exports provided: sharpenPixelShader */
  129503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129504. "use strict";
  129505. __webpack_require__.r(__webpack_exports__);
  129506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  129507. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129508. var name = 'sharpenPixelShader';
  129509. 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}";
  129510. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129511. /** @hidden */
  129512. var sharpenPixelShader = { name: name, shader: shader };
  129513. /***/ }),
  129514. /***/ "./Shaders/sprites.fragment.ts":
  129515. /*!*************************************!*\
  129516. !*** ./Shaders/sprites.fragment.ts ***!
  129517. \*************************************/
  129518. /*! exports provided: spritesPixelShader */
  129519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129520. "use strict";
  129521. __webpack_require__.r(__webpack_exports__);
  129522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  129523. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129524. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  129525. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  129526. var name = 'spritesPixelShader';
  129527. 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}";
  129528. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129529. /** @hidden */
  129530. var spritesPixelShader = { name: name, shader: shader };
  129531. /***/ }),
  129532. /***/ "./Shaders/sprites.vertex.ts":
  129533. /*!***********************************!*\
  129534. !*** ./Shaders/sprites.vertex.ts ***!
  129535. \***********************************/
  129536. /*! exports provided: spritesVertexShader */
  129537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129538. "use strict";
  129539. __webpack_require__.r(__webpack_exports__);
  129540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  129541. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129542. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  129543. var name = 'spritesVertexShader';
  129544. 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}";
  129545. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129546. /** @hidden */
  129547. var spritesVertexShader = { name: name, shader: shader };
  129548. /***/ }),
  129549. /***/ "./Shaders/ssao.fragment.ts":
  129550. /*!**********************************!*\
  129551. !*** ./Shaders/ssao.fragment.ts ***!
  129552. \**********************************/
  129553. /*! exports provided: ssaoPixelShader */
  129554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129555. "use strict";
  129556. __webpack_require__.r(__webpack_exports__);
  129557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  129558. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129559. var name = 'ssaoPixelShader';
  129560. 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";
  129561. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129562. /** @hidden */
  129563. var ssaoPixelShader = { name: name, shader: shader };
  129564. /***/ }),
  129565. /***/ "./Shaders/ssao2.fragment.ts":
  129566. /*!***********************************!*\
  129567. !*** ./Shaders/ssao2.fragment.ts ***!
  129568. \***********************************/
  129569. /*! exports provided: ssao2PixelShader */
  129570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129571. "use strict";
  129572. __webpack_require__.r(__webpack_exports__);
  129573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  129574. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129575. var name = 'ssao2PixelShader';
  129576. 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";
  129577. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129578. /** @hidden */
  129579. var ssao2PixelShader = { name: name, shader: shader };
  129580. /***/ }),
  129581. /***/ "./Shaders/ssaoCombine.fragment.ts":
  129582. /*!*****************************************!*\
  129583. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  129584. \*****************************************/
  129585. /*! exports provided: ssaoCombinePixelShader */
  129586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129587. "use strict";
  129588. __webpack_require__.r(__webpack_exports__);
  129589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  129590. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129591. var name = 'ssaoCombinePixelShader';
  129592. 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";
  129593. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129594. /** @hidden */
  129595. var ssaoCombinePixelShader = { name: name, shader: shader };
  129596. /***/ }),
  129597. /***/ "./Shaders/standard.fragment.ts":
  129598. /*!**************************************!*\
  129599. !*** ./Shaders/standard.fragment.ts ***!
  129600. \**************************************/
  129601. /*! exports provided: standardPixelShader */
  129602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129603. "use strict";
  129604. __webpack_require__.r(__webpack_exports__);
  129605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  129606. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129607. var name = 'standardPixelShader';
  129608. 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";
  129609. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129610. /** @hidden */
  129611. var standardPixelShader = { name: name, shader: shader };
  129612. /***/ }),
  129613. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  129614. /*!***************************************************!*\
  129615. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  129616. \***************************************************/
  129617. /*! exports provided: stereoscopicInterlacePixelShader */
  129618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129619. "use strict";
  129620. __webpack_require__.r(__webpack_exports__);
  129621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  129622. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129623. var name = 'stereoscopicInterlacePixelShader';
  129624. 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}";
  129625. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129626. /** @hidden */
  129627. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  129628. /***/ }),
  129629. /***/ "./Shaders/tonemap.fragment.ts":
  129630. /*!*************************************!*\
  129631. !*** ./Shaders/tonemap.fragment.ts ***!
  129632. \*************************************/
  129633. /*! exports provided: tonemapPixelShader */
  129634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129635. "use strict";
  129636. __webpack_require__.r(__webpack_exports__);
  129637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  129638. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129639. var name = 'tonemapPixelShader';
  129640. 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}";
  129641. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129642. /** @hidden */
  129643. var tonemapPixelShader = { name: name, shader: shader };
  129644. /***/ }),
  129645. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  129646. /*!*******************************************************!*\
  129647. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  129648. \*******************************************************/
  129649. /*! exports provided: volumetricLightScatteringPixelShader */
  129650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129651. "use strict";
  129652. __webpack_require__.r(__webpack_exports__);
  129653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  129654. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129655. var name = 'volumetricLightScatteringPixelShader';
  129656. 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";
  129657. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129658. /** @hidden */
  129659. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  129660. /***/ }),
  129661. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  129662. /*!***********************************************************!*\
  129663. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  129664. \***********************************************************/
  129665. /*! exports provided: volumetricLightScatteringPassPixelShader */
  129666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129667. "use strict";
  129668. __webpack_require__.r(__webpack_exports__);
  129669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  129670. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129671. var name = 'volumetricLightScatteringPassPixelShader';
  129672. 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";
  129673. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129674. /** @hidden */
  129675. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  129676. /***/ }),
  129677. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  129678. /*!****************************************************!*\
  129679. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  129680. \****************************************************/
  129681. /*! exports provided: vrDistortionCorrectionPixelShader */
  129682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129683. "use strict";
  129684. __webpack_require__.r(__webpack_exports__);
  129685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  129686. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129687. var name = 'vrDistortionCorrectionPixelShader';
  129688. 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}";
  129689. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129690. /** @hidden */
  129691. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  129692. /***/ }),
  129693. /***/ "./Sprites/index.ts":
  129694. /*!**************************!*\
  129695. !*** ./Sprites/index.ts ***!
  129696. \**************************/
  129697. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  129698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129699. "use strict";
  129700. __webpack_require__.r(__webpack_exports__);
  129701. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  129702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  129703. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  129704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  129705. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  129706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  129707. /***/ }),
  129708. /***/ "./Sprites/sprite.ts":
  129709. /*!***************************!*\
  129710. !*** ./Sprites/sprite.ts ***!
  129711. \***************************/
  129712. /*! exports provided: Sprite */
  129713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129714. "use strict";
  129715. __webpack_require__.r(__webpack_exports__);
  129716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  129717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  129718. /**
  129719. * Class used to represent a sprite
  129720. * @see http://doc.babylonjs.com/babylon101/sprites
  129721. */
  129722. var Sprite = /** @class */ (function () {
  129723. /**
  129724. * Creates a new Sprite
  129725. * @param name defines the name
  129726. * @param manager defines the manager
  129727. */
  129728. function Sprite(
  129729. /** defines the name */
  129730. name, manager) {
  129731. this.name = name;
  129732. /** Gets or sets the main color */
  129733. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  129734. /** Gets or sets the width */
  129735. this.width = 1.0;
  129736. /** Gets or sets the height */
  129737. this.height = 1.0;
  129738. /** Gets or sets rotation angle */
  129739. this.angle = 0;
  129740. /** Gets or sets the cell index in the sprite sheet */
  129741. this.cellIndex = 0;
  129742. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  129743. this.invertU = 0;
  129744. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  129745. this.invertV = 0;
  129746. /** Gets the list of attached animations */
  129747. this.animations = new Array();
  129748. /** Gets or sets a boolean indicating if the sprite can be picked */
  129749. this.isPickable = false;
  129750. this._animationStarted = false;
  129751. this._loopAnimation = false;
  129752. this._fromIndex = 0;
  129753. this._toIndex = 0;
  129754. this._delay = 0;
  129755. this._direction = 1;
  129756. this._time = 0;
  129757. /**
  129758. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  129759. */
  129760. this.isVisible = true;
  129761. this._manager = manager;
  129762. this._manager.sprites.push(this);
  129763. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  129764. }
  129765. Object.defineProperty(Sprite.prototype, "size", {
  129766. /**
  129767. * Gets or sets the sprite size
  129768. */
  129769. get: function () {
  129770. return this.width;
  129771. },
  129772. set: function (value) {
  129773. this.width = value;
  129774. this.height = value;
  129775. },
  129776. enumerable: true,
  129777. configurable: true
  129778. });
  129779. /**
  129780. * Starts an animation
  129781. * @param from defines the initial key
  129782. * @param to defines the end key
  129783. * @param loop defines if the animation must loop
  129784. * @param delay defines the start delay (in ms)
  129785. * @param onAnimationEnd defines a callback to call when animation ends
  129786. */
  129787. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  129788. this._fromIndex = from;
  129789. this._toIndex = to;
  129790. this._loopAnimation = loop;
  129791. this._delay = delay;
  129792. this._animationStarted = true;
  129793. this._direction = from < to ? 1 : -1;
  129794. this.cellIndex = from;
  129795. this._time = 0;
  129796. this._onAnimationEnd = onAnimationEnd;
  129797. };
  129798. /** Stops current animation (if any) */
  129799. Sprite.prototype.stopAnimation = function () {
  129800. this._animationStarted = false;
  129801. };
  129802. /** @hidden */
  129803. Sprite.prototype._animate = function (deltaTime) {
  129804. if (!this._animationStarted) {
  129805. return;
  129806. }
  129807. this._time += deltaTime;
  129808. if (this._time > this._delay) {
  129809. this._time = this._time % this._delay;
  129810. this.cellIndex += this._direction;
  129811. if (this.cellIndex > this._toIndex) {
  129812. if (this._loopAnimation) {
  129813. this.cellIndex = this._fromIndex;
  129814. }
  129815. else {
  129816. this.cellIndex = this._toIndex;
  129817. this._animationStarted = false;
  129818. if (this._onAnimationEnd) {
  129819. this._onAnimationEnd();
  129820. }
  129821. if (this.disposeWhenFinishedAnimating) {
  129822. this.dispose();
  129823. }
  129824. }
  129825. }
  129826. }
  129827. };
  129828. /** Release associated resources */
  129829. Sprite.prototype.dispose = function () {
  129830. for (var i = 0; i < this._manager.sprites.length; i++) {
  129831. if (this._manager.sprites[i] == this) {
  129832. this._manager.sprites.splice(i, 1);
  129833. }
  129834. }
  129835. };
  129836. return Sprite;
  129837. }());
  129838. /***/ }),
  129839. /***/ "./Sprites/spriteManager.ts":
  129840. /*!**********************************!*\
  129841. !*** ./Sprites/spriteManager.ts ***!
  129842. \**********************************/
  129843. /*! exports provided: SpriteManager */
  129844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129845. "use strict";
  129846. __webpack_require__.r(__webpack_exports__);
  129847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  129848. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  129849. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  129850. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  129851. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  129852. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  129853. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  129854. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  129855. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  129856. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  129857. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  129858. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  129859. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  129860. /**
  129861. * Class used to manage multiple sprites on the same spritesheet
  129862. * @see http://doc.babylonjs.com/babylon101/sprites
  129863. */
  129864. var SpriteManager = /** @class */ (function () {
  129865. /**
  129866. * Creates a new sprite manager
  129867. * @param name defines the manager's name
  129868. * @param imgUrl defines the sprite sheet url
  129869. * @param capacity defines the maximum allowed number of sprites
  129870. * @param cellSize defines the size of a sprite cell
  129871. * @param scene defines the hosting scene
  129872. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129873. * @param samplingMode defines the smapling mode to use with spritesheet
  129874. */
  129875. function SpriteManager(
  129876. /** defines the manager's name */
  129877. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  129878. if (epsilon === void 0) { epsilon = 0.01; }
  129879. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  129880. this.name = name;
  129881. /** Gets the list of sprites */
  129882. this.sprites = new Array();
  129883. /** Gets or sets the rendering group id (0 by default) */
  129884. this.renderingGroupId = 0;
  129885. /** Gets or sets camera layer mask */
  129886. this.layerMask = 0x0FFFFFFF;
  129887. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  129888. this.fogEnabled = true;
  129889. /** Gets or sets a boolean indicating if the sprites are pickable */
  129890. this.isPickable = false;
  129891. /**
  129892. * An event triggered when the manager is disposed.
  129893. */
  129894. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  129895. this._vertexBuffers = {};
  129896. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  129897. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  129898. }
  129899. this._capacity = capacity;
  129900. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  129901. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  129902. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  129903. if (cellSize.width && cellSize.height) {
  129904. this.cellWidth = cellSize.width;
  129905. this.cellHeight = cellSize.height;
  129906. }
  129907. else if (cellSize !== undefined) {
  129908. this.cellWidth = cellSize;
  129909. this.cellHeight = cellSize;
  129910. }
  129911. else {
  129912. return;
  129913. }
  129914. this._epsilon = epsilon;
  129915. this._scene = scene;
  129916. this._scene.spriteManagers.push(this);
  129917. var indices = [];
  129918. var index = 0;
  129919. for (var count = 0; count < capacity; count++) {
  129920. indices.push(index);
  129921. indices.push(index + 1);
  129922. indices.push(index + 2);
  129923. indices.push(index);
  129924. indices.push(index + 2);
  129925. indices.push(index + 3);
  129926. index += 4;
  129927. }
  129928. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  129929. // VBO
  129930. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  129931. this._vertexData = new Float32Array(capacity * 16 * 4);
  129932. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  129933. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  129934. var options = this._buffer.createVertexBuffer("options", 4, 4);
  129935. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  129936. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  129937. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  129938. this._vertexBuffers["options"] = options;
  129939. this._vertexBuffers["cellInfo"] = cellInfo;
  129940. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  129941. // Effects
  129942. 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"], "");
  129943. 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");
  129944. }
  129945. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  129946. /**
  129947. * Callback called when the manager is disposed
  129948. */
  129949. set: function (callback) {
  129950. if (this._onDisposeObserver) {
  129951. this.onDisposeObservable.remove(this._onDisposeObserver);
  129952. }
  129953. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  129954. },
  129955. enumerable: true,
  129956. configurable: true
  129957. });
  129958. Object.defineProperty(SpriteManager.prototype, "texture", {
  129959. /**
  129960. * Gets or sets the spritesheet texture
  129961. */
  129962. get: function () {
  129963. return this._spriteTexture;
  129964. },
  129965. set: function (value) {
  129966. this._spriteTexture = value;
  129967. },
  129968. enumerable: true,
  129969. configurable: true
  129970. });
  129971. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  129972. var arrayOffset = index * 16;
  129973. if (offsetX === 0) {
  129974. offsetX = this._epsilon;
  129975. }
  129976. else if (offsetX === 1) {
  129977. offsetX = 1 - this._epsilon;
  129978. }
  129979. if (offsetY === 0) {
  129980. offsetY = this._epsilon;
  129981. }
  129982. else if (offsetY === 1) {
  129983. offsetY = 1 - this._epsilon;
  129984. }
  129985. this._vertexData[arrayOffset] = sprite.position.x;
  129986. this._vertexData[arrayOffset + 1] = sprite.position.y;
  129987. this._vertexData[arrayOffset + 2] = sprite.position.z;
  129988. this._vertexData[arrayOffset + 3] = sprite.angle;
  129989. this._vertexData[arrayOffset + 4] = sprite.width;
  129990. this._vertexData[arrayOffset + 5] = sprite.height;
  129991. this._vertexData[arrayOffset + 6] = offsetX;
  129992. this._vertexData[arrayOffset + 7] = offsetY;
  129993. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  129994. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  129995. var offset = (sprite.cellIndex / rowSize) >> 0;
  129996. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  129997. this._vertexData[arrayOffset + 11] = offset;
  129998. // Color
  129999. this._vertexData[arrayOffset + 12] = sprite.color.r;
  130000. this._vertexData[arrayOffset + 13] = sprite.color.g;
  130001. this._vertexData[arrayOffset + 14] = sprite.color.b;
  130002. this._vertexData[arrayOffset + 15] = sprite.color.a;
  130003. };
  130004. /**
  130005. * Intersects the sprites with a ray
  130006. * @param ray defines the ray to intersect with
  130007. * @param camera defines the current active camera
  130008. * @param predicate defines a predicate used to select candidate sprites
  130009. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  130010. * @returns null if no hit or a PickingInfo
  130011. */
  130012. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  130013. var count = Math.min(this._capacity, this.sprites.length);
  130014. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  130015. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  130016. var distance = Number.MAX_VALUE;
  130017. var currentSprite = null;
  130018. var pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  130019. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  130020. var cameraView = camera.getViewMatrix();
  130021. for (var index = 0; index < count; index++) {
  130022. var sprite = this.sprites[index];
  130023. if (!sprite) {
  130024. continue;
  130025. }
  130026. if (predicate) {
  130027. if (!predicate(sprite)) {
  130028. continue;
  130029. }
  130030. }
  130031. else if (!sprite.isPickable) {
  130032. continue;
  130033. }
  130034. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  130035. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  130036. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  130037. if (ray.intersectsBoxMinMax(min, max)) {
  130038. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  130039. if (distance > currentDistance) {
  130040. distance = currentDistance;
  130041. currentSprite = sprite;
  130042. if (fastCheck) {
  130043. break;
  130044. }
  130045. }
  130046. }
  130047. }
  130048. if (currentSprite) {
  130049. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  130050. cameraView.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  130051. result.hit = true;
  130052. result.pickedSprite = currentSprite;
  130053. result.distance = distance;
  130054. // Get picked point
  130055. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  130056. direction.copyFrom(ray.direction);
  130057. direction.normalize();
  130058. direction.scaleInPlace(distance);
  130059. ray.origin.addToRef(direction, pickedPoint);
  130060. result.pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(pickedPoint, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  130061. return result;
  130062. }
  130063. return null;
  130064. };
  130065. /**
  130066. * Render all child sprites
  130067. */
  130068. SpriteManager.prototype.render = function () {
  130069. // Check
  130070. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  130071. || !this._spriteTexture.isReady() || !this.sprites.length) {
  130072. return;
  130073. }
  130074. var engine = this._scene.getEngine();
  130075. var baseSize = this._spriteTexture.getBaseSize();
  130076. // Sprites
  130077. var deltaTime = engine.getDeltaTime();
  130078. var max = Math.min(this._capacity, this.sprites.length);
  130079. var rowSize = baseSize.width / this.cellWidth;
  130080. var offset = 0;
  130081. var noSprite = true;
  130082. for (var index = 0; index < max; index++) {
  130083. var sprite = this.sprites[index];
  130084. if (!sprite || !sprite.isVisible) {
  130085. continue;
  130086. }
  130087. noSprite = false;
  130088. sprite._animate(deltaTime);
  130089. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  130090. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  130091. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  130092. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  130093. }
  130094. if (noSprite) {
  130095. return;
  130096. }
  130097. this._buffer.update(this._vertexData);
  130098. // Render
  130099. var effect = this._effectBase;
  130100. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  130101. effect = this._effectFog;
  130102. }
  130103. engine.enableEffect(effect);
  130104. var viewMatrix = this._scene.getViewMatrix();
  130105. effect.setTexture("diffuseSampler", this._spriteTexture);
  130106. effect.setMatrix("view", viewMatrix);
  130107. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  130108. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  130109. // Fog
  130110. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  130111. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  130112. effect.setColor3("vFogColor", this._scene.fogColor);
  130113. }
  130114. // VBOs
  130115. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  130116. // Draw order
  130117. engine.setDepthFunctionToLessOrEqual();
  130118. effect.setBool("alphaTest", true);
  130119. engine.setColorWrite(false);
  130120. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  130121. engine.setColorWrite(true);
  130122. effect.setBool("alphaTest", false);
  130123. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  130124. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  130125. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  130126. };
  130127. /**
  130128. * Release associated resources
  130129. */
  130130. SpriteManager.prototype.dispose = function () {
  130131. if (this._buffer) {
  130132. this._buffer.dispose();
  130133. this._buffer = null;
  130134. }
  130135. if (this._indexBuffer) {
  130136. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  130137. this._indexBuffer = null;
  130138. }
  130139. if (this._spriteTexture) {
  130140. this._spriteTexture.dispose();
  130141. this._spriteTexture = null;
  130142. }
  130143. // Remove from scene
  130144. var index = this._scene.spriteManagers.indexOf(this);
  130145. this._scene.spriteManagers.splice(index, 1);
  130146. // Callback
  130147. this.onDisposeObservable.notifyObservers(this);
  130148. this.onDisposeObservable.clear();
  130149. };
  130150. return SpriteManager;
  130151. }());
  130152. /***/ }),
  130153. /***/ "./Sprites/spriteSceneComponent.ts":
  130154. /*!*****************************************!*\
  130155. !*** ./Sprites/spriteSceneComponent.ts ***!
  130156. \*****************************************/
  130157. /*! exports provided: SpriteSceneComponent */
  130158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130159. "use strict";
  130160. __webpack_require__.r(__webpack_exports__);
  130161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  130162. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  130163. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  130164. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  130165. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  130166. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  130167. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  130168. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  130169. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  130170. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  130171. return null;
  130172. }
  130173. var pickingInfo = null;
  130174. if (!camera) {
  130175. if (!this.activeCamera) {
  130176. return null;
  130177. }
  130178. camera = this.activeCamera;
  130179. }
  130180. if (this.spriteManagers.length > 0) {
  130181. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  130182. var spriteManager = this.spriteManagers[spriteIndex];
  130183. if (!spriteManager.isPickable) {
  130184. continue;
  130185. }
  130186. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  130187. if (!result || !result.hit) {
  130188. continue;
  130189. }
  130190. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  130191. continue;
  130192. }
  130193. pickingInfo = result;
  130194. if (fastCheck) {
  130195. break;
  130196. }
  130197. }
  130198. }
  130199. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  130200. };
  130201. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  130202. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  130203. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  130204. };
  130205. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  130206. if (!this._tempSpritePickingRay) {
  130207. return null;
  130208. }
  130209. if (!camera) {
  130210. if (!this.activeCamera) {
  130211. return null;
  130212. }
  130213. camera = this.activeCamera;
  130214. }
  130215. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  130216. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  130217. };
  130218. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  130219. if (this._pointerOverSprite === sprite) {
  130220. return;
  130221. }
  130222. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  130223. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  130224. }
  130225. this._pointerOverSprite = sprite;
  130226. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  130227. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  130228. }
  130229. };
  130230. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  130231. return this._pointerOverSprite;
  130232. };
  130233. /**
  130234. * Defines the sprite scene component responsible to manage sprites
  130235. * in a given scene.
  130236. */
  130237. var SpriteSceneComponent = /** @class */ (function () {
  130238. /**
  130239. * Creates a new instance of the component for the given scene
  130240. * @param scene Defines the scene to register the component in
  130241. */
  130242. function SpriteSceneComponent(scene) {
  130243. /**
  130244. * The component name helpfull to identify the component in the list of scene components.
  130245. */
  130246. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  130247. this.scene = scene;
  130248. this.scene.spriteManagers = new Array();
  130249. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  130250. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  130251. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  130252. this._spritePredicate = function (sprite) {
  130253. if (!sprite.actionManager) {
  130254. return false;
  130255. }
  130256. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  130257. };
  130258. }
  130259. /**
  130260. * Registers the component in a given scene
  130261. */
  130262. SpriteSceneComponent.prototype.register = function () {
  130263. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  130264. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  130265. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  130266. };
  130267. /**
  130268. * Rebuilds the elements related to this component in case of
  130269. * context lost for instance.
  130270. */
  130271. SpriteSceneComponent.prototype.rebuild = function () {
  130272. /** Nothing to do for sprites */
  130273. };
  130274. /**
  130275. * Disposes the component and the associated ressources.
  130276. */
  130277. SpriteSceneComponent.prototype.dispose = function () {
  130278. this.scene.onBeforeSpritesRenderingObservable.clear();
  130279. this.scene.onAfterSpritesRenderingObservable.clear();
  130280. var spriteManagers = this.scene.spriteManagers;
  130281. while (spriteManagers.length) {
  130282. spriteManagers[0].dispose();
  130283. }
  130284. };
  130285. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  130286. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  130287. if (result) {
  130288. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  130289. }
  130290. return result;
  130291. };
  130292. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  130293. var scene = this.scene;
  130294. if (isMeshPicked) {
  130295. scene.setPointerOverSprite(null);
  130296. }
  130297. else {
  130298. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  130299. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  130300. scene.setPointerOverSprite(pickResult.pickedSprite);
  130301. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  130302. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  130303. }
  130304. else {
  130305. canvas.style.cursor = scene.hoverCursor;
  130306. }
  130307. }
  130308. else {
  130309. scene.setPointerOverSprite(null);
  130310. }
  130311. }
  130312. return pickResult;
  130313. };
  130314. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  130315. var scene = this.scene;
  130316. scene._pickedDownSprite = null;
  130317. if (scene.spriteManagers.length > 0) {
  130318. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  130319. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  130320. if (pickResult.pickedSprite.actionManager) {
  130321. scene._pickedDownSprite = pickResult.pickedSprite;
  130322. switch (evt.button) {
  130323. case 0:
  130324. 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));
  130325. break;
  130326. case 1:
  130327. 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));
  130328. break;
  130329. case 2:
  130330. 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));
  130331. break;
  130332. }
  130333. if (pickResult.pickedSprite.actionManager) {
  130334. 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));
  130335. }
  130336. }
  130337. }
  130338. }
  130339. return pickResult;
  130340. };
  130341. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  130342. var scene = this.scene;
  130343. if (scene.spriteManagers.length > 0) {
  130344. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  130345. if (spritePickResult) {
  130346. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  130347. if (spritePickResult.pickedSprite.actionManager) {
  130348. 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));
  130349. if (spritePickResult.pickedSprite.actionManager) {
  130350. if (!this.scene._isPointerSwiping()) {
  130351. 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));
  130352. }
  130353. }
  130354. }
  130355. }
  130356. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  130357. 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));
  130358. }
  130359. }
  130360. }
  130361. return pickResult;
  130362. };
  130363. return SpriteSceneComponent;
  130364. }());
  130365. /***/ }),
  130366. /***/ "./States/alphaCullingState.ts":
  130367. /*!*************************************!*\
  130368. !*** ./States/alphaCullingState.ts ***!
  130369. \*************************************/
  130370. /*! exports provided: _AlphaState */
  130371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130372. "use strict";
  130373. __webpack_require__.r(__webpack_exports__);
  130374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  130375. /**
  130376. * @hidden
  130377. **/
  130378. var _AlphaState = /** @class */ (function () {
  130379. /**
  130380. * Initializes the state.
  130381. */
  130382. function _AlphaState() {
  130383. this._isAlphaBlendDirty = false;
  130384. this._isBlendFunctionParametersDirty = false;
  130385. this._isBlendEquationParametersDirty = false;
  130386. this._isBlendConstantsDirty = false;
  130387. this._alphaBlend = false;
  130388. this._blendFunctionParameters = new Array(4);
  130389. this._blendEquationParameters = new Array(2);
  130390. this._blendConstants = new Array(4);
  130391. this.reset();
  130392. }
  130393. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  130394. get: function () {
  130395. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  130396. },
  130397. enumerable: true,
  130398. configurable: true
  130399. });
  130400. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  130401. get: function () {
  130402. return this._alphaBlend;
  130403. },
  130404. set: function (value) {
  130405. if (this._alphaBlend === value) {
  130406. return;
  130407. }
  130408. this._alphaBlend = value;
  130409. this._isAlphaBlendDirty = true;
  130410. },
  130411. enumerable: true,
  130412. configurable: true
  130413. });
  130414. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  130415. if (this._blendConstants[0] === r &&
  130416. this._blendConstants[1] === g &&
  130417. this._blendConstants[2] === b &&
  130418. this._blendConstants[3] === a) {
  130419. return;
  130420. }
  130421. this._blendConstants[0] = r;
  130422. this._blendConstants[1] = g;
  130423. this._blendConstants[2] = b;
  130424. this._blendConstants[3] = a;
  130425. this._isBlendConstantsDirty = true;
  130426. };
  130427. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  130428. if (this._blendFunctionParameters[0] === value0 &&
  130429. this._blendFunctionParameters[1] === value1 &&
  130430. this._blendFunctionParameters[2] === value2 &&
  130431. this._blendFunctionParameters[3] === value3) {
  130432. return;
  130433. }
  130434. this._blendFunctionParameters[0] = value0;
  130435. this._blendFunctionParameters[1] = value1;
  130436. this._blendFunctionParameters[2] = value2;
  130437. this._blendFunctionParameters[3] = value3;
  130438. this._isBlendFunctionParametersDirty = true;
  130439. };
  130440. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  130441. if (this._blendEquationParameters[0] === rgb &&
  130442. this._blendEquationParameters[1] === alpha) {
  130443. return;
  130444. }
  130445. this._blendEquationParameters[0] = rgb;
  130446. this._blendEquationParameters[1] = alpha;
  130447. this._isBlendEquationParametersDirty = true;
  130448. };
  130449. _AlphaState.prototype.reset = function () {
  130450. this._alphaBlend = false;
  130451. this._blendFunctionParameters[0] = null;
  130452. this._blendFunctionParameters[1] = null;
  130453. this._blendFunctionParameters[2] = null;
  130454. this._blendFunctionParameters[3] = null;
  130455. this._blendEquationParameters[0] = null;
  130456. this._blendEquationParameters[1] = null;
  130457. this._blendConstants[0] = null;
  130458. this._blendConstants[1] = null;
  130459. this._blendConstants[2] = null;
  130460. this._blendConstants[3] = null;
  130461. this._isAlphaBlendDirty = true;
  130462. this._isBlendFunctionParametersDirty = false;
  130463. this._isBlendEquationParametersDirty = false;
  130464. this._isBlendConstantsDirty = false;
  130465. };
  130466. _AlphaState.prototype.apply = function (gl) {
  130467. if (!this.isDirty) {
  130468. return;
  130469. }
  130470. // Alpha blend
  130471. if (this._isAlphaBlendDirty) {
  130472. if (this._alphaBlend) {
  130473. gl.enable(gl.BLEND);
  130474. }
  130475. else {
  130476. gl.disable(gl.BLEND);
  130477. }
  130478. this._isAlphaBlendDirty = false;
  130479. }
  130480. // Alpha function
  130481. if (this._isBlendFunctionParametersDirty) {
  130482. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  130483. this._isBlendFunctionParametersDirty = false;
  130484. }
  130485. // Alpha equation
  130486. if (this._isBlendEquationParametersDirty) {
  130487. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  130488. this._isBlendEquationParametersDirty = false;
  130489. }
  130490. // Constants
  130491. if (this._isBlendConstantsDirty) {
  130492. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  130493. this._isBlendConstantsDirty = false;
  130494. }
  130495. };
  130496. return _AlphaState;
  130497. }());
  130498. /***/ }),
  130499. /***/ "./States/depthCullingState.ts":
  130500. /*!*************************************!*\
  130501. !*** ./States/depthCullingState.ts ***!
  130502. \*************************************/
  130503. /*! exports provided: _DepthCullingState */
  130504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130505. "use strict";
  130506. __webpack_require__.r(__webpack_exports__);
  130507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  130508. /**
  130509. * @hidden
  130510. **/
  130511. var _DepthCullingState = /** @class */ (function () {
  130512. /**
  130513. * Initializes the state.
  130514. */
  130515. function _DepthCullingState() {
  130516. this._isDepthTestDirty = false;
  130517. this._isDepthMaskDirty = false;
  130518. this._isDepthFuncDirty = false;
  130519. this._isCullFaceDirty = false;
  130520. this._isCullDirty = false;
  130521. this._isZOffsetDirty = false;
  130522. this._isFrontFaceDirty = false;
  130523. this.reset();
  130524. }
  130525. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  130526. get: function () {
  130527. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  130528. },
  130529. enumerable: true,
  130530. configurable: true
  130531. });
  130532. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  130533. get: function () {
  130534. return this._zOffset;
  130535. },
  130536. set: function (value) {
  130537. if (this._zOffset === value) {
  130538. return;
  130539. }
  130540. this._zOffset = value;
  130541. this._isZOffsetDirty = true;
  130542. },
  130543. enumerable: true,
  130544. configurable: true
  130545. });
  130546. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  130547. get: function () {
  130548. return this._cullFace;
  130549. },
  130550. set: function (value) {
  130551. if (this._cullFace === value) {
  130552. return;
  130553. }
  130554. this._cullFace = value;
  130555. this._isCullFaceDirty = true;
  130556. },
  130557. enumerable: true,
  130558. configurable: true
  130559. });
  130560. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  130561. get: function () {
  130562. return this._cull;
  130563. },
  130564. set: function (value) {
  130565. if (this._cull === value) {
  130566. return;
  130567. }
  130568. this._cull = value;
  130569. this._isCullDirty = true;
  130570. },
  130571. enumerable: true,
  130572. configurable: true
  130573. });
  130574. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  130575. get: function () {
  130576. return this._depthFunc;
  130577. },
  130578. set: function (value) {
  130579. if (this._depthFunc === value) {
  130580. return;
  130581. }
  130582. this._depthFunc = value;
  130583. this._isDepthFuncDirty = true;
  130584. },
  130585. enumerable: true,
  130586. configurable: true
  130587. });
  130588. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  130589. get: function () {
  130590. return this._depthMask;
  130591. },
  130592. set: function (value) {
  130593. if (this._depthMask === value) {
  130594. return;
  130595. }
  130596. this._depthMask = value;
  130597. this._isDepthMaskDirty = true;
  130598. },
  130599. enumerable: true,
  130600. configurable: true
  130601. });
  130602. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  130603. get: function () {
  130604. return this._depthTest;
  130605. },
  130606. set: function (value) {
  130607. if (this._depthTest === value) {
  130608. return;
  130609. }
  130610. this._depthTest = value;
  130611. this._isDepthTestDirty = true;
  130612. },
  130613. enumerable: true,
  130614. configurable: true
  130615. });
  130616. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  130617. get: function () {
  130618. return this._frontFace;
  130619. },
  130620. set: function (value) {
  130621. if (this._frontFace === value) {
  130622. return;
  130623. }
  130624. this._frontFace = value;
  130625. this._isFrontFaceDirty = true;
  130626. },
  130627. enumerable: true,
  130628. configurable: true
  130629. });
  130630. _DepthCullingState.prototype.reset = function () {
  130631. this._depthMask = true;
  130632. this._depthTest = true;
  130633. this._depthFunc = null;
  130634. this._cullFace = null;
  130635. this._cull = null;
  130636. this._zOffset = 0;
  130637. this._frontFace = null;
  130638. this._isDepthTestDirty = true;
  130639. this._isDepthMaskDirty = true;
  130640. this._isDepthFuncDirty = false;
  130641. this._isCullFaceDirty = false;
  130642. this._isCullDirty = false;
  130643. this._isZOffsetDirty = false;
  130644. this._isFrontFaceDirty = false;
  130645. };
  130646. _DepthCullingState.prototype.apply = function (gl) {
  130647. if (!this.isDirty) {
  130648. return;
  130649. }
  130650. // Cull
  130651. if (this._isCullDirty) {
  130652. if (this.cull) {
  130653. gl.enable(gl.CULL_FACE);
  130654. }
  130655. else {
  130656. gl.disable(gl.CULL_FACE);
  130657. }
  130658. this._isCullDirty = false;
  130659. }
  130660. // Cull face
  130661. if (this._isCullFaceDirty) {
  130662. gl.cullFace(this.cullFace);
  130663. this._isCullFaceDirty = false;
  130664. }
  130665. // Depth mask
  130666. if (this._isDepthMaskDirty) {
  130667. gl.depthMask(this.depthMask);
  130668. this._isDepthMaskDirty = false;
  130669. }
  130670. // Depth test
  130671. if (this._isDepthTestDirty) {
  130672. if (this.depthTest) {
  130673. gl.enable(gl.DEPTH_TEST);
  130674. }
  130675. else {
  130676. gl.disable(gl.DEPTH_TEST);
  130677. }
  130678. this._isDepthTestDirty = false;
  130679. }
  130680. // Depth func
  130681. if (this._isDepthFuncDirty) {
  130682. gl.depthFunc(this.depthFunc);
  130683. this._isDepthFuncDirty = false;
  130684. }
  130685. // zOffset
  130686. if (this._isZOffsetDirty) {
  130687. if (this.zOffset) {
  130688. gl.enable(gl.POLYGON_OFFSET_FILL);
  130689. gl.polygonOffset(this.zOffset, 0);
  130690. }
  130691. else {
  130692. gl.disable(gl.POLYGON_OFFSET_FILL);
  130693. }
  130694. this._isZOffsetDirty = false;
  130695. }
  130696. // Front face
  130697. if (this._isFrontFaceDirty) {
  130698. gl.frontFace(this.frontFace);
  130699. this._isFrontFaceDirty = false;
  130700. }
  130701. };
  130702. return _DepthCullingState;
  130703. }());
  130704. /***/ }),
  130705. /***/ "./States/index.ts":
  130706. /*!*************************!*\
  130707. !*** ./States/index.ts ***!
  130708. \*************************/
  130709. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  130710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130711. "use strict";
  130712. __webpack_require__.r(__webpack_exports__);
  130713. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  130714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  130715. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  130716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  130717. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  130718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  130719. /***/ }),
  130720. /***/ "./States/stencilState.ts":
  130721. /*!********************************!*\
  130722. !*** ./States/stencilState.ts ***!
  130723. \********************************/
  130724. /*! exports provided: _StencilState */
  130725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130726. "use strict";
  130727. __webpack_require__.r(__webpack_exports__);
  130728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  130729. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  130730. /**
  130731. * @hidden
  130732. **/
  130733. var _StencilState = /** @class */ (function () {
  130734. function _StencilState() {
  130735. this._isStencilTestDirty = false;
  130736. this._isStencilMaskDirty = false;
  130737. this._isStencilFuncDirty = false;
  130738. this._isStencilOpDirty = false;
  130739. this.reset();
  130740. }
  130741. Object.defineProperty(_StencilState.prototype, "isDirty", {
  130742. get: function () {
  130743. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  130744. },
  130745. enumerable: true,
  130746. configurable: true
  130747. });
  130748. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  130749. get: function () {
  130750. return this._stencilFunc;
  130751. },
  130752. set: function (value) {
  130753. if (this._stencilFunc === value) {
  130754. return;
  130755. }
  130756. this._stencilFunc = value;
  130757. this._isStencilFuncDirty = true;
  130758. },
  130759. enumerable: true,
  130760. configurable: true
  130761. });
  130762. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  130763. get: function () {
  130764. return this._stencilFuncRef;
  130765. },
  130766. set: function (value) {
  130767. if (this._stencilFuncRef === value) {
  130768. return;
  130769. }
  130770. this._stencilFuncRef = value;
  130771. this._isStencilFuncDirty = true;
  130772. },
  130773. enumerable: true,
  130774. configurable: true
  130775. });
  130776. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  130777. get: function () {
  130778. return this._stencilFuncMask;
  130779. },
  130780. set: function (value) {
  130781. if (this._stencilFuncMask === value) {
  130782. return;
  130783. }
  130784. this._stencilFuncMask = value;
  130785. this._isStencilFuncDirty = true;
  130786. },
  130787. enumerable: true,
  130788. configurable: true
  130789. });
  130790. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  130791. get: function () {
  130792. return this._stencilOpStencilFail;
  130793. },
  130794. set: function (value) {
  130795. if (this._stencilOpStencilFail === value) {
  130796. return;
  130797. }
  130798. this._stencilOpStencilFail = value;
  130799. this._isStencilOpDirty = true;
  130800. },
  130801. enumerable: true,
  130802. configurable: true
  130803. });
  130804. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  130805. get: function () {
  130806. return this._stencilOpDepthFail;
  130807. },
  130808. set: function (value) {
  130809. if (this._stencilOpDepthFail === value) {
  130810. return;
  130811. }
  130812. this._stencilOpDepthFail = value;
  130813. this._isStencilOpDirty = true;
  130814. },
  130815. enumerable: true,
  130816. configurable: true
  130817. });
  130818. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  130819. get: function () {
  130820. return this._stencilOpStencilDepthPass;
  130821. },
  130822. set: function (value) {
  130823. if (this._stencilOpStencilDepthPass === value) {
  130824. return;
  130825. }
  130826. this._stencilOpStencilDepthPass = value;
  130827. this._isStencilOpDirty = true;
  130828. },
  130829. enumerable: true,
  130830. configurable: true
  130831. });
  130832. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  130833. get: function () {
  130834. return this._stencilMask;
  130835. },
  130836. set: function (value) {
  130837. if (this._stencilMask === value) {
  130838. return;
  130839. }
  130840. this._stencilMask = value;
  130841. this._isStencilMaskDirty = true;
  130842. },
  130843. enumerable: true,
  130844. configurable: true
  130845. });
  130846. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  130847. get: function () {
  130848. return this._stencilTest;
  130849. },
  130850. set: function (value) {
  130851. if (this._stencilTest === value) {
  130852. return;
  130853. }
  130854. this._stencilTest = value;
  130855. this._isStencilTestDirty = true;
  130856. },
  130857. enumerable: true,
  130858. configurable: true
  130859. });
  130860. _StencilState.prototype.reset = function () {
  130861. this._stencilTest = false;
  130862. this._stencilMask = 0xFF;
  130863. this._stencilFunc = _StencilState.ALWAYS;
  130864. this._stencilFuncRef = 1;
  130865. this._stencilFuncMask = 0xFF;
  130866. this._stencilOpStencilFail = _StencilState.KEEP;
  130867. this._stencilOpDepthFail = _StencilState.KEEP;
  130868. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  130869. this._isStencilTestDirty = true;
  130870. this._isStencilMaskDirty = true;
  130871. this._isStencilFuncDirty = true;
  130872. this._isStencilOpDirty = true;
  130873. };
  130874. _StencilState.prototype.apply = function (gl) {
  130875. if (!this.isDirty) {
  130876. return;
  130877. }
  130878. // Stencil test
  130879. if (this._isStencilTestDirty) {
  130880. if (this.stencilTest) {
  130881. gl.enable(gl.STENCIL_TEST);
  130882. }
  130883. else {
  130884. gl.disable(gl.STENCIL_TEST);
  130885. }
  130886. this._isStencilTestDirty = false;
  130887. }
  130888. // Stencil mask
  130889. if (this._isStencilMaskDirty) {
  130890. gl.stencilMask(this.stencilMask);
  130891. this._isStencilMaskDirty = false;
  130892. }
  130893. // Stencil func
  130894. if (this._isStencilFuncDirty) {
  130895. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  130896. this._isStencilFuncDirty = false;
  130897. }
  130898. // Stencil op
  130899. if (this._isStencilOpDirty) {
  130900. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  130901. this._isStencilOpDirty = false;
  130902. }
  130903. };
  130904. /** 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 */
  130905. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  130906. /** Passed to stencilOperation to specify that stencil value must be kept */
  130907. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  130908. /** Passed to stencilOperation to specify that stencil value must be replaced */
  130909. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  130910. return _StencilState;
  130911. }());
  130912. /***/ }),
  130913. /***/ "./abstractScene.ts":
  130914. /*!**************************!*\
  130915. !*** ./abstractScene.ts ***!
  130916. \**************************/
  130917. /*! exports provided: AbstractScene */
  130918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130919. "use strict";
  130920. __webpack_require__.r(__webpack_exports__);
  130921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  130922. /**
  130923. * Base class of the scene acting as a container for the different elements composing a scene.
  130924. * This class is dynamically extended by the different components of the scene increasing
  130925. * flexibility and reducing coupling
  130926. */
  130927. var AbstractScene = /** @class */ (function () {
  130928. function AbstractScene() {
  130929. /**
  130930. * Gets the list of root nodes (ie. nodes with no parent)
  130931. */
  130932. this.rootNodes = new Array();
  130933. /** All of the cameras added to this scene
  130934. * @see http://doc.babylonjs.com/babylon101/cameras
  130935. */
  130936. this.cameras = new Array();
  130937. /**
  130938. * All of the lights added to this scene
  130939. * @see http://doc.babylonjs.com/babylon101/lights
  130940. */
  130941. this.lights = new Array();
  130942. /**
  130943. * All of the (abstract) meshes added to this scene
  130944. */
  130945. this.meshes = new Array();
  130946. /**
  130947. * The list of skeletons added to the scene
  130948. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  130949. */
  130950. this.skeletons = new Array();
  130951. /**
  130952. * All of the particle systems added to this scene
  130953. * @see http://doc.babylonjs.com/babylon101/particles
  130954. */
  130955. this.particleSystems = new Array();
  130956. /**
  130957. * Gets a list of Animations associated with the scene
  130958. */
  130959. this.animations = [];
  130960. /**
  130961. * All of the animation groups added to this scene
  130962. * @see http://doc.babylonjs.com/how_to/group
  130963. */
  130964. this.animationGroups = new Array();
  130965. /**
  130966. * All of the multi-materials added to this scene
  130967. * @see http://doc.babylonjs.com/how_to/multi_materials
  130968. */
  130969. this.multiMaterials = new Array();
  130970. /**
  130971. * All of the materials added to this scene
  130972. * In the context of a Scene, it is not supposed to be modified manually.
  130973. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  130974. * Note also that the order of the Material wihin the array is not significant and might change.
  130975. * @see http://doc.babylonjs.com/babylon101/materials
  130976. */
  130977. this.materials = new Array();
  130978. /**
  130979. * The list of morph target managers added to the scene
  130980. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  130981. */
  130982. this.morphTargetManagers = new Array();
  130983. /**
  130984. * The list of geometries used in the scene.
  130985. */
  130986. this.geometries = new Array();
  130987. /**
  130988. * All of the tranform nodes added to this scene
  130989. * In the context of a Scene, it is not supposed to be modified manually.
  130990. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  130991. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  130992. * @see http://doc.babylonjs.com/how_to/transformnode
  130993. */
  130994. this.transformNodes = new Array();
  130995. /**
  130996. * ActionManagers available on the scene.
  130997. */
  130998. this.actionManagers = new Array();
  130999. /**
  131000. * Textures to keep.
  131001. */
  131002. this.textures = new Array();
  131003. /**
  131004. * Environment texture for the scene
  131005. */
  131006. this.environmentTexture = null;
  131007. }
  131008. /**
  131009. * Adds a parser in the list of available ones
  131010. * @param name Defines the name of the parser
  131011. * @param parser Defines the parser to add
  131012. */
  131013. AbstractScene.AddParser = function (name, parser) {
  131014. this._BabylonFileParsers[name] = parser;
  131015. };
  131016. /**
  131017. * Gets a general parser from the list of avaialble ones
  131018. * @param name Defines the name of the parser
  131019. * @returns the requested parser or null
  131020. */
  131021. AbstractScene.GetParser = function (name) {
  131022. if (this._BabylonFileParsers[name]) {
  131023. return this._BabylonFileParsers[name];
  131024. }
  131025. return null;
  131026. };
  131027. /**
  131028. * Adds n individual parser in the list of available ones
  131029. * @param name Defines the name of the parser
  131030. * @param parser Defines the parser to add
  131031. */
  131032. AbstractScene.AddIndividualParser = function (name, parser) {
  131033. this._IndividualBabylonFileParsers[name] = parser;
  131034. };
  131035. /**
  131036. * Gets an individual parser from the list of avaialble ones
  131037. * @param name Defines the name of the parser
  131038. * @returns the requested parser or null
  131039. */
  131040. AbstractScene.GetIndividualParser = function (name) {
  131041. if (this._IndividualBabylonFileParsers[name]) {
  131042. return this._IndividualBabylonFileParsers[name];
  131043. }
  131044. return null;
  131045. };
  131046. /**
  131047. * Parser json data and populate both a scene and its associated container object
  131048. * @param jsonData Defines the data to parse
  131049. * @param scene Defines the scene to parse the data for
  131050. * @param container Defines the container attached to the parsing sequence
  131051. * @param rootUrl Defines the root url of the data
  131052. */
  131053. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  131054. for (var parserName in this._BabylonFileParsers) {
  131055. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  131056. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  131057. }
  131058. }
  131059. };
  131060. /**
  131061. * Stores the list of available parsers in the application.
  131062. */
  131063. AbstractScene._BabylonFileParsers = {};
  131064. /**
  131065. * Stores the list of available individual parsers in the application.
  131066. */
  131067. AbstractScene._IndividualBabylonFileParsers = {};
  131068. return AbstractScene;
  131069. }());
  131070. /***/ }),
  131071. /***/ "./assetContainer.ts":
  131072. /*!***************************!*\
  131073. !*** ./assetContainer.ts ***!
  131074. \***************************/
  131075. /*! exports provided: KeepAssets, AssetContainer */
  131076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131077. "use strict";
  131078. __webpack_require__.r(__webpack_exports__);
  131079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  131080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  131081. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131082. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  131083. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  131084. /**
  131085. * Set of assets to keep when moving a scene into an asset container.
  131086. */
  131087. var KeepAssets = /** @class */ (function (_super) {
  131088. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  131089. function KeepAssets() {
  131090. return _super !== null && _super.apply(this, arguments) || this;
  131091. }
  131092. return KeepAssets;
  131093. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  131094. /**
  131095. * Container with a set of assets that can be added or removed from a scene.
  131096. */
  131097. var AssetContainer = /** @class */ (function (_super) {
  131098. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  131099. /**
  131100. * Instantiates an AssetContainer.
  131101. * @param scene The scene the AssetContainer belongs to.
  131102. */
  131103. function AssetContainer(scene) {
  131104. var _this = _super.call(this) || this;
  131105. _this.scene = scene;
  131106. _this["sounds"] = [];
  131107. _this["effectLayers"] = [];
  131108. _this["layers"] = [];
  131109. _this["lensFlareSystems"] = [];
  131110. _this["proceduralTextures"] = [];
  131111. _this["reflectionProbes"] = [];
  131112. return _this;
  131113. }
  131114. /**
  131115. * Adds all the assets from the container to the scene.
  131116. */
  131117. AssetContainer.prototype.addAllToScene = function () {
  131118. var _this = this;
  131119. this.cameras.forEach(function (o) {
  131120. _this.scene.addCamera(o);
  131121. });
  131122. this.lights.forEach(function (o) {
  131123. _this.scene.addLight(o);
  131124. });
  131125. this.meshes.forEach(function (o) {
  131126. _this.scene.addMesh(o);
  131127. });
  131128. this.skeletons.forEach(function (o) {
  131129. _this.scene.addSkeleton(o);
  131130. });
  131131. this.animations.forEach(function (o) {
  131132. _this.scene.addAnimation(o);
  131133. });
  131134. this.animationGroups.forEach(function (o) {
  131135. _this.scene.addAnimationGroup(o);
  131136. });
  131137. this.multiMaterials.forEach(function (o) {
  131138. _this.scene.addMultiMaterial(o);
  131139. });
  131140. this.materials.forEach(function (o) {
  131141. _this.scene.addMaterial(o);
  131142. });
  131143. this.morphTargetManagers.forEach(function (o) {
  131144. _this.scene.addMorphTargetManager(o);
  131145. });
  131146. this.geometries.forEach(function (o) {
  131147. _this.scene.addGeometry(o);
  131148. });
  131149. this.transformNodes.forEach(function (o) {
  131150. _this.scene.addTransformNode(o);
  131151. });
  131152. this.actionManagers.forEach(function (o) {
  131153. _this.scene.addActionManager(o);
  131154. });
  131155. this.textures.forEach(function (o) {
  131156. _this.scene.addTexture(o);
  131157. });
  131158. this.reflectionProbes.forEach(function (o) {
  131159. _this.scene.addReflectionProbe(o);
  131160. });
  131161. this.scene.environmentTexture = this.environmentTexture;
  131162. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  131163. var component = _a[_i];
  131164. component.addFromContainer(this);
  131165. }
  131166. };
  131167. /**
  131168. * Removes all the assets in the container from the scene
  131169. */
  131170. AssetContainer.prototype.removeAllFromScene = function () {
  131171. var _this = this;
  131172. this.cameras.forEach(function (o) {
  131173. _this.scene.removeCamera(o);
  131174. });
  131175. this.lights.forEach(function (o) {
  131176. _this.scene.removeLight(o);
  131177. });
  131178. this.meshes.forEach(function (o) {
  131179. _this.scene.removeMesh(o);
  131180. });
  131181. this.skeletons.forEach(function (o) {
  131182. _this.scene.removeSkeleton(o);
  131183. });
  131184. this.animations.forEach(function (o) {
  131185. _this.scene.removeAnimation(o);
  131186. });
  131187. this.animationGroups.forEach(function (o) {
  131188. _this.scene.removeAnimationGroup(o);
  131189. });
  131190. this.multiMaterials.forEach(function (o) {
  131191. _this.scene.removeMultiMaterial(o);
  131192. });
  131193. this.materials.forEach(function (o) {
  131194. _this.scene.removeMaterial(o);
  131195. });
  131196. this.morphTargetManagers.forEach(function (o) {
  131197. _this.scene.removeMorphTargetManager(o);
  131198. });
  131199. this.geometries.forEach(function (o) {
  131200. _this.scene.removeGeometry(o);
  131201. });
  131202. this.transformNodes.forEach(function (o) {
  131203. _this.scene.removeTransformNode(o);
  131204. });
  131205. this.actionManagers.forEach(function (o) {
  131206. _this.scene.removeActionManager(o);
  131207. });
  131208. this.textures.forEach(function (o) {
  131209. _this.scene.removeTexture(o);
  131210. });
  131211. this.reflectionProbes.forEach(function (o) {
  131212. _this.scene.removeReflectionProbe(o);
  131213. });
  131214. if (this.environmentTexture === this.scene.environmentTexture) {
  131215. this.scene.environmentTexture = null;
  131216. }
  131217. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  131218. var component = _a[_i];
  131219. component.removeFromContainer(this);
  131220. }
  131221. };
  131222. /**
  131223. * Disposes all the assets in the container
  131224. */
  131225. AssetContainer.prototype.dispose = function () {
  131226. this.cameras.forEach(function (o) {
  131227. o.dispose();
  131228. });
  131229. this.cameras = [];
  131230. this.lights.forEach(function (o) {
  131231. o.dispose();
  131232. });
  131233. this.lights = [];
  131234. this.meshes.forEach(function (o) {
  131235. o.dispose();
  131236. });
  131237. this.meshes = [];
  131238. this.skeletons.forEach(function (o) {
  131239. o.dispose();
  131240. });
  131241. this.skeletons = [];
  131242. this.animationGroups.forEach(function (o) {
  131243. o.dispose();
  131244. });
  131245. this.animationGroups = [];
  131246. this.multiMaterials.forEach(function (o) {
  131247. o.dispose();
  131248. });
  131249. this.multiMaterials = [];
  131250. this.materials.forEach(function (o) {
  131251. o.dispose();
  131252. });
  131253. this.materials = [];
  131254. this.geometries.forEach(function (o) {
  131255. o.dispose();
  131256. });
  131257. this.geometries = [];
  131258. this.transformNodes.forEach(function (o) {
  131259. o.dispose();
  131260. });
  131261. this.transformNodes = [];
  131262. this.actionManagers.forEach(function (o) {
  131263. o.dispose();
  131264. });
  131265. this.actionManagers = [];
  131266. this.textures.forEach(function (o) {
  131267. o.dispose();
  131268. });
  131269. this.textures = [];
  131270. this.reflectionProbes.forEach(function (o) {
  131271. o.dispose();
  131272. });
  131273. this.reflectionProbes = [];
  131274. if (this.environmentTexture) {
  131275. this.environmentTexture.dispose();
  131276. this.environmentTexture = null;
  131277. }
  131278. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  131279. var component = _a[_i];
  131280. component.removeFromContainer(this, true);
  131281. }
  131282. };
  131283. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  131284. if (!sourceAssets) {
  131285. return;
  131286. }
  131287. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  131288. var asset = sourceAssets_1[_i];
  131289. var move = true;
  131290. if (keepAssets) {
  131291. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  131292. var keepAsset = keepAssets_1[_a];
  131293. if (asset === keepAsset) {
  131294. move = false;
  131295. break;
  131296. }
  131297. }
  131298. }
  131299. if (move) {
  131300. targetAssets.push(asset);
  131301. }
  131302. }
  131303. };
  131304. /**
  131305. * Removes all the assets contained in the scene and adds them to the container.
  131306. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  131307. */
  131308. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  131309. if (keepAssets === undefined) {
  131310. keepAssets = new KeepAssets();
  131311. }
  131312. for (var key in this) {
  131313. if (this.hasOwnProperty(key)) {
  131314. this[key] = this[key] || [];
  131315. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  131316. }
  131317. }
  131318. this.removeAllFromScene();
  131319. };
  131320. /**
  131321. * 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.
  131322. * @returns the root mesh
  131323. */
  131324. AssetContainer.prototype.createRootMesh = function () {
  131325. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  131326. this.meshes.forEach(function (m) {
  131327. if (!m.parent) {
  131328. rootMesh.addChild(m);
  131329. }
  131330. });
  131331. this.meshes.unshift(rootMesh);
  131332. return rootMesh;
  131333. };
  131334. return AssetContainer;
  131335. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  131336. /***/ }),
  131337. /***/ "./index.ts":
  131338. /*!******************!*\
  131339. !*** ./index.ts ***!
  131340. \******************/
  131341. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, MultiviewRenderTarget, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleview, 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, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, CubeMapToSphericalPolynomialTools, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, EquiRectangularCubeTexture, HDRCubeTexture, DummyInternalTextureTracker, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  131342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131343. "use strict";
  131344. __webpack_require__.r(__webpack_exports__);
  131345. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  131346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  131347. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  131348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  131349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  131350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  131351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  131352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  131353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  131354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  131355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  131356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  131357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  131358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  131359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  131360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  131361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  131362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  131363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  131364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  131365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  131366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  131367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  131368. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  131369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  131370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  131371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  131372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  131373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  131374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  131375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  131376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  131377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  131378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  131379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  131380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  131381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  131382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  131383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  131384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  131385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  131386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  131387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  131388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  131389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  131390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  131391. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  131392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  131393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  131394. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  131395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  131396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  131397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  131398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  131399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  131400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  131401. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  131402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  131403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  131404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  131405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  131406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  131407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  131408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  131409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  131410. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  131411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  131412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  131413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  131414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  131415. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  131416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  131417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  131418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  131419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  131420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  131421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  131422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  131423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  131424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  131425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  131426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  131427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  131428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  131429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  131430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  131431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  131432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  131433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  131434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  131435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  131436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  131437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  131438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  131439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  131440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  131441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  131442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  131443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  131444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  131445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  131446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  131447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  131448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  131449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  131450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  131451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  131452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  131453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  131454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  131455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  131456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  131457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  131458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  131459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  131460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  131461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  131462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  131463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  131464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  131465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  131466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  131467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  131468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  131469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  131470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  131471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  131472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  131473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  131474. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  131475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  131476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  131477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  131478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  131479. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  131480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  131481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  131482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  131483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  131484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  131485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  131486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  131487. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  131488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  131489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  131490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  131491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  131492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  131493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  131494. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  131495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  131496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  131497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  131498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  131499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  131500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  131501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  131502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  131503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  131504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  131505. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  131506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  131507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  131508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  131509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  131510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  131511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  131512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  131513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  131514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  131515. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  131516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  131517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  131518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  131519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  131520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  131521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  131522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  131523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  131524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  131525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  131526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  131527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  131528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  131529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  131530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  131531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  131532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  131533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  131534. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  131535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  131536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  131537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  131538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  131539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  131540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  131541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  131542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  131543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  131544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  131545. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  131546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  131547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  131548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  131549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  131550. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  131551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  131552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  131553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  131554. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  131555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  131556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  131557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  131558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  131559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  131560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  131561. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  131562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  131563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  131564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  131565. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  131566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  131567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  131568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  131569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  131570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  131571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  131572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  131573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  131574. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  131575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  131576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  131577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  131578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  131579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  131580. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  131581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  131582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  131583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  131584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  131585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  131586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  131587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  131588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  131589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  131590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  131591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  131592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  131593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  131594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  131595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  131596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  131597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  131598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  131599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  131600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  131601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  131602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiviewRenderTarget"]; });
  131603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  131604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  131605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  131606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  131607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  131608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  131609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  131610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  131611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  131612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  131613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  131614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EquiRectangularCubeTexture"]; });
  131615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  131616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  131617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  131618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  131619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  131620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  131621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  131622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  131623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  131624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  131625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  131626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  131627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  131628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  131629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  131630. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  131631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  131632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  131633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  131634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  131635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  131636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  131637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  131638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  131639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  131640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  131641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  131642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  131643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  131644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  131645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  131646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  131647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  131648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  131649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  131650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  131651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  131652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  131653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  131654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  131655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  131656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  131657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  131658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  131659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  131660. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  131661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  131662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  131663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  131664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  131665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  131666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  131667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  131668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  131669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  131670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  131671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  131672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  131673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  131674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  131675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  131676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  131677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  131678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  131679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  131680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  131681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  131682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  131683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  131684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  131685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  131686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  131687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  131688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  131689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  131690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  131691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  131692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  131693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  131694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  131695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  131696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  131697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  131698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  131699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  131700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  131701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  131702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  131703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  131704. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  131705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  131706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  131707. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  131708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  131709. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  131710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  131711. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  131712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  131713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  131714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  131715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  131716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  131717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  131718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  131719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  131720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  131721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  131722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  131723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  131724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  131725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  131726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  131727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  131728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  131729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  131730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  131731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  131732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  131733. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  131734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  131735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  131736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  131737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEventOptions"]; });
  131738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEventOptions"]; });
  131739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEventOptions"]; });
  131740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  131741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  131742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  131743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  131744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  131745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  131746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  131747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  131748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  131749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  131750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  131751. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  131752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  131753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  131754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  131755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  131756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  131757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  131758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  131759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  131760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  131761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  131762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  131763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  131764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  131765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  131766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  131767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  131768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  131769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  131770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  131771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  131772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  131773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  131774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  131775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  131776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  131777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  131778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  131779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  131780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  131781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  131782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  131783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  131784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  131785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleview", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRMultiviewToSingleview"]; });
  131786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  131787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  131788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  131789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  131790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  131791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  131792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  131793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  131794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  131795. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  131796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  131797. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  131798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  131799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  131800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  131801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  131802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  131803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  131804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  131805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  131806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  131807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  131808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  131809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  131810. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  131811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  131812. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  131813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  131814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  131815. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  131816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  131817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  131818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  131819. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  131820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  131821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  131822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  131823. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  131824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  131825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  131826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  131827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  131828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  131829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  131830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  131831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  131832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  131833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  131834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  131835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  131836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  131837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  131838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  131839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  131840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  131841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  131842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  131843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  131844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  131845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  131846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  131847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  131848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  131849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMatrix"]; });
  131850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  131851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  131852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  131853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  131854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshExploder"]; });
  131855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  131856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  131857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  131858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  131859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  131860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  131861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  131862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  131863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  131864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  131865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  131866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  131867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  131868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  131869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  131870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  131871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  131872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  131873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  131874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  131875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  131876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  131877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  131878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  131879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  131880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  131881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  131882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  131883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  131884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  131885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  131886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  131887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  131888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  131889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  131890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  131891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  131892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  131893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  131894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  131895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  131896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  131897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  131898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  131899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  131900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  131901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  131902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  131903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  131904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WebRequest"]; });
  131905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["InspectableType"]; });
  131906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  131907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  131908. /***/ }),
  131909. /***/ "./node.ts":
  131910. /*!*****************!*\
  131911. !*** ./node.ts ***!
  131912. \*****************/
  131913. /*! exports provided: Node */
  131914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131915. "use strict";
  131916. __webpack_require__.r(__webpack_exports__);
  131917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  131918. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131919. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  131920. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  131921. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  131922. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  131923. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  131924. /**
  131925. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  131926. */
  131927. var Node = /** @class */ (function () {
  131928. /**
  131929. * Creates a new Node
  131930. * @param name the name and id to be given to this node
  131931. * @param scene the scene this node will be added to
  131932. * @param addToRootNodes the node will be added to scene.rootNodes
  131933. */
  131934. function Node(name, scene, addToRootNodes) {
  131935. if (scene === void 0) { scene = null; }
  131936. if (addToRootNodes === void 0) { addToRootNodes = true; }
  131937. /**
  131938. * Gets or sets a string used to store user defined state for the node
  131939. */
  131940. this.state = "";
  131941. /**
  131942. * Gets or sets an object used to store user defined information for the node
  131943. */
  131944. this.metadata = null;
  131945. /**
  131946. * For internal use only. Please do not use.
  131947. */
  131948. this.reservedDataStore = null;
  131949. /**
  131950. * Gets or sets a boolean used to define if the node must be serialized
  131951. */
  131952. this.doNotSerialize = false;
  131953. /** @hidden */
  131954. this._isDisposed = false;
  131955. /**
  131956. * Gets a list of Animations associated with the node
  131957. */
  131958. this.animations = new Array();
  131959. this._ranges = {};
  131960. this._isEnabled = true;
  131961. this._isParentEnabled = true;
  131962. this._isReady = true;
  131963. /** @hidden */
  131964. this._currentRenderId = -1;
  131965. this._parentRenderId = -1;
  131966. this._childRenderId = -1;
  131967. /** @hidden */
  131968. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  131969. /** @hidden */
  131970. this._worldMatrixDeterminant = 0;
  131971. /** @hidden */
  131972. this._sceneRootNodesIndex = -1;
  131973. this._animationPropertiesOverride = null;
  131974. /** @hidden */
  131975. this._isNode = true;
  131976. /**
  131977. * An event triggered when the mesh is disposed
  131978. */
  131979. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  131980. // Behaviors
  131981. this._behaviors = new Array();
  131982. this.name = name;
  131983. this.id = name;
  131984. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  131985. this.uniqueId = this._scene.getUniqueId();
  131986. this._initCache();
  131987. if (addToRootNodes) {
  131988. this.addToSceneRootNodes();
  131989. }
  131990. }
  131991. /**
  131992. * Add a new node constructor
  131993. * @param type defines the type name of the node to construct
  131994. * @param constructorFunc defines the constructor function
  131995. */
  131996. Node.AddNodeConstructor = function (type, constructorFunc) {
  131997. this._NodeConstructors[type] = constructorFunc;
  131998. };
  131999. /**
  132000. * Returns a node constructor based on type name
  132001. * @param type defines the type name
  132002. * @param name defines the new node name
  132003. * @param scene defines the hosting scene
  132004. * @param options defines optional options to transmit to constructors
  132005. * @returns the new constructor or null
  132006. */
  132007. Node.Construct = function (type, name, scene, options) {
  132008. var constructorFunc = this._NodeConstructors[type];
  132009. if (!constructorFunc) {
  132010. return null;
  132011. }
  132012. return constructorFunc(name, scene, options);
  132013. };
  132014. /**
  132015. * Gets a boolean indicating if the node has been disposed
  132016. * @returns true if the node was disposed
  132017. */
  132018. Node.prototype.isDisposed = function () {
  132019. return this._isDisposed;
  132020. };
  132021. Object.defineProperty(Node.prototype, "parent", {
  132022. get: function () {
  132023. return this._parentNode;
  132024. },
  132025. /**
  132026. * Gets or sets the parent of the node (without keeping the current position in the scene)
  132027. * @see https://doc.babylonjs.com/how_to/parenting
  132028. */
  132029. set: function (parent) {
  132030. if (this._parentNode === parent) {
  132031. return;
  132032. }
  132033. var previousParentNode = this._parentNode;
  132034. // Remove self from list of children of parent
  132035. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  132036. var index = this._parentNode._children.indexOf(this);
  132037. if (index !== -1) {
  132038. this._parentNode._children.splice(index, 1);
  132039. }
  132040. if (!parent && !this._isDisposed) {
  132041. this.addToSceneRootNodes();
  132042. }
  132043. }
  132044. // Store new parent
  132045. this._parentNode = parent;
  132046. // Add as child to new parent
  132047. if (this._parentNode) {
  132048. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  132049. this._parentNode._children = new Array();
  132050. }
  132051. this._parentNode._children.push(this);
  132052. if (!previousParentNode) {
  132053. this.removeFromSceneRootNodes();
  132054. }
  132055. }
  132056. // Enabled state
  132057. this._syncParentEnabledState();
  132058. },
  132059. enumerable: true,
  132060. configurable: true
  132061. });
  132062. Node.prototype.addToSceneRootNodes = function () {
  132063. if (this._sceneRootNodesIndex === -1) {
  132064. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  132065. this._scene.rootNodes.push(this);
  132066. }
  132067. };
  132068. Node.prototype.removeFromSceneRootNodes = function () {
  132069. if (this._sceneRootNodesIndex !== -1) {
  132070. var rootNodes = this._scene.rootNodes;
  132071. var lastIdx = rootNodes.length - 1;
  132072. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  132073. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  132074. this._scene.rootNodes.pop();
  132075. this._sceneRootNodesIndex = -1;
  132076. }
  132077. };
  132078. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  132079. /**
  132080. * Gets or sets the animation properties override
  132081. */
  132082. get: function () {
  132083. if (!this._animationPropertiesOverride) {
  132084. return this._scene.animationPropertiesOverride;
  132085. }
  132086. return this._animationPropertiesOverride;
  132087. },
  132088. set: function (value) {
  132089. this._animationPropertiesOverride = value;
  132090. },
  132091. enumerable: true,
  132092. configurable: true
  132093. });
  132094. /**
  132095. * Gets a string idenfifying the name of the class
  132096. * @returns "Node" string
  132097. */
  132098. Node.prototype.getClassName = function () {
  132099. return "Node";
  132100. };
  132101. Object.defineProperty(Node.prototype, "onDispose", {
  132102. /**
  132103. * Sets a callback that will be raised when the node will be disposed
  132104. */
  132105. set: function (callback) {
  132106. if (this._onDisposeObserver) {
  132107. this.onDisposeObservable.remove(this._onDisposeObserver);
  132108. }
  132109. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  132110. },
  132111. enumerable: true,
  132112. configurable: true
  132113. });
  132114. /**
  132115. * Gets the scene of the node
  132116. * @returns a scene
  132117. */
  132118. Node.prototype.getScene = function () {
  132119. return this._scene;
  132120. };
  132121. /**
  132122. * Gets the engine of the node
  132123. * @returns a Engine
  132124. */
  132125. Node.prototype.getEngine = function () {
  132126. return this._scene.getEngine();
  132127. };
  132128. /**
  132129. * Attach a behavior to the node
  132130. * @see http://doc.babylonjs.com/features/behaviour
  132131. * @param behavior defines the behavior to attach
  132132. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  132133. * @returns the current Node
  132134. */
  132135. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  132136. var _this = this;
  132137. if (attachImmediately === void 0) { attachImmediately = false; }
  132138. var index = this._behaviors.indexOf(behavior);
  132139. if (index !== -1) {
  132140. return this;
  132141. }
  132142. behavior.init();
  132143. if (this._scene.isLoading && !attachImmediately) {
  132144. // We defer the attach when the scene will be loaded
  132145. this._scene.onDataLoadedObservable.addOnce(function () {
  132146. behavior.attach(_this);
  132147. });
  132148. }
  132149. else {
  132150. behavior.attach(this);
  132151. }
  132152. this._behaviors.push(behavior);
  132153. return this;
  132154. };
  132155. /**
  132156. * Remove an attached behavior
  132157. * @see http://doc.babylonjs.com/features/behaviour
  132158. * @param behavior defines the behavior to attach
  132159. * @returns the current Node
  132160. */
  132161. Node.prototype.removeBehavior = function (behavior) {
  132162. var index = this._behaviors.indexOf(behavior);
  132163. if (index === -1) {
  132164. return this;
  132165. }
  132166. this._behaviors[index].detach();
  132167. this._behaviors.splice(index, 1);
  132168. return this;
  132169. };
  132170. Object.defineProperty(Node.prototype, "behaviors", {
  132171. /**
  132172. * Gets the list of attached behaviors
  132173. * @see http://doc.babylonjs.com/features/behaviour
  132174. */
  132175. get: function () {
  132176. return this._behaviors;
  132177. },
  132178. enumerable: true,
  132179. configurable: true
  132180. });
  132181. /**
  132182. * Gets an attached behavior by name
  132183. * @param name defines the name of the behavior to look for
  132184. * @see http://doc.babylonjs.com/features/behaviour
  132185. * @returns null if behavior was not found else the requested behavior
  132186. */
  132187. Node.prototype.getBehaviorByName = function (name) {
  132188. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  132189. var behavior = _a[_i];
  132190. if (behavior.name === name) {
  132191. return behavior;
  132192. }
  132193. }
  132194. return null;
  132195. };
  132196. /**
  132197. * Returns the latest update of the World matrix
  132198. * @returns a Matrix
  132199. */
  132200. Node.prototype.getWorldMatrix = function () {
  132201. if (this._currentRenderId !== this._scene.getRenderId()) {
  132202. this.computeWorldMatrix();
  132203. }
  132204. return this._worldMatrix;
  132205. };
  132206. /** @hidden */
  132207. Node.prototype._getWorldMatrixDeterminant = function () {
  132208. return this._worldMatrixDeterminant;
  132209. };
  132210. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  132211. /**
  132212. * Returns directly the latest state of the mesh World matrix.
  132213. * A Matrix is returned.
  132214. */
  132215. get: function () {
  132216. return this._worldMatrix;
  132217. },
  132218. enumerable: true,
  132219. configurable: true
  132220. });
  132221. // override it in derived class if you add new variables to the cache
  132222. // and call the parent class method
  132223. /** @hidden */
  132224. Node.prototype._initCache = function () {
  132225. this._cache = {};
  132226. this._cache.parent = undefined;
  132227. };
  132228. /** @hidden */
  132229. Node.prototype.updateCache = function (force) {
  132230. if (!force && this.isSynchronized()) {
  132231. return;
  132232. }
  132233. this._cache.parent = this.parent;
  132234. this._updateCache();
  132235. };
  132236. /** @hidden */
  132237. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  132238. if (initialCall === void 0) { initialCall = true; }
  132239. if (!this.parent) {
  132240. return null;
  132241. }
  132242. return this.parent._getActionManagerForTrigger(trigger, false);
  132243. };
  132244. // override it in derived class if you add new variables to the cache
  132245. // and call the parent class method if !ignoreParentClass
  132246. /** @hidden */
  132247. Node.prototype._updateCache = function (ignoreParentClass) {
  132248. };
  132249. // override it in derived class if you add new variables to the cache
  132250. /** @hidden */
  132251. Node.prototype._isSynchronized = function () {
  132252. return true;
  132253. };
  132254. /** @hidden */
  132255. Node.prototype._markSyncedWithParent = function () {
  132256. if (this._parentNode) {
  132257. this._parentRenderId = this._parentNode._childRenderId;
  132258. }
  132259. };
  132260. /** @hidden */
  132261. Node.prototype.isSynchronizedWithParent = function () {
  132262. if (!this._parentNode) {
  132263. return true;
  132264. }
  132265. if (this._parentRenderId !== this._parentNode._childRenderId) {
  132266. return false;
  132267. }
  132268. return this._parentNode.isSynchronized();
  132269. };
  132270. /** @hidden */
  132271. Node.prototype.isSynchronized = function () {
  132272. if (this._cache.parent != this._parentNode) {
  132273. this._cache.parent = this._parentNode;
  132274. return false;
  132275. }
  132276. if (this._parentNode && !this.isSynchronizedWithParent()) {
  132277. return false;
  132278. }
  132279. return this._isSynchronized();
  132280. };
  132281. /**
  132282. * Is this node ready to be used/rendered
  132283. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  132284. * @return true if the node is ready
  132285. */
  132286. Node.prototype.isReady = function (completeCheck) {
  132287. if (completeCheck === void 0) { completeCheck = false; }
  132288. return this._isReady;
  132289. };
  132290. /**
  132291. * Is this node enabled?
  132292. * 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
  132293. * @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
  132294. * @return whether this node (and its parent) is enabled
  132295. */
  132296. Node.prototype.isEnabled = function (checkAncestors) {
  132297. if (checkAncestors === void 0) { checkAncestors = true; }
  132298. if (checkAncestors === false) {
  132299. return this._isEnabled;
  132300. }
  132301. if (!this._isEnabled) {
  132302. return false;
  132303. }
  132304. return this._isParentEnabled;
  132305. };
  132306. /** @hidden */
  132307. Node.prototype._syncParentEnabledState = function () {
  132308. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  132309. if (this._children) {
  132310. this._children.forEach(function (c) {
  132311. c._syncParentEnabledState(); // Force children to update accordingly
  132312. });
  132313. }
  132314. };
  132315. /**
  132316. * Set the enabled state of this node
  132317. * @param value defines the new enabled state
  132318. */
  132319. Node.prototype.setEnabled = function (value) {
  132320. this._isEnabled = value;
  132321. this._syncParentEnabledState();
  132322. };
  132323. /**
  132324. * Is this node a descendant of the given node?
  132325. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  132326. * @param ancestor defines the parent node to inspect
  132327. * @returns a boolean indicating if this node is a descendant of the given node
  132328. */
  132329. Node.prototype.isDescendantOf = function (ancestor) {
  132330. if (this.parent) {
  132331. if (this.parent === ancestor) {
  132332. return true;
  132333. }
  132334. return this.parent.isDescendantOf(ancestor);
  132335. }
  132336. return false;
  132337. };
  132338. /** @hidden */
  132339. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  132340. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  132341. if (!this._children) {
  132342. return;
  132343. }
  132344. for (var index = 0; index < this._children.length; index++) {
  132345. var item = this._children[index];
  132346. if (!predicate || predicate(item)) {
  132347. results.push(item);
  132348. }
  132349. if (!directDescendantsOnly) {
  132350. item._getDescendants(results, false, predicate);
  132351. }
  132352. }
  132353. };
  132354. /**
  132355. * Will return all nodes that have this node as ascendant
  132356. * @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
  132357. * @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
  132358. * @return all children nodes of all types
  132359. */
  132360. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  132361. var results = new Array();
  132362. this._getDescendants(results, directDescendantsOnly, predicate);
  132363. return results;
  132364. };
  132365. /**
  132366. * Get all child-meshes of this node
  132367. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  132368. * @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
  132369. * @returns an array of AbstractMesh
  132370. */
  132371. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  132372. var results = [];
  132373. this._getDescendants(results, directDescendantsOnly, function (node) {
  132374. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  132375. });
  132376. return results;
  132377. };
  132378. /**
  132379. * Get all direct children of this node
  132380. * @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
  132381. * @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)
  132382. * @returns an array of Node
  132383. */
  132384. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  132385. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  132386. return this.getDescendants(directDescendantsOnly, predicate);
  132387. };
  132388. /** @hidden */
  132389. Node.prototype._setReady = function (state) {
  132390. if (state === this._isReady) {
  132391. return;
  132392. }
  132393. if (!state) {
  132394. this._isReady = false;
  132395. return;
  132396. }
  132397. if (this.onReady) {
  132398. this.onReady(this);
  132399. }
  132400. this._isReady = true;
  132401. };
  132402. /**
  132403. * Get an animation by name
  132404. * @param name defines the name of the animation to look for
  132405. * @returns null if not found else the requested animation
  132406. */
  132407. Node.prototype.getAnimationByName = function (name) {
  132408. for (var i = 0; i < this.animations.length; i++) {
  132409. var animation = this.animations[i];
  132410. if (animation.name === name) {
  132411. return animation;
  132412. }
  132413. }
  132414. return null;
  132415. };
  132416. /**
  132417. * Creates an animation range for this node
  132418. * @param name defines the name of the range
  132419. * @param from defines the starting key
  132420. * @param to defines the end key
  132421. */
  132422. Node.prototype.createAnimationRange = function (name, from, to) {
  132423. // check name not already in use
  132424. if (!this._ranges[name]) {
  132425. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  132426. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  132427. if (this.animations[i]) {
  132428. this.animations[i].createRange(name, from, to);
  132429. }
  132430. }
  132431. }
  132432. };
  132433. /**
  132434. * Delete a specific animation range
  132435. * @param name defines the name of the range to delete
  132436. * @param deleteFrames defines if animation frames from the range must be deleted as well
  132437. */
  132438. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  132439. if (deleteFrames === void 0) { deleteFrames = true; }
  132440. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  132441. if (this.animations[i]) {
  132442. this.animations[i].deleteRange(name, deleteFrames);
  132443. }
  132444. }
  132445. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  132446. };
  132447. /**
  132448. * Get an animation range by name
  132449. * @param name defines the name of the animation range to look for
  132450. * @returns null if not found else the requested animation range
  132451. */
  132452. Node.prototype.getAnimationRange = function (name) {
  132453. return this._ranges[name];
  132454. };
  132455. /**
  132456. * Gets the list of all animation ranges defined on this node
  132457. * @returns an array
  132458. */
  132459. Node.prototype.getAnimationRanges = function () {
  132460. var animationRanges = [];
  132461. var name;
  132462. for (name in this._ranges) {
  132463. animationRanges.push(this._ranges[name]);
  132464. }
  132465. return animationRanges;
  132466. };
  132467. /**
  132468. * Will start the animation sequence
  132469. * @param name defines the range frames for animation sequence
  132470. * @param loop defines if the animation should loop (false by default)
  132471. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  132472. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  132473. * @returns the object created for this animation. If range does not exist, it will return null
  132474. */
  132475. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  132476. var range = this.getAnimationRange(name);
  132477. if (!range) {
  132478. return null;
  132479. }
  132480. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  132481. };
  132482. /**
  132483. * Serialize animation ranges into a JSON compatible object
  132484. * @returns serialization object
  132485. */
  132486. Node.prototype.serializeAnimationRanges = function () {
  132487. var serializationRanges = [];
  132488. for (var name in this._ranges) {
  132489. var localRange = this._ranges[name];
  132490. if (!localRange) {
  132491. continue;
  132492. }
  132493. var range = {};
  132494. range.name = name;
  132495. range.from = localRange.from;
  132496. range.to = localRange.to;
  132497. serializationRanges.push(range);
  132498. }
  132499. return serializationRanges;
  132500. };
  132501. /**
  132502. * Computes the world matrix of the node
  132503. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  132504. * @returns the world matrix
  132505. */
  132506. Node.prototype.computeWorldMatrix = function (force) {
  132507. if (!this._worldMatrix) {
  132508. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  132509. }
  132510. return this._worldMatrix;
  132511. };
  132512. /**
  132513. * Releases resources associated with this node.
  132514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132516. */
  132517. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  132518. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  132519. this._isDisposed = true;
  132520. if (!doNotRecurse) {
  132521. var nodes = this.getDescendants(true);
  132522. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  132523. var node = nodes_1[_i];
  132524. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  132525. }
  132526. }
  132527. if (!this.parent) {
  132528. this.removeFromSceneRootNodes();
  132529. }
  132530. else {
  132531. this.parent = null;
  132532. }
  132533. // Callback
  132534. this.onDisposeObservable.notifyObservers(this);
  132535. this.onDisposeObservable.clear();
  132536. // Behaviors
  132537. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  132538. var behavior = _b[_a];
  132539. behavior.detach();
  132540. }
  132541. this._behaviors = [];
  132542. };
  132543. /**
  132544. * Parse animation range data from a serialization object and store them into a given node
  132545. * @param node defines where to store the animation ranges
  132546. * @param parsedNode defines the serialization object to read data from
  132547. * @param scene defines the hosting scene
  132548. */
  132549. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  132550. if (parsedNode.ranges) {
  132551. for (var index = 0; index < parsedNode.ranges.length; index++) {
  132552. var data = parsedNode.ranges[index];
  132553. node.createAnimationRange(data.name, data.from, data.to);
  132554. }
  132555. }
  132556. };
  132557. /** @hidden */
  132558. Node._AnimationRangeFactory = function (name, from, to) {
  132559. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  132560. };
  132561. Node._NodeConstructors = {};
  132562. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132564. ], Node.prototype, "name", void 0);
  132565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132567. ], Node.prototype, "id", void 0);
  132568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132570. ], Node.prototype, "uniqueId", void 0);
  132571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132573. ], Node.prototype, "state", void 0);
  132574. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132576. ], Node.prototype, "metadata", void 0);
  132577. return Node;
  132578. }());
  132579. /***/ }),
  132580. /***/ "./scene.ts":
  132581. /*!******************!*\
  132582. !*** ./scene.ts ***!
  132583. \******************/
  132584. /*! exports provided: Scene */
  132585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132586. "use strict";
  132587. __webpack_require__.r(__webpack_exports__);
  132588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  132589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132590. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  132591. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  132592. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  132593. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  132594. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  132595. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  132596. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  132597. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  132598. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  132599. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  132600. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  132601. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  132602. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  132603. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  132604. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  132605. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  132606. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  132607. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  132608. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  132609. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  132610. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  132611. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  132612. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  132613. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  132614. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  132615. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  132616. /** @hidden */
  132617. var ClickInfo = /** @class */ (function () {
  132618. function ClickInfo() {
  132619. this._singleClick = false;
  132620. this._doubleClick = false;
  132621. this._hasSwiped = false;
  132622. this._ignore = false;
  132623. }
  132624. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  132625. get: function () {
  132626. return this._singleClick;
  132627. },
  132628. set: function (b) {
  132629. this._singleClick = b;
  132630. },
  132631. enumerable: true,
  132632. configurable: true
  132633. });
  132634. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  132635. get: function () {
  132636. return this._doubleClick;
  132637. },
  132638. set: function (b) {
  132639. this._doubleClick = b;
  132640. },
  132641. enumerable: true,
  132642. configurable: true
  132643. });
  132644. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  132645. get: function () {
  132646. return this._hasSwiped;
  132647. },
  132648. set: function (b) {
  132649. this._hasSwiped = b;
  132650. },
  132651. enumerable: true,
  132652. configurable: true
  132653. });
  132654. Object.defineProperty(ClickInfo.prototype, "ignore", {
  132655. get: function () {
  132656. return this._ignore;
  132657. },
  132658. set: function (b) {
  132659. this._ignore = b;
  132660. },
  132661. enumerable: true,
  132662. configurable: true
  132663. });
  132664. return ClickInfo;
  132665. }());
  132666. /**
  132667. * Represents a scene to be rendered by the engine.
  132668. * @see http://doc.babylonjs.com/features/scene
  132669. */
  132670. var Scene = /** @class */ (function (_super) {
  132671. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  132672. /**
  132673. * Creates a new Scene
  132674. * @param engine defines the engine to use to render this scene
  132675. * @param options defines the scene options
  132676. */
  132677. function Scene(engine, options) {
  132678. var _this = _super.call(this) || this;
  132679. // Members
  132680. /** @hidden */
  132681. _this._isScene = true;
  132682. /**
  132683. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  132684. */
  132685. _this.autoClear = true;
  132686. /**
  132687. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  132688. */
  132689. _this.autoClearDepthAndStencil = true;
  132690. /**
  132691. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  132692. */
  132693. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  132694. /**
  132695. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  132696. */
  132697. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  132698. _this._forceWireframe = false;
  132699. _this._forcePointsCloud = false;
  132700. /**
  132701. * Gets or sets a boolean indicating if animations are enabled
  132702. */
  132703. _this.animationsEnabled = true;
  132704. _this._animationPropertiesOverride = null;
  132705. /**
  132706. * Gets or sets a boolean indicating if a constant deltatime has to be used
  132707. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  132708. */
  132709. _this.useConstantAnimationDeltaTime = false;
  132710. /**
  132711. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  132712. * Please note that it requires to run a ray cast through the scene on every frame
  132713. */
  132714. _this.constantlyUpdateMeshUnderPointer = false;
  132715. /**
  132716. * Defines the HTML cursor to use when hovering over interactive elements
  132717. */
  132718. _this.hoverCursor = "pointer";
  132719. /**
  132720. * Defines the HTML default cursor to use (empty by default)
  132721. */
  132722. _this.defaultCursor = "";
  132723. /**
  132724. * This is used to call preventDefault() on pointer down
  132725. * in order to block unwanted artifacts like system double clicks
  132726. */
  132727. _this.preventDefaultOnPointerDown = true;
  132728. /**
  132729. * This is used to call preventDefault() on pointer up
  132730. * in order to block unwanted artifacts like system double clicks
  132731. */
  132732. _this.preventDefaultOnPointerUp = true;
  132733. // Metadata
  132734. /**
  132735. * Gets or sets user defined metadata
  132736. */
  132737. _this.metadata = null;
  132738. /**
  132739. * For internal use only. Please do not use.
  132740. */
  132741. _this.reservedDataStore = null;
  132742. /**
  132743. * Use this array to add regular expressions used to disable offline support for specific urls
  132744. */
  132745. _this.disableOfflineSupportExceptionRules = new Array();
  132746. /**
  132747. * An event triggered when the scene is disposed.
  132748. */
  132749. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132750. _this._onDisposeObserver = null;
  132751. /**
  132752. * An event triggered before rendering the scene (right after animations and physics)
  132753. */
  132754. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132755. _this._onBeforeRenderObserver = null;
  132756. /**
  132757. * An event triggered after rendering the scene
  132758. */
  132759. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132760. _this._onAfterRenderObserver = null;
  132761. /**
  132762. * An event triggered before animating the scene
  132763. */
  132764. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132765. /**
  132766. * An event triggered after animations processing
  132767. */
  132768. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132769. /**
  132770. * An event triggered before draw calls are ready to be sent
  132771. */
  132772. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132773. /**
  132774. * An event triggered after draw calls have been sent
  132775. */
  132776. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132777. /**
  132778. * An event triggered when the scene is ready
  132779. */
  132780. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132781. /**
  132782. * An event triggered before rendering a camera
  132783. */
  132784. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132785. _this._onBeforeCameraRenderObserver = null;
  132786. /**
  132787. * An event triggered after rendering a camera
  132788. */
  132789. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132790. _this._onAfterCameraRenderObserver = null;
  132791. /**
  132792. * An event triggered when active meshes evaluation is about to start
  132793. */
  132794. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132795. /**
  132796. * An event triggered when active meshes evaluation is done
  132797. */
  132798. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132799. /**
  132800. * An event triggered when particles rendering is about to start
  132801. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  132802. */
  132803. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132804. /**
  132805. * An event triggered when particles rendering is done
  132806. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  132807. */
  132808. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132809. /**
  132810. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  132811. */
  132812. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132813. /**
  132814. * An event triggered when a camera is created
  132815. */
  132816. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132817. /**
  132818. * An event triggered when a camera is removed
  132819. */
  132820. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132821. /**
  132822. * An event triggered when a light is created
  132823. */
  132824. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132825. /**
  132826. * An event triggered when a light is removed
  132827. */
  132828. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132829. /**
  132830. * An event triggered when a geometry is created
  132831. */
  132832. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132833. /**
  132834. * An event triggered when a geometry is removed
  132835. */
  132836. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132837. /**
  132838. * An event triggered when a transform node is created
  132839. */
  132840. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132841. /**
  132842. * An event triggered when a transform node is removed
  132843. */
  132844. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132845. /**
  132846. * An event triggered when a mesh is created
  132847. */
  132848. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132849. /**
  132850. * An event triggered when a mesh is removed
  132851. */
  132852. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132853. /**
  132854. * An event triggered when a skeleton is created
  132855. */
  132856. _this.onNewSkeletonAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132857. /**
  132858. * An event triggered when a skeleton is removed
  132859. */
  132860. _this.onSkeletonRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132861. /**
  132862. * An event triggered when a material is created
  132863. */
  132864. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132865. /**
  132866. * An event triggered when a material is removed
  132867. */
  132868. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132869. /**
  132870. * An event triggered when a texture is created
  132871. */
  132872. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132873. /**
  132874. * An event triggered when a texture is removed
  132875. */
  132876. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132877. /**
  132878. * An event triggered when render targets are about to be rendered
  132879. * Can happen multiple times per frame.
  132880. */
  132881. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132882. /**
  132883. * An event triggered when render targets were rendered.
  132884. * Can happen multiple times per frame.
  132885. */
  132886. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132887. /**
  132888. * An event triggered before calculating deterministic simulation step
  132889. */
  132890. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132891. /**
  132892. * An event triggered after calculating deterministic simulation step
  132893. */
  132894. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132895. /**
  132896. * An event triggered when the activeCamera property is updated
  132897. */
  132898. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132899. /**
  132900. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  132901. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  132902. * 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)
  132903. */
  132904. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132905. /**
  132906. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  132907. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  132908. * 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)
  132909. */
  132910. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132911. /**
  132912. * This Observable will when a mesh has been imported into the scene.
  132913. */
  132914. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132915. // Animations
  132916. /** @hidden */
  132917. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  132918. /**
  132919. * 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).
  132920. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  132921. */
  132922. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132923. /**
  132924. * Observable event triggered each time an input event is received from the rendering canvas
  132925. */
  132926. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132927. _this._meshPickProceed = false;
  132928. _this._currentPickResult = null;
  132929. _this._previousPickResult = null;
  132930. _this._totalPointersPressed = 0;
  132931. _this._doubleClickOccured = false;
  132932. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  132933. _this.cameraToUseForPointers = null;
  132934. _this._pointerX = 0;
  132935. _this._pointerY = 0;
  132936. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  132937. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  132938. _this._startingPointerTime = 0;
  132939. _this._previousStartingPointerTime = 0;
  132940. _this._pointerCaptures = {};
  132941. // Deterministic lockstep
  132942. _this._timeAccumulator = 0;
  132943. _this._currentStepId = 0;
  132944. _this._currentInternalStep = 0;
  132945. // Keyboard
  132946. /**
  132947. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  132948. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  132949. */
  132950. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132951. /**
  132952. * Observable event triggered each time an keyboard event is received from the hosting window
  132953. */
  132954. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132955. // Coordinates system
  132956. _this._useRightHandedSystem = false;
  132957. // Fog
  132958. _this._fogEnabled = true;
  132959. _this._fogMode = Scene.FOGMODE_NONE;
  132960. /**
  132961. * Gets or sets the fog color to use
  132962. * @see http://doc.babylonjs.com/babylon101/environment#fog
  132963. * (Default is Color3(0.2, 0.2, 0.3))
  132964. */
  132965. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  132966. /**
  132967. * Gets or sets the fog density to use
  132968. * @see http://doc.babylonjs.com/babylon101/environment#fog
  132969. * (Default is 0.1)
  132970. */
  132971. _this.fogDensity = 0.1;
  132972. /**
  132973. * Gets or sets the fog start distance to use
  132974. * @see http://doc.babylonjs.com/babylon101/environment#fog
  132975. * (Default is 0)
  132976. */
  132977. _this.fogStart = 0;
  132978. /**
  132979. * Gets or sets the fog end distance to use
  132980. * @see http://doc.babylonjs.com/babylon101/environment#fog
  132981. * (Default is 1000)
  132982. */
  132983. _this.fogEnd = 1000.0;
  132984. // Lights
  132985. _this._shadowsEnabled = true;
  132986. _this._lightsEnabled = true;
  132987. /** All of the active cameras added to this scene. */
  132988. _this.activeCameras = new Array();
  132989. // Textures
  132990. _this._texturesEnabled = true;
  132991. // Particles
  132992. /**
  132993. * Gets or sets a boolean indicating if particles are enabled on this scene
  132994. */
  132995. _this.particlesEnabled = true;
  132996. // Sprites
  132997. /**
  132998. * Gets or sets a boolean indicating if sprites are enabled on this scene
  132999. */
  133000. _this.spritesEnabled = true;
  133001. // Skeletons
  133002. _this._skeletonsEnabled = true;
  133003. // Lens flares
  133004. /**
  133005. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  133006. */
  133007. _this.lensFlaresEnabled = true;
  133008. // Collisions
  133009. /**
  133010. * Gets or sets a boolean indicating if collisions are enabled on this scene
  133011. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  133012. */
  133013. _this.collisionsEnabled = true;
  133014. /**
  133015. * Defines the gravity applied to this scene (used only for collisions)
  133016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  133017. */
  133018. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  133019. // Postprocesses
  133020. /**
  133021. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  133022. */
  133023. _this.postProcessesEnabled = true;
  133024. /**
  133025. * The list of postprocesses added to the scene
  133026. */
  133027. _this.postProcesses = new Array();
  133028. // Customs render targets
  133029. /**
  133030. * Gets or sets a boolean indicating if render targets are enabled on this scene
  133031. */
  133032. _this.renderTargetsEnabled = true;
  133033. /**
  133034. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  133035. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  133036. */
  133037. _this.dumpNextRenderTargets = false;
  133038. /**
  133039. * The list of user defined render targets added to the scene
  133040. */
  133041. _this.customRenderTargets = new Array();
  133042. /**
  133043. * Gets the list of meshes imported to the scene through SceneLoader
  133044. */
  133045. _this.importedMeshesFiles = new Array();
  133046. // Probes
  133047. /**
  133048. * Gets or sets a boolean indicating if probes are enabled on this scene
  133049. */
  133050. _this.probesEnabled = true;
  133051. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  133052. // Procedural textures
  133053. /**
  133054. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  133055. */
  133056. _this.proceduralTexturesEnabled = true;
  133057. // Performance counters
  133058. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  133059. /** @hidden */
  133060. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  133061. /** @hidden */
  133062. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  133063. /** @hidden */
  133064. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  133065. /** @hidden */
  133066. _this._animationTime = 0;
  133067. /**
  133068. * Gets or sets a general scale for animation speed
  133069. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  133070. */
  133071. _this.animationTimeScale = 1;
  133072. _this._renderId = 0;
  133073. _this._frameId = 0;
  133074. _this._executeWhenReadyTimeoutId = -1;
  133075. _this._intermediateRendering = false;
  133076. _this._viewUpdateFlag = -1;
  133077. _this._projectionUpdateFlag = -1;
  133078. /** @hidden */
  133079. _this._toBeDisposed = new Array(256);
  133080. _this._activeRequests = new Array();
  133081. /** @hidden */
  133082. _this._pendingData = new Array();
  133083. _this._isDisposed = false;
  133084. /**
  133085. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  133086. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  133087. */
  133088. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  133089. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  133090. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  133091. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  133092. /** @hidden */
  133093. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  133094. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  133095. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  133096. /** @hidden */
  133097. _this._activeAnimatables = new Array();
  133098. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  133099. _this._transformMatrixR = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  133100. _this._wheelEventName = "";
  133101. /**
  133102. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  133103. * This is useful if there are more lights that the maximum simulteanous authorized
  133104. */
  133105. _this.requireLightSorting = false;
  133106. /**
  133107. * @hidden
  133108. * Backing store of defined scene components.
  133109. */
  133110. _this._components = [];
  133111. /**
  133112. * @hidden
  133113. * Backing store of defined scene components.
  133114. */
  133115. _this._serializableComponents = [];
  133116. /**
  133117. * List of components to register on the next registration step.
  133118. */
  133119. _this._transientComponents = [];
  133120. /**
  133121. * @hidden
  133122. * Defines the actions happening before camera updates.
  133123. */
  133124. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133125. /**
  133126. * @hidden
  133127. * Defines the actions happening before clear the canvas.
  133128. */
  133129. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133130. /**
  133131. * @hidden
  133132. * Defines the actions when collecting render targets for the frame.
  133133. */
  133134. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133135. /**
  133136. * @hidden
  133137. * Defines the actions happening for one camera in the frame.
  133138. */
  133139. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133140. /**
  133141. * @hidden
  133142. * Defines the actions happening during the per mesh ready checks.
  133143. */
  133144. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133145. /**
  133146. * @hidden
  133147. * Defines the actions happening before evaluate active mesh checks.
  133148. */
  133149. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133150. /**
  133151. * @hidden
  133152. * Defines the actions happening during the evaluate sub mesh checks.
  133153. */
  133154. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133155. /**
  133156. * @hidden
  133157. * Defines the actions happening during the active mesh stage.
  133158. */
  133159. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133160. /**
  133161. * @hidden
  133162. * Defines the actions happening during the per camera render target step.
  133163. */
  133164. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133165. /**
  133166. * @hidden
  133167. * Defines the actions happening just before the active camera is drawing.
  133168. */
  133169. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133170. /**
  133171. * @hidden
  133172. * Defines the actions happening just before a render target is drawing.
  133173. */
  133174. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133175. /**
  133176. * @hidden
  133177. * Defines the actions happening just before a rendering group is drawing.
  133178. */
  133179. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133180. /**
  133181. * @hidden
  133182. * Defines the actions happening just before a mesh is drawing.
  133183. */
  133184. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133185. /**
  133186. * @hidden
  133187. * Defines the actions happening just after a mesh has been drawn.
  133188. */
  133189. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133190. /**
  133191. * @hidden
  133192. * Defines the actions happening just after a rendering group has been drawn.
  133193. */
  133194. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133195. /**
  133196. * @hidden
  133197. * Defines the actions happening just after the active camera has been drawn.
  133198. */
  133199. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133200. /**
  133201. * @hidden
  133202. * Defines the actions happening just after a render target has been drawn.
  133203. */
  133204. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133205. /**
  133206. * @hidden
  133207. * Defines the actions happening just after rendering all cameras and computing intersections.
  133208. */
  133209. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133210. /**
  133211. * @hidden
  133212. * Defines the actions happening when a pointer move event happens.
  133213. */
  133214. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133215. /**
  133216. * @hidden
  133217. * Defines the actions happening when a pointer down event happens.
  133218. */
  133219. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133220. /**
  133221. * @hidden
  133222. * Defines the actions happening when a pointer up event happens.
  133223. */
  133224. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133225. /**
  133226. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  133227. */
  133228. _this.geometriesByUniqueId = null;
  133229. _this._defaultMeshCandidates = {
  133230. data: [],
  133231. length: 0
  133232. };
  133233. _this._defaultSubMeshCandidates = {
  133234. data: [],
  133235. length: 0
  133236. };
  133237. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  133238. _this._activeMeshesFrozen = false;
  133239. /** @hidden */
  133240. _this._allowPostProcessClearColor = true;
  133241. /**
  133242. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  133243. */
  133244. _this.getDeterministicFrameTime = function () {
  133245. return 1000.0 / 60.0; // frame time in ms
  133246. };
  133247. _this._blockMaterialDirtyMechanism = false;
  133248. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  133249. _this._engine.scenes.push(_this);
  133250. _this._uid = null;
  133251. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  133252. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  133253. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  133254. }
  133255. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  133256. _this.attachControl();
  133257. }
  133258. // Uniform Buffer
  133259. _this._createUbo();
  133260. // Default Image processing definition
  133261. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  133262. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  133263. }
  133264. _this.setDefaultCandidateProviders();
  133265. if (options && options.useGeometryUniqueIdsMap === true) {
  133266. _this.geometriesByUniqueId = {};
  133267. }
  133268. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  133269. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  133270. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  133271. return _this;
  133272. }
  133273. /**
  133274. * Factory used to create the default material.
  133275. * @param name The name of the material to create
  133276. * @param scene The scene to create the material for
  133277. * @returns The default material
  133278. */
  133279. Scene.DefaultMaterialFactory = function (scene) {
  133280. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  133281. };
  133282. /**
  133283. * Factory used to create the a collision coordinator.
  133284. * @returns The collision coordinator
  133285. */
  133286. Scene.CollisionCoordinatorFactory = function () {
  133287. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  133288. };
  133289. Object.defineProperty(Scene.prototype, "environmentTexture", {
  133290. /**
  133291. * Texture used in all pbr material as the reflection texture.
  133292. * As in the majority of the scene they are the same (exception for multi room and so on),
  133293. * this is easier to reference from here than from all the materials.
  133294. */
  133295. get: function () {
  133296. return this._environmentTexture;
  133297. },
  133298. /**
  133299. * Texture used in all pbr material as the reflection texture.
  133300. * As in the majority of the scene they are the same (exception for multi room and so on),
  133301. * this is easier to set here than in all the materials.
  133302. */
  133303. set: function (value) {
  133304. if (this._environmentTexture === value) {
  133305. return;
  133306. }
  133307. this._environmentTexture = value;
  133308. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  133309. },
  133310. enumerable: true,
  133311. configurable: true
  133312. });
  133313. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  133314. /**
  133315. * Default image processing configuration used either in the rendering
  133316. * Forward main pass or through the imageProcessingPostProcess if present.
  133317. * As in the majority of the scene they are the same (exception for multi camera),
  133318. * this is easier to reference from here than from all the materials and post process.
  133319. *
  133320. * No setter as we it is a shared configuration, you can set the values instead.
  133321. */
  133322. get: function () {
  133323. return this._imageProcessingConfiguration;
  133324. },
  133325. enumerable: true,
  133326. configurable: true
  133327. });
  133328. Object.defineProperty(Scene.prototype, "forceWireframe", {
  133329. get: function () {
  133330. return this._forceWireframe;
  133331. },
  133332. /**
  133333. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  133334. */
  133335. set: function (value) {
  133336. if (this._forceWireframe === value) {
  133337. return;
  133338. }
  133339. this._forceWireframe = value;
  133340. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  133341. },
  133342. enumerable: true,
  133343. configurable: true
  133344. });
  133345. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  133346. get: function () {
  133347. return this._forcePointsCloud;
  133348. },
  133349. /**
  133350. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  133351. */
  133352. set: function (value) {
  133353. if (this._forcePointsCloud === value) {
  133354. return;
  133355. }
  133356. this._forcePointsCloud = value;
  133357. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  133358. },
  133359. enumerable: true,
  133360. configurable: true
  133361. });
  133362. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  133363. /**
  133364. * Gets or sets the animation properties override
  133365. */
  133366. get: function () {
  133367. return this._animationPropertiesOverride;
  133368. },
  133369. set: function (value) {
  133370. this._animationPropertiesOverride = value;
  133371. },
  133372. enumerable: true,
  133373. configurable: true
  133374. });
  133375. Object.defineProperty(Scene.prototype, "onDispose", {
  133376. /** Sets a function to be executed when this scene is disposed. */
  133377. set: function (callback) {
  133378. if (this._onDisposeObserver) {
  133379. this.onDisposeObservable.remove(this._onDisposeObserver);
  133380. }
  133381. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  133382. },
  133383. enumerable: true,
  133384. configurable: true
  133385. });
  133386. Object.defineProperty(Scene.prototype, "beforeRender", {
  133387. /** Sets a function to be executed before rendering this scene */
  133388. set: function (callback) {
  133389. if (this._onBeforeRenderObserver) {
  133390. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  133391. }
  133392. if (callback) {
  133393. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  133394. }
  133395. },
  133396. enumerable: true,
  133397. configurable: true
  133398. });
  133399. Object.defineProperty(Scene.prototype, "afterRender", {
  133400. /** Sets a function to be executed after rendering this scene */
  133401. set: function (callback) {
  133402. if (this._onAfterRenderObserver) {
  133403. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  133404. }
  133405. if (callback) {
  133406. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  133407. }
  133408. },
  133409. enumerable: true,
  133410. configurable: true
  133411. });
  133412. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  133413. /** Sets a function to be executed before rendering a camera*/
  133414. set: function (callback) {
  133415. if (this._onBeforeCameraRenderObserver) {
  133416. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  133417. }
  133418. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  133419. },
  133420. enumerable: true,
  133421. configurable: true
  133422. });
  133423. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  133424. /** Sets a function to be executed after rendering a camera*/
  133425. set: function (callback) {
  133426. if (this._onAfterCameraRenderObserver) {
  133427. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  133428. }
  133429. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  133430. },
  133431. enumerable: true,
  133432. configurable: true
  133433. });
  133434. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  133435. /**
  133436. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  133437. */
  133438. get: function () {
  133439. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  133440. },
  133441. enumerable: true,
  133442. configurable: true
  133443. });
  133444. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  133445. get: function () {
  133446. return this._useRightHandedSystem;
  133447. },
  133448. /**
  133449. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  133450. */
  133451. set: function (value) {
  133452. if (this._useRightHandedSystem === value) {
  133453. return;
  133454. }
  133455. this._useRightHandedSystem = value;
  133456. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  133457. },
  133458. enumerable: true,
  133459. configurable: true
  133460. });
  133461. /**
  133462. * Sets the step Id used by deterministic lock step
  133463. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  133464. * @param newStepId defines the step Id
  133465. */
  133466. Scene.prototype.setStepId = function (newStepId) {
  133467. this._currentStepId = newStepId;
  133468. };
  133469. /**
  133470. * Gets the step Id used by deterministic lock step
  133471. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  133472. * @returns the step Id
  133473. */
  133474. Scene.prototype.getStepId = function () {
  133475. return this._currentStepId;
  133476. };
  133477. /**
  133478. * Gets the internal step used by deterministic lock step
  133479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  133480. * @returns the internal step
  133481. */
  133482. Scene.prototype.getInternalStep = function () {
  133483. return this._currentInternalStep;
  133484. };
  133485. Object.defineProperty(Scene.prototype, "fogEnabled", {
  133486. get: function () {
  133487. return this._fogEnabled;
  133488. },
  133489. /**
  133490. * Gets or sets a boolean indicating if fog is enabled on this scene
  133491. * @see http://doc.babylonjs.com/babylon101/environment#fog
  133492. * (Default is true)
  133493. */
  133494. set: function (value) {
  133495. if (this._fogEnabled === value) {
  133496. return;
  133497. }
  133498. this._fogEnabled = value;
  133499. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  133500. },
  133501. enumerable: true,
  133502. configurable: true
  133503. });
  133504. Object.defineProperty(Scene.prototype, "fogMode", {
  133505. get: function () {
  133506. return this._fogMode;
  133507. },
  133508. /**
  133509. * Gets or sets the fog mode to use
  133510. * @see http://doc.babylonjs.com/babylon101/environment#fog
  133511. * | mode | value |
  133512. * | --- | --- |
  133513. * | FOGMODE_NONE | 0 |
  133514. * | FOGMODE_EXP | 1 |
  133515. * | FOGMODE_EXP2 | 2 |
  133516. * | FOGMODE_LINEAR | 3 |
  133517. */
  133518. set: function (value) {
  133519. if (this._fogMode === value) {
  133520. return;
  133521. }
  133522. this._fogMode = value;
  133523. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  133524. },
  133525. enumerable: true,
  133526. configurable: true
  133527. });
  133528. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  133529. get: function () {
  133530. return this._shadowsEnabled;
  133531. },
  133532. /**
  133533. * Gets or sets a boolean indicating if shadows are enabled on this scene
  133534. */
  133535. set: function (value) {
  133536. if (this._shadowsEnabled === value) {
  133537. return;
  133538. }
  133539. this._shadowsEnabled = value;
  133540. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  133541. },
  133542. enumerable: true,
  133543. configurable: true
  133544. });
  133545. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  133546. get: function () {
  133547. return this._lightsEnabled;
  133548. },
  133549. /**
  133550. * Gets or sets a boolean indicating if lights are enabled on this scene
  133551. */
  133552. set: function (value) {
  133553. if (this._lightsEnabled === value) {
  133554. return;
  133555. }
  133556. this._lightsEnabled = value;
  133557. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  133558. },
  133559. enumerable: true,
  133560. configurable: true
  133561. });
  133562. Object.defineProperty(Scene.prototype, "activeCamera", {
  133563. /** Gets or sets the current active camera */
  133564. get: function () {
  133565. return this._activeCamera;
  133566. },
  133567. set: function (value) {
  133568. if (value === this._activeCamera) {
  133569. return;
  133570. }
  133571. this._activeCamera = value;
  133572. this.onActiveCameraChanged.notifyObservers(this);
  133573. },
  133574. enumerable: true,
  133575. configurable: true
  133576. });
  133577. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  133578. /** The default material used on meshes when no material is affected */
  133579. get: function () {
  133580. if (!this._defaultMaterial) {
  133581. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  133582. }
  133583. return this._defaultMaterial;
  133584. },
  133585. /** The default material used on meshes when no material is affected */
  133586. set: function (value) {
  133587. this._defaultMaterial = value;
  133588. },
  133589. enumerable: true,
  133590. configurable: true
  133591. });
  133592. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  133593. get: function () {
  133594. return this._texturesEnabled;
  133595. },
  133596. /**
  133597. * Gets or sets a boolean indicating if textures are enabled on this scene
  133598. */
  133599. set: function (value) {
  133600. if (this._texturesEnabled === value) {
  133601. return;
  133602. }
  133603. this._texturesEnabled = value;
  133604. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  133605. },
  133606. enumerable: true,
  133607. configurable: true
  133608. });
  133609. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  133610. get: function () {
  133611. return this._skeletonsEnabled;
  133612. },
  133613. /**
  133614. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  133615. */
  133616. set: function (value) {
  133617. if (this._skeletonsEnabled === value) {
  133618. return;
  133619. }
  133620. this._skeletonsEnabled = value;
  133621. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  133622. },
  133623. enumerable: true,
  133624. configurable: true
  133625. });
  133626. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  133627. /** @hidden */
  133628. get: function () {
  133629. if (!this._collisionCoordinator) {
  133630. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  133631. this._collisionCoordinator.init(this);
  133632. }
  133633. return this._collisionCoordinator;
  133634. },
  133635. enumerable: true,
  133636. configurable: true
  133637. });
  133638. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  133639. /**
  133640. * Gets the list of frustum planes (built from the active camera)
  133641. */
  133642. get: function () {
  133643. return this._frustumPlanes;
  133644. },
  133645. enumerable: true,
  133646. configurable: true
  133647. });
  133648. /**
  133649. * Registers the transient components if needed.
  133650. */
  133651. Scene.prototype._registerTransientComponents = function () {
  133652. // Register components that have been associated lately to the scene.
  133653. if (this._transientComponents.length > 0) {
  133654. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  133655. var component = _a[_i];
  133656. component.register();
  133657. }
  133658. this._transientComponents = [];
  133659. }
  133660. };
  133661. /**
  133662. * @hidden
  133663. * Add a component to the scene.
  133664. * Note that the ccomponent could be registered on th next frame if this is called after
  133665. * the register component stage.
  133666. * @param component Defines the component to add to the scene
  133667. */
  133668. Scene.prototype._addComponent = function (component) {
  133669. this._components.push(component);
  133670. this._transientComponents.push(component);
  133671. var serializableComponent = component;
  133672. if (serializableComponent.addFromContainer) {
  133673. this._serializableComponents.push(serializableComponent);
  133674. }
  133675. };
  133676. /**
  133677. * @hidden
  133678. * Gets a component from the scene.
  133679. * @param name defines the name of the component to retrieve
  133680. * @returns the component or null if not present
  133681. */
  133682. Scene.prototype._getComponent = function (name) {
  133683. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  133684. var component = _a[_i];
  133685. if (component.name === name) {
  133686. return component;
  133687. }
  133688. }
  133689. return null;
  133690. };
  133691. /**
  133692. * Gets a string idenfifying the name of the class
  133693. * @returns "Scene" string
  133694. */
  133695. Scene.prototype.getClassName = function () {
  133696. return "Scene";
  133697. };
  133698. /**
  133699. * @hidden
  133700. */
  133701. Scene.prototype._getDefaultMeshCandidates = function () {
  133702. this._defaultMeshCandidates.data = this.meshes;
  133703. this._defaultMeshCandidates.length = this.meshes.length;
  133704. return this._defaultMeshCandidates;
  133705. };
  133706. /**
  133707. * @hidden
  133708. */
  133709. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  133710. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  133711. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  133712. return this._defaultSubMeshCandidates;
  133713. };
  133714. /**
  133715. * Sets the default candidate providers for the scene.
  133716. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  133717. * and getCollidingSubMeshCandidates to their default function
  133718. */
  133719. Scene.prototype.setDefaultCandidateProviders = function () {
  133720. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  133721. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  133722. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  133723. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  133724. };
  133725. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  133726. /**
  133727. * Gets the mesh that is currently under the pointer
  133728. */
  133729. get: function () {
  133730. return this._pointerOverMesh;
  133731. },
  133732. enumerable: true,
  133733. configurable: true
  133734. });
  133735. Object.defineProperty(Scene.prototype, "pointerX", {
  133736. /**
  133737. * Gets or sets the current on-screen X position of the pointer
  133738. */
  133739. get: function () {
  133740. return this._pointerX;
  133741. },
  133742. set: function (value) {
  133743. this._pointerX = value;
  133744. },
  133745. enumerable: true,
  133746. configurable: true
  133747. });
  133748. Object.defineProperty(Scene.prototype, "pointerY", {
  133749. /**
  133750. * Gets or sets the current on-screen Y position of the pointer
  133751. */
  133752. get: function () {
  133753. return this._pointerY;
  133754. },
  133755. set: function (value) {
  133756. this._pointerY = value;
  133757. },
  133758. enumerable: true,
  133759. configurable: true
  133760. });
  133761. /**
  133762. * Gets the cached material (ie. the latest rendered one)
  133763. * @returns the cached material
  133764. */
  133765. Scene.prototype.getCachedMaterial = function () {
  133766. return this._cachedMaterial;
  133767. };
  133768. /**
  133769. * Gets the cached effect (ie. the latest rendered one)
  133770. * @returns the cached effect
  133771. */
  133772. Scene.prototype.getCachedEffect = function () {
  133773. return this._cachedEffect;
  133774. };
  133775. /**
  133776. * Gets the cached visibility state (ie. the latest rendered one)
  133777. * @returns the cached visibility state
  133778. */
  133779. Scene.prototype.getCachedVisibility = function () {
  133780. return this._cachedVisibility;
  133781. };
  133782. /**
  133783. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  133784. * @param material defines the current material
  133785. * @param effect defines the current effect
  133786. * @param visibility defines the current visibility state
  133787. * @returns true if one parameter is not cached
  133788. */
  133789. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  133790. if (visibility === void 0) { visibility = 1; }
  133791. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  133792. };
  133793. /**
  133794. * Gets the engine associated with the scene
  133795. * @returns an Engine
  133796. */
  133797. Scene.prototype.getEngine = function () {
  133798. return this._engine;
  133799. };
  133800. /**
  133801. * Gets the total number of vertices rendered per frame
  133802. * @returns the total number of vertices rendered per frame
  133803. */
  133804. Scene.prototype.getTotalVertices = function () {
  133805. return this._totalVertices.current;
  133806. };
  133807. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  133808. /**
  133809. * Gets the performance counter for total vertices
  133810. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  133811. */
  133812. get: function () {
  133813. return this._totalVertices;
  133814. },
  133815. enumerable: true,
  133816. configurable: true
  133817. });
  133818. /**
  133819. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  133820. * @returns the total number of active indices rendered per frame
  133821. */
  133822. Scene.prototype.getActiveIndices = function () {
  133823. return this._activeIndices.current;
  133824. };
  133825. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  133826. /**
  133827. * Gets the performance counter for active indices
  133828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  133829. */
  133830. get: function () {
  133831. return this._activeIndices;
  133832. },
  133833. enumerable: true,
  133834. configurable: true
  133835. });
  133836. /**
  133837. * Gets the total number of active particles rendered per frame
  133838. * @returns the total number of active particles rendered per frame
  133839. */
  133840. Scene.prototype.getActiveParticles = function () {
  133841. return this._activeParticles.current;
  133842. };
  133843. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  133844. /**
  133845. * Gets the performance counter for active particles
  133846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  133847. */
  133848. get: function () {
  133849. return this._activeParticles;
  133850. },
  133851. enumerable: true,
  133852. configurable: true
  133853. });
  133854. /**
  133855. * Gets the total number of active bones rendered per frame
  133856. * @returns the total number of active bones rendered per frame
  133857. */
  133858. Scene.prototype.getActiveBones = function () {
  133859. return this._activeBones.current;
  133860. };
  133861. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  133862. /**
  133863. * Gets the performance counter for active bones
  133864. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  133865. */
  133866. get: function () {
  133867. return this._activeBones;
  133868. },
  133869. enumerable: true,
  133870. configurable: true
  133871. });
  133872. /**
  133873. * Gets the array of active meshes
  133874. * @returns an array of AbstractMesh
  133875. */
  133876. Scene.prototype.getActiveMeshes = function () {
  133877. return this._activeMeshes;
  133878. };
  133879. /**
  133880. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  133881. * @returns a number
  133882. */
  133883. Scene.prototype.getAnimationRatio = function () {
  133884. return this._animationRatio !== undefined ? this._animationRatio : 1;
  133885. };
  133886. /**
  133887. * Gets an unique Id for the current render phase
  133888. * @returns a number
  133889. */
  133890. Scene.prototype.getRenderId = function () {
  133891. return this._renderId;
  133892. };
  133893. /**
  133894. * Gets an unique Id for the current frame
  133895. * @returns a number
  133896. */
  133897. Scene.prototype.getFrameId = function () {
  133898. return this._frameId;
  133899. };
  133900. /** Call this function if you want to manually increment the render Id*/
  133901. Scene.prototype.incrementRenderId = function () {
  133902. this._renderId++;
  133903. };
  133904. Scene.prototype._updatePointerPosition = function (evt) {
  133905. var canvasRect = this._engine.getRenderingCanvasClientRect();
  133906. if (!canvasRect) {
  133907. return;
  133908. }
  133909. this._pointerX = evt.clientX - canvasRect.left;
  133910. this._pointerY = evt.clientY - canvasRect.top;
  133911. this._unTranslatedPointerX = this._pointerX;
  133912. this._unTranslatedPointerY = this._pointerY;
  133913. };
  133914. Scene.prototype._createUbo = function () {
  133915. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  133916. this._sceneUbo.addUniform("viewProjection", 16);
  133917. this._sceneUbo.addUniform("view", 16);
  133918. };
  133919. Scene.prototype._createMultiviewUbo = function () {
  133920. this._multiviewSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  133921. this._multiviewSceneUbo.addUniform("viewProjection", 16);
  133922. this._multiviewSceneUbo.addUniform("viewProjectionR", 16);
  133923. this._multiviewSceneUbo.addUniform("view", 16);
  133924. };
  133925. // Pointers handling
  133926. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  133927. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  133928. if (!pointerInfo.pickInfo.ray) {
  133929. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  133930. }
  133931. }
  133932. };
  133933. /**
  133934. * Use this method to simulate a pointer move on a mesh
  133935. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  133936. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  133937. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  133938. * @returns the current scene
  133939. */
  133940. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  133941. var evt = new PointerEvent("pointermove", pointerEventInit);
  133942. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  133943. return this;
  133944. }
  133945. return this._processPointerMove(pickResult, evt);
  133946. };
  133947. Scene.prototype._processPointerMove = function (pickResult, evt) {
  133948. var canvas = this._engine.getRenderingCanvas();
  133949. if (!canvas) {
  133950. return this;
  133951. }
  133952. // Restore pointer
  133953. canvas.style.cursor = this.defaultCursor;
  133954. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  133955. if (isMeshPicked) {
  133956. this.setPointerOverMesh(pickResult.pickedMesh);
  133957. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  133958. if (this._pointerOverMesh.actionManager.hoverCursor) {
  133959. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  133960. }
  133961. else {
  133962. canvas.style.cursor = this.hoverCursor;
  133963. }
  133964. }
  133965. }
  133966. else {
  133967. this.setPointerOverMesh(null);
  133968. }
  133969. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  133970. var step = _a[_i];
  133971. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  133972. }
  133973. if (pickResult) {
  133974. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  133975. if (this.onPointerMove) {
  133976. this.onPointerMove(evt, pickResult, type);
  133977. }
  133978. if (this.onPointerObservable.hasObservers()) {
  133979. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  133980. this._setRayOnPointerInfo(pi);
  133981. this.onPointerObservable.notifyObservers(pi, type);
  133982. }
  133983. }
  133984. return this;
  133985. };
  133986. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  133987. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  133988. if (pickResult) {
  133989. pi.ray = pickResult.ray;
  133990. }
  133991. this.onPrePointerObservable.notifyObservers(pi, type);
  133992. if (pi.skipOnPointerObservable) {
  133993. return true;
  133994. }
  133995. else {
  133996. return false;
  133997. }
  133998. };
  133999. /**
  134000. * Use this method to simulate a pointer down on a mesh
  134001. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  134002. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  134003. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  134004. * @returns the current scene
  134005. */
  134006. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  134007. var evt = new PointerEvent("pointerdown", pointerEventInit);
  134008. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  134009. return this;
  134010. }
  134011. return this._processPointerDown(pickResult, evt);
  134012. };
  134013. Scene.prototype._processPointerDown = function (pickResult, evt) {
  134014. var _this = this;
  134015. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  134016. this._pickedDownMesh = pickResult.pickedMesh;
  134017. var actionManager = pickResult.pickedMesh.actionManager;
  134018. if (actionManager) {
  134019. if (actionManager.hasPickTriggers) {
  134020. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134021. switch (evt.button) {
  134022. case 0:
  134023. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134024. break;
  134025. case 1:
  134026. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134027. break;
  134028. case 2:
  134029. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134030. break;
  134031. }
  134032. }
  134033. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  134034. window.setTimeout(function () {
  134035. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  134036. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  134037. if (_this._totalPointersPressed !== 0 &&
  134038. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  134039. !_this._isPointerSwiping()) {
  134040. _this._startingPointerTime = 0;
  134041. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134042. }
  134043. }
  134044. }, Scene.LongPressDelay);
  134045. }
  134046. }
  134047. }
  134048. else {
  134049. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  134050. var step = _a[_i];
  134051. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  134052. }
  134053. }
  134054. if (pickResult) {
  134055. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  134056. if (this.onPointerDown) {
  134057. this.onPointerDown(evt, pickResult, type);
  134058. }
  134059. if (this.onPointerObservable.hasObservers()) {
  134060. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  134061. this._setRayOnPointerInfo(pi);
  134062. this.onPointerObservable.notifyObservers(pi, type);
  134063. }
  134064. }
  134065. return this;
  134066. };
  134067. /**
  134068. * Use this method to simulate a pointer up on a mesh
  134069. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  134070. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  134071. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  134072. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  134073. * @returns the current scene
  134074. */
  134075. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  134076. var evt = new PointerEvent("pointerup", pointerEventInit);
  134077. var clickInfo = new ClickInfo();
  134078. if (doubleTap) {
  134079. clickInfo.doubleClick = true;
  134080. }
  134081. else {
  134082. clickInfo.singleClick = true;
  134083. }
  134084. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  134085. return this;
  134086. }
  134087. return this._processPointerUp(pickResult, evt, clickInfo);
  134088. };
  134089. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  134090. if (pickResult && pickResult && pickResult.pickedMesh) {
  134091. this._pickedUpMesh = pickResult.pickedMesh;
  134092. if (this._pickedDownMesh === this._pickedUpMesh) {
  134093. if (this.onPointerPick) {
  134094. this.onPointerPick(evt, pickResult);
  134095. }
  134096. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  134097. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  134098. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  134099. this._setRayOnPointerInfo(pi);
  134100. this.onPointerObservable.notifyObservers(pi, type_1);
  134101. }
  134102. }
  134103. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  134104. if (actionManager && !clickInfo.ignore) {
  134105. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134106. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  134107. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134108. }
  134109. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  134110. if (clickInfo.doubleClick && doubleClickActionManager) {
  134111. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134112. }
  134113. }
  134114. }
  134115. else {
  134116. if (!clickInfo.ignore) {
  134117. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  134118. var step = _a[_i];
  134119. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  134120. }
  134121. }
  134122. }
  134123. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  134124. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger);
  134125. if (pickedDownActionManager) {
  134126. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  134127. }
  134128. }
  134129. var type = 0;
  134130. if (this.onPointerObservable.hasObservers()) {
  134131. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  134132. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  134133. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  134134. }
  134135. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  134136. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  134137. }
  134138. if (type) {
  134139. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  134140. this._setRayOnPointerInfo(pi);
  134141. this.onPointerObservable.notifyObservers(pi, type);
  134142. }
  134143. }
  134144. if (!clickInfo.ignore) {
  134145. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  134146. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  134147. this._setRayOnPointerInfo(pi);
  134148. this.onPointerObservable.notifyObservers(pi, type);
  134149. }
  134150. }
  134151. if (this.onPointerUp && !clickInfo.ignore) {
  134152. this.onPointerUp(evt, pickResult, type);
  134153. }
  134154. return this;
  134155. };
  134156. /**
  134157. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  134158. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  134159. * @returns true if the pointer was captured
  134160. */
  134161. Scene.prototype.isPointerCaptured = function (pointerId) {
  134162. if (pointerId === void 0) { pointerId = 0; }
  134163. return this._pointerCaptures[pointerId];
  134164. };
  134165. /** @hidden */
  134166. Scene.prototype._isPointerSwiping = function () {
  134167. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  134168. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  134169. };
  134170. /**
  134171. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  134172. * @param attachUp defines if you want to attach events to pointerup
  134173. * @param attachDown defines if you want to attach events to pointerdown
  134174. * @param attachMove defines if you want to attach events to pointermove
  134175. */
  134176. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  134177. var _this = this;
  134178. if (attachUp === void 0) { attachUp = true; }
  134179. if (attachDown === void 0) { attachDown = true; }
  134180. if (attachMove === void 0) { attachMove = true; }
  134181. this._initActionManager = function (act, clickInfo) {
  134182. if (!_this._meshPickProceed) {
  134183. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  134184. _this._currentPickResult = pickResult;
  134185. if (pickResult) {
  134186. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  134187. }
  134188. _this._meshPickProceed = true;
  134189. }
  134190. return act;
  134191. };
  134192. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  134193. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  134194. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  134195. btn !== _this._previousButtonPressed) {
  134196. _this._doubleClickOccured = false;
  134197. clickInfo.singleClick = true;
  134198. clickInfo.ignore = false;
  134199. cb(clickInfo, _this._currentPickResult);
  134200. }
  134201. };
  134202. this._initClickEvent = function (obs1, obs2, evt, cb) {
  134203. var clickInfo = new ClickInfo();
  134204. _this._currentPickResult = null;
  134205. var act = null;
  134206. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  134207. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  134208. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  134209. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  134210. act = _this._initActionManager(act, clickInfo);
  134211. if (act) {
  134212. checkPicking = act.hasPickTriggers;
  134213. }
  134214. }
  134215. var needToIgnoreNext = false;
  134216. if (checkPicking) {
  134217. var btn = evt.button;
  134218. clickInfo.hasSwiped = _this._isPointerSwiping();
  134219. if (!clickInfo.hasSwiped) {
  134220. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  134221. if (!checkSingleClickImmediately) {
  134222. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  134223. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  134224. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  134225. act = _this._initActionManager(act, clickInfo);
  134226. if (act) {
  134227. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  134228. }
  134229. }
  134230. }
  134231. if (checkSingleClickImmediately) {
  134232. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  134233. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  134234. btn !== _this._previousButtonPressed) {
  134235. clickInfo.singleClick = true;
  134236. cb(clickInfo, _this._currentPickResult);
  134237. needToIgnoreNext = true;
  134238. }
  134239. }
  134240. // at least one double click is required to be check and exclusive double click is enabled
  134241. else {
  134242. // wait that no double click has been raised during the double click delay
  134243. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  134244. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  134245. }
  134246. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  134247. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  134248. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  134249. act = _this._initActionManager(act, clickInfo);
  134250. if (act) {
  134251. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  134252. }
  134253. }
  134254. if (checkDoubleClick) {
  134255. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  134256. if (btn === _this._previousButtonPressed &&
  134257. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  134258. !_this._doubleClickOccured) {
  134259. // pointer has not moved for 2 clicks, it's a double click
  134260. if (!clickInfo.hasSwiped &&
  134261. !_this._isPointerSwiping()) {
  134262. _this._previousStartingPointerTime = 0;
  134263. _this._doubleClickOccured = true;
  134264. clickInfo.doubleClick = true;
  134265. clickInfo.ignore = false;
  134266. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  134267. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  134268. }
  134269. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  134270. cb(clickInfo, _this._currentPickResult);
  134271. }
  134272. // if the two successive clicks are too far, it's just two simple clicks
  134273. else {
  134274. _this._doubleClickOccured = false;
  134275. _this._previousStartingPointerTime = _this._startingPointerTime;
  134276. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  134277. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  134278. _this._previousButtonPressed = btn;
  134279. if (Scene.ExclusiveDoubleClickMode) {
  134280. if (_this._previousDelayedSimpleClickTimeout) {
  134281. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  134282. }
  134283. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  134284. cb(clickInfo, _this._previousPickResult);
  134285. }
  134286. else {
  134287. cb(clickInfo, _this._currentPickResult);
  134288. }
  134289. }
  134290. needToIgnoreNext = true;
  134291. }
  134292. // just the first click of the double has been raised
  134293. else {
  134294. _this._doubleClickOccured = false;
  134295. _this._previousStartingPointerTime = _this._startingPointerTime;
  134296. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  134297. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  134298. _this._previousButtonPressed = btn;
  134299. }
  134300. }
  134301. }
  134302. }
  134303. if (!needToIgnoreNext) {
  134304. cb(clickInfo, _this._currentPickResult);
  134305. }
  134306. };
  134307. this._onPointerMove = function (evt) {
  134308. _this._updatePointerPosition(evt);
  134309. // PreObservable support
  134310. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  134311. return;
  134312. }
  134313. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  134314. return;
  134315. }
  134316. if (!_this.pointerMovePredicate) {
  134317. _this.pointerMovePredicate = function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)) && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0)); };
  134318. }
  134319. // Meshes
  134320. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  134321. _this._processPointerMove(pickResult, evt);
  134322. };
  134323. this._onPointerDown = function (evt) {
  134324. _this._totalPointersPressed++;
  134325. _this._pickedDownMesh = null;
  134326. _this._meshPickProceed = false;
  134327. _this._updatePointerPosition(evt);
  134328. if (_this.preventDefaultOnPointerDown && canvas) {
  134329. evt.preventDefault();
  134330. canvas.focus();
  134331. }
  134332. _this._startingPointerPosition.x = _this._pointerX;
  134333. _this._startingPointerPosition.y = _this._pointerY;
  134334. _this._startingPointerTime = Date.now();
  134335. // PreObservable support
  134336. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  134337. return;
  134338. }
  134339. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  134340. return;
  134341. }
  134342. _this._pointerCaptures[evt.pointerId] = true;
  134343. if (!_this.pointerDownPredicate) {
  134344. _this.pointerDownPredicate = function (mesh) {
  134345. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  134346. };
  134347. }
  134348. // Meshes
  134349. _this._pickedDownMesh = null;
  134350. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  134351. _this._processPointerDown(pickResult, evt);
  134352. };
  134353. this._onPointerUp = function (evt) {
  134354. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  134355. return; // So we need to test it the pointer down was pressed before.
  134356. }
  134357. _this._totalPointersPressed--;
  134358. _this._pickedUpMesh = null;
  134359. _this._meshPickProceed = false;
  134360. _this._updatePointerPosition(evt);
  134361. if (_this.preventDefaultOnPointerUp && canvas) {
  134362. evt.preventDefault();
  134363. canvas.focus();
  134364. }
  134365. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  134366. // PreObservable support
  134367. if (_this.onPrePointerObservable.hasObservers()) {
  134368. if (!clickInfo.ignore) {
  134369. if (!clickInfo.hasSwiped) {
  134370. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  134371. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  134372. return;
  134373. }
  134374. }
  134375. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  134376. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  134377. return;
  134378. }
  134379. }
  134380. }
  134381. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  134382. return;
  134383. }
  134384. }
  134385. }
  134386. if (!_this._pointerCaptures[evt.pointerId]) {
  134387. return;
  134388. }
  134389. _this._pointerCaptures[evt.pointerId] = false;
  134390. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  134391. return;
  134392. }
  134393. if (!_this.pointerUpPredicate) {
  134394. _this.pointerUpPredicate = function (mesh) {
  134395. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  134396. };
  134397. }
  134398. // Meshes
  134399. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  134400. _this._initActionManager(null, clickInfo);
  134401. }
  134402. if (!pickResult) {
  134403. pickResult = _this._currentPickResult;
  134404. }
  134405. _this._processPointerUp(pickResult, evt, clickInfo);
  134406. _this._previousPickResult = _this._currentPickResult;
  134407. });
  134408. };
  134409. this._onKeyDown = function (evt) {
  134410. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  134411. if (_this.onPreKeyboardObservable.hasObservers()) {
  134412. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  134413. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  134414. if (pi.skipOnPointerObservable) {
  134415. return;
  134416. }
  134417. }
  134418. if (_this.onKeyboardObservable.hasObservers()) {
  134419. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  134420. _this.onKeyboardObservable.notifyObservers(pi, type);
  134421. }
  134422. if (_this.actionManager) {
  134423. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  134424. }
  134425. };
  134426. this._onKeyUp = function (evt) {
  134427. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  134428. if (_this.onPreKeyboardObservable.hasObservers()) {
  134429. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  134430. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  134431. if (pi.skipOnPointerObservable) {
  134432. return;
  134433. }
  134434. }
  134435. if (_this.onKeyboardObservable.hasObservers()) {
  134436. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  134437. _this.onKeyboardObservable.notifyObservers(pi, type);
  134438. }
  134439. if (_this.actionManager) {
  134440. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  134441. }
  134442. };
  134443. var engine = this.getEngine();
  134444. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  134445. if (!canvas) {
  134446. return;
  134447. }
  134448. canvas.addEventListener("keydown", _this._onKeyDown, false);
  134449. canvas.addEventListener("keyup", _this._onKeyUp, false);
  134450. });
  134451. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  134452. if (!canvas) {
  134453. return;
  134454. }
  134455. canvas.removeEventListener("keydown", _this._onKeyDown);
  134456. canvas.removeEventListener("keyup", _this._onKeyUp);
  134457. });
  134458. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  134459. var canvas = this._engine.getRenderingCanvas();
  134460. if (!canvas) {
  134461. return;
  134462. }
  134463. if (attachMove) {
  134464. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  134465. // Wheel
  134466. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  134467. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  134468. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  134469. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  134470. }
  134471. if (attachDown) {
  134472. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  134473. }
  134474. if (attachUp) {
  134475. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  134476. }
  134477. canvas.tabIndex = 1;
  134478. };
  134479. /** Detaches all event handlers*/
  134480. Scene.prototype.detachControl = function () {
  134481. var engine = this.getEngine();
  134482. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  134483. var canvas = engine.getRenderingCanvas();
  134484. if (!canvas) {
  134485. return;
  134486. }
  134487. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  134488. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  134489. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  134490. if (this._onCanvasBlurObserver) {
  134491. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  134492. }
  134493. if (this._onCanvasFocusObserver) {
  134494. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  134495. }
  134496. // Wheel
  134497. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  134498. // Keyboard
  134499. canvas.removeEventListener("keydown", this._onKeyDown);
  134500. canvas.removeEventListener("keyup", this._onKeyUp);
  134501. // Observables
  134502. this.onKeyboardObservable.clear();
  134503. this.onPreKeyboardObservable.clear();
  134504. this.onPointerObservable.clear();
  134505. this.onPrePointerObservable.clear();
  134506. };
  134507. /**
  134508. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  134509. * Delay loaded resources are not taking in account
  134510. * @return true if all required resources are ready
  134511. */
  134512. Scene.prototype.isReady = function () {
  134513. if (this._isDisposed) {
  134514. return false;
  134515. }
  134516. var index;
  134517. var engine = this.getEngine();
  134518. // Effects
  134519. if (!engine.areAllEffectsReady()) {
  134520. return false;
  134521. }
  134522. // Pending data
  134523. if (this._pendingData.length > 0) {
  134524. return false;
  134525. }
  134526. // Meshes
  134527. for (index = 0; index < this.meshes.length; index++) {
  134528. var mesh = this.meshes[index];
  134529. if (!mesh.isEnabled()) {
  134530. continue;
  134531. }
  134532. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  134533. continue;
  134534. }
  134535. if (!mesh.isReady(true)) {
  134536. return false;
  134537. }
  134538. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  134539. // Is Ready For Mesh
  134540. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  134541. var step = _a[_i];
  134542. if (!step.action(mesh, hardwareInstancedRendering)) {
  134543. return false;
  134544. }
  134545. }
  134546. }
  134547. // Geometries
  134548. for (index = 0; index < this.geometries.length; index++) {
  134549. var geometry = this.geometries[index];
  134550. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  134551. return false;
  134552. }
  134553. }
  134554. // Post-processes
  134555. if (this.activeCameras && this.activeCameras.length > 0) {
  134556. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  134557. var camera = _c[_b];
  134558. if (!camera.isReady(true)) {
  134559. return false;
  134560. }
  134561. }
  134562. }
  134563. else if (this.activeCamera) {
  134564. if (!this.activeCamera.isReady(true)) {
  134565. return false;
  134566. }
  134567. }
  134568. // Particles
  134569. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  134570. var particleSystem = _e[_d];
  134571. if (!particleSystem.isReady()) {
  134572. return false;
  134573. }
  134574. }
  134575. return true;
  134576. };
  134577. /** Resets all cached information relative to material (including effect and visibility) */
  134578. Scene.prototype.resetCachedMaterial = function () {
  134579. this._cachedMaterial = null;
  134580. this._cachedEffect = null;
  134581. this._cachedVisibility = null;
  134582. };
  134583. /**
  134584. * Registers a function to be called before every frame render
  134585. * @param func defines the function to register
  134586. */
  134587. Scene.prototype.registerBeforeRender = function (func) {
  134588. this.onBeforeRenderObservable.add(func);
  134589. };
  134590. /**
  134591. * Unregisters a function called before every frame render
  134592. * @param func defines the function to unregister
  134593. */
  134594. Scene.prototype.unregisterBeforeRender = function (func) {
  134595. this.onBeforeRenderObservable.removeCallback(func);
  134596. };
  134597. /**
  134598. * Registers a function to be called after every frame render
  134599. * @param func defines the function to register
  134600. */
  134601. Scene.prototype.registerAfterRender = function (func) {
  134602. this.onAfterRenderObservable.add(func);
  134603. };
  134604. /**
  134605. * Unregisters a function called after every frame render
  134606. * @param func defines the function to unregister
  134607. */
  134608. Scene.prototype.unregisterAfterRender = function (func) {
  134609. this.onAfterRenderObservable.removeCallback(func);
  134610. };
  134611. Scene.prototype._executeOnceBeforeRender = function (func) {
  134612. var _this = this;
  134613. var execFunc = function () {
  134614. func();
  134615. setTimeout(function () {
  134616. _this.unregisterBeforeRender(execFunc);
  134617. });
  134618. };
  134619. this.registerBeforeRender(execFunc);
  134620. };
  134621. /**
  134622. * The provided function will run before render once and will be disposed afterwards.
  134623. * A timeout delay can be provided so that the function will be executed in N ms.
  134624. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  134625. * @param func The function to be executed.
  134626. * @param timeout optional delay in ms
  134627. */
  134628. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  134629. var _this = this;
  134630. if (timeout !== undefined) {
  134631. setTimeout(function () {
  134632. _this._executeOnceBeforeRender(func);
  134633. }, timeout);
  134634. }
  134635. else {
  134636. this._executeOnceBeforeRender(func);
  134637. }
  134638. };
  134639. /** @hidden */
  134640. Scene.prototype._addPendingData = function (data) {
  134641. this._pendingData.push(data);
  134642. };
  134643. /** @hidden */
  134644. Scene.prototype._removePendingData = function (data) {
  134645. var wasLoading = this.isLoading;
  134646. var index = this._pendingData.indexOf(data);
  134647. if (index !== -1) {
  134648. this._pendingData.splice(index, 1);
  134649. }
  134650. if (wasLoading && !this.isLoading) {
  134651. this.onDataLoadedObservable.notifyObservers(this);
  134652. }
  134653. };
  134654. /**
  134655. * Returns the number of items waiting to be loaded
  134656. * @returns the number of items waiting to be loaded
  134657. */
  134658. Scene.prototype.getWaitingItemsCount = function () {
  134659. return this._pendingData.length;
  134660. };
  134661. Object.defineProperty(Scene.prototype, "isLoading", {
  134662. /**
  134663. * Returns a boolean indicating if the scene is still loading data
  134664. */
  134665. get: function () {
  134666. return this._pendingData.length > 0;
  134667. },
  134668. enumerable: true,
  134669. configurable: true
  134670. });
  134671. /**
  134672. * Registers a function to be executed when the scene is ready
  134673. * @param {Function} func - the function to be executed
  134674. */
  134675. Scene.prototype.executeWhenReady = function (func) {
  134676. var _this = this;
  134677. this.onReadyObservable.add(func);
  134678. if (this._executeWhenReadyTimeoutId !== -1) {
  134679. return;
  134680. }
  134681. this._executeWhenReadyTimeoutId = setTimeout(function () {
  134682. _this._checkIsReady();
  134683. }, 150);
  134684. };
  134685. /**
  134686. * Returns a promise that resolves when the scene is ready
  134687. * @returns A promise that resolves when the scene is ready
  134688. */
  134689. Scene.prototype.whenReadyAsync = function () {
  134690. var _this = this;
  134691. return new Promise(function (resolve) {
  134692. _this.executeWhenReady(function () {
  134693. resolve();
  134694. });
  134695. });
  134696. };
  134697. /** @hidden */
  134698. Scene.prototype._checkIsReady = function () {
  134699. var _this = this;
  134700. this._registerTransientComponents();
  134701. if (this.isReady()) {
  134702. this.onReadyObservable.notifyObservers(this);
  134703. this.onReadyObservable.clear();
  134704. this._executeWhenReadyTimeoutId = -1;
  134705. return;
  134706. }
  134707. this._executeWhenReadyTimeoutId = setTimeout(function () {
  134708. _this._checkIsReady();
  134709. }, 150);
  134710. };
  134711. Object.defineProperty(Scene.prototype, "animatables", {
  134712. /**
  134713. * Gets all animatable attached to the scene
  134714. */
  134715. get: function () {
  134716. return this._activeAnimatables;
  134717. },
  134718. enumerable: true,
  134719. configurable: true
  134720. });
  134721. /**
  134722. * Resets the last animation time frame.
  134723. * Useful to override when animations start running when loading a scene for the first time.
  134724. */
  134725. Scene.prototype.resetLastAnimationTimeFrame = function () {
  134726. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  134727. };
  134728. // Matrix
  134729. /**
  134730. * Gets the current view matrix
  134731. * @returns a Matrix
  134732. */
  134733. Scene.prototype.getViewMatrix = function () {
  134734. return this._viewMatrix;
  134735. };
  134736. /**
  134737. * Gets the current projection matrix
  134738. * @returns a Matrix
  134739. */
  134740. Scene.prototype.getProjectionMatrix = function () {
  134741. return this._projectionMatrix;
  134742. };
  134743. /**
  134744. * Gets the current transform matrix
  134745. * @returns a Matrix made of View * Projection
  134746. */
  134747. Scene.prototype.getTransformMatrix = function () {
  134748. return this._transformMatrix;
  134749. };
  134750. /**
  134751. * Sets the current transform matrix
  134752. * @param viewL defines the View matrix to use
  134753. * @param projectionL defines the Projection matrix to use
  134754. * @param viewR defines the right View matrix to use (if provided)
  134755. * @param projectionR defines the right Projection matrix to use (if provided)
  134756. */
  134757. Scene.prototype.setTransformMatrix = function (viewL, projectionL, viewR, projectionR) {
  134758. if (this._viewUpdateFlag === viewL.updateFlag && this._projectionUpdateFlag === projectionL.updateFlag) {
  134759. return;
  134760. }
  134761. this._viewUpdateFlag = viewL.updateFlag;
  134762. this._projectionUpdateFlag = projectionL.updateFlag;
  134763. this._viewMatrix = viewL;
  134764. this._projectionMatrix = projectionL;
  134765. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  134766. if (viewR && projectionR) {
  134767. viewR.multiplyToRef(projectionR, this._transformMatrixR);
  134768. }
  134769. // Update frustum
  134770. if (!this._frustumPlanes) {
  134771. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  134772. }
  134773. else {
  134774. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  134775. }
  134776. if (viewR && projectionR) {
  134777. viewR.multiplyToRef(projectionR, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  134778. _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
  134779. }
  134780. if (this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo) {
  134781. this._multiviewSceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  134782. this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR);
  134783. this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix);
  134784. this._multiviewSceneUbo.update();
  134785. }
  134786. else if (this._sceneUbo.useUbo) {
  134787. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  134788. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  134789. this._sceneUbo.update();
  134790. }
  134791. };
  134792. /**
  134793. * Gets the uniform buffer used to store scene data
  134794. * @returns a UniformBuffer
  134795. */
  134796. Scene.prototype.getSceneUniformBuffer = function () {
  134797. return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo;
  134798. };
  134799. /**
  134800. * Gets an unique (relatively to the current scene) Id
  134801. * @returns an unique number for the scene
  134802. */
  134803. Scene.prototype.getUniqueId = function () {
  134804. var result = Scene._uniqueIdCounter;
  134805. Scene._uniqueIdCounter++;
  134806. return result;
  134807. };
  134808. /**
  134809. * Add a mesh to the list of scene's meshes
  134810. * @param newMesh defines the mesh to add
  134811. * @param recursive if all child meshes should also be added to the scene
  134812. */
  134813. Scene.prototype.addMesh = function (newMesh, recursive) {
  134814. var _this = this;
  134815. if (recursive === void 0) { recursive = false; }
  134816. this.meshes.push(newMesh);
  134817. newMesh._resyncLightSources();
  134818. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  134819. if (recursive) {
  134820. newMesh.getChildMeshes().forEach(function (m) {
  134821. _this.addMesh(m);
  134822. });
  134823. }
  134824. };
  134825. /**
  134826. * Remove a mesh for the list of scene's meshes
  134827. * @param toRemove defines the mesh to remove
  134828. * @param recursive if all child meshes should also be removed from the scene
  134829. * @returns the index where the mesh was in the mesh list
  134830. */
  134831. Scene.prototype.removeMesh = function (toRemove, recursive) {
  134832. var _this = this;
  134833. if (recursive === void 0) { recursive = false; }
  134834. var index = this.meshes.indexOf(toRemove);
  134835. if (index !== -1) {
  134836. // Remove from the scene if mesh found
  134837. this.meshes[index] = this.meshes[this.meshes.length - 1];
  134838. this.meshes.pop();
  134839. }
  134840. this.onMeshRemovedObservable.notifyObservers(toRemove);
  134841. if (recursive) {
  134842. toRemove.getChildMeshes().forEach(function (m) {
  134843. _this.removeMesh(m);
  134844. });
  134845. }
  134846. return index;
  134847. };
  134848. /**
  134849. * Add a transform node to the list of scene's transform nodes
  134850. * @param newTransformNode defines the transform node to add
  134851. */
  134852. Scene.prototype.addTransformNode = function (newTransformNode) {
  134853. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  134854. this.transformNodes.push(newTransformNode);
  134855. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  134856. };
  134857. /**
  134858. * Remove a transform node for the list of scene's transform nodes
  134859. * @param toRemove defines the transform node to remove
  134860. * @returns the index where the transform node was in the transform node list
  134861. */
  134862. Scene.prototype.removeTransformNode = function (toRemove) {
  134863. var index = toRemove._indexInSceneTransformNodesArray;
  134864. if (index !== -1) {
  134865. if (index !== this.transformNodes.length - 1) {
  134866. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  134867. this.transformNodes[index] = lastNode;
  134868. lastNode._indexInSceneTransformNodesArray = index;
  134869. }
  134870. toRemove._indexInSceneTransformNodesArray = -1;
  134871. this.transformNodes.pop();
  134872. }
  134873. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  134874. return index;
  134875. };
  134876. /**
  134877. * Remove a skeleton for the list of scene's skeletons
  134878. * @param toRemove defines the skeleton to remove
  134879. * @returns the index where the skeleton was in the skeleton list
  134880. */
  134881. Scene.prototype.removeSkeleton = function (toRemove) {
  134882. var index = this.skeletons.indexOf(toRemove);
  134883. if (index !== -1) {
  134884. // Remove from the scene if found
  134885. this.skeletons.splice(index, 1);
  134886. this.onSkeletonRemovedObservable.notifyObservers(toRemove);
  134887. }
  134888. return index;
  134889. };
  134890. /**
  134891. * Remove a morph target for the list of scene's morph targets
  134892. * @param toRemove defines the morph target to remove
  134893. * @returns the index where the morph target was in the morph target list
  134894. */
  134895. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  134896. var index = this.morphTargetManagers.indexOf(toRemove);
  134897. if (index !== -1) {
  134898. // Remove from the scene if found
  134899. this.morphTargetManagers.splice(index, 1);
  134900. }
  134901. return index;
  134902. };
  134903. /**
  134904. * Remove a light for the list of scene's lights
  134905. * @param toRemove defines the light to remove
  134906. * @returns the index where the light was in the light list
  134907. */
  134908. Scene.prototype.removeLight = function (toRemove) {
  134909. var index = this.lights.indexOf(toRemove);
  134910. if (index !== -1) {
  134911. // Remove from meshes
  134912. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  134913. var mesh = _a[_i];
  134914. mesh._removeLightSource(toRemove);
  134915. }
  134916. // Remove from the scene if mesh found
  134917. this.lights.splice(index, 1);
  134918. this.sortLightsByPriority();
  134919. }
  134920. this.onLightRemovedObservable.notifyObservers(toRemove);
  134921. return index;
  134922. };
  134923. /**
  134924. * Remove a camera for the list of scene's cameras
  134925. * @param toRemove defines the camera to remove
  134926. * @returns the index where the camera was in the camera list
  134927. */
  134928. Scene.prototype.removeCamera = function (toRemove) {
  134929. var index = this.cameras.indexOf(toRemove);
  134930. if (index !== -1) {
  134931. // Remove from the scene if mesh found
  134932. this.cameras.splice(index, 1);
  134933. }
  134934. // Remove from activeCameras
  134935. var index2 = this.activeCameras.indexOf(toRemove);
  134936. if (index2 !== -1) {
  134937. // Remove from the scene if mesh found
  134938. this.activeCameras.splice(index2, 1);
  134939. }
  134940. // Reset the activeCamera
  134941. if (this.activeCamera === toRemove) {
  134942. if (this.cameras.length > 0) {
  134943. this.activeCamera = this.cameras[0];
  134944. }
  134945. else {
  134946. this.activeCamera = null;
  134947. }
  134948. }
  134949. this.onCameraRemovedObservable.notifyObservers(toRemove);
  134950. return index;
  134951. };
  134952. /**
  134953. * Remove a particle system for the list of scene's particle systems
  134954. * @param toRemove defines the particle system to remove
  134955. * @returns the index where the particle system was in the particle system list
  134956. */
  134957. Scene.prototype.removeParticleSystem = function (toRemove) {
  134958. var index = this.particleSystems.indexOf(toRemove);
  134959. if (index !== -1) {
  134960. this.particleSystems.splice(index, 1);
  134961. }
  134962. return index;
  134963. };
  134964. /**
  134965. * Remove a animation for the list of scene's animations
  134966. * @param toRemove defines the animation to remove
  134967. * @returns the index where the animation was in the animation list
  134968. */
  134969. Scene.prototype.removeAnimation = function (toRemove) {
  134970. var index = this.animations.indexOf(toRemove);
  134971. if (index !== -1) {
  134972. this.animations.splice(index, 1);
  134973. }
  134974. return index;
  134975. };
  134976. /**
  134977. * Removes the given animation group from this scene.
  134978. * @param toRemove The animation group to remove
  134979. * @returns The index of the removed animation group
  134980. */
  134981. Scene.prototype.removeAnimationGroup = function (toRemove) {
  134982. var index = this.animationGroups.indexOf(toRemove);
  134983. if (index !== -1) {
  134984. this.animationGroups.splice(index, 1);
  134985. }
  134986. return index;
  134987. };
  134988. /**
  134989. * Removes the given multi-material from this scene.
  134990. * @param toRemove The multi-material to remove
  134991. * @returns The index of the removed multi-material
  134992. */
  134993. Scene.prototype.removeMultiMaterial = function (toRemove) {
  134994. var index = this.multiMaterials.indexOf(toRemove);
  134995. if (index !== -1) {
  134996. this.multiMaterials.splice(index, 1);
  134997. }
  134998. return index;
  134999. };
  135000. /**
  135001. * Removes the given material from this scene.
  135002. * @param toRemove The material to remove
  135003. * @returns The index of the removed material
  135004. */
  135005. Scene.prototype.removeMaterial = function (toRemove) {
  135006. var index = toRemove._indexInSceneMaterialArray;
  135007. if (index !== -1 && index < this.materials.length) {
  135008. if (index !== this.materials.length - 1) {
  135009. var lastMaterial = this.materials[this.materials.length - 1];
  135010. this.materials[index] = lastMaterial;
  135011. lastMaterial._indexInSceneMaterialArray = index;
  135012. }
  135013. toRemove._indexInSceneMaterialArray = -1;
  135014. this.materials.pop();
  135015. }
  135016. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  135017. return index;
  135018. };
  135019. /**
  135020. * Removes the given action manager from this scene.
  135021. * @param toRemove The action manager to remove
  135022. * @returns The index of the removed action manager
  135023. */
  135024. Scene.prototype.removeActionManager = function (toRemove) {
  135025. var index = this.actionManagers.indexOf(toRemove);
  135026. if (index !== -1) {
  135027. this.actionManagers.splice(index, 1);
  135028. }
  135029. return index;
  135030. };
  135031. /**
  135032. * Removes the given texture from this scene.
  135033. * @param toRemove The texture to remove
  135034. * @returns The index of the removed texture
  135035. */
  135036. Scene.prototype.removeTexture = function (toRemove) {
  135037. var index = this.textures.indexOf(toRemove);
  135038. if (index !== -1) {
  135039. this.textures.splice(index, 1);
  135040. }
  135041. this.onTextureRemovedObservable.notifyObservers(toRemove);
  135042. return index;
  135043. };
  135044. /**
  135045. * Adds the given light to this scene
  135046. * @param newLight The light to add
  135047. */
  135048. Scene.prototype.addLight = function (newLight) {
  135049. this.lights.push(newLight);
  135050. this.sortLightsByPriority();
  135051. // Add light to all meshes (To support if the light is removed and then readded)
  135052. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  135053. var mesh = _a[_i];
  135054. if (mesh._lightSources.indexOf(newLight) === -1) {
  135055. mesh._lightSources.push(newLight);
  135056. mesh._resyncLightSources();
  135057. }
  135058. }
  135059. this.onNewLightAddedObservable.notifyObservers(newLight);
  135060. };
  135061. /**
  135062. * Sorts the list list based on light priorities
  135063. */
  135064. Scene.prototype.sortLightsByPriority = function () {
  135065. if (this.requireLightSorting) {
  135066. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  135067. }
  135068. };
  135069. /**
  135070. * Adds the given camera to this scene
  135071. * @param newCamera The camera to add
  135072. */
  135073. Scene.prototype.addCamera = function (newCamera) {
  135074. this.cameras.push(newCamera);
  135075. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  135076. };
  135077. /**
  135078. * Adds the given skeleton to this scene
  135079. * @param newSkeleton The skeleton to add
  135080. */
  135081. Scene.prototype.addSkeleton = function (newSkeleton) {
  135082. this.skeletons.push(newSkeleton);
  135083. this.onNewSkeletonAddedObservable.notifyObservers(newSkeleton);
  135084. };
  135085. /**
  135086. * Adds the given particle system to this scene
  135087. * @param newParticleSystem The particle system to add
  135088. */
  135089. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  135090. this.particleSystems.push(newParticleSystem);
  135091. };
  135092. /**
  135093. * Adds the given animation to this scene
  135094. * @param newAnimation The animation to add
  135095. */
  135096. Scene.prototype.addAnimation = function (newAnimation) {
  135097. this.animations.push(newAnimation);
  135098. };
  135099. /**
  135100. * Adds the given animation group to this scene.
  135101. * @param newAnimationGroup The animation group to add
  135102. */
  135103. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  135104. this.animationGroups.push(newAnimationGroup);
  135105. };
  135106. /**
  135107. * Adds the given multi-material to this scene
  135108. * @param newMultiMaterial The multi-material to add
  135109. */
  135110. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  135111. this.multiMaterials.push(newMultiMaterial);
  135112. };
  135113. /**
  135114. * Adds the given material to this scene
  135115. * @param newMaterial The material to add
  135116. */
  135117. Scene.prototype.addMaterial = function (newMaterial) {
  135118. newMaterial._indexInSceneMaterialArray = this.materials.length;
  135119. this.materials.push(newMaterial);
  135120. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  135121. };
  135122. /**
  135123. * Adds the given morph target to this scene
  135124. * @param newMorphTargetManager The morph target to add
  135125. */
  135126. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  135127. this.morphTargetManagers.push(newMorphTargetManager);
  135128. };
  135129. /**
  135130. * Adds the given geometry to this scene
  135131. * @param newGeometry The geometry to add
  135132. */
  135133. Scene.prototype.addGeometry = function (newGeometry) {
  135134. if (this.geometriesByUniqueId) {
  135135. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  135136. }
  135137. this.geometries.push(newGeometry);
  135138. };
  135139. /**
  135140. * Adds the given action manager to this scene
  135141. * @param newActionManager The action manager to add
  135142. */
  135143. Scene.prototype.addActionManager = function (newActionManager) {
  135144. this.actionManagers.push(newActionManager);
  135145. };
  135146. /**
  135147. * Adds the given texture to this scene.
  135148. * @param newTexture The texture to add
  135149. */
  135150. Scene.prototype.addTexture = function (newTexture) {
  135151. this.textures.push(newTexture);
  135152. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  135153. };
  135154. /**
  135155. * Switch active camera
  135156. * @param newCamera defines the new active camera
  135157. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  135158. */
  135159. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  135160. if (attachControl === void 0) { attachControl = true; }
  135161. var canvas = this._engine.getRenderingCanvas();
  135162. if (!canvas) {
  135163. return;
  135164. }
  135165. if (this.activeCamera) {
  135166. this.activeCamera.detachControl(canvas);
  135167. }
  135168. this.activeCamera = newCamera;
  135169. if (attachControl) {
  135170. newCamera.attachControl(canvas);
  135171. }
  135172. };
  135173. /**
  135174. * sets the active camera of the scene using its ID
  135175. * @param id defines the camera's ID
  135176. * @return the new active camera or null if none found.
  135177. */
  135178. Scene.prototype.setActiveCameraByID = function (id) {
  135179. var camera = this.getCameraByID(id);
  135180. if (camera) {
  135181. this.activeCamera = camera;
  135182. return camera;
  135183. }
  135184. return null;
  135185. };
  135186. /**
  135187. * sets the active camera of the scene using its name
  135188. * @param name defines the camera's name
  135189. * @returns the new active camera or null if none found.
  135190. */
  135191. Scene.prototype.setActiveCameraByName = function (name) {
  135192. var camera = this.getCameraByName(name);
  135193. if (camera) {
  135194. this.activeCamera = camera;
  135195. return camera;
  135196. }
  135197. return null;
  135198. };
  135199. /**
  135200. * get an animation group using its name
  135201. * @param name defines the material's name
  135202. * @return the animation group or null if none found.
  135203. */
  135204. Scene.prototype.getAnimationGroupByName = function (name) {
  135205. for (var index = 0; index < this.animationGroups.length; index++) {
  135206. if (this.animationGroups[index].name === name) {
  135207. return this.animationGroups[index];
  135208. }
  135209. }
  135210. return null;
  135211. };
  135212. /**
  135213. * Get a material using its unique id
  135214. * @param uniqueId defines the material's unique id
  135215. * @return the material or null if none found.
  135216. */
  135217. Scene.prototype.getMaterialByUniqueID = function (uniqueId) {
  135218. for (var index = 0; index < this.materials.length; index++) {
  135219. if (this.materials[index].uniqueId === uniqueId) {
  135220. return this.materials[index];
  135221. }
  135222. }
  135223. return null;
  135224. };
  135225. /**
  135226. * get a material using its id
  135227. * @param id defines the material's ID
  135228. * @return the material or null if none found.
  135229. */
  135230. Scene.prototype.getMaterialByID = function (id) {
  135231. for (var index = 0; index < this.materials.length; index++) {
  135232. if (this.materials[index].id === id) {
  135233. return this.materials[index];
  135234. }
  135235. }
  135236. return null;
  135237. };
  135238. /**
  135239. * Gets a material using its name
  135240. * @param name defines the material's name
  135241. * @return the material or null if none found.
  135242. */
  135243. Scene.prototype.getMaterialByName = function (name) {
  135244. for (var index = 0; index < this.materials.length; index++) {
  135245. if (this.materials[index].name === name) {
  135246. return this.materials[index];
  135247. }
  135248. }
  135249. return null;
  135250. };
  135251. /**
  135252. * Gets a camera using its id
  135253. * @param id defines the id to look for
  135254. * @returns the camera or null if not found
  135255. */
  135256. Scene.prototype.getCameraByID = function (id) {
  135257. for (var index = 0; index < this.cameras.length; index++) {
  135258. if (this.cameras[index].id === id) {
  135259. return this.cameras[index];
  135260. }
  135261. }
  135262. return null;
  135263. };
  135264. /**
  135265. * Gets a camera using its unique id
  135266. * @param uniqueId defines the unique id to look for
  135267. * @returns the camera or null if not found
  135268. */
  135269. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  135270. for (var index = 0; index < this.cameras.length; index++) {
  135271. if (this.cameras[index].uniqueId === uniqueId) {
  135272. return this.cameras[index];
  135273. }
  135274. }
  135275. return null;
  135276. };
  135277. /**
  135278. * Gets a camera using its name
  135279. * @param name defines the camera's name
  135280. * @return the camera or null if none found.
  135281. */
  135282. Scene.prototype.getCameraByName = function (name) {
  135283. for (var index = 0; index < this.cameras.length; index++) {
  135284. if (this.cameras[index].name === name) {
  135285. return this.cameras[index];
  135286. }
  135287. }
  135288. return null;
  135289. };
  135290. /**
  135291. * Gets a bone using its id
  135292. * @param id defines the bone's id
  135293. * @return the bone or null if not found
  135294. */
  135295. Scene.prototype.getBoneByID = function (id) {
  135296. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  135297. var skeleton = this.skeletons[skeletonIndex];
  135298. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  135299. if (skeleton.bones[boneIndex].id === id) {
  135300. return skeleton.bones[boneIndex];
  135301. }
  135302. }
  135303. }
  135304. return null;
  135305. };
  135306. /**
  135307. * Gets a bone using its id
  135308. * @param name defines the bone's name
  135309. * @return the bone or null if not found
  135310. */
  135311. Scene.prototype.getBoneByName = function (name) {
  135312. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  135313. var skeleton = this.skeletons[skeletonIndex];
  135314. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  135315. if (skeleton.bones[boneIndex].name === name) {
  135316. return skeleton.bones[boneIndex];
  135317. }
  135318. }
  135319. }
  135320. return null;
  135321. };
  135322. /**
  135323. * Gets a light node using its name
  135324. * @param name defines the the light's name
  135325. * @return the light or null if none found.
  135326. */
  135327. Scene.prototype.getLightByName = function (name) {
  135328. for (var index = 0; index < this.lights.length; index++) {
  135329. if (this.lights[index].name === name) {
  135330. return this.lights[index];
  135331. }
  135332. }
  135333. return null;
  135334. };
  135335. /**
  135336. * Gets a light node using its id
  135337. * @param id defines the light's id
  135338. * @return the light or null if none found.
  135339. */
  135340. Scene.prototype.getLightByID = function (id) {
  135341. for (var index = 0; index < this.lights.length; index++) {
  135342. if (this.lights[index].id === id) {
  135343. return this.lights[index];
  135344. }
  135345. }
  135346. return null;
  135347. };
  135348. /**
  135349. * Gets a light node using its scene-generated unique ID
  135350. * @param uniqueId defines the light's unique id
  135351. * @return the light or null if none found.
  135352. */
  135353. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  135354. for (var index = 0; index < this.lights.length; index++) {
  135355. if (this.lights[index].uniqueId === uniqueId) {
  135356. return this.lights[index];
  135357. }
  135358. }
  135359. return null;
  135360. };
  135361. /**
  135362. * Gets a particle system by id
  135363. * @param id defines the particle system id
  135364. * @return the corresponding system or null if none found
  135365. */
  135366. Scene.prototype.getParticleSystemByID = function (id) {
  135367. for (var index = 0; index < this.particleSystems.length; index++) {
  135368. if (this.particleSystems[index].id === id) {
  135369. return this.particleSystems[index];
  135370. }
  135371. }
  135372. return null;
  135373. };
  135374. /**
  135375. * Gets a geometry using its ID
  135376. * @param id defines the geometry's id
  135377. * @return the geometry or null if none found.
  135378. */
  135379. Scene.prototype.getGeometryByID = function (id) {
  135380. for (var index = 0; index < this.geometries.length; index++) {
  135381. if (this.geometries[index].id === id) {
  135382. return this.geometries[index];
  135383. }
  135384. }
  135385. return null;
  135386. };
  135387. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  135388. if (this.geometriesByUniqueId) {
  135389. var index_1 = this.geometriesByUniqueId[uniqueId];
  135390. if (index_1 !== undefined) {
  135391. return this.geometries[index_1];
  135392. }
  135393. }
  135394. else {
  135395. for (var index = 0; index < this.geometries.length; index++) {
  135396. if (this.geometries[index].uniqueId === uniqueId) {
  135397. return this.geometries[index];
  135398. }
  135399. }
  135400. }
  135401. return null;
  135402. };
  135403. /**
  135404. * Add a new geometry to this scene
  135405. * @param geometry defines the geometry to be added to the scene.
  135406. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  135407. * @return a boolean defining if the geometry was added or not
  135408. */
  135409. Scene.prototype.pushGeometry = function (geometry, force) {
  135410. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  135411. return false;
  135412. }
  135413. this.addGeometry(geometry);
  135414. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  135415. return true;
  135416. };
  135417. /**
  135418. * Removes an existing geometry
  135419. * @param geometry defines the geometry to be removed from the scene
  135420. * @return a boolean defining if the geometry was removed or not
  135421. */
  135422. Scene.prototype.removeGeometry = function (geometry) {
  135423. var index;
  135424. if (this.geometriesByUniqueId) {
  135425. index = this.geometriesByUniqueId[geometry.uniqueId];
  135426. if (index === undefined) {
  135427. return false;
  135428. }
  135429. }
  135430. else {
  135431. index = this.geometries.indexOf(geometry);
  135432. if (index < 0) {
  135433. return false;
  135434. }
  135435. }
  135436. if (index !== this.geometries.length - 1) {
  135437. var lastGeometry = this.geometries[this.geometries.length - 1];
  135438. this.geometries[index] = lastGeometry;
  135439. if (this.geometriesByUniqueId) {
  135440. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  135441. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  135442. }
  135443. }
  135444. this.geometries.pop();
  135445. this.onGeometryRemovedObservable.notifyObservers(geometry);
  135446. return true;
  135447. };
  135448. /**
  135449. * Gets the list of geometries attached to the scene
  135450. * @returns an array of Geometry
  135451. */
  135452. Scene.prototype.getGeometries = function () {
  135453. return this.geometries;
  135454. };
  135455. /**
  135456. * Gets the first added mesh found of a given ID
  135457. * @param id defines the id to search for
  135458. * @return the mesh found or null if not found at all
  135459. */
  135460. Scene.prototype.getMeshByID = function (id) {
  135461. for (var index = 0; index < this.meshes.length; index++) {
  135462. if (this.meshes[index].id === id) {
  135463. return this.meshes[index];
  135464. }
  135465. }
  135466. return null;
  135467. };
  135468. /**
  135469. * Gets a list of meshes using their id
  135470. * @param id defines the id to search for
  135471. * @returns a list of meshes
  135472. */
  135473. Scene.prototype.getMeshesByID = function (id) {
  135474. return this.meshes.filter(function (m) {
  135475. return m.id === id;
  135476. });
  135477. };
  135478. /**
  135479. * Gets the first added transform node found of a given ID
  135480. * @param id defines the id to search for
  135481. * @return the found transform node or null if not found at all.
  135482. */
  135483. Scene.prototype.getTransformNodeByID = function (id) {
  135484. for (var index = 0; index < this.transformNodes.length; index++) {
  135485. if (this.transformNodes[index].id === id) {
  135486. return this.transformNodes[index];
  135487. }
  135488. }
  135489. return null;
  135490. };
  135491. /**
  135492. * Gets a transform node with its auto-generated unique id
  135493. * @param uniqueId efines the unique id to search for
  135494. * @return the found transform node or null if not found at all.
  135495. */
  135496. Scene.prototype.getTransformNodeByUniqueID = function (uniqueId) {
  135497. for (var index = 0; index < this.transformNodes.length; index++) {
  135498. if (this.transformNodes[index].uniqueId === uniqueId) {
  135499. return this.transformNodes[index];
  135500. }
  135501. }
  135502. return null;
  135503. };
  135504. /**
  135505. * Gets a list of transform nodes using their id
  135506. * @param id defines the id to search for
  135507. * @returns a list of transform nodes
  135508. */
  135509. Scene.prototype.getTransformNodesByID = function (id) {
  135510. return this.transformNodes.filter(function (m) {
  135511. return m.id === id;
  135512. });
  135513. };
  135514. /**
  135515. * Gets a mesh with its auto-generated unique id
  135516. * @param uniqueId defines the unique id to search for
  135517. * @return the found mesh or null if not found at all.
  135518. */
  135519. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  135520. for (var index = 0; index < this.meshes.length; index++) {
  135521. if (this.meshes[index].uniqueId === uniqueId) {
  135522. return this.meshes[index];
  135523. }
  135524. }
  135525. return null;
  135526. };
  135527. /**
  135528. * Gets a the last added mesh using a given id
  135529. * @param id defines the id to search for
  135530. * @return the found mesh or null if not found at all.
  135531. */
  135532. Scene.prototype.getLastMeshByID = function (id) {
  135533. for (var index = this.meshes.length - 1; index >= 0; index--) {
  135534. if (this.meshes[index].id === id) {
  135535. return this.meshes[index];
  135536. }
  135537. }
  135538. return null;
  135539. };
  135540. /**
  135541. * Gets a the last added node (Mesh, Camera, Light) using a given id
  135542. * @param id defines the id to search for
  135543. * @return the found node or null if not found at all
  135544. */
  135545. Scene.prototype.getLastEntryByID = function (id) {
  135546. var index;
  135547. for (index = this.meshes.length - 1; index >= 0; index--) {
  135548. if (this.meshes[index].id === id) {
  135549. return this.meshes[index];
  135550. }
  135551. }
  135552. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  135553. if (this.transformNodes[index].id === id) {
  135554. return this.transformNodes[index];
  135555. }
  135556. }
  135557. for (index = this.cameras.length - 1; index >= 0; index--) {
  135558. if (this.cameras[index].id === id) {
  135559. return this.cameras[index];
  135560. }
  135561. }
  135562. for (index = this.lights.length - 1; index >= 0; index--) {
  135563. if (this.lights[index].id === id) {
  135564. return this.lights[index];
  135565. }
  135566. }
  135567. return null;
  135568. };
  135569. /**
  135570. * Gets a node (Mesh, Camera, Light) using a given id
  135571. * @param id defines the id to search for
  135572. * @return the found node or null if not found at all
  135573. */
  135574. Scene.prototype.getNodeByID = function (id) {
  135575. var mesh = this.getMeshByID(id);
  135576. if (mesh) {
  135577. return mesh;
  135578. }
  135579. var transformNode = this.getTransformNodeByID(id);
  135580. if (transformNode) {
  135581. return transformNode;
  135582. }
  135583. var light = this.getLightByID(id);
  135584. if (light) {
  135585. return light;
  135586. }
  135587. var camera = this.getCameraByID(id);
  135588. if (camera) {
  135589. return camera;
  135590. }
  135591. var bone = this.getBoneByID(id);
  135592. if (bone) {
  135593. return bone;
  135594. }
  135595. return null;
  135596. };
  135597. /**
  135598. * Gets a node (Mesh, Camera, Light) using a given name
  135599. * @param name defines the name to search for
  135600. * @return the found node or null if not found at all.
  135601. */
  135602. Scene.prototype.getNodeByName = function (name) {
  135603. var mesh = this.getMeshByName(name);
  135604. if (mesh) {
  135605. return mesh;
  135606. }
  135607. var transformNode = this.getTransformNodeByName(name);
  135608. if (transformNode) {
  135609. return transformNode;
  135610. }
  135611. var light = this.getLightByName(name);
  135612. if (light) {
  135613. return light;
  135614. }
  135615. var camera = this.getCameraByName(name);
  135616. if (camera) {
  135617. return camera;
  135618. }
  135619. var bone = this.getBoneByName(name);
  135620. if (bone) {
  135621. return bone;
  135622. }
  135623. return null;
  135624. };
  135625. /**
  135626. * Gets a mesh using a given name
  135627. * @param name defines the name to search for
  135628. * @return the found mesh or null if not found at all.
  135629. */
  135630. Scene.prototype.getMeshByName = function (name) {
  135631. for (var index = 0; index < this.meshes.length; index++) {
  135632. if (this.meshes[index].name === name) {
  135633. return this.meshes[index];
  135634. }
  135635. }
  135636. return null;
  135637. };
  135638. /**
  135639. * Gets a transform node using a given name
  135640. * @param name defines the name to search for
  135641. * @return the found transform node or null if not found at all.
  135642. */
  135643. Scene.prototype.getTransformNodeByName = function (name) {
  135644. for (var index = 0; index < this.transformNodes.length; index++) {
  135645. if (this.transformNodes[index].name === name) {
  135646. return this.transformNodes[index];
  135647. }
  135648. }
  135649. return null;
  135650. };
  135651. /**
  135652. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  135653. * @param id defines the id to search for
  135654. * @return the found skeleton or null if not found at all.
  135655. */
  135656. Scene.prototype.getLastSkeletonByID = function (id) {
  135657. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  135658. if (this.skeletons[index].id === id) {
  135659. return this.skeletons[index];
  135660. }
  135661. }
  135662. return null;
  135663. };
  135664. /**
  135665. * Gets a skeleton using a given auto generated unique id
  135666. * @param uniqueId defines the unique id to search for
  135667. * @return the found skeleton or null if not found at all.
  135668. */
  135669. Scene.prototype.getSkeletonByUniqueId = function (uniqueId) {
  135670. for (var index = 0; index < this.skeletons.length; index++) {
  135671. if (this.skeletons[index].uniqueId === uniqueId) {
  135672. return this.skeletons[index];
  135673. }
  135674. }
  135675. return null;
  135676. };
  135677. /**
  135678. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  135679. * @param id defines the id to search for
  135680. * @return the found skeleton or null if not found at all.
  135681. */
  135682. Scene.prototype.getSkeletonById = function (id) {
  135683. for (var index = 0; index < this.skeletons.length; index++) {
  135684. if (this.skeletons[index].id === id) {
  135685. return this.skeletons[index];
  135686. }
  135687. }
  135688. return null;
  135689. };
  135690. /**
  135691. * Gets a skeleton using a given name
  135692. * @param name defines the name to search for
  135693. * @return the found skeleton or null if not found at all.
  135694. */
  135695. Scene.prototype.getSkeletonByName = function (name) {
  135696. for (var index = 0; index < this.skeletons.length; index++) {
  135697. if (this.skeletons[index].name === name) {
  135698. return this.skeletons[index];
  135699. }
  135700. }
  135701. return null;
  135702. };
  135703. /**
  135704. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  135705. * @param id defines the id to search for
  135706. * @return the found morph target manager or null if not found at all.
  135707. */
  135708. Scene.prototype.getMorphTargetManagerById = function (id) {
  135709. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  135710. if (this.morphTargetManagers[index].uniqueId === id) {
  135711. return this.morphTargetManagers[index];
  135712. }
  135713. }
  135714. return null;
  135715. };
  135716. /**
  135717. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  135718. * @param id defines the id to search for
  135719. * @return the found morph target or null if not found at all.
  135720. */
  135721. Scene.prototype.getMorphTargetById = function (id) {
  135722. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  135723. var morphTargetManager = this.morphTargetManagers[managerIndex];
  135724. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  135725. var target = morphTargetManager.getTarget(index);
  135726. if (target.id === id) {
  135727. return target;
  135728. }
  135729. }
  135730. }
  135731. return null;
  135732. };
  135733. /**
  135734. * Gets a boolean indicating if the given mesh is active
  135735. * @param mesh defines the mesh to look for
  135736. * @returns true if the mesh is in the active list
  135737. */
  135738. Scene.prototype.isActiveMesh = function (mesh) {
  135739. return (this._activeMeshes.indexOf(mesh) !== -1);
  135740. };
  135741. Object.defineProperty(Scene.prototype, "uid", {
  135742. /**
  135743. * Return a unique id as a string which can serve as an identifier for the scene
  135744. */
  135745. get: function () {
  135746. if (!this._uid) {
  135747. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  135748. }
  135749. return this._uid;
  135750. },
  135751. enumerable: true,
  135752. configurable: true
  135753. });
  135754. /**
  135755. * Add an externaly attached data from its key.
  135756. * This method call will fail and return false, if such key already exists.
  135757. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  135758. * @param key the unique key that identifies the data
  135759. * @param data the data object to associate to the key for this Engine instance
  135760. * @return true if no such key were already present and the data was added successfully, false otherwise
  135761. */
  135762. Scene.prototype.addExternalData = function (key, data) {
  135763. if (!this._externalData) {
  135764. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  135765. }
  135766. return this._externalData.add(key, data);
  135767. };
  135768. /**
  135769. * Get an externaly attached data from its key
  135770. * @param key the unique key that identifies the data
  135771. * @return the associated data, if present (can be null), or undefined if not present
  135772. */
  135773. Scene.prototype.getExternalData = function (key) {
  135774. if (!this._externalData) {
  135775. return null;
  135776. }
  135777. return this._externalData.get(key);
  135778. };
  135779. /**
  135780. * Get an externaly attached data from its key, create it using a factory if it's not already present
  135781. * @param key the unique key that identifies the data
  135782. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  135783. * @return the associated data, can be null if the factory returned null.
  135784. */
  135785. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  135786. if (!this._externalData) {
  135787. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  135788. }
  135789. return this._externalData.getOrAddWithFactory(key, factory);
  135790. };
  135791. /**
  135792. * Remove an externaly attached data from the Engine instance
  135793. * @param key the unique key that identifies the data
  135794. * @return true if the data was successfully removed, false if it doesn't exist
  135795. */
  135796. Scene.prototype.removeExternalData = function (key) {
  135797. return this._externalData.remove(key);
  135798. };
  135799. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  135800. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  135801. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  135802. var step = _a[_i];
  135803. step.action(mesh, subMesh);
  135804. }
  135805. var material = subMesh.getMaterial();
  135806. if (material !== null && material !== undefined) {
  135807. // Render targets
  135808. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  135809. if (this._processedMaterials.indexOf(material) === -1) {
  135810. this._processedMaterials.push(material);
  135811. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  135812. }
  135813. }
  135814. // Dispatch
  135815. this._activeIndices.addCount(subMesh.indexCount, false);
  135816. this._renderingManager.dispatch(subMesh, mesh, material);
  135817. }
  135818. }
  135819. };
  135820. /**
  135821. * Clear the processed materials smart array preventing retention point in material dispose.
  135822. */
  135823. Scene.prototype.freeProcessedMaterials = function () {
  135824. this._processedMaterials.dispose();
  135825. };
  135826. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  135827. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  135828. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  135829. * when disposing several meshes in a row or a hierarchy of meshes.
  135830. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  135831. */
  135832. get: function () {
  135833. return this._preventFreeActiveMeshesAndRenderingGroups;
  135834. },
  135835. set: function (value) {
  135836. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  135837. return;
  135838. }
  135839. if (value) {
  135840. this.freeActiveMeshes();
  135841. this.freeRenderingGroups();
  135842. }
  135843. this._preventFreeActiveMeshesAndRenderingGroups = value;
  135844. },
  135845. enumerable: true,
  135846. configurable: true
  135847. });
  135848. /**
  135849. * Clear the active meshes smart array preventing retention point in mesh dispose.
  135850. */
  135851. Scene.prototype.freeActiveMeshes = function () {
  135852. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  135853. return;
  135854. }
  135855. this._activeMeshes.dispose();
  135856. if (this.activeCamera && this.activeCamera._activeMeshes) {
  135857. this.activeCamera._activeMeshes.dispose();
  135858. }
  135859. if (this.activeCameras) {
  135860. for (var i = 0; i < this.activeCameras.length; i++) {
  135861. var activeCamera = this.activeCameras[i];
  135862. if (activeCamera && activeCamera._activeMeshes) {
  135863. activeCamera._activeMeshes.dispose();
  135864. }
  135865. }
  135866. }
  135867. };
  135868. /**
  135869. * Clear the info related to rendering groups preventing retention points during dispose.
  135870. */
  135871. Scene.prototype.freeRenderingGroups = function () {
  135872. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  135873. return;
  135874. }
  135875. if (this._renderingManager) {
  135876. this._renderingManager.freeRenderingGroups();
  135877. }
  135878. if (this.textures) {
  135879. for (var i = 0; i < this.textures.length; i++) {
  135880. var texture = this.textures[i];
  135881. if (texture && texture.renderList) {
  135882. texture.freeRenderingGroups();
  135883. }
  135884. }
  135885. }
  135886. };
  135887. /** @hidden */
  135888. Scene.prototype._isInIntermediateRendering = function () {
  135889. return this._intermediateRendering;
  135890. };
  135891. /**
  135892. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  135893. * @returns the current scene
  135894. */
  135895. Scene.prototype.freezeActiveMeshes = function () {
  135896. if (!this.activeCamera) {
  135897. return this;
  135898. }
  135899. if (!this._frustumPlanes) {
  135900. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  135901. }
  135902. this._evaluateActiveMeshes();
  135903. this._activeMeshesFrozen = true;
  135904. return this;
  135905. };
  135906. /**
  135907. * Use this function to restart evaluating active meshes on every frame
  135908. * @returns the current scene
  135909. */
  135910. Scene.prototype.unfreezeActiveMeshes = function () {
  135911. this._activeMeshesFrozen = false;
  135912. return this;
  135913. };
  135914. Scene.prototype._evaluateActiveMeshes = function () {
  135915. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  135916. return;
  135917. }
  135918. if (!this.activeCamera) {
  135919. return;
  135920. }
  135921. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  135922. this.activeCamera._activeMeshes.reset();
  135923. this._activeMeshes.reset();
  135924. this._renderingManager.reset();
  135925. this._processedMaterials.reset();
  135926. this._activeParticleSystems.reset();
  135927. this._activeSkeletons.reset();
  135928. this._softwareSkinnedMeshes.reset();
  135929. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  135930. var step = _a[_i];
  135931. step.action();
  135932. }
  135933. // Determine mesh candidates
  135934. var meshes = this.getActiveMeshCandidates();
  135935. // Check each mesh
  135936. var len = meshes.length;
  135937. for (var i = 0; i < len; i++) {
  135938. var mesh = meshes.data[i];
  135939. if (mesh.isBlocked) {
  135940. continue;
  135941. }
  135942. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  135943. if (!mesh.isReady() || !mesh.isEnabled()) {
  135944. continue;
  135945. }
  135946. mesh.computeWorldMatrix();
  135947. // Intersections
  135948. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  135949. this._meshesForIntersections.pushNoDuplicate(mesh);
  135950. }
  135951. // Switch to current LOD
  135952. var meshLOD = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  135953. if (meshLOD === undefined || meshLOD === null) {
  135954. continue;
  135955. }
  135956. mesh._preActivate();
  135957. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  135958. this._activeMeshes.push(mesh);
  135959. this.activeCamera._activeMeshes.push(mesh);
  135960. mesh._activate(this._renderId);
  135961. if (meshLOD !== mesh) {
  135962. meshLOD._activate(this._renderId);
  135963. }
  135964. this._activeMesh(mesh, meshLOD);
  135965. }
  135966. }
  135967. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  135968. // Particle systems
  135969. if (this.particlesEnabled) {
  135970. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  135971. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  135972. var particleSystem = this.particleSystems[particleIndex];
  135973. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  135974. continue;
  135975. }
  135976. var emitter = particleSystem.emitter;
  135977. if (!emitter.position || emitter.isEnabled()) {
  135978. this._activeParticleSystems.push(particleSystem);
  135979. particleSystem.animate();
  135980. this._renderingManager.dispatchParticles(particleSystem);
  135981. }
  135982. }
  135983. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  135984. }
  135985. };
  135986. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  135987. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  135988. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  135989. mesh.skeleton.prepare();
  135990. }
  135991. if (!mesh.computeBonesUsingShaders) {
  135992. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  135993. }
  135994. }
  135995. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  135996. var step = _a[_i];
  135997. step.action(sourceMesh, mesh);
  135998. }
  135999. if (mesh !== undefined && mesh !== null
  136000. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  136001. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  136002. var len = subMeshes.length;
  136003. for (var i = 0; i < len; i++) {
  136004. var subMesh = subMeshes.data[i];
  136005. this._evaluateSubMesh(subMesh, mesh);
  136006. }
  136007. }
  136008. };
  136009. /**
  136010. * Update the transform matrix to update from the current active camera
  136011. * @param force defines a boolean used to force the update even if cache is up to date
  136012. */
  136013. Scene.prototype.updateTransformMatrix = function (force) {
  136014. if (!this.activeCamera) {
  136015. return;
  136016. }
  136017. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  136018. };
  136019. Scene.prototype._bindFrameBuffer = function () {
  136020. if (this.activeCamera && this.activeCamera._multiviewTexture) {
  136021. this.activeCamera._multiviewTexture._bindFrameBuffer();
  136022. }
  136023. else if (this.activeCamera && this.activeCamera.outputRenderTarget) {
  136024. var useMultiview = this.getEngine().getCaps().multiview && this.activeCamera.outputRenderTarget && this.activeCamera.outputRenderTarget.getViewCount() > 1;
  136025. if (useMultiview) {
  136026. this.activeCamera.outputRenderTarget._bindFrameBuffer();
  136027. }
  136028. else {
  136029. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  136030. if (internalTexture) {
  136031. this.getEngine().bindFramebuffer(internalTexture);
  136032. }
  136033. else {
  136034. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  136035. }
  136036. }
  136037. }
  136038. else {
  136039. this.getEngine().restoreDefaultFramebuffer(); // Restore back buffer if needed
  136040. }
  136041. };
  136042. Scene.prototype._renderForCamera = function (camera, rigParent) {
  136043. if (camera && camera._skipRendering) {
  136044. return;
  136045. }
  136046. var engine = this._engine;
  136047. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  136048. this._activeCamera = camera;
  136049. if (!this.activeCamera) {
  136050. throw new Error("Active camera not set");
  136051. }
  136052. // Viewport
  136053. engine.setViewport(this.activeCamera.viewport);
  136054. // Camera
  136055. this.resetCachedMaterial();
  136056. this._renderId++;
  136057. var useMultiview = this.getEngine().getCaps().multiview && camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1;
  136058. if (useMultiview) {
  136059. this.setTransformMatrix(camera._rigCameras[0].getViewMatrix(), camera._rigCameras[0].getProjectionMatrix(), camera._rigCameras[1].getViewMatrix(), camera._rigCameras[1].getProjectionMatrix());
  136060. }
  136061. else {
  136062. this.updateTransformMatrix();
  136063. }
  136064. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  136065. // Meshes
  136066. this._evaluateActiveMeshes();
  136067. // Software skinning
  136068. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  136069. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  136070. mesh.applySkeleton(mesh.skeleton);
  136071. }
  136072. // Render targets
  136073. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  136074. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  136075. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  136076. }
  136077. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  136078. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  136079. }
  136080. // Collects render targets from external components.
  136081. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  136082. var step = _a[_i];
  136083. step.action(this._renderTargets);
  136084. }
  136085. if (this.renderTargetsEnabled) {
  136086. this._intermediateRendering = true;
  136087. if (this._renderTargets.length > 0) {
  136088. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  136089. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  136090. var renderTarget = this._renderTargets.data[renderIndex];
  136091. if (renderTarget._shouldRender()) {
  136092. this._renderId++;
  136093. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  136094. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  136095. }
  136096. }
  136097. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  136098. this._renderId++;
  136099. }
  136100. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  136101. var step = _c[_b];
  136102. step.action(this.activeCamera);
  136103. }
  136104. this._intermediateRendering = false;
  136105. // Restore framebuffer after rendering to targets
  136106. this._bindFrameBuffer();
  136107. }
  136108. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  136109. // Prepare Frame
  136110. if (this.postProcessManager && !camera._multiviewTexture) {
  136111. this.postProcessManager._prepareFrame();
  136112. }
  136113. // Before Camera Draw
  136114. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  136115. var step = _e[_d];
  136116. step.action(this.activeCamera);
  136117. }
  136118. // Render
  136119. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  136120. this._renderingManager.render(null, null, true, true);
  136121. this.onAfterDrawPhaseObservable.notifyObservers(this);
  136122. // After Camera Draw
  136123. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  136124. var step = _g[_f];
  136125. step.action(this.activeCamera);
  136126. }
  136127. // Finalize frame
  136128. if (this.postProcessManager && !camera._multiviewTexture) {
  136129. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  136130. }
  136131. // Reset some special arrays
  136132. this._renderTargets.reset();
  136133. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  136134. };
  136135. Scene.prototype._processSubCameras = function (camera) {
  136136. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE || (camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview)) {
  136137. this._renderForCamera(camera);
  136138. return;
  136139. }
  136140. if (camera._useMultiviewToSingleView) {
  136141. // Multiview is only able to be displayed directly for API's such as webXR
  136142. // This displays a multiview image by rendering to the multiview image and then
  136143. // copying the result into the sub cameras instead of rendering them and proceeding as normal from there
  136144. // Render to a multiview texture
  136145. camera._resizeOrCreateMultiviewTexture(this.getEngine().getRenderWidth(true) / 2, this.getEngine().getRenderHeight(true));
  136146. if (!this._multiviewSceneUbo) {
  136147. this._createMultiviewUbo();
  136148. }
  136149. camera.outputRenderTarget = camera._multiviewTexture;
  136150. this._renderForCamera(camera);
  136151. camera.outputRenderTarget = null;
  136152. // Consume the multiview texture through a shader for each eye
  136153. for (var index = 0; index < camera._rigCameras.length; index++) {
  136154. var engine = this._engine;
  136155. this._activeCamera = camera._rigCameras[index];
  136156. engine.setViewport(this._activeCamera.viewport);
  136157. if (this.postProcessManager) {
  136158. this.postProcessManager._prepareFrame();
  136159. this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate);
  136160. }
  136161. }
  136162. }
  136163. else {
  136164. // rig cameras
  136165. for (var index = 0; index < camera._rigCameras.length; index++) {
  136166. this._renderForCamera(camera._rigCameras[index], camera);
  136167. }
  136168. }
  136169. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  136170. this._activeCamera = camera;
  136171. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  136172. };
  136173. Scene.prototype._checkIntersections = function () {
  136174. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  136175. var sourceMesh = this._meshesForIntersections.data[index];
  136176. if (!sourceMesh.actionManager) {
  136177. continue;
  136178. }
  136179. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  136180. var action = sourceMesh.actionManager.actions[actionIndex];
  136181. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  136182. var parameters = action.getTriggerParameter();
  136183. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  136184. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  136185. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  136186. if (areIntersecting && currentIntersectionInProgress === -1) {
  136187. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  136188. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  136189. sourceMesh._intersectionsInProgress.push(otherMesh);
  136190. }
  136191. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  136192. sourceMesh._intersectionsInProgress.push(otherMesh);
  136193. }
  136194. }
  136195. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  136196. //They intersected, and now they don't.
  136197. //is this trigger an exit trigger? execute an event.
  136198. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  136199. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  136200. }
  136201. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  136202. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  136203. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  136204. return otherMesh === parameterMesh;
  136205. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  136206. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  136207. }
  136208. }
  136209. }
  136210. }
  136211. }
  136212. };
  136213. /** @hidden */
  136214. Scene.prototype._advancePhysicsEngineStep = function (step) {
  136215. // Do nothing. Code will be replaced if physics engine component is referenced
  136216. };
  136217. /** @hidden */
  136218. Scene.prototype._animate = function () {
  136219. // Nothing to do as long as Animatable have not been imported.
  136220. };
  136221. /**
  136222. * Render the scene
  136223. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  136224. */
  136225. Scene.prototype.render = function (updateCameras) {
  136226. if (updateCameras === void 0) { updateCameras = true; }
  136227. if (this.isDisposed) {
  136228. return;
  136229. }
  136230. this._frameId++;
  136231. // Register components that have been associated lately to the scene.
  136232. this._registerTransientComponents();
  136233. this._activeParticles.fetchNewFrame();
  136234. this._totalVertices.fetchNewFrame();
  136235. this._activeIndices.fetchNewFrame();
  136236. this._activeBones.fetchNewFrame();
  136237. this._meshesForIntersections.reset();
  136238. this.resetCachedMaterial();
  136239. this.onBeforeAnimationsObservable.notifyObservers(this);
  136240. // Actions
  136241. if (this.actionManager) {
  136242. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  136243. }
  136244. if (this._engine.isDeterministicLockStep()) {
  136245. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  136246. var defaultFPS = (60.0 / 1000.0);
  136247. var defaultFrameTime = this.getDeterministicFrameTime();
  136248. var stepsTaken = 0;
  136249. var maxSubSteps = this._engine.getLockstepMaxSteps();
  136250. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  136251. internalSteps = Math.min(internalSteps, maxSubSteps);
  136252. do {
  136253. this.onBeforeStepObservable.notifyObservers(this);
  136254. // Animations
  136255. this._animationRatio = defaultFrameTime * defaultFPS;
  136256. this._animate();
  136257. this.onAfterAnimationsObservable.notifyObservers(this);
  136258. // Physics
  136259. this._advancePhysicsEngineStep(defaultFrameTime);
  136260. this.onAfterStepObservable.notifyObservers(this);
  136261. this._currentStepId++;
  136262. stepsTaken++;
  136263. deltaTime -= defaultFrameTime;
  136264. } while (deltaTime > 0 && stepsTaken < internalSteps);
  136265. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  136266. }
  136267. else {
  136268. // Animations
  136269. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  136270. this._animationRatio = deltaTime * (60.0 / 1000.0);
  136271. this._animate();
  136272. this.onAfterAnimationsObservable.notifyObservers(this);
  136273. // Physics
  136274. this._advancePhysicsEngineStep(deltaTime);
  136275. }
  136276. // Before camera update steps
  136277. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  136278. var step = _a[_i];
  136279. step.action();
  136280. }
  136281. // Update Cameras
  136282. if (updateCameras) {
  136283. if (this.activeCameras.length > 0) {
  136284. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  136285. var camera = this.activeCameras[cameraIndex];
  136286. camera.update();
  136287. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  136288. // rig cameras
  136289. for (var index = 0; index < camera._rigCameras.length; index++) {
  136290. camera._rigCameras[index].update();
  136291. }
  136292. }
  136293. }
  136294. }
  136295. else if (this.activeCamera) {
  136296. this.activeCamera.update();
  136297. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  136298. // rig cameras
  136299. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  136300. this.activeCamera._rigCameras[index].update();
  136301. }
  136302. }
  136303. }
  136304. }
  136305. // Before render
  136306. this.onBeforeRenderObservable.notifyObservers(this);
  136307. // Customs render targets
  136308. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  136309. var engine = this.getEngine();
  136310. var currentActiveCamera = this.activeCamera;
  136311. if (this.renderTargetsEnabled) {
  136312. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  136313. this._intermediateRendering = true;
  136314. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  136315. var renderTarget = this.customRenderTargets[customIndex];
  136316. if (renderTarget._shouldRender()) {
  136317. this._renderId++;
  136318. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  136319. if (!this.activeCamera) {
  136320. throw new Error("Active camera not set");
  136321. }
  136322. // Viewport
  136323. engine.setViewport(this.activeCamera.viewport);
  136324. // Camera
  136325. this.updateTransformMatrix();
  136326. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  136327. }
  136328. }
  136329. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  136330. this._intermediateRendering = false;
  136331. this._renderId++;
  136332. }
  136333. // Restore back buffer
  136334. this.activeCamera = currentActiveCamera;
  136335. this._bindFrameBuffer();
  136336. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  136337. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  136338. var step = _c[_b];
  136339. step.action();
  136340. }
  136341. // Clear
  136342. if (this.autoClearDepthAndStencil || this.autoClear) {
  136343. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  136344. }
  136345. // Collects render targets from external components.
  136346. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  136347. var step = _e[_d];
  136348. step.action(this._renderTargets);
  136349. }
  136350. // Multi-cameras?
  136351. if (this.activeCameras.length > 0) {
  136352. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  136353. if (cameraIndex > 0) {
  136354. this._engine.clear(null, false, true, true);
  136355. }
  136356. this._processSubCameras(this.activeCameras[cameraIndex]);
  136357. }
  136358. }
  136359. else {
  136360. if (!this.activeCamera) {
  136361. throw new Error("No camera defined");
  136362. }
  136363. this._processSubCameras(this.activeCamera);
  136364. }
  136365. // Intersection checks
  136366. this._checkIntersections();
  136367. // Executes the after render stage actions.
  136368. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  136369. var step = _g[_f];
  136370. step.action();
  136371. }
  136372. // After render
  136373. if (this.afterRender) {
  136374. this.afterRender();
  136375. }
  136376. this.onAfterRenderObservable.notifyObservers(this);
  136377. // Cleaning
  136378. if (this._toBeDisposed.length) {
  136379. for (var index = 0; index < this._toBeDisposed.length; index++) {
  136380. var data = this._toBeDisposed[index];
  136381. if (data) {
  136382. data.dispose();
  136383. }
  136384. }
  136385. this._toBeDisposed = [];
  136386. }
  136387. if (this.dumpNextRenderTargets) {
  136388. this.dumpNextRenderTargets = false;
  136389. }
  136390. this._activeBones.addCount(0, true);
  136391. this._activeIndices.addCount(0, true);
  136392. this._activeParticles.addCount(0, true);
  136393. };
  136394. /**
  136395. * Freeze all materials
  136396. * A frozen material will not be updatable but should be faster to render
  136397. */
  136398. Scene.prototype.freezeMaterials = function () {
  136399. for (var i = 0; i < this.materials.length; i++) {
  136400. this.materials[i].freeze();
  136401. }
  136402. };
  136403. /**
  136404. * Unfreeze all materials
  136405. * A frozen material will not be updatable but should be faster to render
  136406. */
  136407. Scene.prototype.unfreezeMaterials = function () {
  136408. for (var i = 0; i < this.materials.length; i++) {
  136409. this.materials[i].unfreeze();
  136410. }
  136411. };
  136412. /**
  136413. * Releases all held ressources
  136414. */
  136415. Scene.prototype.dispose = function () {
  136416. this.beforeRender = null;
  136417. this.afterRender = null;
  136418. this.skeletons = [];
  136419. this.morphTargetManagers = [];
  136420. this._transientComponents = [];
  136421. this._isReadyForMeshStage.clear();
  136422. this._beforeEvaluateActiveMeshStage.clear();
  136423. this._evaluateSubMeshStage.clear();
  136424. this._activeMeshStage.clear();
  136425. this._cameraDrawRenderTargetStage.clear();
  136426. this._beforeCameraDrawStage.clear();
  136427. this._beforeRenderTargetDrawStage.clear();
  136428. this._beforeRenderingGroupDrawStage.clear();
  136429. this._beforeRenderingMeshStage.clear();
  136430. this._afterRenderingMeshStage.clear();
  136431. this._afterRenderingGroupDrawStage.clear();
  136432. this._afterCameraDrawStage.clear();
  136433. this._afterRenderTargetDrawStage.clear();
  136434. this._afterRenderStage.clear();
  136435. this._beforeCameraUpdateStage.clear();
  136436. this._beforeClearStage.clear();
  136437. this._gatherRenderTargetsStage.clear();
  136438. this._gatherActiveCameraRenderTargetsStage.clear();
  136439. this._pointerMoveStage.clear();
  136440. this._pointerDownStage.clear();
  136441. this._pointerUpStage.clear();
  136442. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  136443. var component = _a[_i];
  136444. component.dispose();
  136445. }
  136446. this.importedMeshesFiles = new Array();
  136447. this.stopAllAnimations();
  136448. this.resetCachedMaterial();
  136449. // Smart arrays
  136450. if (this.activeCamera) {
  136451. this.activeCamera._activeMeshes.dispose();
  136452. this.activeCamera = null;
  136453. }
  136454. this._activeMeshes.dispose();
  136455. this._renderingManager.dispose();
  136456. this._processedMaterials.dispose();
  136457. this._activeParticleSystems.dispose();
  136458. this._activeSkeletons.dispose();
  136459. this._softwareSkinnedMeshes.dispose();
  136460. this._renderTargets.dispose();
  136461. this._registeredForLateAnimationBindings.dispose();
  136462. this._meshesForIntersections.dispose();
  136463. this._toBeDisposed = [];
  136464. // Abort active requests
  136465. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  136466. var request = _c[_b];
  136467. request.abort();
  136468. }
  136469. // Events
  136470. this.onDisposeObservable.notifyObservers(this);
  136471. this.onDisposeObservable.clear();
  136472. this.onBeforeRenderObservable.clear();
  136473. this.onAfterRenderObservable.clear();
  136474. this.onBeforeRenderTargetsRenderObservable.clear();
  136475. this.onAfterRenderTargetsRenderObservable.clear();
  136476. this.onAfterStepObservable.clear();
  136477. this.onBeforeStepObservable.clear();
  136478. this.onBeforeActiveMeshesEvaluationObservable.clear();
  136479. this.onAfterActiveMeshesEvaluationObservable.clear();
  136480. this.onBeforeParticlesRenderingObservable.clear();
  136481. this.onAfterParticlesRenderingObservable.clear();
  136482. this.onBeforeDrawPhaseObservable.clear();
  136483. this.onAfterDrawPhaseObservable.clear();
  136484. this.onBeforeAnimationsObservable.clear();
  136485. this.onAfterAnimationsObservable.clear();
  136486. this.onDataLoadedObservable.clear();
  136487. this.onBeforeRenderingGroupObservable.clear();
  136488. this.onAfterRenderingGroupObservable.clear();
  136489. this.onMeshImportedObservable.clear();
  136490. this.onBeforeCameraRenderObservable.clear();
  136491. this.onAfterCameraRenderObservable.clear();
  136492. this.onReadyObservable.clear();
  136493. this.onNewCameraAddedObservable.clear();
  136494. this.onCameraRemovedObservable.clear();
  136495. this.onNewLightAddedObservable.clear();
  136496. this.onLightRemovedObservable.clear();
  136497. this.onNewGeometryAddedObservable.clear();
  136498. this.onGeometryRemovedObservable.clear();
  136499. this.onNewTransformNodeAddedObservable.clear();
  136500. this.onTransformNodeRemovedObservable.clear();
  136501. this.onNewMeshAddedObservable.clear();
  136502. this.onMeshRemovedObservable.clear();
  136503. this.onNewSkeletonAddedObservable.clear();
  136504. this.onSkeletonRemovedObservable.clear();
  136505. this.onNewMaterialAddedObservable.clear();
  136506. this.onMaterialRemovedObservable.clear();
  136507. this.onNewTextureAddedObservable.clear();
  136508. this.onTextureRemovedObservable.clear();
  136509. this.onPrePointerObservable.clear();
  136510. this.onPointerObservable.clear();
  136511. this.onPreKeyboardObservable.clear();
  136512. this.onKeyboardObservable.clear();
  136513. this.onActiveCameraChanged.clear();
  136514. this.detachControl();
  136515. // Detach cameras
  136516. var canvas = this._engine.getRenderingCanvas();
  136517. if (canvas) {
  136518. var index;
  136519. for (index = 0; index < this.cameras.length; index++) {
  136520. this.cameras[index].detachControl(canvas);
  136521. }
  136522. }
  136523. // Release animation groups
  136524. while (this.animationGroups.length) {
  136525. this.animationGroups[0].dispose();
  136526. }
  136527. // Release lights
  136528. while (this.lights.length) {
  136529. this.lights[0].dispose();
  136530. }
  136531. // Release meshes
  136532. while (this.meshes.length) {
  136533. this.meshes[0].dispose(true);
  136534. }
  136535. while (this.transformNodes.length) {
  136536. this.transformNodes[0].dispose(true);
  136537. }
  136538. // Release cameras
  136539. while (this.cameras.length) {
  136540. this.cameras[0].dispose();
  136541. }
  136542. // Release materials
  136543. if (this.defaultMaterial) {
  136544. this.defaultMaterial.dispose();
  136545. }
  136546. while (this.multiMaterials.length) {
  136547. this.multiMaterials[0].dispose();
  136548. }
  136549. while (this.materials.length) {
  136550. this.materials[0].dispose();
  136551. }
  136552. // Release particles
  136553. while (this.particleSystems.length) {
  136554. this.particleSystems[0].dispose();
  136555. }
  136556. // Release postProcesses
  136557. while (this.postProcesses.length) {
  136558. this.postProcesses[0].dispose();
  136559. }
  136560. // Release textures
  136561. while (this.textures.length) {
  136562. this.textures[0].dispose();
  136563. }
  136564. // Release UBO
  136565. this._sceneUbo.dispose();
  136566. if (this._multiviewSceneUbo) {
  136567. this._multiviewSceneUbo.dispose();
  136568. }
  136569. // Post-processes
  136570. this.postProcessManager.dispose();
  136571. // Remove from engine
  136572. index = this._engine.scenes.indexOf(this);
  136573. if (index > -1) {
  136574. this._engine.scenes.splice(index, 1);
  136575. }
  136576. this._engine.wipeCaches(true);
  136577. this._isDisposed = true;
  136578. };
  136579. Object.defineProperty(Scene.prototype, "isDisposed", {
  136580. /**
  136581. * Gets if the scene is already disposed
  136582. */
  136583. get: function () {
  136584. return this._isDisposed;
  136585. },
  136586. enumerable: true,
  136587. configurable: true
  136588. });
  136589. /**
  136590. * Call this function to reduce memory footprint of the scene.
  136591. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  136592. */
  136593. Scene.prototype.clearCachedVertexData = function () {
  136594. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  136595. var mesh = this.meshes[meshIndex];
  136596. var geometry = mesh.geometry;
  136597. if (geometry) {
  136598. geometry._indices = [];
  136599. for (var vbName in geometry._vertexBuffers) {
  136600. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  136601. continue;
  136602. }
  136603. geometry._vertexBuffers[vbName]._buffer._data = null;
  136604. }
  136605. }
  136606. }
  136607. };
  136608. /**
  136609. * This function will remove the local cached buffer data from texture.
  136610. * It will save memory but will prevent the texture from being rebuilt
  136611. */
  136612. Scene.prototype.cleanCachedTextureBuffer = function () {
  136613. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  136614. var baseTexture = _a[_i];
  136615. var buffer = baseTexture._buffer;
  136616. if (buffer) {
  136617. baseTexture._buffer = null;
  136618. }
  136619. }
  136620. };
  136621. /**
  136622. * Get the world extend vectors with an optional filter
  136623. *
  136624. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  136625. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  136626. */
  136627. Scene.prototype.getWorldExtends = function (filterPredicate) {
  136628. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  136629. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  136630. filterPredicate = filterPredicate || (function () { return true; });
  136631. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  136632. mesh.computeWorldMatrix(true);
  136633. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  136634. return;
  136635. }
  136636. var boundingInfo = mesh.getBoundingInfo();
  136637. var minBox = boundingInfo.boundingBox.minimumWorld;
  136638. var maxBox = boundingInfo.boundingBox.maximumWorld;
  136639. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  136640. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  136641. });
  136642. return {
  136643. min: min,
  136644. max: max
  136645. };
  136646. };
  136647. // Picking
  136648. /**
  136649. * Creates a ray that can be used to pick in the scene
  136650. * @param x defines the x coordinate of the origin (on-screen)
  136651. * @param y defines the y coordinate of the origin (on-screen)
  136652. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  136653. * @param camera defines the camera to use for the picking
  136654. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  136655. * @returns a Ray
  136656. */
  136657. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  136658. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  136659. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136660. };
  136661. /**
  136662. * Creates a ray that can be used to pick in the scene
  136663. * @param x defines the x coordinate of the origin (on-screen)
  136664. * @param y defines the y coordinate of the origin (on-screen)
  136665. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  136666. * @param result defines the ray where to store the picking ray
  136667. * @param camera defines the camera to use for the picking
  136668. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  136669. * @returns the current scene
  136670. */
  136671. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  136672. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  136673. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136674. };
  136675. /**
  136676. * Creates a ray that can be used to pick in the scene
  136677. * @param x defines the x coordinate of the origin (on-screen)
  136678. * @param y defines the y coordinate of the origin (on-screen)
  136679. * @param camera defines the camera to use for the picking
  136680. * @returns a Ray
  136681. */
  136682. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  136683. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136684. };
  136685. /**
  136686. * Creates a ray that can be used to pick in the scene
  136687. * @param x defines the x coordinate of the origin (on-screen)
  136688. * @param y defines the y coordinate of the origin (on-screen)
  136689. * @param result defines the ray where to store the picking ray
  136690. * @param camera defines the camera to use for the picking
  136691. * @returns the current scene
  136692. */
  136693. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  136694. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136695. };
  136696. /** Launch a ray to try to pick a mesh in the scene
  136697. * @param x position on screen
  136698. * @param y position on screen
  136699. * @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
  136700. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  136701. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  136702. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  136703. * @returns a PickingInfo
  136704. */
  136705. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  136706. // Dummy info if picking as not been imported
  136707. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  136708. pi._pickingUnavailable = true;
  136709. return pi;
  136710. };
  136711. /** Use the given ray to pick a mesh in the scene
  136712. * @param ray The ray to use to pick meshes
  136713. * @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
  136714. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  136715. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  136716. * @returns a PickingInfo
  136717. */
  136718. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  136719. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136720. };
  136721. /**
  136722. * Launch a ray to try to pick a mesh in the scene
  136723. * @param x X position on screen
  136724. * @param y Y position on screen
  136725. * @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
  136726. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  136727. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  136728. * @returns an array of PickingInfo
  136729. */
  136730. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  136731. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136732. };
  136733. /**
  136734. * Launch a ray to try to pick a mesh in the scene
  136735. * @param ray Ray to use
  136736. * @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
  136737. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  136738. * @returns an array of PickingInfo
  136739. */
  136740. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  136741. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136742. };
  136743. /**
  136744. * Force the value of meshUnderPointer
  136745. * @param mesh defines the mesh to use
  136746. */
  136747. Scene.prototype.setPointerOverMesh = function (mesh) {
  136748. if (this._pointerOverMesh === mesh) {
  136749. return;
  136750. }
  136751. var actionManager;
  136752. if (this._pointerOverMesh) {
  136753. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger);
  136754. if (actionManager) {
  136755. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  136756. }
  136757. }
  136758. this._pointerOverMesh = mesh;
  136759. if (this._pointerOverMesh) {
  136760. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger);
  136761. if (actionManager) {
  136762. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  136763. }
  136764. }
  136765. };
  136766. /**
  136767. * Gets the mesh under the pointer
  136768. * @returns a Mesh or null if no mesh is under the pointer
  136769. */
  136770. Scene.prototype.getPointerOverMesh = function () {
  136771. return this._pointerOverMesh;
  136772. };
  136773. // Misc.
  136774. /** @hidden */
  136775. Scene.prototype._rebuildGeometries = function () {
  136776. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  136777. var geometry = _a[_i];
  136778. geometry._rebuild();
  136779. }
  136780. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  136781. var mesh = _c[_b];
  136782. mesh._rebuild();
  136783. }
  136784. if (this.postProcessManager) {
  136785. this.postProcessManager._rebuild();
  136786. }
  136787. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  136788. var component = _e[_d];
  136789. component.rebuild();
  136790. }
  136791. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  136792. var system = _g[_f];
  136793. system.rebuild();
  136794. }
  136795. };
  136796. /** @hidden */
  136797. Scene.prototype._rebuildTextures = function () {
  136798. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  136799. var texture = _a[_i];
  136800. texture._rebuild();
  136801. }
  136802. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  136803. };
  136804. // Tags
  136805. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  136806. if (tagsQuery === undefined) {
  136807. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  136808. return list;
  136809. }
  136810. var listByTags = [];
  136811. forEach = forEach || (function (item) { return; });
  136812. for (var i in list) {
  136813. var item = list[i];
  136814. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  136815. listByTags.push(item);
  136816. forEach(item);
  136817. }
  136818. }
  136819. return listByTags;
  136820. };
  136821. /**
  136822. * Get a list of meshes by tags
  136823. * @param tagsQuery defines the tags query to use
  136824. * @param forEach defines a predicate used to filter results
  136825. * @returns an array of Mesh
  136826. */
  136827. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  136828. return this._getByTags(this.meshes, tagsQuery, forEach);
  136829. };
  136830. /**
  136831. * Get a list of cameras by tags
  136832. * @param tagsQuery defines the tags query to use
  136833. * @param forEach defines a predicate used to filter results
  136834. * @returns an array of Camera
  136835. */
  136836. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  136837. return this._getByTags(this.cameras, tagsQuery, forEach);
  136838. };
  136839. /**
  136840. * Get a list of lights by tags
  136841. * @param tagsQuery defines the tags query to use
  136842. * @param forEach defines a predicate used to filter results
  136843. * @returns an array of Light
  136844. */
  136845. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  136846. return this._getByTags(this.lights, tagsQuery, forEach);
  136847. };
  136848. /**
  136849. * Get a list of materials by tags
  136850. * @param tagsQuery defines the tags query to use
  136851. * @param forEach defines a predicate used to filter results
  136852. * @returns an array of Material
  136853. */
  136854. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  136855. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  136856. };
  136857. /**
  136858. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  136859. * This allowed control for front to back rendering or reversly depending of the special needs.
  136860. *
  136861. * @param renderingGroupId The rendering group id corresponding to its index
  136862. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  136863. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  136864. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  136865. */
  136866. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  136867. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  136868. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  136869. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  136870. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  136871. };
  136872. /**
  136873. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  136874. *
  136875. * @param renderingGroupId The rendering group id corresponding to its index
  136876. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  136877. * @param depth Automatically clears depth between groups if true and autoClear is true.
  136878. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  136879. */
  136880. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  136881. if (depth === void 0) { depth = true; }
  136882. if (stencil === void 0) { stencil = true; }
  136883. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  136884. };
  136885. /**
  136886. * Gets the current auto clear configuration for one rendering group of the rendering
  136887. * manager.
  136888. * @param index the rendering group index to get the information for
  136889. * @returns The auto clear setup for the requested rendering group
  136890. */
  136891. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  136892. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  136893. };
  136894. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  136895. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  136896. get: function () {
  136897. return this._blockMaterialDirtyMechanism;
  136898. },
  136899. set: function (value) {
  136900. if (this._blockMaterialDirtyMechanism === value) {
  136901. return;
  136902. }
  136903. this._blockMaterialDirtyMechanism = value;
  136904. if (!value) { // Do a complete update
  136905. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  136906. }
  136907. },
  136908. enumerable: true,
  136909. configurable: true
  136910. });
  136911. /**
  136912. * Will flag all materials as dirty to trigger new shader compilation
  136913. * @param flag defines the flag used to specify which material part must be marked as dirty
  136914. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  136915. */
  136916. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  136917. if (this._blockMaterialDirtyMechanism) {
  136918. return;
  136919. }
  136920. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  136921. var material = _a[_i];
  136922. if (predicate && !predicate(material)) {
  136923. continue;
  136924. }
  136925. material.markAsDirty(flag);
  136926. }
  136927. };
  136928. /** @hidden */
  136929. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  136930. var _this = this;
  136931. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  136932. this._activeRequests.push(request);
  136933. request.onCompleteObservable.add(function (request) {
  136934. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  136935. });
  136936. return request;
  136937. };
  136938. /** @hidden */
  136939. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  136940. var _this = this;
  136941. return new Promise(function (resolve, reject) {
  136942. _this._loadFile(url, function (data) {
  136943. resolve(data);
  136944. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  136945. reject(exception);
  136946. });
  136947. });
  136948. };
  136949. // Statics
  136950. Scene._uniqueIdCounter = 0;
  136951. /** The fog is deactivated */
  136952. Scene.FOGMODE_NONE = 0;
  136953. /** The fog density is following an exponential function */
  136954. Scene.FOGMODE_EXP = 1;
  136955. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  136956. Scene.FOGMODE_EXP2 = 2;
  136957. /** The fog density is following a linear function. */
  136958. Scene.FOGMODE_LINEAR = 3;
  136959. /**
  136960. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  136961. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136962. */
  136963. Scene.MinDeltaTime = 1.0;
  136964. /**
  136965. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  136966. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136967. */
  136968. Scene.MaxDeltaTime = 1000.0;
  136969. /** The distance in pixel that you have to move to prevent some events */
  136970. Scene.DragMovementThreshold = 10; // in pixels
  136971. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  136972. Scene.LongPressDelay = 500; // in milliseconds
  136973. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  136974. Scene.DoubleClickDelay = 300; // in milliseconds
  136975. /** If you need to check double click without raising a single click at first click, enable this flag */
  136976. Scene.ExclusiveDoubleClickMode = false;
  136977. return Scene;
  136978. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  136979. /***/ }),
  136980. /***/ "./sceneComponent.ts":
  136981. /*!***************************!*\
  136982. !*** ./sceneComponent.ts ***!
  136983. \***************************/
  136984. /*! exports provided: SceneComponentConstants, Stage */
  136985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136986. "use strict";
  136987. __webpack_require__.r(__webpack_exports__);
  136988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  136989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  136990. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136991. /**
  136992. * Groups all the scene component constants in one place to ease maintenance.
  136993. * @hidden
  136994. */
  136995. var SceneComponentConstants = /** @class */ (function () {
  136996. function SceneComponentConstants() {
  136997. }
  136998. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  136999. SceneComponentConstants.NAME_LAYER = "Layer";
  137000. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  137001. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  137002. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  137003. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  137004. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  137005. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  137006. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  137007. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  137008. SceneComponentConstants.NAME_SPRITE = "Sprite";
  137009. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  137010. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  137011. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  137012. SceneComponentConstants.NAME_OCTREE = "Octree";
  137013. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  137014. SceneComponentConstants.NAME_AUDIO = "Audio";
  137015. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  137016. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  137017. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  137018. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  137019. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  137020. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  137021. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  137022. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  137023. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  137024. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  137025. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  137026. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  137027. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  137028. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  137029. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  137030. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  137031. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  137032. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  137033. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  137034. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  137035. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  137036. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  137037. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  137038. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  137039. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  137040. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  137041. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  137042. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  137043. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  137044. return SceneComponentConstants;
  137045. }());
  137046. /**
  137047. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  137048. * @hidden
  137049. */
  137050. var Stage = /** @class */ (function (_super) {
  137051. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  137052. /**
  137053. * Hide ctor from the rest of the world.
  137054. * @param items The items to add.
  137055. */
  137056. function Stage(items) {
  137057. return _super.apply(this, items) || this;
  137058. }
  137059. /**
  137060. * Creates a new Stage.
  137061. * @returns A new instance of a Stage
  137062. */
  137063. Stage.Create = function () {
  137064. return Object.create(Stage.prototype);
  137065. };
  137066. /**
  137067. * Registers a step in an ordered way in the targeted stage.
  137068. * @param index Defines the position to register the step in
  137069. * @param component Defines the component attached to the step
  137070. * @param action Defines the action to launch during the step
  137071. */
  137072. Stage.prototype.registerStep = function (index, component, action) {
  137073. var i = 0;
  137074. var maxIndex = Number.MAX_VALUE;
  137075. for (; i < this.length; i++) {
  137076. var step = this[i];
  137077. maxIndex = step.index;
  137078. if (index < maxIndex) {
  137079. break;
  137080. }
  137081. }
  137082. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  137083. };
  137084. /**
  137085. * Clears all the steps from the stage.
  137086. */
  137087. Stage.prototype.clear = function () {
  137088. this.length = 0;
  137089. };
  137090. return Stage;
  137091. }(Array));
  137092. /***/ })
  137093. /******/ });
  137094. });
  137095. //# sourceMappingURL=babylon.max.js.map